[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260117044904.GD15522@frogsfrogsfrogs>
Date: Fri, 16 Jan 2026 20:49:04 -0800
From: "Darrick J. Wong" <djwong@...nel.org>
To: Theodore Tso <tytso@....edu>
Cc: Daniel Tang <danielzgtg.opensource@...il.com>,
linux-ext4@...r.kernel.org
Subject: Re: [GIT PULL] e4defrag inline data segfault fix
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@...nel.org>
--D
> - Ted
>
Powered by blists - more mailing lists