All of lore.kernel.org
 help / color / mirror / Atom feed
From: xiubli@redhat.com
To: jlayton@kernel.org
Cc: idryomov@gmail.com, vshankar@redhat.com, lhenriques@suse.de,
	ceph-devel@vger.kernel.org, Xiubo Li <xiubli@redhat.com>
Subject: [PATCH 4/4] ceph: clean up the ceph_readdir() code
Date: Fri, 11 Mar 2022 18:45:58 +0800	[thread overview]
Message-ID: <20220311104558.157283-5-xiubli@redhat.com> (raw)
In-Reply-To: <20220311104558.157283-1-xiubli@redhat.com>

From: Xiubo Li <xiubli@redhat.com>

Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/dir.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index d006ad675c49..959756d44597 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -394,14 +394,13 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
 		dout("readdir fetching %llx.%llx frag %x offset '%s'\n",
 		     ceph_vinop(inode), frag, dfi->last_name);
 		req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS);
-		if (IS_ERR(req)) {
-			err = PTR_ERR(req);
-			goto out;
-		}
+		if (IS_ERR(req))
+			return PTR_ERR(req);
+
 		err = ceph_alloc_readdir_reply_buffer(req, inode);
 		if (err) {
 			ceph_mdsc_put_request(req);
-			goto out;
+			return err;
 		}
 		/* hints to request -> mds selection code */
 		req->r_direct_mode = USE_AUTH_MDS;
@@ -417,14 +416,13 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
 			req->r_path2 = kzalloc(NAME_MAX, GFP_KERNEL);
 			if (!req->r_path2) {
 				ceph_mdsc_put_request(req);
-				err = -ENOMEM;
-				goto out;
+				return -ENOMEM;
 			}
 
 			err = ceph_encode_encrypted_dname(inode, &d_name, req->r_path2);
 			if (err < 0) {
 				ceph_mdsc_put_request(req);
-				goto out;
+				return err;
 			}
 		} else if (is_hash_order(ctx->pos)) {
 			req->r_args.readdir.offset_hash =
@@ -445,7 +443,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
 		err = ceph_mdsc_do_request(mdsc, NULL, req);
 		if (err < 0) {
 			ceph_mdsc_put_request(req);
-			goto out;
+			return err;
 		}
 		dout("readdir got and parsed readdir result=%d on "
 		     "frag %x, end=%d, complete=%d, hash_order=%d\n",
@@ -500,7 +498,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
 			if (err) {
 				ceph_mdsc_put_request(dfi->last_readdir);
 				dfi->last_readdir = NULL;
-				goto out;
+				return err;
 			}
 		} else if (req->r_reply_info.dir_end) {
 			dfi->next_offset = 2;
@@ -548,8 +546,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
 			 * it will continue.
 			 */
 			dout("filldir stopping us...\n");
-			err = 0;
-			goto out;
+			return 0;
 		}
 
 		/* Reset the lengths to their original allocated vals */
@@ -607,10 +604,8 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
 					dfi->dir_ordered_count);
 		spin_unlock(&ci->i_ceph_lock);
 	}
-	err = 0;
 	dout("readdir %p file %p done.\n", inode, file);
-out:
-	return err;
+	return 0;
 }
 
 static void reset_readdir(struct ceph_dir_file_info *dfi)
-- 
2.27.0


  parent reply	other threads:[~2022-03-11 10:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11 10:45 [PATCH 0/4] ceph: dencrypt the dentry names early and once for readdir xiubli
2022-03-11 10:45 ` [PATCH 1/4] ceph: pass the request to parse_reply_info_readdir() xiubli
2022-03-11 10:45 ` [PATCH 2/4] ceph: add ceph_encode_encrypted_dname() helper xiubli
2022-03-11 10:45 ` [PATCH 3/4] ceph: dencrypt the dentry names early and once for readdir xiubli
2022-03-11 10:45 ` xiubli [this message]
2022-03-11 16:02 ` [PATCH 0/4] " Luís Henriques
2022-03-12  0:21   ` Xiubo Li

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=20220311104558.157283-5-xiubli@redhat.com \
    --to=xiubli@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=lhenriques@suse.de \
    --cc=vshankar@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.