mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br>
Cc: linux-fsdevel@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] fat: preallocate space before expanding in fat_cont_expand()
Date: Sat, 24 Oct 2026 09:06:35 +0900	[thread overview]
Message-ID: <8733twq7w4.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <atvP82ca9Gl0DiAG@DESKTOP-PJTTJ93.localdomain>

Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br> writes:

> On Sat, Oct 24, 2026 at 12:44:04AM +0900, OGAWA Hirofumi wrote:
>>OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> 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@mail.parknet.co.jp>
>
> The behavior on a fallocate() ENOSPC failure seems to differ across
> filesystems, some (e.g. exFAT, NTFS3) keep the original size while others
> (e.g. ext4) keep the partially extended size.
>
> If preserving the current FAT behavior is preferred, I can look into that
> for a v3. Maybe adding a new fat_try_alloc_chain() helper that allocates
> as many clusters as it can instead of failing the entire allocation.
>
> What do you think?

fallocate() or expand truncate() path. Hm, well, we can try to change
the error behavior (if failed, revert then).
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

  reply	other threads:[~2026-10-24  0:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 15:40 Matheus Alves de Almeida
2026-10-23  7:33 ` OGAWA Hirofumi
2026-10-23 15:44   ` OGAWA Hirofumi
2026-10-23 21:23     ` Matheus Alves de Almeida
2026-10-24  0:06       ` OGAWA Hirofumi [this message]
2026-10-23 21:21   ` Matheus Alves de Almeida
2026-10-23 23:48     ` OGAWA Hirofumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8733twq7w4.fsf@mail.parknet.co.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matheus.aalmeida@inf.ufrgs.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®