From patchwork Fri Jan 24 19:19:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13949888 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 02E79C0218B for ; Fri, 24 Jan 2025 19:20:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E2AD28009B; Fri, 24 Jan 2025 14:20:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 06CCD280092; Fri, 24 Jan 2025 14:20:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E764328009B; Fri, 24 Jan 2025 14:20:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C998A280092 for ; Fri, 24 Jan 2025 14:20:00 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8906EA0CFE for ; Fri, 24 Jan 2025 19:20:00 +0000 (UTC) X-FDA: 83043310560.28.AA345DF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id F36D3160003 for ; Fri, 24 Jan 2025 19:19:58 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JmvAjPom; spf=pass (imf08.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737746399; 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=+B4fdgo4GC1VJ3upIVmh+khf1AOGUc+90aykYpHwOAw=; b=DtmfofFLUPCq7ymDNQdVs/fE2VP5cwWtCXfA6c29jaggoM5lInRxc9biEvc0Rp+hGMVl6n zENKo9BWowxkgTsqBdsdEjVc1FjMn2J0J16XiexTzCv1mdPf/VHhwXzXpuy3x98GVLxRSt fld4Z49WhNbUwPmMGACkILjFgyTxzKQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JmvAjPom; spf=pass (imf08.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737746399; a=rsa-sha256; cv=none; b=6MpCjyrE6VIH7TGeY09UnhkLHxXYm94t3kxzWb4JWclECYYE3Gqaa3Y4g4AphPL0OoVo0S yyq2v0EiL95INUwpWpE2F8sqLVq2yArPFFL6VSrgpnnxxmt9xaDaJitH9u8LX3K62IR7T7 BhUEx6G16EcNeOa/Qg2um4o3qN3mgHA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0C7E35C61AB; Fri, 24 Jan 2025 19:19:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB29EC4CEE6; Fri, 24 Jan 2025 19:19:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737746398; bh=PSeXT5OPmZ3CLHOWnsn06fMWMBlx3JfvOW356lmNS5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JmvAjPomIA5ROix25gQqohqFQGadayGDEb/GVgwrMLYV3LfblJ1SQbdIFz86sl0xC XL/9Ei90N5aEa39nCIzzxj/gvmPgeB8HdFiaQJKSnRrkjt3FG4yrd2FEi/POCCrLx3 C5YgCEt9JpNtn6eTApz2lQKkl9g96Ff7iOmm4/1EW+fZKPQW3M1s7mvf9dbyk1TTsR bbmFDhNn0JK1sPZqpnwHe5IahIHFxnYxbO+mBOIaOO/SNFhdmkoWGKeTdEqdEmDN1G oh88dnCbSO0Dcnnxx+arF0++YHwKEVvPPOk/3mjyyu17Uv6ygJ1Qpv5H5BvT03Pcjy tw9+K+hGvT0jw== From: cel@kernel.org To: Hugh Dickins , Andrew Morten , Christian Brauner , Al Viro , Greg Kroah-Hartman , Sasha Levin Cc: , , , yukuai3@huawei.com, yangerkun@huawei.com, Chuck Lever Subject: [RFC PATCH v6.6 06/10] shmem: Fix shmem_rename2() Date: Fri, 24 Jan 2025 14:19:41 -0500 Message-ID: <20250124191946.22308-7-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250124191946.22308-1-cel@kernel.org> References: <20250124191946.22308-1-cel@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: F36D3160003 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 8b8m1bo6jffyzm3fi3ztcth8p6eda675 X-HE-Tag: 1737746398-681546 X-HE-Meta: U2FsdGVkX1/j7+UbE/jCet1e55s5D/elph1UY6nGmGdzvUWO6PGTwTHISQI5OtNi0+U1bYZAO+8F2ZMVqpmQuRGR6v/sQt/1H3MjZ+zkpSaoRCGso30grxlyWCSn6Djl+Fn/7sZovEtMxLSCzPK3fH79y0bq4KdVO1dF2WLr69OuKjlILGDCfzwoppGTnaaTT2A3EK/5PC1gFXGJTa3uq2hcZmw+NR2HM9wA4ddyCIu578jI784vfQPErUe7rL3W01PyB2q7D5l2OI39VuNP69WaOheKY7ry1xPB7WVSc2mB+Yf46SOIWcVxR6nahmKtzS4lMz0FihiaUjfS6c8Kg5q1S2aU/5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ulk 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 15d8c3300dae..ab9fc182fd22 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); }