From 4287e4deb1280633ffbda608f946d6d7c2d76d4a Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 9 Dec 2019 11:10:16 +0000 Subject: fs/adfs: dir: add more efficient iterate() per-format method Rather than using setpos + getnext to iterate through the directory entries, pass iterate() down to the dir format code to populate the dirents. Signed-off-by: Russell King Signed-off-by: Al Viro --- fs/adfs/dir.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'fs/adfs/dir.c') diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c index 2a8f5f1fd3d0..7fda44464121 100644 --- a/fs/adfs/dir.c +++ b/fs/adfs/dir.c @@ -240,12 +240,8 @@ static int adfs_iterate(struct file *file, struct dir_context *ctx) struct inode *inode = file_inode(file); struct super_block *sb = inode->i_sb; const struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir; - struct object_info obj; struct adfs_dir dir; - int ret = 0; - - if (ctx->pos >> 32) - return 0; + int ret; down_read(&adfs_dir_rwsem); ret = adfs_dir_read_inode(sb, inode, &dir); @@ -263,15 +259,7 @@ static int adfs_iterate(struct file *file, struct dir_context *ctx) ctx->pos = 2; } - ret = ops->setpos(&dir, ctx->pos - 2); - if (ret) - goto unlock_relse; - while (ops->getnext(&dir, &obj) == 0) { - if (!dir_emit(ctx, obj.name, obj.name_len, - obj.indaddr, DT_UNKNOWN)) - break; - ctx->pos++; - } + ret = ops->iterate(&dir, ctx); unlock_relse: up_read(&adfs_dir_rwsem); -- cgit v1.2.3