From: Christoph Hellwig <hch@infradead.org>
To: Mitta Sai Chaithanya <mittas@microsoft.com>
Cc: "linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>
Subject: Re: XFS: Approach to persist data & metadata changes on original file before IO acknowledgment when file is reflinked
Date: Mon, 9 Dec 2024 20:43:24 -0800 [thread overview]
Message-ID: <Z1fG7DSi4SaqYYf6@infradead.org> (raw)
In-Reply-To: <PUZP153MB07280F8AE7FA1BB00946E25CD7352@PUZP153MB0728.APCP153.PROD.OUTLOOK.COM>
On Mon, Dec 02, 2024 at 10:41:02AM +0000, Mitta Sai Chaithanya wrote:
> Hi Team,
> We are using XFS reflink feature to create snapshot of an origin
> file (a thick file, created through fallocate) and exposing origin file
> as a block device to the users.
How do you expose it as a block device? As a loop device? And what is
a "thick" file?
> XFS file was opened with O_DIRECT option to avoid buffers at lower
> layer while performing writes,
Note that O_DIRECT can still create page cache, e.g. when writing less
than the block size to a reflinked file. Note that it should matter
as the caching is transparent to the user.
> even though a thick file is created, when user performs writes then
> there are metadata changes associated to writes (mostly xfs marks
> extents to know whether the data is written to physical blocks or not).
Any write can create metadata changes, and you must always call
fdatasync to persist them. There are a few corner cases where we try
to optimize some of them away, but that's an internal implementation
detail. In that case fdatasync will do nothing, but you still need to
call it.
> To avoid metadata changes during user writes we are explicitly zeroing
> entire file range post creation of file, so that there won't be any
> metadata changes in future for writes that happen on zeroed blocks.
Why do you care about avoiding metadata changes?
> Now, if reflink copy of origin file is created then there will
> be metadata changes which need to be persisted if data is overwritten
> on the reflinked blocks of original file. Even though the file is opened
> in O_DIRECT mode changes to metadata do not persist before write is
> acknowledged back to user, if system crashes when changes are in buffer
> then post recovery writes which were acknowledged are not available to
> read.
Of course. O_DIRECT is completely unrelated to using O_(D)SYNC or
f(data)sync to persist data.
prev parent reply other threads:[~2024-12-10 4:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 10:41 XFS: Approach to persist data & metadata changes on original file before IO acknowledgment when file is reflinked Mitta Sai Chaithanya
2024-12-02 23:40 ` Dave Chinner
2024-12-06 12:43 ` [EXTERNAL] " Mitta Sai Chaithanya
2024-12-09 22:23 ` Dave Chinner
2024-12-10 4:43 ` Christoph Hellwig [this message]
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=Z1fG7DSi4SaqYYf6@infradead.org \
--to=hch@infradead.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mittas@microsoft.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