From: Pankaj Raghav <pankaj.raghav@linux.dev>
To: Pankaj Raghav <p.raghav@samsung.com>,
linux-xfs@vger.kernel.org, dgc@kernel.org
Cc: bfoster@redhat.com, lukas@herbolt.com,
"Darrick J . Wong" <djwong@kernel.org>,
gost.dev@samsung.com, andres@anarazel.de,
kundan.kumar@samsung.com, hch@lst.de, cem@kernel.org,
hch@infradead.org, pankaj.raghav@linux.dev
Subject: Re: [PATCH v5 2/2] xfs: add support for FALLOC_FL_WRITE_ZEROES
Date: Mon, 8 Jun 2026 12:20:29 +0200 [thread overview]
Message-ID: <7084832c-800b-4248-aaee-3da5ea266c1f@linux.dev> (raw)
In-Reply-To: <20260604101442.2613872-3-p.raghav@samsung.com>
> +
> + error = xfs_alloc_file_space(ip, offset, len,
> + XFS_ALLOC_FILE_SPACE_WRITE_ZEROES);
> + if (error)
> + return error;
> +
> + /*
> + * xfs_falloc_setsize() would re-zero the written extents via
> + * iomap_zero_range(). Use xfs_setfilesize() instead.
> + * Update in-core i_size first as xfs_setfilesize() clamps the on-disk
> + * size to it.
> + */
> + if (new_size > i_size_read(inode))
> + i_size_write(inode, new_size);
> +
> + return xfs_setfilesize(ip, offset, len);
Sashiko reported:
On 32-bit systems where size_t is 32 bits, lengths exceeding 4GB will be
truncated, which might cause the on-disk inode size to be permanently updated
to a severely incorrect smaller size.
So a simple fix would be the following as we already store the value of offset + len locally:
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 37623baaaed6..86fae2190c24 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -1426,7 +1426,7 @@ xfs_falloc_write_zeroes(
if (new_size > i_size_read(inode))
i_size_write(inode, new_size);
- return xfs_setfilesize(ip, offset, len);
+ return xfs_setfilesize(ip, new_size, 0);
}
Probably I will update setfilesize to take 64bit values for len in a separate series.
I will also wait if others have any comments before sending the next version.
@Dave: You were against the initial design[1]. Let me know your thoughts on the current version.
[1] https://lore.kernel.org/linux-xfs/abCzhDSVmFx4PtWI@dread/
--
Pankaj
next prev parent reply other threads:[~2026-06-08 10:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 10:14 [PATCH v5 0/2] add FALLOC_FL_WRITE_ZEROES support to xfs Pankaj Raghav
2026-06-04 10:14 ` [PATCH v5 1/2] xfs: add an allocation mode to xfs_alloc_file_space() Pankaj Raghav
2026-06-04 10:14 ` [PATCH v5 2/2] xfs: add support for FALLOC_FL_WRITE_ZEROES Pankaj Raghav
2026-06-08 10:20 ` Pankaj Raghav [this message]
2026-06-10 5:56 ` Christoph Hellwig
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=7084832c-800b-4248-aaee-3da5ea266c1f@linux.dev \
--to=pankaj.raghav@linux.dev \
--cc=andres@anarazel.de \
--cc=bfoster@redhat.com \
--cc=cem@kernel.org \
--cc=dgc@kernel.org \
--cc=djwong@kernel.org \
--cc=gost.dev@samsung.com \
--cc=hch@infradead.org \
--cc=hch@lst.de \
--cc=kundan.kumar@samsung.com \
--cc=linux-xfs@vger.kernel.org \
--cc=lukas@herbolt.com \
--cc=p.raghav@samsung.com \
/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