Skip to content

Commit 7ae1681

Browse files
geliangtangkdave
authored andcommitted
btrfs: use list_for_each_entry_safe in free-space-cache.c
Use list_for_each_entry_safe() instead of list_for_each_safe() to simplify the code. Signed-off-by: Geliang Tang <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent b69f2be commit 7ae1681

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

fs/btrfs/free-space-cache.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,14 +1086,11 @@ write_pinned_extent_entries(struct btrfs_root *root,
10861086
static noinline_for_stack int
10871087
write_bitmap_entries(struct btrfs_io_ctl *io_ctl, struct list_head *bitmap_list)
10881088
{
1089-
struct list_head *pos, *n;
1089+
struct btrfs_free_space *entry, *next;
10901090
int ret;
10911091

10921092
/* Write out the bitmaps */
1093-
list_for_each_safe(pos, n, bitmap_list) {
1094-
struct btrfs_free_space *entry =
1095-
list_entry(pos, struct btrfs_free_space, list);
1096-
1093+
list_for_each_entry_safe(entry, next, bitmap_list, list) {
10971094
ret = io_ctl_add_bitmap(io_ctl, entry->bitmap);
10981095
if (ret)
10991096
return -ENOSPC;
@@ -1119,13 +1116,10 @@ static int flush_dirty_cache(struct inode *inode)
11191116
static void noinline_for_stack
11201117
cleanup_bitmap_list(struct list_head *bitmap_list)
11211118
{
1122-
struct list_head *pos, *n;
1119+
struct btrfs_free_space *entry, *next;
11231120

1124-
list_for_each_safe(pos, n, bitmap_list) {
1125-
struct btrfs_free_space *entry =
1126-
list_entry(pos, struct btrfs_free_space, list);
1121+
list_for_each_entry_safe(entry, next, bitmap_list, list)
11271122
list_del_init(&entry->list);
1128-
}
11291123
}
11301124

11311125
static void noinline_for_stack

0 commit comments

Comments
 (0)