From patchwork Tue Feb 13 21:37:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13555682 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 46E45C4829A for ; Tue, 13 Feb 2024 21:37:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE23E8D0012; Tue, 13 Feb 2024 16:37:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C6B496B008C; Tue, 13 Feb 2024 16:37:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0D878D0012; Tue, 13 Feb 2024 16:37:37 -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 9EB6F6B0089 for ; Tue, 13 Feb 2024 16:37:37 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 471C6120467 for ; Tue, 13 Feb 2024 21:37:37 +0000 (UTC) X-FDA: 81788092554.25.C115DC2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 944164000E for ; Tue, 13 Feb 2024 21:37:35 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Z/MEawuU"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.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=1707860255; 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:references:dkim-signature; bh=mZDvb//WTZ9zZsQSCdxiKoP98n1vIsP+SpP9N6y1aoM=; b=Fyzoyo02vYcnZINX7phkqvM+WFRkrWwF4mIXEaRZUfgTSAlMTXdYsnOKXoTBVsD0RDhqjA oAl4bwrLjWSWjDdg/LDXbI0D1bkz3fhPtz3jEtXpMquMfJ0FhrpgPSettxmEORNKEEyJvg IlC3NuexVmZ5kJzrtD6oKDmitLjtjsY= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Z/MEawuU"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.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=1707860255; a=rsa-sha256; cv=none; b=6EDRebLcO3cip4Aie32L3/wFox8uvT4oBusSEQRa7SjhZRJCdekkWGznqTa16qfKOQ9lLl LCrw6VhyaXhbEW1lwIOyS5lolPFvfHFyn4TCpUKuRJK8qy+0Mof5Q7g0ndmLUNMmDQX2+U KuF56kr8FI0OKKAJuFe/nJf/Fj0aFKQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C5FC4616C6; Tue, 13 Feb 2024 21:37:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D906C43390; Tue, 13 Feb 2024 21:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707860254; bh=O0qvn792AlXiXQ1lPPSwqR9KB9RhTSpZi4O/hP+kqjE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Z/MEawuUMQulNCp3MzLp2FmSSCfSgusNftEj26+lYW33qg3nVQgaYiwA/JCowq7NM UoX2zesRaT68Nrwd8NX3XY9+HeCzOAKrXh9q+a2QuyR3XFug07/4eurf+sd/VWQwQz u6UnXVo1sm6+EFDsCqRoRkAXjb/yXCTJW2mUFtRM/z3D12EH5T4iDL3KGIH4lRDfkm LGL5+KOaU4C13CeGv8HXfxKN1X702KXavl8GCO3zYbhf/FzrlS1bI10WT8bpxMnz2a Jc2Ikzn20LMe/okVAdTAeuZjsWRAww2x+GFLS+XM3E5c8lhxYbjiKkMAs/IyqJULrd wSQ6F6bJbwXGQ== Subject: [PATCH RFC 2/7] libfs: Define a minimum directory offset From: Chuck Lever To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, hughd@google.com, akpm@linux-foundation.org, Liam.Howlett@oracle.com, oliver.sang@intel.com, feng.tang@intel.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, maple-tree@lists.infradead.org, linux-mm@kvack.org, lkp@intel.com Date: Tue, 13 Feb 2024 16:37:32 -0500 Message-ID: <170786025248.11135.14453586596030949713.stgit@91.116.238.104.host.secureserver.net> In-Reply-To: <170785993027.11135.8830043889278631735.stgit@91.116.238.104.host.secureserver.net> References: <170785993027.11135.8830043889278631735.stgit@91.116.238.104.host.secureserver.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspamd-Queue-Id: 944164000E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: kuajbe1ue4mxzjkxwhxump5dszba9fgk X-HE-Tag: 1707860255-537736 X-HE-Meta: U2FsdGVkX19J2EPdNN7JAfdBP6tMvO5tDLxfvBt0q7/YW9IoVi3v5IkLqoLyV6R02/yX/cxwG2Pot3eLu4H9MxSSUYWG8xUlrKlE4SrEeZs7sMP3jK0o2fbOfkcgQj9jxnHiQaYAjGhgoRgbL5MbHb5VL4/hCLaPfhGvyCvZvTnmdgL/1rwG8qTCZHROUvYvDZzZDt6dgzbO8Yw67hLVh4vhY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X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Chuck Lever This value is used in several places, so make it a symbolic constant. Signed-off-by: Chuck Lever Reviewed-by: Jan Kara --- fs/libfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index bfbe1a8c5d2d..a38af72f4719 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -240,6 +240,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)); @@ -261,9 +266,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; } /** @@ -276,7 +279,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; @@ -481,7 +484,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;