Re: [PATCH v2] fat: preallocate space before expanding in fat_cont_expand()
From: OGAWA Hirofumi
Date: Fri Oct 23 2026 - 11:57:52 EST
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx> writes:
>> static int fat_cont_expand(struct inode *inode, loff_t size)
>> {
>> struct address_space *mapping = inode->i_mapping;
>> loff_t start = inode->i_size, count = size - inode->i_size;
>> int err;
>>
>> - err = generic_cont_expand_simple(inode, size);
>> + /*
>> + * Preallocating space here is more efficient than during
>> + * generic_cont_expand_simple() because of batching.
>> + */
>> + err = inode_newsize_ok(inode, size);
>> if (err)
>> goto out;
>> + err = fat_preallocate(inode, size);
>> + if (err)
>> + goto out;
>> + err = generic_cont_expand_simple(inode, size);
>> + if (err) {
>> + down_write(&MSDOS_I(inode)->truncate_lock);
>> + fat_truncate_blocks(inode, inode->i_size);
>> + up_write(&MSDOS_I(inode)->truncate_lock);
>
> Is this fat_truncate_blocks() really required?
>
>> + goto out;
>> + }
And maybe this will change the user visible behavior for ENOSPC. (I'm
not sure if it is ok for now)
Thanks.
--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>