mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] f2fs: use inode_lock_shared instead of inode_lock in f2fs_seek_block()
@ 2023-10-21 12:19 zhangxirui
  2023-11-07 14:16 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: zhangxirui @ 2023-10-21 12:19 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, zhangxirui

inode_lock_shared() -> down_read(&inode->i_rwsem)
       inode_lock() -> down_write(&inode->i_rwsem)

Inode is not updated in f2fs_seek_block(), so there is no need
to hold write lock, use read lock for more efficiency.

Signed-off-by: zhangxirui <xirui.zhang@vivo.com>
---
 fs/f2fs/file.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 304d0516d3a4..d600ff48914f 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -418,7 +418,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
        loff_t isize;
        int err = 0;

-       inode_lock(inode);
+       inode_lock_shared(inode);

        isize = i_size_read(inode);
        if (offset >= isize)
@@ -483,10 +483,10 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
 found:
        if (whence == SEEK_HOLE && data_ofs > isize)
                data_ofs = isize;
-       inode_unlock(inode);
+       inode_unlock_shared(inode);
        return vfs_setpos(file, data_ofs, maxbytes);
 fail:
-       inode_unlock(inode);
+       inode_unlock_shared(inode);
        return -ENXIO;
 }

--
2.39.0


________________________________
本邮件及其附件内容可能含有机密和/或隐私信息,仅供指定个人或机构使用。若您非发件人指定收件人或其代理人,请勿使用、传播、复制或存储此邮件之任何内容或其附件。如您误收本邮件,请即以回复或电话方式通知发件人,并将原始邮件、附件及其所有复本删除。谢谢。
The contents of this message and any attachments may contain confidential and/or privileged information and are intended exclusively for the addressee(s). If you are not the intended recipient of this message or their agent, please note that any use, dissemination, copying, or storage of this message or its attachments is not allowed. If you receive this message in error, please notify the sender by reply the message or phone and delete this message, any attachments and any copies immediately.
Thank you

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] f2fs: use inode_lock_shared instead of inode_lock in f2fs_seek_block()
  2023-10-21 12:19 [PATCH] f2fs: use inode_lock_shared instead of inode_lock in f2fs_seek_block() zhangxirui
@ 2023-11-07 14:16 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2023-11-07 14:16 UTC (permalink / raw)
  To: zhangxirui, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

On 2023/10/21 20:19, zhangxirui wrote:
> inode_lock_shared() -> down_read(&inode->i_rwsem)
>         inode_lock() -> down_write(&inode->i_rwsem)
> 
> Inode is not updated in f2fs_seek_block(), so there is no need
> to hold write lock, use read lock for more efficiency.
> 
> Signed-off-by: zhangxirui <xirui.zhang@vivo.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-07 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-21 12:19 [PATCH] f2fs: use inode_lock_shared instead of inode_lock in f2fs_seek_block() zhangxirui
2023-11-07 14:16 ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®