On Mon, Jul 29, 2024 at 09:53:52PM +0800, yangerkun wrote: > But after commit a2e459555c5f("shmem: stable directory offsets"), > simple_offset_rename will just add the new dentry to the maple tree of > &SHMEM_I(inode)->dir_offsets->mt with the key always inc by 1(since > simple_offset_add we will find free entry start with octx->newx_offset, so > the entry freed in simple_offset_remove won't be found). And the same case > upper will be break since we loop too many times(we can fall into infinite > readdir without this break). > > I prefer this is really a bug, and for the way to fix it, I think we can > just use the same logic what 9b378f6ad48cf("btrfs: fix infinite directory > reads") has did, introduce a last_index when we open the dir, and then > readdir will not return the entry which index greater than the last index. > > Looking forward to your comments! I agree to all of the above.