* [PATCH 1/3] btrfs: Fix in-segment calculation for reada
@ 2015-12-18 14:10 Zhao Lei
2015-12-18 14:10 ` [PATCH 2/3] btrfs: reduce additional fs_info->reada_lock in reada_find_zone Zhao Lei
2015-12-18 14:10 ` [PATCH 3/3] btrfs: Add missed segment checking " Zhao Lei
0 siblings, 2 replies; 3+ messages in thread
From: Zhao Lei @ 2015-12-18 14:10 UTC (permalink / raw)
To: linux-btrfs; +Cc: Zhao Lei
reada_zone->end is end pos of segment:
end = start + cache->key.offset - 1;
So we need to use "<=" in condition to judge is a pos in the
segment.
The problem happened rearly, because logical pos rarely pointed
to last 4k of a blockgroup, but we need to fix it to make code
right in logic.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
fs/btrfs/reada.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index 7bbd656..6fb9c37 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -265,7 +265,7 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
spin_unlock(&fs_info->reada_lock);
if (ret == 1) {
- if (logical >= zone->start && logical < zone->end)
+ if (logical >= zone->start && logical <= zone->end)
return zone;
spin_lock(&fs_info->reada_lock);
kref_put(&zone->refcnt, reada_zone_release);
@@ -684,7 +684,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
*/
ret = radix_tree_gang_lookup(&dev->reada_extents, (void **)&re,
dev->reada_next >> PAGE_CACHE_SHIFT, 1);
- if (ret == 0 || re->logical >= dev->reada_curr_zone->end) {
+ if (ret == 0 || re->logical > dev->reada_curr_zone->end) {
ret = reada_pick_zone(dev);
if (!ret) {
spin_unlock(&fs_info->reada_lock);
--
1.8.5.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] btrfs: reduce additional fs_info->reada_lock in reada_find_zone
2015-12-18 14:10 [PATCH 1/3] btrfs: Fix in-segment calculation for reada Zhao Lei
@ 2015-12-18 14:10 ` Zhao Lei
2015-12-18 14:10 ` [PATCH 3/3] btrfs: Add missed segment checking " Zhao Lei
1 sibling, 0 replies; 3+ messages in thread
From: Zhao Lei @ 2015-12-18 14:10 UTC (permalink / raw)
To: linux-btrfs; +Cc: Zhao Lei
We can avoid additional locking-acquirment and one pair of
kref_get/put by combine two condition.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
fs/btrfs/reada.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index 6fb9c37..d8116fe 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -260,18 +260,14 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
spin_lock(&fs_info->reada_lock);
ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone,
logical >> PAGE_CACHE_SHIFT, 1);
- if (ret == 1)
+ if (ret == 1 && logical >= zone->start && logical <= zone->end) {
kref_get(&zone->refcnt);
- spin_unlock(&fs_info->reada_lock);
-
- if (ret == 1) {
- if (logical >= zone->start && logical <= zone->end)
- return zone;
- spin_lock(&fs_info->reada_lock);
- kref_put(&zone->refcnt, reada_zone_release);
spin_unlock(&fs_info->reada_lock);
+ return zone;
}
+ spin_unlock(&fs_info->reada_lock);
+
cache = btrfs_lookup_block_group(fs_info, logical);
if (!cache)
return NULL;
--
1.8.5.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] btrfs: Add missed segment checking in reada_find_zone
2015-12-18 14:10 [PATCH 1/3] btrfs: Fix in-segment calculation for reada Zhao Lei
2015-12-18 14:10 ` [PATCH 2/3] btrfs: reduce additional fs_info->reada_lock in reada_find_zone Zhao Lei
@ 2015-12-18 14:10 ` Zhao Lei
1 sibling, 0 replies; 3+ messages in thread
From: Zhao Lei @ 2015-12-18 14:10 UTC (permalink / raw)
To: linux-btrfs; +Cc: Zhao Lei
In rechecking zone-in-tree, we still need to check zone include
our logical address.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
fs/btrfs/reada.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index d8116fe..c65b42f 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -303,8 +303,10 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
kfree(zone);
ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone,
logical >> PAGE_CACHE_SHIFT, 1);
- if (ret == 1)
+ if (ret == 1 && logical >= zone->start && logical <= zone->end)
kref_get(&zone->refcnt);
+ else
+ zone = NULL;
}
spin_unlock(&fs_info->reada_lock);
--
1.8.5.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-18 14:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18 14:10 [PATCH 1/3] btrfs: Fix in-segment calculation for reada Zhao Lei
2015-12-18 14:10 ` [PATCH 2/3] btrfs: reduce additional fs_info->reada_lock in reada_find_zone Zhao Lei
2015-12-18 14:10 ` [PATCH 3/3] btrfs: Add missed segment checking " Zhao Lei
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.