From: "Darrick J. Wong" <djwong@kernel.org>
To: Theodore Tso <tytso@mit.edu>
Cc: Daniel Tang <danielzgtg.opensource@gmail.com>,
linux-ext4@vger.kernel.org
Subject: Re: [GIT PULL] e4defrag inline data segfault fix
Date: Fri, 16 Jan 2026 20:49:04 -0800 [thread overview]
Message-ID: <20260117044904.GD15522@frogsfrogsfrogs> (raw)
In-Reply-To: <20260117034747.GA19954@macsyma.local>
On Fri, Jan 16, 2026 at 05:47:47PM -1000, Theodore Tso wrote:
> On Fri, Jan 16, 2026 at 06:35:59PM -0800, Darrick J. Wong wrote:
> > > - /* Has no blocks */
> > > - if (buf->st_blocks == 0) {
> > > + /* Has 0 or 1 blocks, no point to defragment */
> > > + if (buf->st_blocks <= buf->st_blksize / 512) {
> >
> > ...because can't you call FS_IOC_GETFLAGS and look for
> > EXT4_INLINE_DATA_FL?
>
> I could have checked for EXT4_INLINE_DATA_FL, but we need to call
> stat(2) to check for the st_blocks == 0 case, and while it is harmless
> to defrag a file with a single data block, it's also pointless and a
> waste of system calls. So it's best that we skip defragging the file
> in these cases:
>
> A) A zero-length file with st_blocks == 0
> B) A file with a single data block (st_blocks == st_blksize / 512)
> C) A file with inline data (st_blocks == 1)
>
> ... and we can do that only by checking the values returned by
> stat(2).
>
> Yes, (B) and (C) relies on Linux's behavior, since Posix is silent on
> the semantics of st_blocks, but e4defrag works only by using a
> Linux-specific ioctl, and using FS_IOC_GETFLAGS would also be
> Linux-only.
Fair enough.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> - Ted
>
prev parent reply other threads:[~2026-01-17 4:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 10:25 [GIT PULL] e4defrag inline data segfault fix Daniel Tang
2026-01-16 17:21 ` Darrick J. Wong
2026-01-16 23:44 ` Theodore Tso
2026-01-17 2:35 ` Darrick J. Wong
2026-01-17 3:47 ` Theodore Tso
2026-01-17 4:49 ` Darrick J. Wong [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=20260117044904.GD15522@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=danielzgtg.opensource@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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