linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: hughd@google.com, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH v2 4/5] shmem: Add a shmem-specific dir_emit helper
Date: Fri, 05 May 2023 14:39:34 -0400	[thread overview]
Message-ID: <168331196437.20728.1655558228044135552.stgit@oracle-102.nfsv4bat.org> (raw)
In-Reply-To: <168331111400.20728.2327812215536431362.stgit@oracle-102.nfsv4bat.org>

From: Chuck Lever <chuck.lever@oracle.com>

Clean up to improve the readability of shmem_readdir().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 mm/shmem.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index b78253996108..733b98ca8517 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3329,6 +3329,15 @@ static loff_t shmem_dir_llseek(struct file *file, loff_t offset, int whence)
 	return offset;
 }
 
+static bool shmem_dir_emit(struct dir_context *ctx, struct dentry *dentry)
+{
+	struct inode *inode = d_inode(dentry);
+
+	return ctx->actor(ctx, dentry->d_name.name, dentry->d_name.len,
+			  ctx->pos, inode->i_ino,
+			  fs_umode_to_dtype(inode->i_mode));
+}
+
 /**
  * shmem_readdir - Emit entries starting at offset @ctx->pos
  * @file: an open directory to iterate over
@@ -3369,9 +3378,7 @@ static int shmem_readdir(struct file *file, struct dir_context *ctx)
 		return 0;
 
 	while ((next = scan_positives(cursor, p, 1, next)) != NULL) {
-		if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
-			      d_inode(next)->i_ino,
-			      fs_umode_to_dtype(d_inode(next)->i_mode)))
+		if (!shmem_dir_emit(ctx, dentry))
 			break;
 		ctx->pos++;
 		p = &next->d_child;



  parent reply	other threads:[~2023-05-05 18:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 18:37 [PATCH v2 0/5] shmemfs stable directory cookies Chuck Lever
2023-05-05 18:38 ` [PATCH v2 1/5] shmem: Refactor shmem_symlink() Chuck Lever
2023-05-05 18:38 ` [PATCH v2 2/5] shmem: Add dir_operations specific to tmpfs Chuck Lever
2023-05-05 18:39 ` [PATCH v2 3/5] shmem: Add a per-directory xarray Chuck Lever
2023-05-05 18:39 ` Chuck Lever [this message]
2023-05-05 18:39 ` [PATCH v2 5/5] shmem: stable directory cookies Chuck Lever

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=168331196437.20728.1655558228044135552.stgit@oracle-102.nfsv4bat.org \
    --to=cel@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.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