btrfs: reada: move reada_extent_put to place after __readahead_hook()
authorZhao Lei <zhaolei@cn.fujitsu.com>
Thu, 31 Dec 2015 13:07:17 +0000 (21:07 +0800)
committerDavid Sterba <dsterba@suse.com>
Thu, 18 Feb 2016 09:26:12 +0000 (10:26 +0100)
We can't release reada_extent earlier than __readahead_hook(), because
__readahead_hook() still need to use it, it is necessary to hode a refcnt
to avoid it be freed.

Actually it is not a problem after my patch named:
  Avoid many times of empty loop
It make reada_extent in above line include at least one reada_extctl,
which keeps additional one refcnt for reada_extent.

But we still need this patch to make the code in pretty logic.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/reada.c

index b40dbf717737689248b8cdaa40264547a817e03b..f7642e569bd98f814950b7feda0466ce5b867440 100644 (file)
@@ -717,8 +717,6 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
        }
        logical = re->logical;
 
-       reada_extent_put(fs_info, re);
-
        atomic_inc(&dev->reada_in_flight);
        ret = reada_tree_block_flagged(fs_info->extent_root, logical,
                        mirror_num, &eb);
@@ -730,6 +728,8 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
        if (eb)
                free_extent_buffer(eb);
 
+       reada_extent_put(fs_info, re);
+
        return 1;
 
 }