diff mbox series

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

Message ID 20240126063723.2926123-1-xirui.zhang@vivo.com (mailing list archive)
State New
Headers show
Series [f2fs-dev] f2fs-tools: skip check device mount state in sparse mode | expand

Commit Message

zhangxirui Jan. 26, 2024, 6:37 a.m. UTC
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 <xirui.zhang@vivo.com>
---
 lib/libf2fs.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Chao Yu Jan. 31, 2024, 7:39 a.m. UTC | #1
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/20240131073425.4043962-1-chao@kernel.org

Thanks,

> 
> Signed-off-by: zhangxirui <xirui.zhang@vivo.com>
> ---
>   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;
Chao Yu Feb. 1, 2024, 6:37 a.m. UTC | #2
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/20240131073425.4043962-1-chao@kernel.org
>>
>> 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,

> 
>>
>>>
>>> Signed-off-by: zhangxirui <xirui.zhang@vivo.com>
>>> ---
>>>    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;
>
zhangxirui Feb. 1, 2024, 6:40 a.m. UTC | #3
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/20240131073425.4043962-1-chao@kernel.org
>
>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 <xirui.zhang@vivo.com>
>> ---
>>   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;
zhangxirui Feb. 1, 2024, 7:17 a.m. UTC | #4
>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/20240131073425.4043962-1-chao@kernel.org
>>>
>>> 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 <xirui.zhang@vivo.com>
>>>> ---
>>>>    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;
diff mbox series

Patch

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;