From patchwork Mon Nov 11 00:52:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13870105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FBFFD12D5C for ; Mon, 11 Nov 2024 00:53:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDEA96B0096; Sun, 10 Nov 2024 19:53:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B42256B0098; Sun, 10 Nov 2024 19:53:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 994806B0099; Sun, 10 Nov 2024 19:53:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 78D146B0096 for ; Sun, 10 Nov 2024 19:53:21 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0051F4160F for ; Mon, 11 Nov 2024 00:53:21 +0000 (UTC) X-FDA: 82771989426.24.9CF30F0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id B7F681C0010 for ; Mon, 11 Nov 2024 00:53:01 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aMIYzEMN; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731286225; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iGU/kFBZllJTKWG3r8FweNF45RNtpFgrUWWP1Gmir4s=; b=uQfUNolnRzu6grzrIIf3+MGqhtg7zXPuxl7lie5HcTTo4nZxtq9vWVvqVeGPTwK0BSOX2m VEHVbNaGeyPLnHtTnp7S4imWD6OIlSZpjUKHDykqApJsj0XV3S6l7XOa6ZpVcsg4SeYA2o JhOtsOhXYNt2mi0tNrxsZVd/7exhbYs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aMIYzEMN; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731286225; a=rsa-sha256; cv=none; b=jL2xk08/+TGd0z/ojaTlsD4w6N6o5NvE5Oz53ma9VGMtq6bqXkw0kQfXbqcF0HCxdxhss7 bHQMAnb8rR2yOmMEyXflYL1wfWE+t3WNH4sMgvBEtszxuw3msMZWfMyNABd1kqBn+uZqzq 09ygTuEa51jtQW6yXzbbFl/n7enI8uk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 20DA45C548D; Mon, 11 Nov 2024 00:52:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35F69C4CEDA; Mon, 11 Nov 2024 00:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731286398; bh=Eq6hm/AurEpUBcGjs15qnEqlTE8OCuozLkUE85txKaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aMIYzEMNY9q4iFf2JUztZP3Jyhw3wEtFmFm9g1gY0/ekzc6Sm1//MNk70I+7KwldA 7/eY37HChonjEeA2109emE/Syd1tdoK4X3vzsxDHeVEc7SN338hQcoXLla/Hz2eq2l 8J5TzUVJosjhO11krG92weLktbMPDx+YF3N0M8SlyDq4JCNWlTP4fWqe1VB8ewQXt+ 4QJ0G6CXfvWQBdx+b9eYPSJJ6z/cXyMoRkxcuD3xg3AtkuFrpLKBfyHFGJBClHw5hV ge+cgqwUijpgvDIodDRso5iDS72XZie2UXIw8VTekxd3mGzAhY21s6Q+AUj2vc3IQB J8PSNpMRiiqyQ== From: cel@kernel.org To: Cc: yukuai1@huaweicloud.com, harry.wentland@amd.com, sunpeng.li@amd.com, Rodrigo.Siqueira@amd.com, alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, viro@zeniv.linux.org.uk, brauner@kernel.org, Liam.Howlett@oracle.com, akpm@linux-foundation.org, hughd@google.com, willy@infradead.org, gregkh@linuxfoundation.org, sashal@kernel.org, srinivasan.shanmugam@amd.com, chiahsuan.chung@amd.com, mingo@kernel.org, mgorman@techsingularity.net, yukuai3@huawei.com, chengming.zhou@linux.dev, zhangpeng.00@bytedance.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, , linux-fsdevel@vger.kernel.org, maple-tree@lists.infradead.org, linux-mm@kvack.org, yi.zhang@huawei.com, yangerkun@huawei.com, Chuck Lever Subject: [RFC PATCH 5/6 6.6] shmem: Fix shmem_rename2() Date: Sun, 10 Nov 2024 19:52:41 -0500 Message-ID: <20241111005242.34654-6-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241111005242.34654-1-cel@kernel.org> References: <20241111005242.34654-1-cel@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B7F681C0010 X-Stat-Signature: hb8s33sp1gurkq5moaiik4ihaca4ybkz X-Rspam-User: X-HE-Tag: 1731286381-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pLyp1NTs27USSJbx/1CHMufWdKiLUel91VtBWTtObYdMMPrmQig2IzlEthxra9eS882tm0R3dsEzJATh0Q8P3+vnP+r75djxjC4wsJBDi+qnDNlDujWzEPWZMc49rP8zU4NxeYVlIEEqjjFXHVbVhhQPMHcMSxi835fQVSOu0AaoW1b0Q2JwvsX2CdMJdO3kkMYveje5o3ekNP7l4Vvte9Lh2Yjns9+dF1uMfINlvUaMjwgOSFXx8nZc1gwYC0rHu0belLk84Z1lqnrww7g8MV5WbA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Chuck Lever [ Upstream commit ad191eb6d6942bb835a0b20b647f7c53c1d99ca4 ] When renaming onto an existing directory entry, user space expects the replacement entry to have the same directory offset as the original one. Link: https://gitlab.alpinelinux.org/alpine/aports/-/issues/15966 Fixes: a2e459555c5f ("shmem: stable directory offsets") Signed-off-by: Chuck Lever Link: https://lore.kernel.org/r/20240415152057.4605-4-cel@kernel.org Signed-off-by: Christian Brauner Signed-off-by: Chuck Lever --- fs/libfs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index b2dcb15d993a..a87005c89534 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -365,6 +365,9 @@ int simple_offset_empty(struct dentry *dentry) * * Caller provides appropriate serialization. * + * User space expects the directory offset value of the replaced + * (new) directory entry to be unchanged after a rename. + * * Returns zero on success, a negative errno value on failure. */ int simple_offset_rename(struct inode *old_dir, struct dentry *old_dentry, @@ -372,8 +375,14 @@ int simple_offset_rename(struct inode *old_dir, struct dentry *old_dentry, { struct offset_ctx *old_ctx = old_dir->i_op->get_offset_ctx(old_dir); struct offset_ctx *new_ctx = new_dir->i_op->get_offset_ctx(new_dir); + long new_offset = dentry2offset(new_dentry); simple_offset_remove(old_ctx, old_dentry); + + if (new_offset) { + offset_set(new_dentry, 0); + return simple_offset_replace(new_ctx, old_dentry, new_offset); + } return simple_offset_add(new_ctx, old_dentry); }