From: Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: linux-fsdevel@vger.kernel.org, brauner@kernel.org,
djwong@kernel.org, hch@lst.de, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 6/8] fat: add iomap buffered I/O support
Date: Thu, 12 Nov 2026 22:49:37 -0300 [thread overview]
Message-ID: <avZrAxczb507gDls@DESKTOP-PJTTJ93.localdomain> (raw)
In-Reply-To: <878q2yaba4.fsf@mail.parknet.co.jp>
On Thu, Nov 12, 2026 at 02:06:43PM +0900, OGAWA Hirofumi wrote:
>Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br> writes:
>
>> On Mon, Nov 09, 2026 at 12:03:00AM +0900, OGAWA Hirofumi wrote:
>>>Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br> writes:
>>>
>>>> Use iomap for buffered I/O, replacing buffer_heads. Remove
>>>> fat_get_block(), fat_write_begin(), fat_write_failed() as the iomap path
>>>> makes them unnecessary.
>>>>
>>>> Signed-off-by: Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br>
>>>> ---
>>>> fs/fat/fat.h | 4 +-
>>>> fs/fat/file.c | 72 +++++++++++++++++++----
>>>> fs/fat/inode.c | 157 +++++--------------------------------------------
>>>> fs/fat/iomap.c | 84 ++++++++++++++++++++++++++
>>>> 4 files changed, 164 insertions(+), 153 deletions(-)
>>>>
>>>
>>>[...]
>>>
>>>> diff --git a/fs/fat/file.c b/fs/fat/file.c
>>>> index 8689cbbdad13..723b671d5b4b 100644
>>>> --- a/fs/fat/file.c
>>>> +++ b/fs/fat/file.c
>>>
>>>[...]
>>>
>>>> +static int fat_cont_expand(struct inode *inode, loff_t new_size);
>>>> +
>>>> +static ssize_t fat_file_write_iter_buffered(struct kiocb *iocb,
>>>> + struct iov_iter *iter)
>>>> +{
>>>> + struct inode *inode = file_inode(iocb->ki_filp);
>>>> + struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
>>>> + loff_t offset, old_size, old_alloc, keep_alloc;
>>>> + ssize_t ret;
>>>> +
>>>> + inode_lock(inode);
>>>> + ret = generic_write_checks(iocb, iter);
>>>> + if (ret <= 0)
>>>> + goto out;
>>>> +
>>>> + ret = file_modified(iocb->ki_filp);
>>>> + if (ret)
>>>> + goto out;
>>>> +
>>>> + offset = iocb->ki_pos;
>>>> + old_size = i_size_read(inode);
>>>> + if (offset > old_size) {
>>>> + /* We need to fill this hole */
>>>> + ret = fat_cont_expand(inode, offset);
>>>> + if (ret)
>>>> + goto out;
>>>> + }
>>>> +
>>>> + inode_dio_wait(inode);
>>>> + old_alloc = inode_get_bytes(inode);
>>>> + ret = iomap_file_buffered_write(iocb, iter, &fat_iomap_write_ops,
>>>> + NULL, NULL);
>>>> + keep_alloc = max(old_alloc, round_up(i_size_read(inode),
>>>> + sbi->cluster_size));
>>>> + if (inode_get_bytes(inode) > keep_alloc)
>>>> + fat_truncate_blocks(inode, keep_alloc);
>>>
>>>What is doing by this fat_truncate_blocks?
>>>
>>
>> It's trimming the clusters past EOF and keeping the fallocate KEEP_SIZE
>> preallocation. I can add a comment stating this.
>
>Hm, I wonder mostly why this truncate without checking "ret"...
>
>Thanks.
>
It is meant as a cleanup for a failed or short write, serving the same
role as fat_write_failed(). I'll add a ret check for readability.
Thanks,
Matheus
next prev parent reply other threads:[~2026-11-13 1:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 16:43 [RFC PATCH 0/8] fat: convert to iomap Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 1/8] fat: support FIEMAP Matheus Alves de Almeida
2026-11-08 14:51 ` OGAWA Hirofumi
2026-11-12 4:09 ` Matheus Alves de Almeida
2026-11-12 5:03 ` OGAWA Hirofumi
2026-11-13 1:41 ` Matheus Alves de Almeida
2026-11-13 3:53 ` OGAWA Hirofumi
2026-10-31 16:43 ` [RFC PATCH 2/8] fat: use iomap for ->bmap() Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 3/8] fat: add iomap direct I/O support Matheus Alves de Almeida
2026-11-08 14:56 ` OGAWA Hirofumi
2026-11-12 4:18 ` Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 4/8] fat: clean stale bdev buffers of newly allocated clusters Matheus Alves de Almeida
2026-11-08 14:57 ` OGAWA Hirofumi
2026-11-12 4:22 ` Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 5/8] fat: drop ->write_begin() and ->write_end() usage from fat_cont_expand() Matheus Alves de Almeida
2026-11-08 14:59 ` OGAWA Hirofumi
2026-11-12 4:26 ` Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 6/8] fat: add iomap buffered I/O support Matheus Alves de Almeida
2026-11-08 15:03 ` OGAWA Hirofumi
2026-11-12 4:35 ` Matheus Alves de Almeida
2026-11-12 5:06 ` OGAWA Hirofumi
2026-11-13 1:49 ` Matheus Alves de Almeida [this message]
2026-10-31 16:43 ` [RFC PATCH 7/8] fat: remove ->mmu_private Matheus Alves de Almeida
2026-10-31 16:43 ` [RFC PATCH 8/8] fat: add multi-cluster allocation for write Matheus Alves de Almeida
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=avZrAxczb507gDls@DESKTOP-PJTTJ93.localdomain \
--to=matheus.aalmeida@inf.ufrgs.br \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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®