Re: [PATCH] Add EXT4_STATE_MAY_INLINE_DATA check in ext4_readdir
shuo chen <[email protected]>
| Newsgroups | org.kernel.vger.linux-ext4 |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Aug 13, 2026 at 11:31:03PM -0400, Theodore Tso wrote: > On Thu, Aug 13, 2026 at 04:33:57PM -0500, pipishuo wrote: > > After a failure in the route ext4_restore_inline_data -> > > ext4_create_inline_data -> ext4_mark_iloc_dirty, the inode will still > > be considered as having inline data. > > How did you run across this? Was this something that was actually > happening? If so, what was triggering the error? > > Or was this something that was found via AI? I didn't have a reproducer. I was reviewing the inline data error paths and noticed the interaction with ext4_readdir looked fragile so I attempted to make it more robust. > > I'm fairly sure this patch was created using AI. This useless > inclusion was a bit of a tip-off: > > > +#include <asm-generic/errno-base.h> It was automatically inserted by my editor's include suggestion feature, and I missed it in review. That's entirely my fault. > > As far as the fix is concerned, there's a much better way of > implementing the functionality in ext4_restore_inline_data(), which is > to just capture a copy of the inode (since the inline data is stored > in the inode), and if we need to back out a failed conversion in > ext4_convert_inline_data_nolock(), we can just copy the old contents > of the inode back in place. Because ext4_convert_inline_data_nolock() has already called ext4_destroy_inline_data_nolock(), the inode is no longer in the inline state. So we need ext4_create_inline_data() to rebuild the inline state. > > We can also do the conversion in a much safer way, by allocating the > data block first, and writing a copy of the data to the data block, > and only if that is successful, do we update the extent tree or > indirect block mapping in the inode. Of course, this would require a > rewrite of ext4_convert_inline_data_nolock(), but this would allow us > to fix up the other aspects of the error handling which is not quite > right. I agree with your direction. I'll take some time to study the code and work on a proper v2 that rewrites ext4_convert_inline_data_nolock() following that model. > > - Ted