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: 200671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp828670dyb; Tue, 13 Feb 2024 13:55:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWekGGMhN15qAdKRceMFWc5QcDy4PpTbEBu7LylIdAiIfP9AiIyp1xLhIRVxptDsHNpM7p9GgXvs0EX5IXKpcGLRaM5+Q== X-Google-Smtp-Source: AGHT+IFTQ01FBh1A1i+b2SPOlOFKnixtQEgjTCHbm1hZjVjh/NwP2uEOjjbe9ClTrku/OWyWc8Cl X-Received: by 2002:a17:902:a3c1:b0:1db:55cc:d222 with SMTP id q1-20020a170902a3c100b001db55ccd222mr429868plb.4.1707861350820; Tue, 13 Feb 2024 13:55:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707861350; cv=pass; d=google.com; s=arc-20160816; b=RfgEX806XWnRVuSPBu7GuCYHjj0YGnYzKw0A5BGALqAB5526ICAboS7imCgF9rBw/y KuvwHBBG7EXUMiVRnsAq3VjWX0nSmjHFdzwDvpHv2JrqozZ1hH+HbhBf7LWTrKNyzXGc qtqkrpEniJ2DVePzC2Km1i3ebW9u8POLtu9o3DpaLKxUM5+bQ5pdEsXwtYU1xAZqBBDy hmz7Ygw7Br9CEsBtYxc5T8FEMKA3OT6+M/2SX8CsDiYymbAB5opE1ar9zD2BvNWml5JE 2YzWXOarPnesMHo3UTOATgsv4KOCH412gWOtHWRgKiZ0qxh3jXsBavu0rPWvhcEuAejN KW2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:cc:to:from:subject:dkim-signature; bh=mZDvb//WTZ9zZsQSCdxiKoP98n1vIsP+SpP9N6y1aoM=; fh=CIdlduNe0Mj3lyq04DQs/Jf4lhLrrj4s+U0lQJa1O38=; b=cVJd6W7ViVtTrEn95v4xRrIBxmqsY5JCRNd6CZpo1qErq+D1hiBf91L+8K3X4zhL6v 0Gn5ni6UTtFf6AV4YKdsAq+DayhuWtZX1v+F9Q12Y+ZYJf/EJ1w1/kaIu3Vvv4DgPRwi HTnVns1RVsuZ9UKvuNr63X2DKwKvufv3o7JpOjsPdRtZ4OUdwchxVznpt/2sPijl1l+l T/xQNMcYgtgqYexAhZaLQA4CkHx6Ot4jHrQFQY6+C2M8Z+pY6Y72Mh5AbPudyQGfSTYv 24k24RptS8i9kx9Bxg2PKwSjquMitUsduseXJ/+A9tUKNEFZLMYkUdZ6y8LuX47pTSqb P5Bw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Z/MEawuU"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-64343-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64343-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVLTO6WS4yAhqAu20PGXIyfGahrthqnWEuwuFJDoTco0nA47VcnOnufMvO1UpTYfgK1xHDgtMXBLPMfoiRleM/Dgqq7zQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d15-20020a170902ef0f00b001db40a7519dsi1292003plx.590.2024.02.13.13.55.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 13:55:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64343-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Z/MEawuU"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-64343-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64343-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 88873B208B3 for ; Tue, 13 Feb 2024 21:38:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93285626D5; Tue, 13 Feb 2024 21:37:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z/MEawuU" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED835612FE; Tue, 13 Feb 2024 21:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707860255; cv=none; b=gPPErK0qRkQHam2HyJOoBmWhCRJP9Zeo9X78oPmaGhzSs1JR1QtsXF3qo73r46fyjAgm+1l2wpQyUCsZCCvaN9gPqJ3lEC8fvYzk0fCNQyZL7Ns+/505fqJ/l29OyO1R/SnKHhvnh9aoBNIxfxcUYPdJnn0WtmaTXQw2wktCQyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707860255; c=relaxed/simple; bh=O0qvn792AlXiXQ1lPPSwqR9KB9RhTSpZi4O/hP+kqjE=; h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kTFCLqsV6zZCsC7e3ajXCAozB41GhRegOtp+DOuRE1kk6ToUIxtP6KGtvPGz2UjaO5TzwmJ5JSQqjn0MgpVknVnwuHLwbDFBF6p9yiMut/1KYQrgVV3Tm+Pkf5YcDQZixSxES4xK60knu/kj4+xCd1BfdrK6ivp4ivVYEHNHlr0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z/MEawuU; arc=none smtp.client-ip=10.30.226.201 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790822423574860819 X-GMAIL-MSGID: 1790822423574860819 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;