From patchwork Fri Jan 24 19:19:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13949884 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 689DAC02181 for ; Fri, 24 Jan 2025 19:19:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BD21280097; Fri, 24 Jan 2025 14:19:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F127A280092; Fri, 24 Jan 2025 14:19:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD9A4280097; Fri, 24 Jan 2025 14:19:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C281D280092 for ; Fri, 24 Jan 2025 14:19:55 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 740B11C8F9E for ; Fri, 24 Jan 2025 19:19:55 +0000 (UTC) X-FDA: 83043310350.25.CFB44A3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id BF9F640011 for ; Fri, 24 Jan 2025 19:19:53 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RcLi3zNw; spf=pass (imf11.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=1737746393; 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=ihmQOTy6+BASqWfzRvTfXF5KdhKLJ9REmXJq/W81ygA=; b=b3nv+CG/Cf9tfIfUl/hEdo83B4Jqt07ffXBkiz8h3d+E8CnLflMtUR5F5IgiVtMnxPqGCg 4ehvz7QQpMdcgN6oe3pxtVGMx15cXcWOnQOxrHUw12WZeY76P6IZwmgwmJQnIlBSGANpT8 wBaIQkNroGcsln2R/+Gtr133Liq3OuI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RcLi3zNw; spf=pass (imf11.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=1737746393; a=rsa-sha256; cv=none; b=JG2kNMO6KZAEh4YUFDNfBuML0/9/b9C77ZhL4QwSP/mrP6xZaRbUFsozWAkxtAWc7eKVqR 2FMsZj5krrhJMV/1yfKNQcaYTr6QJMKHq3W7wqFpBsBSCeGHho5rk7bvxqkjVqot5D8Q5A 9dx4GHLwJgKB0kfQ9lEZYTnHZV/Q9SU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9C7715C6197; Fri, 24 Jan 2025 19:19:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 972E7C4CEE1; Fri, 24 Jan 2025 19:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737746392; bh=aTa/oPIRhiZqsiUQhL063GDzxrb6flC1H3iG2TVuGAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RcLi3zNwUmn6+D7krNKMAsLu2+/e4oFjxsu0wxzCUBNfUbOBKRndiLIbvyh6gRVcK yvusJypoKUf3J07VZh/SGZ+ayRV9WfralmbkSzFaoaksAUv1YRtX70/pM43krhTpDs 3LYGPKs4zAtTllP4ZJs8pYaJNDQP8XUQkefM/Gs9hoBZhAwdzz/HfOTl+HY71Wli4x wsUg86mAIbqmASezLl0yPIkg+kzWr1fDNMm11d9FizatAu9iaQOefDGJj7l5qCO4+2 60xlPNVkfUYE2gUfVk5DkErDmcoOHDwLKFacFwmKPwyOcHcU1cz+UGzOG3sgYKKPT5 OiduZIrMtg68Q== 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 , Jan Kara Subject: [RFC PATCH v6.6 02/10] libfs: Define a minimum directory offset Date: Fri, 24 Jan 2025 14:19:37 -0500 Message-ID: <20250124191946.22308-3-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: BF9F640011 X-Stat-Signature: foi7ixarrfoahnsoy5rk8bxz1xbgsgsn X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1737746393-352392 X-HE-Meta: U2FsdGVkX1+wHxhA3fmDAGL/xXBXwC+/80rshKQtDKO0kG+h4RpkZYaSdkizJ+op8z9Spg08ErNbIxQKN41lnHK25dTCYZ4Ea5nj3twtFhrvQVOTtWavFbNTgUEf7IocdCNvqCj504CiiR+XF/SY4FRz0oP946AEoH8yQ+/KIqeRuyIz7pE+UYalBOUTrs9PtiSIahAX2RiA38AftrNmaygiiHiekHHXWGBwpVlV6M6VPMJGg66CUpi5Lx+R7z8KDhGJSmfiCY47KoZC7olekEsffReO4gUHuMPnQvWkM38JnK8EVXh1cPBwqWOxfA78D031YIyMRi/4vfagItT2NigVDDF93NQZVGdAknMrvaYlgsO47BJToxbz+IJg9paFlE9p9rPBw9xctcD42P5Ilta6QA4dz91lrJM3sQzzO2Lx2dhvPl3yPsL80b8wChFbimS/I21ZUtESbEUtLnR26F1qafJpizxJ2wULi/C0kVE8g7mcMcn+l8MMLBFx8+oLvcooYIxnUaPh/Sudg1oU/4k3mWZVrqUfdHt6zbuGKDEsY/V9XOiAj/2u3OYaFIcEl/5mKt9b5ITGgs25onu+maikFg/amKF/JTMC2PYmLaP63MVW9ogAV827bageFX/yffOMW8jf7nfQdYSyGHW9qOekU/lrrItZm7zg8sUvjd7b4OoH3EP2tGk6e1LaGgNoyjYlaZkBPQ7pzTnx0OOHk6GNbcBzXENKyy4mshva2xwldZa//iD4BsmNZ+ddqNpV2m0ey0SLq/9p1NWe5UA1CjcY4k2O6aXIHSPmaWDtDWxNMl4/aWAUV5tOmVvgGoIiDOeuKOp4C8qjuLzqsNm4ZLohSTZJqashHOGiaf3yGW4TJQWF01fOwZCiQv1iqtL9sTe0Uf5sNlBDm5h2CJCz0lqajqa8BcSkgtB/gqO2dAw02Mm4q12P+dZ6KxAkNBBJDTKUK8uqp8bBuB7g5Hf DXzbSYZ7 VAOlMUChhwlHrtt5aKr1LIhgT6E2myaxG4nczWt0OLLhlC8biOGyys6Ht5PYTnfM8Wtt3qDhrGz4g/OXa6VnYow9q2UCXoilJzgG5X2gYAhlsa7+cexv/IXPFtPJgAXBylIisUfU8KqKHsUGRVpHTQ65OBo+qcfnA0HJ3eANm+xXbtMzkACxwktIxhe8dlA1hWE98R5pKq7v6/gwFcw0+gjXPkKU7UCfAGYgBx7rKg1jH0Zd0tSmxM7Tq9/rQRdM2G0ACBlcqhCA9nobVH4ISj6HfAhRTOh+hAm5sU71yqOb3LkwHV4QrZDSdRA== 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 7beea725a8ca412c6190090ce7c3a13b169592a1 ] This value is used in several places, so make it a symbolic constant. Reviewed-by: Jan Kara Signed-off-by: Chuck Lever Link: https://lore.kernel.org/r/170820142741.6328.12428356024575347885.stgit@91.116.238.104.host.secureserver.net Signed-off-by: Christian Brauner Stable-dep-of: ecba88a3b32d ("libfs: Add simple_offset_empty()") Signed-off-by: Chuck Lever --- fs/libfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 430f7c95336c..c3dc58e776f9 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -239,6 +239,11 @@ const struct inode_operations simple_dir_inode_operations = { }; EXPORT_SYMBOL(simple_dir_inode_operations); +/* 0 is '.', 1 is '..', so always start with offset 2 or more */ +enum { + DIR_OFFSET_MIN = 2, +}; + static void offset_set(struct dentry *dentry, u32 offset) { dentry->d_fsdata = (void *)((uintptr_t)(offset)); @@ -260,9 +265,7 @@ void simple_offset_init(struct offset_ctx *octx) { xa_init_flags(&octx->xa, XA_FLAGS_ALLOC1); lockdep_set_class(&octx->xa.xa_lock, &simple_offset_xa_lock); - - /* 0 is '.', 1 is '..', so always start with offset 2 */ - octx->next_offset = 2; + octx->next_offset = DIR_OFFSET_MIN; } /** @@ -275,7 +278,7 @@ void simple_offset_init(struct offset_ctx *octx) */ int simple_offset_add(struct offset_ctx *octx, struct dentry *dentry) { - static const struct xa_limit limit = XA_LIMIT(2, U32_MAX); + static const struct xa_limit limit = XA_LIMIT(DIR_OFFSET_MIN, U32_MAX); u32 offset; int ret; @@ -480,7 +483,7 @@ static int offset_readdir(struct file *file, struct dir_context *ctx) return 0; /* In this case, ->private_data is protected by f_pos_lock */ - if (ctx->pos == 2) + if (ctx->pos == DIR_OFFSET_MIN) file->private_data = NULL; else if (file->private_data == ERR_PTR(-ENOENT)) return 0;