2020-06-28 01:28:35

by fengyubo

[permalink] [raw]
Subject: [PATCH] fatfs: switch write_lock to read_lock in fat_ioctl_get_attributes

From: Yubo Feng <[email protected]>

There is no necessery to hold write_lock in fat_ioctl_get_attributes.
write_lock may make an impact on concurrency of fat_ioctl_get_attributes.

Signed-off-by: Yubo Feng <[email protected]>
---
fs/fat/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/fat/file.c b/fs/fat/file.c
index 42134c5..f9ee27c 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -25,9 +25,9 @@ static int fat_ioctl_get_attributes(struct inode *inode, u32 __user *user_attr)
{
u32 attr;

- inode_lock(inode);
+ inode_lock_shared(inode);
attr = fat_make_attrs(inode);
- inode_unlock(inode);
+ inode_unlock_shared(inode);

return put_user(attr, user_attr);
}
--
2.7.4


2020-06-30 11:02:06

by OGAWA Hirofumi

[permalink] [raw]
Subject: Re: [PATCH] fatfs: switch write_lock to read_lock in fat_ioctl_get_attributes

fengyubo <[email protected]> writes:

> From: Yubo Feng <[email protected]>
>
> There is no necessery to hold write_lock in fat_ioctl_get_attributes.
> write_lock may make an impact on concurrency of fat_ioctl_get_attributes.
>
> Signed-off-by: Yubo Feng <[email protected]>

Looks good.

Acked-by: OGAWA Hirofumi <[email protected]>

> ---
> fs/fat/file.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fat/file.c b/fs/fat/file.c
> index 42134c5..f9ee27c 100644
> --- a/fs/fat/file.c
> +++ b/fs/fat/file.c
> @@ -25,9 +25,9 @@ static int fat_ioctl_get_attributes(struct inode *inode, u32 __user *user_attr)
> {
> u32 attr;
>
> - inode_lock(inode);
> + inode_lock_shared(inode);
> attr = fat_make_attrs(inode);
> - inode_unlock(inode);
> + inode_unlock_shared(inode);
>
> return put_user(attr, user_attr);
> }

--
OGAWA Hirofumi <[email protected]>