[f2fs-dev] [PATCH] f2fs: use inode_lock_shared instead of inode_lock in f2fs_seek_block()

2023-10-21 Thread zhangxirui via Linux-f2fs-devel
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 
---
 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


___
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs-tools: skip check device mount state in sparse mode

2024-01-25 Thread zhangxirui via Linux-f2fs-devel
In sparse mode we just read or write to a sparse file not a block device
so no need to check device mount state in sparse mode.

Signed-off-by: zhangxirui 
---
 lib/libf2fs.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 2451201..5315de2 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -830,6 +830,10 @@ int f2fs_devs_are_umounted(void)
 {
int i;
 
+   /*no need to check device mount state in sparse mode*/
+   if (c.sparse_mode)
+   return 0;
+
for (i = 0; i < c.ndevs; i++)
if (f2fs_dev_is_umounted((char *)c.devices[i].path))
return -1;
-- 
2.25.1



___
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] f2fs-tools: skip check device mount state in sparse mode

2024-01-31 Thread zhangxirui via Linux-f2fs-devel
On 2024/1/26 14:37, zhangxirui wrote:
>> In sparse mode we just read or write to a sparse file not a block device
>> so no need to check device mount state in sparse mode.
>
>I guess it needs to check whether regular file was a backfile of mounted
>loop device, so we can only skip block device related check?
>
>https://lore.kernel.org/linux-f2fs-devel/[email protected]
>
>Thanks,

Ah, yes, it needs to check whether regular file was a backfile of mounted loop 
devce,
but it does not conflict with skip check device mount state in sparse mode.

Sparse file is Android only for making userdata.img or other rw partion image, 
in this case
i guess we will not mkfs to a backfile of mounted loop device, right? skip 
check mount state is more efficient.

>
>>
>> Signed-off-by: zhangxirui 
>> ---
>>   lib/libf2fs.c | 4 
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
>> index 2451201..5315de2 100644
>> --- a/lib/libf2fs.c
>> +++ b/lib/libf2fs.c
>> @@ -830,6 +830,10 @@ int f2fs_devs_are_umounted(void)
>>   {
>>  int i;
>>
>> +/*no need to check device mount state in sparse mode*/
>> +if (c.sparse_mode)
>> +return 0;
>> +
>>  for (i = 0; i < c.ndevs; i++)
>>  if (f2fs_dev_is_umounted((char *)c.devices[i].path))
>>  return -1;



___
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] f2fs-tools: skip check device mount state in sparse mode

2024-01-31 Thread zhangxirui via Linux-f2fs-devel
>On 2024/2/1 14:40, zhangxirui wrote:
>> On 2024/1/26 14:37, zhangxirui wrote:
 In sparse mode we just read or write to a sparse file not a block device
 so no need to check device mount state in sparse mode.
>>>
>>> I guess it needs to check whether regular file was a backfile of mounted
>>> loop device, so we can only skip block device related check?
>>>
>>> https://lore.kernel.org/linux-f2fs-devel/[email protected]
>>>
>>> Thanks,
>>
>> Ah, yes, it needs to check whether regular file was a backfile of mounted 
>> loop devce,
>> but it does not conflict with skip check device mount state in sparse mode.
>>
>> Sparse file is Android only for making userdata.img or other rw partion 
>> image, in this case
>> i guess we will not mkfs to a backfile of mounted loop device, right? skip 
>> check mount state is more efficient.
>
>But this patch leaves a hole to mkfs backfile of loop device w/ -S option
>in non-Android system, right?
>
>Thanks,
>
Ok, get it.

Thanks

>>
>>>

 Signed-off-by: zhangxirui 
 ---
lib/libf2fs.c | 4 
1 file changed, 4 insertions(+)

 diff --git a/lib/libf2fs.c b/lib/libf2fs.c
 index 2451201..5315de2 100644
 --- a/lib/libf2fs.c
 +++ b/lib/libf2fs.c
 @@ -830,6 +830,10 @@ int f2fs_devs_are_umounted(void)
{
int i;

 +  /*no need to check device mount state in sparse mode*/
 +  if (c.sparse_mode)
 +  return 0;
 +
for (i = 0; i < c.ndevs; i++)
if (f2fs_dev_is_umounted((char *)c.devices[i].path))
return -1;



___
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs-tools: reduce overprov_segment_count set times

2024-08-01 Thread zhangxirui via Linux-f2fs-devel
If overprov_segment_count < rsvd_segment_count will
set_cp(overprov_segment_count) twice, reduce it.

Signed-off-by: zhangxirui 
---
 mkfs/f2fs_format.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index e26a513..794ced5 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -764,10 +764,6 @@ static int f2fs_write_check_point_pack(void)
get_cp(rsvd_segment_count)) *
c.overprovision / 100);
 
-   if (!(c.conf_reserved_sections) &&
-   get_cp(overprov_segment_count) < get_cp(rsvd_segment_count))
-   set_cp(overprov_segment_count, get_cp(rsvd_segment_count));
-
/*
 * If conf_reserved_sections has a non zero value, 
overprov_segment_count
 * is set to overprov_segment_count + rsvd_segment_count.
@@ -787,8 +783,11 @@ static int f2fs_write_check_point_pack(void)
set_cp(overprov_segment_count, get_cp(overprov_segment_count) +
get_cp(rsvd_segment_count));
 } else {
-   set_cp(overprov_segment_count, get_cp(overprov_segment_count) +
-   overprovision_segment_buffer(sb));
+   /*
+* overprov_segment_count must bigger than rsvd_segment_count.
+*/
+   set_cp(overprov_segment_count, max(get_cp(rsvd_segment_count),
+   get_cp(overprov_segment_count)) + 
overprovision_segment_buffer(sb));
 }
 
if (f2fs_get_usable_segments(sb) <= get_cp(overprov_segment_count)) {
-- 
2.25.1



___
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel