linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: linux-fsdevel@vger.kernel.org
Cc: devel@lists.orangefs.org
Subject: [PATCH 21/22] orangefs: saner arguments passing in readdir guts
Date: Wed, 20 Dec 2023 05:32:38 +0000	[thread overview]
Message-ID: <20231220053238.GT1674809@ZenIV> (raw)
In-Reply-To: <20231220051348.GY1674809@ZenIV>

orangefs_dir_fill() doesn't use oi and dentry arguments at all
do_readdir() gets dentry, uses only dentry->d_inode; it also
gets oi, which is ORANGEFS_I(dentry->d_inode) (i.e. ->d_inode -
constant offset).
orangefs_dir_mode() gets dentry and oi, uses only to pass those
to do_readdir().
orangefs_dir_iterate() uses dentry and oi only to pass those to
orangefs_dir_fill() and orangefs_dir_more().

The only thing it really needs is ->d_inode; moreover, that's
better expressed as file_inode(file) - no need to go through
->f_path.dentry->d_inode.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/orangefs/dir.c | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/fs/orangefs/dir.c b/fs/orangefs/dir.c
index 9cacce5d55c1..6d1fbeca9d81 100644
--- a/fs/orangefs/dir.c
+++ b/fs/orangefs/dir.c
@@ -58,10 +58,10 @@ struct orangefs_dir {
  * first part of the part list.
  */
 
-static int do_readdir(struct orangefs_inode_s *oi,
-    struct orangefs_dir *od, struct dentry *dentry,
+static int do_readdir(struct orangefs_dir *od, struct inode *inode,
     struct orangefs_kernel_op_s *op)
 {
+	struct orangefs_inode_s *oi = ORANGEFS_I(inode);
 	struct orangefs_readdir_response_s *resp;
 	int bufi, r;
 
@@ -87,7 +87,7 @@ static int do_readdir(struct orangefs_inode_s *oi,
 	op->upcall.req.readdir.buf_index = bufi;
 
 	r = service_operation(op, "orangefs_readdir",
-	    get_interruptible_flag(dentry->d_inode));
+	    get_interruptible_flag(inode));
 
 	orangefs_readdir_index_put(bufi);
 
@@ -158,8 +158,7 @@ static int parse_readdir(struct orangefs_dir *od,
 	return 0;
 }
 
-static int orangefs_dir_more(struct orangefs_inode_s *oi,
-    struct orangefs_dir *od, struct dentry *dentry)
+static int orangefs_dir_more(struct orangefs_dir *od, struct inode *inode)
 {
 	struct orangefs_kernel_op_s *op;
 	int r;
@@ -169,7 +168,7 @@ static int orangefs_dir_more(struct orangefs_inode_s *oi,
 		od->error = -ENOMEM;
 		return -ENOMEM;
 	}
-	r = do_readdir(oi, od, dentry, op);
+	r = do_readdir(od, inode, op);
 	if (r) {
 		od->error = r;
 		goto out;
@@ -238,9 +237,7 @@ static int fill_from_part(struct orangefs_dir_part *part,
 	return 1;
 }
 
-static int orangefs_dir_fill(struct orangefs_inode_s *oi,
-    struct orangefs_dir *od, struct dentry *dentry,
-    struct dir_context *ctx)
+static int orangefs_dir_fill(struct orangefs_dir *od, struct dir_context *ctx)
 {
 	struct orangefs_dir_part *part;
 	size_t count;
@@ -304,15 +301,10 @@ static loff_t orangefs_dir_llseek(struct file *file, loff_t offset,
 static int orangefs_dir_iterate(struct file *file,
     struct dir_context *ctx)
 {
-	struct orangefs_inode_s *oi;
-	struct orangefs_dir *od;
-	struct dentry *dentry;
+	struct orangefs_dir *od = file->private_data;
+	struct inode *inode = file_inode(file);
 	int r;
 
-	dentry = file->f_path.dentry;
-	oi = ORANGEFS_I(dentry->d_inode);
-	od = file->private_data;
-
 	if (od->error)
 		return od->error;
 
@@ -342,7 +334,7 @@ static int orangefs_dir_iterate(struct file *file,
 	 */
 	while (od->token != ORANGEFS_ITERATE_END &&
 	    ctx->pos > od->end) {
-		r = orangefs_dir_more(oi, od, dentry);
+		r = orangefs_dir_more(od, inode);
 		if (r)
 			return r;
 	}
@@ -351,17 +343,17 @@ static int orangefs_dir_iterate(struct file *file,
 
 	/* Then try to fill if there's any left in the buffer. */
 	if (ctx->pos < od->end) {
-		r = orangefs_dir_fill(oi, od, dentry, ctx);
+		r = orangefs_dir_fill(od, ctx);
 		if (r)
 			return r;
 	}
 
 	/* Finally get some more and try to fill. */
 	if (od->token != ORANGEFS_ITERATE_END) {
-		r = orangefs_dir_more(oi, od, dentry);
+		r = orangefs_dir_more(od, inode);
 		if (r)
 			return r;
-		r = orangefs_dir_fill(oi, od, dentry, ctx);
+		r = orangefs_dir_fill(od, ctx);
 	}
 
 	return r;
-- 
2.39.2


  parent reply	other threads:[~2023-12-20  5:32 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20  5:13 [PATCHES] assorted fs cleanups Al Viro
2023-12-20  5:15 ` PATCH 01/22] hostfs: use d_splice_alias() calling conventions to simplify failure exits Al Viro
2023-12-20  5:16 ` [PATCH 02/22] /proc/sys: " Al Viro
2023-12-20  5:17 ` [PATCH 03/22] zonefs: d_splice_alias() will do the right thing on ERR_PTR() inode Al Viro
2023-12-20  7:09   ` Damien Le Moal
2023-12-20  5:18 ` [PATCH 04/22] udf: " Al Viro
2023-12-21 12:19   ` Jan Kara
2023-12-20  5:19 ` [PATCH 05/22] affs: d_obtain_alias(ERR_PTR(...)) will do the right thing Al Viro
2023-12-20  5:19 ` [PATCH 06/22] befs: " Al Viro
2023-12-20  5:20 ` [PATCH 07/22] ceph: d_obtain_{alias,root}(ERR_PTR(...)) " Al Viro
2023-12-21  0:35   ` Xiubo Li
2023-12-20  5:21 ` [PATCH 08/22] gfs2: d_obtain_alias(ERR_PTR(...)) " Al Viro
2023-12-20  5:22 ` [PATCH 09/22] kernfs: d_obtain_alias(NULL) " Al Viro
2023-12-20  5:23 ` nilfs2: d_obtain_alias(ERR_PTR(...)) " Al Viro
2023-12-20 14:46   ` Ryusuke Konishi
2023-12-20  5:23 ` [PATCH 11/22] udf: " Al Viro
2023-12-21 12:20   ` Jan Kara
2023-12-20  5:24 ` [PATCH 12/22] ext4_add_entry(): ->d_name.len is never 0 Al Viro
2023-12-20  5:25 ` [PATCH 13/22] bfs_add_entry(): get rid of pointless ->d_name.len checks Al Viro
2023-12-20 11:03   ` Tigran Aivazian
2023-12-20  5:26 ` [PATCH 14/22] __ocfs2_add_entry(), ocfs2_prepare_dir_for_insert(): namelen checks Al Viro
2023-12-20  5:27 ` [PATCH 15/22] reiserfs_add_entry(): get rid of pointless " Al Viro
2023-12-20  5:28 ` [PATCH 16/22] udf_fiiter_add_entry(): check for zero ->d_name.len is bogus Al Viro
2023-12-21 12:22   ` Jan Kara
2023-12-20  5:29 ` [PATCH 17/22] get rid of passing callbacks to ceph __dentry_leases_walk() Al Viro
2023-12-21  0:45   ` Xiubo Li
2023-12-21  1:12     ` Al Viro
2023-12-21  1:16       ` Xiubo Li
2023-12-20  5:30 ` [PATCH 18/22] nfsd: kill stale comment about simple_fill_super() requirements Al Viro
2023-12-20 14:22   ` Chuck Lever
2023-12-20  5:31 ` [PATCH 19/22] ocfs2_find_match(): there's no such thing as NULL or negative ->d_parent Al Viro
2023-12-20  5:31 ` [PATCH 20/22] gfs2: use is_subdir() Al Viro
2023-12-20  5:32 ` Al Viro [this message]
2023-12-27 12:05   ` [PATCH 21/22] orangefs: saner arguments passing in readdir guts Mike Marshall
2024-01-02 16:25     ` Mike Marshall
2023-12-20  5:33 ` [PATCH 22/22] apparmorfs: don't duplicate kfree_link() Al Viro
2023-12-20 12:16 ` [PATCHES] assorted fs cleanups Andreas Grünbacher
2023-12-20 17:15   ` Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231220053238.GT1674809@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=devel@lists.orangefs.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).