From patchwork Sat Feb 17 20:23:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13561581 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 4450BC48BC4 for ; Sat, 17 Feb 2024 20:23:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 981D38D0006; Sat, 17 Feb 2024 15:23:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 930E58D0001; Sat, 17 Feb 2024 15:23:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F8158D0006; Sat, 17 Feb 2024 15:23:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6B4338D0001 for ; Sat, 17 Feb 2024 15:23:55 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 345E814031E for ; Sat, 17 Feb 2024 20:23:55 +0000 (UTC) X-FDA: 81802422030.14.F12F6E6 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf20.hostedemail.com (Postfix) with ESMTP id 1E9B81C0013 for ; Sat, 17 Feb 2024 20:23:52 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=u+UucdZp; spf=pass (imf20.hostedemail.com: domain of cel@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708201433; 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=4esY7/t9LpWl+KnSBbx/mU7dFpjJbd72wLpgnvk0B5o=; b=28xU6szaqMo1KgMhgDvZgV/YcnbNi55f4PmI1YctSRLsEQIlerWfuylESQLoNJNemWSa/9 m/KkSEpOXrNQiyPAozKOtQj75TfNYjPze05JOpBSSg+858gbwkOeheViCSy2dWKR5pScAC hfOH9dxXGrJQ0vFhs9tpP1rEXsXkZtk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708201433; a=rsa-sha256; cv=none; b=SyJrcXgls9bWw+xuGlxd9kIskjZzvUJOO/nZH1Dl5W4TtHd5TZdyuDYqCalE4ketpjANJC uZvvyBzdH5apCHbmk5bWC8dXkSx1LkksG+mzG6QnOVK8TkeVCOiIe9nrs6C2kAsWQRyVTh HaV0k7TUyID5vuLj0E85UolPEQjKW1k= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=u+UucdZp; spf=pass (imf20.hostedemail.com: domain of cel@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 3315FCE0B88; Sat, 17 Feb 2024 20:23:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67695C433F1; Sat, 17 Feb 2024 20:23:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708201429; bh=zZF7EKK8ftmerUGGzBqiAHI4dgUgyTG9wsRPzQOCpuw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=u+UucdZptl0WKrqPf/GzRK/R6NMFecqwM1YYAZqGuTX8Ybt6NeHmaEbfcq4uMU3U9 Ecw2UXrIEBHT8fRD9InGawCnpOxNmcCwZ3ahX2kS2mH4tgddN77dJbqWyCVNT0bMA0 uCsmWi90+2ZSjAPCwOFrlaJNnxcvMf1DHC0MSm/5B9QZw7+aAvDn42p2lZ+yy+GcIn qhcNCJFzcAb5Jnw3TT63+A5NFCXaOpx52dL57L05xf7l8y9xkTdOKKrbztYnBt3Vns pWl/My0Gwa3PLUcjSsCc6gbFPHphzxIOwKUeNRyGz/+J92oHuycuFbRbeF/gWsHo+A Yq/c76UNcJfgQ== Subject: [PATCH v2 2/6] 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: Sat, 17 Feb 2024 15:23:47 -0500 Message-ID: <170820142741.6328.12428356024575347885.stgit@91.116.238.104.host.secureserver.net> In-Reply-To: <170820083431.6328.16233178852085891453.stgit@91.116.238.104.host.secureserver.net> References: <170820083431.6328.16233178852085891453.stgit@91.116.238.104.host.secureserver.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspamd-Queue-Id: 1E9B81C0013 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: difzgxs35ixwhxz6dzsocqdhst9nz13d X-HE-Tag: 1708201432-209799 X-HE-Meta: U2FsdGVkX18sm6DTAQ+rW3WzFmA1YhZw2N5HReaRjuQaY/LFRw6O8XWT+bCBRyHRQT/xU3QRBm/I/5yibovGuCOdp8JbhesFgT+0cm8+3Vn9QH4gC8TxLWn9iRRsXMwqDfQOE733EGo3eUL9hfqIxUc0Qx2Waz62v1x92XAsx2Orbu05wuAh9uCSArB62nN3HPcFXHldawmzrWh14sQDc0cXKOUq7EEz7XDVOYgBKpJaS/l89egKTtwZau3U6ekds2kqrkE835YUMQYdM+c4k5akbEBNmKVSPOea3sM+n7EBVgo4QCZ5zYZdzcU/gxpHshOzN23preYlsfc8gQmo2C2O+iYEuqQmIzJ1na+EWNSrRUoEdfkoH4XM5MnTBfgZcPnspSUpPbsgXr4cR5KyJh5zMuhEcPFapikDFKVBWB7qsFbyhYU4iBHqPZNn6DQbf04SvWZ2mPAgZnfSHd3XKk/eVoX2s4wTAuA/yteEP5MfJt+VP5uRweYnDhpQdqAvSyKKjZesshtrMxbQdi72oqJ7nfEkMBARq6VGsrApqmSeMmb69wN8lIOR6DSWEcF+6+9C2TJfSE5qpk9vYNMHzQs/Z+K3vQ1xWqQZW5BDz0hvsA74PYjnzZV90WBkSdtB542eYSO890siOFVlUSu3IpVL1SrQoqhpE39i6Y3EBXnBh54aRxyUP3G12S4Ec/NNNzeVtSESJ6/Mfs0Rfd6Q111l/sj/ZflpZF4IsoPAKpS/dOO/9tMFhKsZRyKNtSKUb9jgzlf3TgPL9Qekt7prjabvGxuWjaeHQzteUvNRZv5ITrdznkTBD3mhSDzjLo5PEcrXkVh1A5aK0tblGotfRVIpZuNJbYnqKxLkmRRe/FNAcmSJLrQ94jcIOFimDf8Vc/YSdgKN0ps7btlVHC21EaecJissp20Uo7v+38CHnT3SPx0msWoboNhsBkXn55FDTN3FIax3dJHRKMQOJq/ yqZuiZHk +jYVXXpd8UHi8QbPyXB5AC0mVaRVwBTKVcT1USXsKKKQZuBcTVqWyE2u7CqrcxFDFpJBhfZX4KCqaFuP3+Z6j3HDUAu1vk7uCimzHxz2+WLt1BeSaB94MTpCOvT/N8HidvAatLJuVYG3qV7vcJ0WuI/0eXUtSMQUloaEjxAyuKFxoEndeXj/K5X5LHRxrEd01CJ099ynwmnAXOSouZCuQKj0ncBFftBKHaa8w 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 This value is used in several places, so make it a symbolic constant. Reviewed-by: Jan Kara 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 752e24c669d9..f0045db739df 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;