2014-02-03 04:46:35

by OGAWA Hirofumi

[permalink] [raw]
Subject: Re: [PATCH v3 2/6] fat: add fat_fallocate operation


Sorry for long delay.

Namjae Jeon <[email protected]> writes:

> + if (mode & FALLOC_FL_KEEP_SIZE) {
> + /* First compute the number of clusters to be allocated */
> + mm_bytes = offset + len - round_up(MSDOS_I(inode)->mmu_private,
> + sbi->cluster_size);

This should use ->i_disksize?

[...]

> + /* Release unwritten fallocated blocks on inode eviction. */
> + if (MSDOS_I(inode)->mmu_private < MSDOS_I(inode)->i_disksize) {
> + int err;
> + fat_truncate_blocks(inode, MSDOS_I(inode)->mmu_private);
> + /* Fallocate results in updating the i_start/iogstart
> + * for the zero byte file. So, make it return to
> + * original state during evict and commit it
> + * synchrnously to avoid any corruption on the next
> + * access to the cluster chain for the file.
> + */
> + err = fat_sync_inode(inode);

Ah, good catch. We have to update i_size. I was forgetting about this.
Well, sync inode unconditionally would not be good. Maybe, we better to
use __fat_write_inode() with inode_needs_sync() or such.
--
OGAWA Hirofumi <[email protected]>


2014-02-03 23:04:53

by Namjae Jeon

[permalink] [raw]
Subject: Re: [PATCH v3 2/6] fat: add fat_fallocate operation

2014-02-03, OGAWA Hirofumi <[email protected]>:
>
> Sorry for long delay.
>
> Namjae Jeon <[email protected]> writes:
>
>> + if (mode & FALLOC_FL_KEEP_SIZE) {
>> + /* First compute the number of clusters to be allocated */
>> + mm_bytes = offset + len - round_up(MSDOS_I(inode)->mmu_private,
>> + sbi->cluster_size);
>
Hi OGAWA.
> This should use ->i_disksize?
Right, I will fix it.
>
> [...]
>
>> + /* Release unwritten fallocated blocks on inode eviction. */
>> + if (MSDOS_I(inode)->mmu_private < MSDOS_I(inode)->i_disksize) {
>> + int err;
>> + fat_truncate_blocks(inode, MSDOS_I(inode)->mmu_private);
>> + /* Fallocate results in updating the i_start/iogstart
>> + * for the zero byte file. So, make it return to
>> + * original state during evict and commit it
>> + * synchrnously to avoid any corruption on the next
>> + * access to the cluster chain for the file.
>> + */
>> + err = fat_sync_inode(inode);
>
> Ah, good catch. We have to update i_size. I was forgetting about this.
> Well, sync inode unconditionally would not be good. Maybe, we better to
> use __fat_write_inode() with inode_needs_sync() or such.
Okay, I will change it.

Thanks.
> --
> OGAWA Hirofumi <[email protected]>
>

2014-02-14 04:53:29

by Namjae Jeon

[permalink] [raw]
Subject: Re: [PATCH v3 2/6] fat: add fat_fallocate operation

>> [...]
>>
>>> + /* Release unwritten fallocated blocks on inode eviction. */
>>> + if (MSDOS_I(inode)->mmu_private < MSDOS_I(inode)->i_disksize) {
>>> + int err;
>>> + fat_truncate_blocks(inode, MSDOS_I(inode)->mmu_private);
>>> + /* Fallocate results in updating the i_start/iogstart
>>> + * for the zero byte file. So, make it return to
>>> + * original state during evict and commit it
>>> + * synchrnously to avoid any corruption on the next
>>> + * access to the cluster chain for the file.
>>> + */
>>> + err = fat_sync_inode(inode);
>>
>> Ah, good catch. We have to update i_size. I was forgetting about this.
>> Well, sync inode unconditionally would not be good. Maybe, we better to
>> use __fat_write_inode() with inode_needs_sync() or such.
> Okay, I will change it.
Hi OGAWA

When I checked more, we should wait till inode is sync. Because in the
eviction it will leave the inode/buffers being marked dirty.
Not waiting for it get sync over here. It will leave cluster chain
corrupted when remounting.
It mean we cannot use __fat_write_inode with inode_needs_sync() conditionally.

Thanks.
>
> Thanks.
>> --
>> OGAWA Hirofumi <[email protected]>
>>
>

2014-02-14 07:30:25

by OGAWA Hirofumi

[permalink] [raw]
Subject: Re: [PATCH v3 2/6] fat: add fat_fallocate operation

Namjae Jeon <[email protected]> writes:

>>> [...]
>>>
>>>> + /* Release unwritten fallocated blocks on inode eviction. */
>>>> + if (MSDOS_I(inode)->mmu_private < MSDOS_I(inode)->i_disksize) {
>>>> + int err;
>>>> + fat_truncate_blocks(inode, MSDOS_I(inode)->mmu_private);
>>>> + /* Fallocate results in updating the i_start/iogstart
>>>> + * for the zero byte file. So, make it return to
>>>> + * original state during evict and commit it
>>>> + * synchrnously to avoid any corruption on the next
>>>> + * access to the cluster chain for the file.
>>>> + */
>>>> + err = fat_sync_inode(inode);
>>>
>>> Ah, good catch. We have to update i_size. I was forgetting about this.
>>> Well, sync inode unconditionally would not be good. Maybe, we better to
>>> use __fat_write_inode() with inode_needs_sync() or such.
>> Okay, I will change it.
> Hi OGAWA
>
> When I checked more, we should wait till inode is sync. Because in the
> eviction it will leave the inode/buffers being marked dirty.
> Not waiting for it get sync over here. It will leave cluster chain
> corrupted when remounting.
> It mean we cannot use __fat_write_inode with inode_needs_sync() conditionally.

Yeah, this situation bothers us. However, the inode is not marked as
dirty after I_FREEING. And in fatfs case, all related dirty buffers
should goes into blockdev inode buffers (i.e. metadata only), right?

So, I thought sync is not necessary.

Thanks.
--
OGAWA Hirofumi <[email protected]>

2014-02-14 10:16:14

by Namjae Jeon

[permalink] [raw]
Subject: Re: [PATCH v3 2/6] fat: add fat_fallocate operation

2014-02-14 16:30 GMT+09:00, OGAWA Hirofumi <[email protected]>:
> Namjae Jeon <[email protected]> writes:
>
>>>> [...]
>>>>
>>>>> + /* Release unwritten fallocated blocks on inode eviction. */
>>>>> + if (MSDOS_I(inode)->mmu_private < MSDOS_I(inode)->i_disksize) {
>>>>> + int err;
>>>>> + fat_truncate_blocks(inode, MSDOS_I(inode)->mmu_private);
>>>>> + /* Fallocate results in updating the i_start/iogstart
>>>>> + * for the zero byte file. So, make it return to
>>>>> + * original state during evict and commit it
>>>>> + * synchrnously to avoid any corruption on the next
>>>>> + * access to the cluster chain for the file.
>>>>> + */
>>>>> + err = fat_sync_inode(inode);
>>>>
>>>> Ah, good catch. We have to update i_size. I was forgetting about this.
>>>> Well, sync inode unconditionally would not be good. Maybe, we better to
>>>> use __fat_write_inode() with inode_needs_sync() or such.
>>> Okay, I will change it.
>> Hi OGAWA
>>
>> When I checked more, we should wait till inode is sync. Because in the
>> eviction it will leave the inode/buffers being marked dirty.
>> Not waiting for it get sync over here. It will leave cluster chain
>> corrupted when remounting.
>> It mean we cannot use __fat_write_inode with inode_needs_sync()
>> conditionally.
>
> Yeah, this situation bothers us. However, the inode is not marked as
> dirty after I_FREEING. And in fatfs case, all related dirty buffers
> should goes into blockdev inode buffers (i.e. metadata only), right?
Right.
>
> So, I thought sync is not necessary.
Yes, I will add it as you pointed.

Thanks for review!
>
> Thanks.
> --
> OGAWA Hirofumi <[email protected]>
>