Re: XFS: Approach to persist data & metadata changes on original file before IO acknowledgment when file is reflinked

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux