Message ID | b433c98aae18577662767e98d4119450913dc516.1706183427.git.fdmanana@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: some directory fixes for stable 5.15 | expand |
On Thu, Jan 25, 2024 at 11:59:36AM +0000, fdmanana@kernel.org wrote: > From: Filipe Manana <fdmanana@suse.com> > > commit 357950361cbc6d54fb68ed878265c647384684ae upstream. > > When opening a directory for reading it, we set the last index where we > stop iteration to the value in struct btrfs_inode::index_cnt. That value > does not match the index of the most recently added directory entry but > it's instead the index number that will be assigned the next directory > entry. [..] > CC: stable@vger.kernel.org # 6.5+ > Signed-off-by: Filipe Manana <fdmanana@suse.com> > Signed-off-by: David Sterba <dsterba@suse.com> Based on https://lore.kernel.org/stable/20240126185534.GA2668448@lxhi-087: Reviewed-by: Eugeniu Rosca <eugeniu.rosca@bosch.com>
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 1df374ce829b..b144e346f24c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6184,7 +6184,8 @@ static int btrfs_get_dir_last_index(struct btrfs_inode *dir, u64 *index) } } - *index = dir->index_cnt; + /* index_cnt is the index number of next new entry, so decrement it. */ + *index = dir->index_cnt - 1; return 0; }