Skip to contentSkip to conversation

staging: erofs: no need to take page lock in readdir

PATCH In review Gao Xiang 2 participants 5 messages Feb 21, 2019 – Feb 25, 2019 Staging

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/2 staging: erofs: no need to take page lock in readdir

VFS will take inode_lock for readdir, therefore no need to take page lock in readdir at all just as the majority of other generic filesystems.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 drivers/staging/erofs/dir.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/erofs/dir.c +0 -2
index e1955703ab8f..8f8ac9675921 100644
@@ -98,7 +98,6 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
 		if (IS_ERR(dentry_page))
 			continue;
 
-		lock_page(dentry_page);
 		de = (struct erofs_dirent *)kmap(dentry_page);
 
 		nameoff = le16_to_cpu(de->nameoff);
@@ -128,7 +127,6 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
 skip_this:
 		kunmap(dentry_page);
 
-		unlock_page(dentry_page);
 		put_page(dentry_page);
 
 		ctx->pos = blknr_to_addr(i) + ofs;
Signature · 1 line
2.14.4
author
#1 lore raw

PATCH 2/2 staging: erofs: switch to ->iterate_shared()

After commit 6192269444eb ("introduce a parallel variant of ->iterate()"), readdir can be done without taking exclusive inode lock of course.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 drivers/staging/erofs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/erofs/dir.c +1 -1
index 8f8ac9675921..829f7b12e0dc 100644
@@ -142,6 +142,6 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
 const struct file_operations erofs_dir_fops = {
 	.llseek		= generic_file_llseek,
 	.read		= generic_read_dir,
-	.iterate	= erofs_readdir,
+	.iterate_shared	= erofs_readdir,
 };
 
Signature · 1 line
2.14.4
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] staging: erofs: switch to ->iterate_shared()

Quoted 4 lines · Gao Xiang

After commit 6192269444eb ("introduce a parallel variant of ->iterate()"), readdir can be done without taking exclusive inode lock of course.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
Reviewed-by Chao Yu <yuchao0 at huawei.com>

Thanks,

author
#3 lore raw

Re: [PATCH 2/2] staging: erofs: switch to ->iterate_shared()

Quoted 7 lines · Chao Yu
Quoted 4 lines · Gao Xiang

After commit 6192269444eb ("introduce a parallel variant of ->iterate()"), readdir can be done without taking exclusive inode lock of course.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
Reviewed-by Chao Yu <yuchao0 at huawei.com>

Thanks for review :)

Quoted 3 lines

Thanks,

Reviewed-by on v1 1/2
#4 lore raw
In reply to Gao Xiang
Quoted 5 lines · Gao Xiang

VFS will take inode_lock for readdir, therefore no need to take page lock in readdir at all just as the majority of other generic filesystems.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
Reviewed-by Chao Yu <yuchao0 at huawei.com>

Thanks,