Readahead clenups
David Sterba
maintainercover Readahead clenups
I spotted some GFP_NOFS uses in readahead and converted them to GFP_KERNEL with a few cleanups along the way.
David Sterba (7):
btrfs: preallocate radix tree node for readahead
btrfs: use simpler readahead zone lookups
btrfs: preallocate radix tree node for global readahead tree
btrfs: remove redundant parameter from btree_readahead_hook
btrfs: remove redundant parameter from reada_find_zone
btrfs: remove redundant parameter from reada_start_machine_dev
btrfs: remove local blocksize variable in reada_find_extent
fs/btrfs/ctree.h | 3 +- fs/btrfs/disk-io.c | 6 ++-- fs/btrfs/reada.c | 89 ++++++++++++++++++++++++++++-------------------------- fs/btrfs/volumes.c | 2 +- 4 files changed, 51 insertions(+), 49 deletions(-)
Signature · 1 line
2.12.0
David Sterba
maintainerPATCH 1/7 btrfs: preallocate radix tree node for readahead
We can preallocate the node so insertion does not have to do that under the lock. The GFP flags for the per-device radix tree are initialized to
GFP_NOFS & ~__GFP_DIRECT_RECLAIM
but we can use GFP_KERNEL, same as an allocation above anyway, but also because readahead is optional and not on any critical writeout path.
--- fs/btrfs/reada.c | 7 +++++++ fs/btrfs/volumes.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
fs/btrfs/reada.c +7 -0
@@ -270,6 +270,12 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,if (!zone)return NULL ; + ret =radix_tree_preload (GFP_KERNEL ); +if (ret) { +kfree (zone); +return NULL ; + } + zone->start = start; zone->end = end;INIT_LIST_HEAD (&zone->list);
@@ -299,6 +305,7 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info, zone =NULL ; }spin_unlock (&fs_info->reada_lock); +radix_tree_preload_end ();return zone; }
fs/btrfs/volumes.c +1 -1
@@ -247,7 +247,7 @@ static struct btrfs_device *__alloc_device(void)atomic_set (&dev->reada_in_flight,0 );atomic_set (&dev->dev_stats_ccnt,0 );btrfs_device_data_ordered_init (dev); -INIT_RADIX_TREE (&dev->reada_zones,GFP_NOFS & ~__GFP_DIRECT_RECLAIM); +INIT_RADIX_TREE (&dev->reada_zones,GFP_KERNEL );INIT_RADIX_TREE (&dev->reada_extents,GFP_NOFS & ~__GFP_DIRECT_RECLAIM);return dev;
Signature · 1 line
2.12.0
Re: [PATCH 1/7] btrfs: preallocate radix tree node for readahead
Quoted 6 lines · David Sterba
We can preallocate the node so insertion does not have to do that under the lock. The GFP flags for the per-device radix tree are initialized to
GFP_NOFS& ~__GFP_DIRECT_RECLAIM
but we can useGFP_KERNEL, same as an allocation above anyway, but also because readahead is optional and not on any critical writeout path.
Thanks,
-liubo
Quoted 51 lines
Signed-off-by David Sterba <[email protected]>--- fs/btrfs/reada.c | 7 +++++++ fs/btrfs/volumes.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)fs/btrfs/reada.c +7
-0@@ -270,6 +270,12 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,if (!zone)return NULL ; + ret =radix_tree_preload (GFP_KERNEL ); +if (ret) { +kfree (zone); +return NULL ; + } + zone->start = start; zone->end = end;INIT_LIST_HEAD (&zone->list);@@ -299,6 +305,7 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info, zone =NULL ; }spin_unlock (&fs_info->reada_lock); +radix_tree_preload_end ();return zone; }fs/btrfs/volumes.c +1
-1@@ -247,7 +247,7 @@ static struct btrfs_device *__alloc_device(void)atomic_set (&dev->reada_in_flight,0 );atomic_set (&dev->dev_stats_ccnt,0 );btrfs_device_data_ordered_init (dev); -INIT_RADIX_TREE (&dev->reada_zones,GFP_NOFS & ~__GFP_DIRECT_RECLAIM); +INIT_RADIX_TREE (&dev->reada_zones,GFP_KERNEL );INIT_RADIX_TREE (&dev->reada_extents,GFP_NOFS & ~__GFP_DIRECT_RECLAIM);return dev;Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
maintainerPATCH 2/7 btrfs: use simpler readahead zone lookups
In reply to David SterbaNo point using radix_tree_gang_lookup if we're looking up just one slot.
--- fs/btrfs/reada.c | 52 ++++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 30 deletions(-)
fs/btrfs/reada.c +22 -30
@@ -246,11 +246,9 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,u64 end;int i; - zone =NULL ;spin_lock (&fs_info->reada_lock); - ret =radix_tree_gang_lookup (&dev->reada_zones, (void **)&zone, - logical >>PAGE_SHIFT ,1 ); -if (ret ==1 && logical >= zone->start && logical <= zone->end) { + zone =radix_tree_lookup (&dev->reada_zones, logical >>PAGE_SHIFT ); +if (zone && logical >= zone->start && logical <= zone->end) {kref_get (&zone->refcnt);spin_unlock (&fs_info->reada_lock);return zone;
@@ -297,9 +295,9 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,if (ret == -EEXIST ) {kfree (zone); - ret =radix_tree_gang_lookup (&dev->reada_zones, (void **)&zone, - logical >>PAGE_SHIFT ,1 ); -if (ret ==1 && logical >= zone->start && logical <= zone->end) + zone =radix_tree_lookup (&dev->reada_zones, + logical >>PAGE_SHIFT ); +if (zone && logical >= zone->start && logical <= zone->end)kref_get (&zone->refcnt);else zone =NULL ;
@@ -604,7 +602,6 @@ static int reada_pick_zone(struct btrfs_device *dev)u64 top_elems =0 ;u64 top_locked_elems =0 ;unsigned long index =0 ; -int ret;if (dev->reada_curr_zone) {reada_peer_zones_set_lock (dev->reada_curr_zone,0 );
@@ -615,9 +612,8 @@ static int reada_pick_zone(struct btrfs_device *dev)while (1 ) {struct reada_zone *zone; - ret =radix_tree_gang_lookup (&dev->reada_zones, - (void **)&zone, index,1 ); -if (ret ==0 ) + zone =radix_tree_lookup (&dev->reada_zones, index); +if (!zone)break ; index = (zone->end >>PAGE_SHIFT ) +1 ;if (zone->locked) {
@@ -669,19 +665,18 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,* a contiguous block of extents, we could also coagulate them or use * plugging to speed things up */ - ret =radix_tree_gang_lookup (&dev->reada_extents, (void **)&re, - dev->reada_next >>PAGE_SHIFT ,1 ); -if (ret ==0 || re->logical > dev->reada_curr_zone->end) { + re =radix_tree_lookup (&dev->reada_extents, + dev->reada_next >>PAGE_SHIFT ); +if (!re || re->logical > dev->reada_curr_zone->end) { ret =reada_pick_zone (dev);if (!ret) {spin_unlock (&fs_info->reada_lock);return 0 ; } - re =NULL ; - ret =radix_tree_gang_lookup (&dev->reada_extents, (void **)&re, - dev->reada_next >>PAGE_SHIFT ,1 ); + re =radix_tree_lookup (&dev->reada_extents, + dev->reada_next >>PAGE_SHIFT ); } -if (ret ==0 ) { +if (!re) {spin_unlock (&fs_info->reada_lock);return 0 ; }
@@ -809,7 +804,6 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)struct btrfs_device *device;struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;unsigned long index; -int ret;int i;int j;int cnt;
@@ -821,9 +815,9 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) index =0 ;while (1 ) {struct reada_zone *zone; - ret =radix_tree_gang_lookup (&device->reada_zones, - (void **)&zone, index,1 ); -if (ret ==0 ) + + zone =radix_tree_lookup (&device->reada_zones, index); +if (!zone)break ; pr_debug(" zone %llu-%llu elems %llu locked %d devs", zone->start, zone->end, zone->elems,
@@ -841,11 +835,10 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) cnt =0 ; index =0 ;while (all) { -struct reada_extent *re =NULL ; +struct reada_extent *re; - ret =radix_tree_gang_lookup (&device->reada_extents, - (void **)&re, index,1 ); -if (ret ==0 ) + re =radix_tree_lookup (&device->reada_extents, index); +if (!re)break ; pr_debug(" re: logical %llu size %u empty %d scheduled %d", re->logical, fs_info->nodesize,
@@ -870,11 +863,10 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) index =0 ; cnt =0 ;while (all) { -struct reada_extent *re =NULL ; +struct reada_extent *re; - ret =radix_tree_gang_lookup (&fs_info->reada_tree, (void **)&re, - index,1 ); -if (ret ==0 ) + re =radix_tree_lookup (&fs_info->reada_tree, index); +if (!re)break ;if (!re->scheduled) { index = (re->logical >>PAGE_SHIFT ) +1 ;
Signature · 1 line
2.12.0
Re: [PATCH 2/7] btrfs: use simpler readahead zone lookups
Quoted 2 lines · David Sterba
No point using
radix_tree_gang_lookupif we're looking up just one slot.
Thanks,
-liubo
Quoted 140 lines
Signed-off-by David Sterba <[email protected]>--- fs/btrfs/reada.c | 52 ++++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 30 deletions(-)fs/btrfs/reada.c +22
-30@@ -246,11 +246,9 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,u64 end;int i; - zone =NULL ;spin_lock (&fs_info->reada_lock); - ret =radix_tree_gang_lookup (&dev->reada_zones, (void **)&zone, - logical >>PAGE_SHIFT ,1 ); -if (ret ==1 && logical >= zone->start && logical <= zone->end) { + zone =radix_tree_lookup (&dev->reada_zones, logical >>PAGE_SHIFT ); +if (zone && logical >= zone->start && logical <= zone->end) {kref_get (&zone->refcnt);spin_unlock (&fs_info->reada_lock);return zone;@@ -297,9 +295,9 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,if (ret == -EEXIST ) {kfree (zone); - ret =radix_tree_gang_lookup (&dev->reada_zones, (void **)&zone, - logical >>PAGE_SHIFT ,1 ); -if (ret ==1 && logical >= zone->start && logical <= zone->end) + zone =radix_tree_lookup (&dev->reada_zones, + logical >>PAGE_SHIFT ); +if (zone && logical >= zone->start && logical <= zone->end)kref_get (&zone->refcnt);else zone =NULL ;@@ -604,7 +602,6 @@ static int reada_pick_zone(struct btrfs_device *dev)u64 top_elems =0 ;u64 top_locked_elems =0 ;unsigned long index =0 ; -int ret;if (dev->reada_curr_zone) {reada_peer_zones_set_lock (dev->reada_curr_zone,0 );@@ -615,9 +612,8 @@ static int reada_pick_zone(struct btrfs_device *dev)while (1 ) {struct reada_zone *zone; - ret =radix_tree_gang_lookup (&dev->reada_zones, - (void **)&zone, index,1 ); -if (ret ==0 ) + zone =radix_tree_lookup (&dev->reada_zones, index); +if (!zone)break ; index = (zone->end >>PAGE_SHIFT ) +1 ;if (zone->locked) {@@ -669,19 +665,18 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,* a contiguous block of extents, we could also coagulate them or use * plugging to speed things up */ - ret =radix_tree_gang_lookup (&dev->reada_extents, (void **)&re, - dev->reada_next >>PAGE_SHIFT ,1 ); -if (ret ==0 || re->logical > dev->reada_curr_zone->end) { + re =radix_tree_lookup (&dev->reada_extents, + dev->reada_next >>PAGE_SHIFT ); +if (!re || re->logical > dev->reada_curr_zone->end) { ret =reada_pick_zone (dev);if (!ret) {spin_unlock (&fs_info->reada_lock);return 0 ; } - re =NULL ; - ret =radix_tree_gang_lookup (&dev->reada_extents, (void **)&re, - dev->reada_next >>PAGE_SHIFT ,1 ); + re =radix_tree_lookup (&dev->reada_extents, + dev->reada_next >>PAGE_SHIFT ); } -if (ret ==0 ) { +if (!re) {spin_unlock (&fs_info->reada_lock);return 0 ; }@@ -809,7 +804,6 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)struct btrfs_device *device;struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;unsigned long index; -int ret;int i;int j;int cnt;@@ -821,9 +815,9 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) index =0 ;while (1 ) {struct reada_zone *zone; - ret =radix_tree_gang_lookup (&device->reada_zones, - (void **)&zone, index,1 ); -if (ret ==0 ) + + zone =radix_tree_lookup (&device->reada_zones, index); +if (!zone)break ; pr_debug(" zone %llu-%llu elems %llu locked %d devs", zone->start, zone->end, zone->elems,@@ -841,11 +835,10 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) cnt =0 ; index =0 ;while (all) { -struct reada_extent *re =NULL ; +struct reada_extent *re; - ret =radix_tree_gang_lookup (&device->reada_extents, - (void **)&re, index,1 ); -if (ret ==0 ) + re =radix_tree_lookup (&device->reada_extents, index); +if (!re)break ; pr_debug(" re: logical %llu size %u empty %d scheduled %d", re->logical, fs_info->nodesize,@@ -870,11 +863,10 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) index =0 ; cnt =0 ;while (all) { -struct reada_extent *re =NULL ; +struct reada_extent *re; - ret =radix_tree_gang_lookup (&fs_info->reada_tree, (void **)&re, - index,1 ); -if (ret ==0 ) + re =radix_tree_lookup (&fs_info->reada_tree, index); +if (!re)break ;if (!re->scheduled) { index = (re->logical >>PAGE_SHIFT ) +1 ;Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/7] btrfs: use simpler readahead zone lookups
In reply to David SterbaQuoted 3 lines · David Sterba
No point using
radix_tree_gang_lookupif we're looking up just one slot.Signed-off-by David Sterba <[email protected]>
I've bisected to this patch, causes a hang in btrfs/011. I'll revert it for until I find out the cause.
David Sterba
maintainerPATCH 3/7 btrfs: preallocate radix tree node for global readahead tree
In reply to David SterbaWe can preallocate the node so insertion does not have to do that under the lock. The GFP flags for the global radix tree are initialized to
GFP_NOFS & ~__GFP_DIRECT_RECLAIM
but we can use GFP_KERNEL, because readahead is optional and not on any critical writeout path.
--- fs/btrfs/disk-io.c | 2 +- fs/btrfs/reada.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
fs/btrfs/disk-io.c +1 -1
@@ -2693,7 +2693,7 @@ int open_ctree(struct super_block *sb, fs_info->commit_interval =BTRFS_DEFAULT_COMMIT_INTERVAL ; fs_info->avg_delayed_ref_runtime =NSEC_PER_SEC >>6 ;/* div by 64 */ /* readahead state */ -INIT_RADIX_TREE (&fs_info->reada_tree,GFP_NOFS & ~__GFP_DIRECT_RECLAIM); +INIT_RADIX_TREE (&fs_info->reada_tree,GFP_KERNEL );spin_lock_init (&fs_info->reada_lock); fs_info->thread_pool_size = min_t(unsigned long,
fs/btrfs/reada.c +7 -0
@@ -391,6 +391,10 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info, goto error; } + ret =radix_tree_preload (GFP_KERNEL ); +if (ret) + goto error; +/* insert extent in reada_tree + all per-device trees, all or nothing */ btrfs_dev_replace_lock (&fs_info->dev_replace,0 );spin_lock (&fs_info->reada_lock);
@@ -400,13 +404,16 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info, re_exist->refcnt++;spin_unlock (&fs_info->reada_lock);btrfs_dev_replace_unlock (&fs_info->dev_replace,0 ); +radix_tree_preload_end (); goto error; }if (ret) {spin_unlock (&fs_info->reada_lock);btrfs_dev_replace_unlock (&fs_info->dev_replace,0 ); +radix_tree_preload_end (); goto error; } +radix_tree_preload_end (); prev_dev =NULL ; dev_replace_is_ongoing =btrfs_dev_replace_is_ongoing ( &fs_info->dev_replace);
Signature · 1 line
2.12.0
Re: [PATCH 3/7] btrfs: preallocate radix tree node for global readahead tree
Quoted 5 lines · David Sterba
We can preallocate the node so insertion does not have to do that under the lock. The GFP flags for the global radix tree are initialized to
GFP_NOFS& ~__GFP_DIRECT_RECLAIM
but we can useGFP_KERNEL, because readahead is optional and not on any critical writeout path.
Thanks,
-liubo
Quoted 59 lines
Signed-off-by David Sterba <[email protected]>--- fs/btrfs/disk-io.c | 2 +- fs/btrfs/reada.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)fs/btrfs/disk-io.c +1
-1@@ -2693,7 +2693,7 @@ int open_ctree(struct super_block *sb, fs_info->commit_interval =BTRFS_DEFAULT_COMMIT_INTERVAL ; fs_info->avg_delayed_ref_runtime =NSEC_PER_SEC >>6 ;/* div by 64 */ /* readahead state */ -INIT_RADIX_TREE (&fs_info->reada_tree,GFP_NOFS & ~__GFP_DIRECT_RECLAIM); +INIT_RADIX_TREE (&fs_info->reada_tree,GFP_KERNEL );spin_lock_init (&fs_info->reada_lock); fs_info->thread_pool_size = min_t(unsigned long,fs/btrfs/reada.c +7
-0@@ -391,6 +391,10 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info, goto error; } + ret =radix_tree_preload (GFP_KERNEL ); +if (ret) + goto error; +/* insert extent in reada_tree + all per-device trees, all or nothing */ btrfs_dev_replace_lock (&fs_info->dev_replace,0 );spin_lock (&fs_info->reada_lock);@@ -400,13 +404,16 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info, re_exist->refcnt++;spin_unlock (&fs_info->reada_lock);btrfs_dev_replace_unlock (&fs_info->dev_replace,0 ); +radix_tree_preload_end (); goto error; }if (ret) {spin_unlock (&fs_info->reada_lock);btrfs_dev_replace_unlock (&fs_info->dev_replace,0 ); +radix_tree_preload_end (); goto error; } +radix_tree_preload_end (); prev_dev =NULL ; dev_replace_is_ongoing =btrfs_dev_replace_is_ongoing ( &fs_info->dev_replace);Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
maintainerPATCH 4/7 btrfs: remove redundant parameter from btree_readahead_hook
In reply to David SterbaWe can read fs_info from eb.
--- fs/btrfs/ctree.h | 3 +-- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/reada.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-)
fs/btrfs/ctree.h +1 -2
@@ -3671,8 +3671,7 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root, struct btrfs_key *start, struct btrfs_key *end);int btrfs_reada_wait (void *handle);void btrfs_reada_detach (void *handle); -int btree_readahead_hook (struct btrfs_fs_info *fs_info, -struct extent_buffer *eb,int err); +int btree_readahead_hook (struct extent_buffer *eb,int err);static inline int is_fstree (u64 rootid) {
fs/btrfs/disk-io.c +2 -2
@@ -762,7 +762,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, err:if (reads_done &&test_and_clear_bit (EXTENT_BUFFER_READAHEAD , &eb->bflags)) -btree_readahead_hook (fs_info, eb, ret); +btree_readahead_hook (eb, ret);if (ret) {/*
@@ -787,7 +787,7 @@ static int btree_io_failed_hook(struct page *page, int failed_mirror) eb->read_mirror = failed_mirror;atomic_dec (&eb->io_pages);if (test_and_clear_bit (EXTENT_BUFFER_READAHEAD , &eb->bflags)) -btree_readahead_hook (eb->fs_info, eb, -EIO ); +btree_readahead_hook (eb, -EIO );return -EIO ;/* we fixed nothing */ }
fs/btrfs/reada.c +2 -2
@@ -209,9 +209,9 @@ static void __readahead_hook(struct btrfs_fs_info *fs_info,return ; } -int btree_readahead_hook (struct btrfs_fs_info *fs_info, -struct extent_buffer *eb,int err) +int btree_readahead_hook (struct extent_buffer *eb,int err) { +struct btrfs_fs_info *fs_info = eb->fs_info;int ret =0 ;struct reada_extent *re;
Signature · 1 line
2.12.0
Re: [PATCH 4/7] btrfs: remove redundant parameter from btree_readahead_hook
Quoted 1 line · David Sterba
We can read
fs_infofrom eb.
Thanks,
-liubo
Quoted 67 lines
Signed-off-by David Sterba <[email protected]>--- fs/btrfs/ctree.h | 3 +-- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/reada.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-)fs/btrfs/ctree.h +1
-2@@ -3671,8 +3671,7 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root, struct btrfs_key *start, struct btrfs_key *end);int btrfs_reada_wait (void *handle);void btrfs_reada_detach (void *handle); -int btree_readahead_hook (struct btrfs_fs_info *fs_info, -struct extent_buffer *eb,int err); +int btree_readahead_hook (struct extent_buffer *eb,int err);static inline int is_fstree (u64 rootid) {fs/btrfs/disk-io.c +2
-2@@ -762,7 +762,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, err:if (reads_done &&test_and_clear_bit (EXTENT_BUFFER_READAHEAD , &eb->bflags)) -btree_readahead_hook (fs_info, eb, ret); +btree_readahead_hook (eb, ret);if (ret) {/* @@ -787,7 +787,7 @@ static int btree_io_failed_hook(struct page *page, int failed_mirror) eb->read_mirror = failed_mirror;atomic_dec (&eb->io_pages);if (test_and_clear_bit (EXTENT_BUFFER_READAHEAD , &eb->bflags)) -btree_readahead_hook (eb->fs_info, eb, -EIO ); +btree_readahead_hook (eb, -EIO );return -EIO ;/* we fixed nothing */ }fs/btrfs/reada.c +2
-2@@ -209,9 +209,9 @@ static void __readahead_hook(struct btrfs_fs_info *fs_info,return ; } -int btree_readahead_hook (struct btrfs_fs_info *fs_info, -struct extent_buffer *eb,int err) +int btree_readahead_hook (struct extent_buffer *eb,int err) { +struct btrfs_fs_info *fs_info = eb->fs_info;int ret =0 ;struct reada_extent *re;Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
maintainerPATCH 5/7 btrfs: remove redundant parameter from reada_find_zone
In reply to David SterbaWe can read fs_info from dev.
--- fs/btrfs/reada.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/reada.c +3 -3
@@ -235,10 +235,10 @@ int btree_readahead_hook(struct extent_buffer *eb, int err)return ret; } -static struct reada_zone *reada_find_zone (struct btrfs_fs_info *fs_info, -struct btrfs_device *dev,u64 logical, +static struct reada_zone *reada_find_zone (struct btrfs_device *dev,u64 logical,struct btrfs_bio *bbio) { +struct btrfs_fs_info *fs_info = dev->fs_info;int ret;struct reada_zone *zone;struct btrfs_block_group_cache *cache =NULL ;
@@ -372,7 +372,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,if (!dev->bdev)continue ; - zone =reada_find_zone (fs_info, dev, logical, bbio); + zone =reada_find_zone (dev, logical, bbio);if (!zone)continue ;
Signature · 1 line
2.12.0
Re: [PATCH 5/7] btrfs: remove redundant parameter from reada_find_zone
Quoted 2 lines · David Sterba
We can read
fs_infofrom dev.
Thanks,
-liubo
Quoted 38 lines
Signed-off-by David Sterba <[email protected]>--- fs/btrfs/reada.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/btrfs/reada.c +3
-3@@ -235,10 +235,10 @@ int btree_readahead_hook(struct extent_buffer *eb, int err)return ret; } -static struct reada_zone *reada_find_zone (struct btrfs_fs_info *fs_info, -struct btrfs_device *dev,u64 logical, +static struct reada_zone *reada_find_zone (struct btrfs_device *dev,u64 logical,struct btrfs_bio *bbio) { +struct btrfs_fs_info *fs_info = dev->fs_info;int ret;struct reada_zone *zone;struct btrfs_block_group_cache *cache =NULL ;@@ -372,7 +372,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,if (!dev->bdev)continue ; - zone =reada_find_zone (fs_info, dev, logical, bbio); + zone =reada_find_zone (dev, logical, bbio);if (!zone)continue ;Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
maintainerPATCH 6/7 btrfs: remove redundant parameter from reada_start_machine_dev
In reply to David SterbaWe can read fs_info from dev.
--- fs/btrfs/reada.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/btrfs/reada.c +3 -4
@@ -649,9 +649,9 @@ static int reada_pick_zone(struct btrfs_device *dev)return 1 ; } -static int reada_start_machine_dev (struct btrfs_fs_info *fs_info, -struct btrfs_device *dev) +static int reada_start_machine_dev (struct btrfs_device *dev) { +struct btrfs_fs_info *fs_info = dev->fs_info;struct reada_extent *re =NULL ;int mirror_num =0 ;struct extent_buffer *eb =NULL ;
@@ -763,8 +763,7 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info)list_for_each_entry (device, &fs_devices->devices, dev_list) {if (atomic_read (&device->reada_in_flight) <MAX_IN_FLIGHT ) - enqueued +=reada_start_machine_dev (fs_info, - device); + enqueued +=reada_start_machine_dev (device); }mutex_unlock (&fs_devices->device_list_mutex); total += enqueued;
Signature · 1 line
2.12.0
Re: [PATCH 6/7] btrfs: remove redundant parameter from reada_start_machine_dev
Quoted 2 lines · David Sterba
We can read
fs_infofrom dev.
Thanks,
-liubo
Quoted 38 lines
Signed-off-by David Sterba <[email protected]>--- fs/btrfs/reada.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)fs/btrfs/reada.c +3
-4@@ -649,9 +649,9 @@ static int reada_pick_zone(struct btrfs_device *dev)return 1 ; } -static int reada_start_machine_dev (struct btrfs_fs_info *fs_info, -struct btrfs_device *dev) +static int reada_start_machine_dev (struct btrfs_device *dev) { +struct btrfs_fs_info *fs_info = dev->fs_info;struct reada_extent *re =NULL ;int mirror_num =0 ;struct extent_buffer *eb =NULL ;@@ -763,8 +763,7 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info)list_for_each_entry (device, &fs_devices->devices, dev_list) {if (atomic_read (&device->reada_in_flight) <MAX_IN_FLIGHT ) - enqueued +=reada_start_machine_dev (fs_info, - device); + enqueued +=reada_start_machine_dev (device); }mutex_unlock (&fs_devices->device_list_mutex); total += enqueued;Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
maintainerPATCH 7/7 btrfs: remove local blocksize variable in reada_find_extent
In reply to David SterbaThe name is misleading and the local variable serves no purpose.
--- fs/btrfs/reada.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/btrfs/reada.c +2 -4
@@ -318,7 +318,6 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,struct btrfs_bio *bbio =NULL ;struct btrfs_device *dev;struct btrfs_device *prev_dev; -u32 blocksize;u64 length;int real_stripes;int nzones =0 ;
@@ -339,7 +338,6 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,if (!re)return NULL ; - blocksize = fs_info->nodesize; re->logical = logical; re->top = *top;INIT_LIST_HEAD (&re->extctl);
@@ -349,10 +347,10 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,/* * map block */ - length = blocksize; + length = fs_info->nodesize; ret =btrfs_map_block (fs_info,BTRFS_MAP_GET_READ_MIRRORS , logical, &length, &bbio,0 ); -if (ret || !bbio || length < blocksize) +if (ret || !bbio || length < fs_info->nodesize) goto error;if (bbio->num_stripes >BTRFS_MAX_MIRRORS ) {
Signature · 1 line
2.12.0
Re: [PATCH 7/7] btrfs: remove local blocksize variable in reada_find_extent
Quoted 1 line · David Sterba
The name is misleading and the local variable serves no purpose.
Thanks,
-liubo
Quoted 46 lines
Signed-off-by David Sterba <[email protected]>--- fs/btrfs/reada.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/btrfs/reada.c +2
-4@@ -318,7 +318,6 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,struct btrfs_bio *bbio =NULL ;struct btrfs_device *dev;struct btrfs_device *prev_dev; -u32 blocksize;u64 length;int real_stripes;int nzones =0 ;@@ -339,7 +338,6 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,if (!re)return NULL ; - blocksize = fs_info->nodesize; re->logical = logical; re->top = *top;INIT_LIST_HEAD (&re->extctl);@@ -349,10 +347,10 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,/* * map block */ - length = blocksize; + length = fs_info->nodesize; ret =btrfs_map_block (fs_info,BTRFS_MAP_GET_READ_MIRRORS , logical, &length, &bbio,0 ); -if (ret || !bbio || length < blocksize) +if (ret || !bbio || length < fs_info->nodesize) goto error;if (bbio->num_stripes >BTRFS_MAX_MIRRORS ) {Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html