From: "Darrick J. Wong" <djwong@kernel.org>
To: Sai Chaitanya Mitta <mittachaitu@gmail.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: Approach to quickly zeroing large XFS file (or) tool to mark XFS file extents as written
Date: Mon, 6 Jan 2025 11:46:39 -0800 [thread overview]
Message-ID: <20250106194639.GH6174@frogsfrogsfrogs> (raw)
In-Reply-To: <CAN=PFfKDd=Y=14re01hY970JJNG7QCKUb6NOiZisQ0WWNmhcsw@mail.gmail.com>
On Tue, Dec 24, 2024 at 11:17:08AM +0530, Sai Chaitanya Mitta wrote:
> Hi Darrick,
> Thanks for the quick response, we are exposing XFS file (created
> through fallocate -l <size> <path>) as block device through
> SPDK bdev (https://github.com/spdk/spdk) over NVMe-oF, Now initiator will
> connect to the target and provide a block device to database applications.
> What I have observed is databases' applications are issuing flush IO post
> each/couple of writes, this flush at backend at backend translates to
> fsync (through aio/io_uring) operation on FD (which is time taking process),
> if we are doing no-op for flush IO then performance is 5x better compared to
> serving flush operation. Doing no-op for flush and if system shutdown abruptly
> then we are observing data loss (since metadata for new extents are not yet
> persistent) to overcome this data loss issue and having better performance
> below are the steps used:
> 1. Created file through fallocate using FALLOC_FL_ZERO_RANGE option
> 2. Explicitly zeroed file as mentioned in code (this marks all extents as
> written and there are no metadata changes related to data [what I observed],
> but there are atime and mtime updates of file).
> 3. Expose zeroed file to user as block device (as mentioned above).
>
> Using above approach if system shutdown abruptly then I am not able
> to reproduce data loss issue. So, planning to use above method to ensure
> both data integrity and better performance
That sounds brittle -- even if someday a FALLOC_FL_WRITE_ZEROES gets
merged into the kernel, if anything perturbs the file mapping (e.g.
background backup process reflinks the file) then you immediately become
vulnerable to these crash integrity problems without notice.
(Unless you're actually getting leases on the file ranges and reacting
appropriately when the leases break...)
--D
> On Tue, Dec 24, 2024 at 3:23 AM Darrick J. Wong <djwong@kernel.org> wrote:
> >
> > On Mon, Dec 23, 2024 at 10:12:32PM +0530, Sai Chaitanya Mitta wrote:
> > > Hi Team,
> > > Is there any method/tool available to explicitly mark XFS
> > > file extents as written? One approach I
> > > am aware is explicitly zeroing the entire file (this file may be even
> > > in hundreds of GB in size) through
> > > synchronous/asynchronous(aio/io_uring) mechanism but it is time taking
> > > process for large files,
> > > is there any optimization/approach we can do to explicitly zeroing
> > > file/mark extents as written?
> >
> > Why do you need to mark them written?
> >
> > --D
> >
> > >
> > > Synchronous Approach:
> > > while offset < size {
> > > let bytes_written = img_file
> > > .write_at(&buf, offset)
> > > .map_err(|e| {
> > > error!("Failed to zero out file: {}
> > > error: {:?}", vol_name, e);
> > > })?;
> > > if offset == size {
> > > break;
> > > }
> > > offset = offset + bytes_written as u64;
> > > }
> > > img_file.sync_all();
> > >
> > > Asynchronous approach:
> > > Currently used fio with libaio as ioengine but
> > > results are almost same.
> > >
> > > --
> > > Thanks& Regards,
> > > M.Sai Chaithanya.
> > >
>
>
>
> --
> Thanks& Regards,
> M.Sai Chaithanya.
>
next prev parent reply other threads:[~2025-01-06 19:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-23 16:42 Approach to quickly zeroing large XFS file (or) tool to mark XFS file extents as written Sai Chaitanya Mitta
2024-12-23 21:53 ` Darrick J. Wong
2024-12-24 5:47 ` Sai Chaitanya Mitta
2025-01-06 19:46 ` Darrick J. Wong [this message]
2025-01-07 6:14 ` Christoph Hellwig
2025-01-07 7:04 ` Darrick J. Wong
2025-01-07 8:37 ` Christoph Hellwig
2025-01-07 22:11 ` Darrick J. Wong
2024-12-24 3:42 ` Dave Chinner
2025-01-06 11:15 ` 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=20250106194639.GH6174@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mittachaitu@gmail.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