diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2014-03-06 00:55:03 -0500 |
---|---|---|
committer | Josef Bacik <jbacik@fb.com> | 2014-03-10 15:17:29 -0400 |
commit | 573bfb72f7608eb7097d2dd036a714a6ab20cffe (patch) | |
tree | 5434c2e82299cf22af4470fef31d3890d209a0b9 /fs/btrfs/ctree.h | |
parent | 31f3d255c677073f83daa1e0671bbf2157bf8edc (diff) |
Btrfs: fix possible empty list access when flushing the delalloc inodes
We didn't have a lock to protect the access to the delalloc inodes list, that is
we might access a empty delalloc inodes list if someone start flushing delalloc
inodes because the delalloc inodes were moved into a other list temporarily.
Fix it by wrapping the access with a lock.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 5f4921554f0a..2a9d32e193a5 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1490,6 +1490,7 @@ struct btrfs_fs_info { | |||
1490 | */ | 1490 | */ |
1491 | struct list_head ordered_roots; | 1491 | struct list_head ordered_roots; |
1492 | 1492 | ||
1493 | struct mutex delalloc_root_mutex; | ||
1493 | spinlock_t delalloc_root_lock; | 1494 | spinlock_t delalloc_root_lock; |
1494 | /* all fs/file tree roots that have delalloc inodes. */ | 1495 | /* all fs/file tree roots that have delalloc inodes. */ |
1495 | struct list_head delalloc_roots; | 1496 | struct list_head delalloc_roots; |
@@ -1805,6 +1806,7 @@ struct btrfs_root { | |||
1805 | spinlock_t root_item_lock; | 1806 | spinlock_t root_item_lock; |
1806 | atomic_t refs; | 1807 | atomic_t refs; |
1807 | 1808 | ||
1809 | struct mutex delalloc_mutex; | ||
1808 | spinlock_t delalloc_lock; | 1810 | spinlock_t delalloc_lock; |
1809 | /* | 1811 | /* |
1810 | * all of the inodes that have delalloc bytes. It is possible for | 1812 | * all of the inodes that have delalloc bytes. It is possible for |