Skip to content

Commit

Permalink
Merge tag 'for-4.15-tag' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/kdave/linux

Pull btrfs fix from David Sterba:
 "It's been reported recently that readdir can list stale entries under
  some conditions. Fix it."

* tag 'for-4.15-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  Btrfs: fix stale entries in readdir
  • Loading branch information
Linus Torvalds committed Jan 25, 2018
2 parents 5b7d279 + e4fd493 commit 525273f
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions fs/btrfs/delayed-inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1633,28 +1633,18 @@ void btrfs_readdir_put_delayed_items(struct inode *inode,
int btrfs_should_delete_dir_index(struct list_head *del_list,
u64 index)
{
struct btrfs_delayed_item *curr, *next;
int ret;

if (list_empty(del_list))
return 0;
struct btrfs_delayed_item *curr;
int ret = 0;

list_for_each_entry_safe(curr, next, del_list, readdir_list) {
list_for_each_entry(curr, del_list, readdir_list) {
if (curr->key.offset > index)
break;

list_del(&curr->readdir_list);
ret = (curr->key.offset == index);

if (refcount_dec_and_test(&curr->refs))
kfree(curr);

if (ret)
return 1;
else
continue;
if (curr->key.offset == index) {
ret = 1;
break;
}
}
return 0;
return ret;
}

/*
Expand Down

0 comments on commit 525273f

Please sign in to comment.