From mboxrd@z Thu Jan 1 00:00:00 1970 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 8892DC0218A for ; Thu, 30 Jan 2025 08:59:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1ADE628026C; Thu, 30 Jan 2025 03:59:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 15D5E2800D0; Thu, 30 Jan 2025 03:59:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 027A028026C; Thu, 30 Jan 2025 03:59:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CB20D2800D0 for ; Thu, 30 Jan 2025 03:59:42 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 840E780A9B for ; Thu, 30 Jan 2025 08:59:42 +0000 (UTC) X-FDA: 83063520204.17.A10D924 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf07.hostedemail.com (Postfix) with ESMTP id DF6B740009 for ; Thu, 30 Jan 2025 08:59:40 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=la3rQsmF; spf=pass (imf07.hostedemail.com: domain of gregkh@linuxfoundation.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738227580; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:dkim-signature; bh=dSK8c5Fhl0arCJMG6sL6R0qGX+2Ueu8GRoPw2ftFAAk=; b=Oy0j5kDAQEYkY7pgvCvqBblr7oZcNrf9Fwqb3hXmfX7A6N2A3LM/Hu7m+0AEUjZW4bSUKd wFXvyYE5tKLUwhB+Dl0oD+4Y6wJuzFifWlqcbetecA7QV2pL8onuPwlNpCU3WgTL0WWVuo iC+ubarPoLHTHfJC05BZP51isQnqhHw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=la3rQsmF; spf=pass (imf07.hostedemail.com: domain of gregkh@linuxfoundation.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738227580; a=rsa-sha256; cv=none; b=RsOfuwZ1/kaRAYsjIIRqY75GpFOH4eCEmrWLPvMMvpjkMF37OKnS6W+wRvOEhF5wZhSRa7 scuYD4La4NRCaU5G0O4fio8SYON2hMSGwS8cGeXJTE4IH+5xN7PjP6biAAXgkMod8iQ5d/ kQgPYxHvc1RV3LrY7ObhmSKVCtCgRHk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 8FE0DA41C0A; Thu, 30 Jan 2025 08:57:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A1BFC4CED3; Thu, 30 Jan 2025 08:59:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738227580; bh=sZLIoDSqpidHUB5ubtT6d5nsUlQHKnMzeytrpHRfPZg=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=la3rQsmF/SyiqMABF0wT5gr9l+gAYlTez5NmeJlUSjQKPJTVA9AguOBXLak8OdnTT glxKdSvGM4nNiMRkXX83OuyHrdIB3xQoA5JAKWRxCA7we3uE1D8KEMSF9NgT0LuOi+ Gl5rG2oGQghotHHAWBcDGnvsTfOzezCWdQA1uiNg= Subject: Patch "libfs: Fix simple_offset_rename_exchange()" has been added to the 6.6-stable tree To: akpm@linux-foundation.org,brauner@kernel.org,cel@kernel.org,chuck.lever@oracle.com,gregkh@linuxfoundation.org,hughd@google.com,linux-mm@kvack.org,sashal@kernel.org,viro@zeniv.linux.org.uk,yangerkun@huawei.com,yukuai3@huawei.com Cc: From: Date: Thu, 30 Jan 2025 09:59:30 +0100 In-Reply-To: <20250124191946.22308-5-cel@kernel.org> Message-ID: <2025013030-proclaim-battery-a988@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-stable: commit X-Patchwork-Hint: ignore X-Rspamd-Queue-Id: DF6B740009 X-Stat-Signature: 3ywh8izpomntgapebbfoomtiefwnnh8d X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1738227580-531923 X-HE-Meta: U2FsdGVkX1/JzYL7+dVY0JyLPQ0Pp0WRuIHWDSwDqN+hI2tdenjooh4RZic6zeAEdwixd8SHJiMvjdVrqGon0+nNbkG8nHk5gMbBetSDn/yzCaQ6WFFREeOwC6Lqwc2xldKt2IeRs+ezfjEFpFIJAKgw7p51JKbcc6lQm5w/cJQcz9hKkLUDYnwFdAMMWYwZYeMOEytcMFDW79LKD3IVpa6WLEpjoPANWNF9ZcR/tDb2UtiFORSv4ISlrll06pwQg/N95d7HwfR6k0q+ooHW5mJ6FHRPdCjRGnVb9IqfHckE7H1IZsVJCHDM7xvPRsP9uNAsqNXiDsIVBTCukth5BkCft7CYjFgHqm2qbGY3upMRgYwxYCp5/uFCRdgVnZIwCnDXgL7vsY5cuFj/+YDAynZn9eNQMzj2mn+tHUyYH6QaaPKA1yGpBjqp7C9fnglOERr5rMwdpgfAzKFhlOhy3blPtpY8tqLmpZ7Za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X7ZcOUVkVCPm+QrAlalyxCYZ/WxSVXEkuaF4kja6dxXc1M8i5R2C9w6HO7xyCRo4UqlKKJJvLIbW/eptRP/V1gYgCzsBiweHbJIHQklGqG4yLOOwmbQG+cYf+Rom6 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: This is a note to let you know that I've just added the patch titled libfs: Fix simple_offset_rename_exchange() to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: libfs-fix-simple_offset_rename_exchange.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From stable+bounces-110404-greg=kroah.com@vger.kernel.org Fri Jan 24 20:21:48 2025 From: cel@kernel.org Date: Fri, 24 Jan 2025 14:19:39 -0500 Subject: libfs: Fix simple_offset_rename_exchange() To: Hugh Dickins , Andrew Morten , Christian Brauner , Al Viro , Greg Kroah-Hartman , Sasha Levin Cc: , , , yukuai3@huawei.com, yangerkun@huawei.com, Chuck Lever Message-ID: <20250124191946.22308-5-cel@kernel.org> From: Chuck Lever [ Upstream commit 23cdd0eed3f1fff3af323092b0b88945a7950d8e ] User space expects the replacement (old) directory entry to have the same directory offset after the rename. Suggested-by: Christian Brauner Fixes: a2e459555c5f ("shmem: stable directory offsets") Signed-off-by: Chuck Lever Link: https://lore.kernel.org/r/20240415152057.4605-2-cel@kernel.org Signed-off-by: Christian Brauner [ cel: adjusted to apply to origin/linux-6.6.y ] Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- fs/libfs.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) --- a/fs/libfs.c +++ b/fs/libfs.c @@ -294,6 +294,18 @@ int simple_offset_add(struct offset_ctx return 0; } +static int simple_offset_replace(struct offset_ctx *octx, struct dentry *dentry, + long offset) +{ + void *ret; + + ret = xa_store(&octx->xa, offset, dentry, GFP_KERNEL); + if (xa_is_err(ret)) + return xa_err(ret); + offset_set(dentry, offset); + return 0; +} + /** * simple_offset_remove - Remove an entry to a directory's offset map * @octx: directory offset ctx to be updated @@ -351,6 +363,9 @@ int simple_offset_empty(struct dentry *d * @new_dir: destination parent * @new_dentry: destination dentry * + * This API preserves the directory offset values. Caller provides + * appropriate serialization. + * * Returns zero on success. Otherwise a negative errno is returned and the * rename is rolled back. */ @@ -368,11 +383,11 @@ int simple_offset_rename_exchange(struct simple_offset_remove(old_ctx, old_dentry); simple_offset_remove(new_ctx, new_dentry); - ret = simple_offset_add(new_ctx, old_dentry); + ret = simple_offset_replace(new_ctx, old_dentry, new_index); if (ret) goto out_restore; - ret = simple_offset_add(old_ctx, new_dentry); + ret = simple_offset_replace(old_ctx, new_dentry, old_index); if (ret) { simple_offset_remove(new_ctx, old_dentry); goto out_restore; @@ -387,10 +402,8 @@ int simple_offset_rename_exchange(struct return 0; out_restore: - offset_set(old_dentry, old_index); - xa_store(&old_ctx->xa, old_index, old_dentry, GFP_KERNEL); - offset_set(new_dentry, new_index); - xa_store(&new_ctx->xa, new_index, new_dentry, GFP_KERNEL); + (void)simple_offset_replace(old_ctx, old_dentry, old_index); + (void)simple_offset_replace(new_ctx, new_dentry, new_index); return ret; } Patches currently in stable-queue which might be from cel@kernel.org are queue-6.6/libfs-replace-simple_offset-end-of-directory-detection.patch queue-6.6/libfs-re-arrange-locking-in-offset_iterate_dir.patch queue-6.6/libfs-add-simple_offset_empty.patch queue-6.6/shmem-fix-shmem_rename2.patch queue-6.6/revert-libfs-add-simple_offset_empty.patch queue-6.6/libfs-use-d_children-list-to-iterate-simple_offset-directories.patch queue-6.6/libfs-define-a-minimum-directory-offset.patch queue-6.6/libfs-return-enospc-when-the-directory-offset-range-is-exhausted.patch queue-6.6/libfs-fix-simple_offset_rename_exchange.patch queue-6.6/libfs-add-simple_offset_rename-api.patch