Skip to contentSkip to conversation

Btrfs: don't do async reclaim during log replay V2

PATCH In review Josef Bacik 2 participants 5 messages Sep 18, 2014 – Nov 7, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: don't do async reclaim during log replay V2

Trying to reproduce a log enospc bug I hit a panic in the async reclaim code during log replay. This is because we use fs_info->fs_root as our root for shrinking and such. Technically we can use whatever root we want, but let's just not allow async reclaim while we're doing log replay. Thanks,

---
V1->V2: use fs_info->log_root_recovering instead, didn't notice this existed before.

 fs/btrfs/extent-tree.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
fs/btrfs/extent-tree.c +7 -1
index 28a27d5..44d0497 100644
@@ -4513,7 +4513,13 @@ again:
 		space_info->flush = 1;
 	} else if (!ret && space_info->flags & BTRFS_BLOCK_GROUP_METADATA) {
 		used += orig_bytes;
-		if (need_do_async_reclaim(space_info, root->fs_info, used) &&
+		/*
+		 * We will do the space reservation dance during log replay,
+		 * which means we won't have fs_info->fs_root set, so don't do
+		 * the async reclaim as we will panic.
+		 */
+		if (!root->fs_info->log_root_recovering &&
+		    need_do_async_reclaim(space_info, root->fs_info, used) &&
 		    !work_busy(&root->fs_info->async_reclaim_work))
 			queue_work(system_unbound_wq,
 				   &root->fs_info->async_reclaim_work);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 4 lines · Josef Bacik

Trying to reproduce a log enospc bug I hit a panic in the async reclaim code during log replay. This is because we use fs_info->fs_root as our root for shrinking and such. Technically we can use whatever root we want, but let's just not allow async reclaim while we're doing log replay. Thanks,

Why not move the code of fs_root initialization to the front of log replay? I think it is better than the fix way in this patch because the async reclaimer can help us do some work.

Thanks
Miao

Quoted 29 lines

---
V1->V2: use fs_info->log_root_recovering instead, didn't notice this existed before.

 fs/btrfs/extent-tree.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
fs/btrfs/extent-tree.c +7 -1
index 28a27d5..44d0497 100644
@@ -4513,7 +4513,13 @@ again:
 		space_info->flush = 1;
 	} else if (!ret && space_info->flags & BTRFS_BLOCK_GROUP_METADATA) {
 		used += orig_bytes;
-		if (need_do_async_reclaim(space_info, root->fs_info, used) &&
+		/*
+		 * We will do the space reservation dance during log replay,
+		 * which means we won't have fs_info->fs_root set, so don't do
+		 * the async reclaim as we will panic.
+		 */
+		if (!root->fs_info->log_root_recovering &&
+		    need_do_async_reclaim(space_info, root->fs_info, used) &&
 		    !work_busy(&root->fs_info->async_reclaim_work))
 			queue_work(system_unbound_wq,
 				   &root->fs_info->async_reclaim_work);
#2 lore raw

Ping..

Quoted 48 lines · Miao Xie
Quoted 4 lines · Josef Bacik

Trying to reproduce a log enospc bug I hit a panic in the async reclaim code during log replay. This is because we use fs_info->fs_root as our root for shrinking and such. Technically we can use whatever root we want, but let's just not allow async reclaim while we're doing log replay. Thanks,

Why not move the code of fs_root initialization to the front of log replay? I think it is better than the fix way in this patch because the async reclaimer can help us do some work.

Thanks
Miao

Quoted 19 lines

---
V1->V2: use fs_info->log_root_recovering instead, didn't notice this existed before.

 fs/btrfs/extent-tree.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
fs/btrfs/extent-tree.c +0 -1
index 28a27d5..44d0497 100644
@@ -4513,7 +4513,13 @@ again:
 		space_info->flush = 1;
 	} else if (!ret && space_info->flags & BTRFS_BLOCK_GROUP_METADATA) {
 		used += orig_bytes;
-		if (need_do_async_reclaim(space_info, root->fs_info, used) &&

fs/btrfs/extent-tree.c again: · line 4525

Quoted 10 lines
fs/btrfs/extent-tree.c +7 -0
+		/*
+		 * We will do the space reservation dance during log replay,
+		 * which means we won't have fs_info->fs_root set, so don't do
+		 * the async reclaim as we will panic.
+		 */
+		if (!root->fs_info->log_root_recovering &&
+		    need_do_async_reclaim(space_info, root->fs_info, used) &&
 		    !work_busy(&root->fs_info->async_reclaim_work))
 			queue_work(system_unbound_wq,
 				   &root->fs_info->async_reclaim_work);

--
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

#3 lore raw
In reply to Miao Xie
Quoted 10 lines · Miao Xie
Quoted 4 lines · Josef Bacik

Trying to reproduce a log enospc bug I hit a panic in the async reclaim code during log replay. This is because we use fs_info->fs_root as our root for shrinking and such. Technically we can use whatever root we want, but let's just not allow async reclaim while we're doing log replay. Thanks,

Why not move the code of fs_root initialization to the front of log replay? I think it is better than the fix way in this patch because the async reclaimer can help us do some work.

Because this is simpler. We could move the initialization forward, but then say somebody comes and adds some other dependency to the async reclaim stuff in the future and doesn't think about log replay and suddenly some poor sap's box panics on mount. Log replay is a known quantity, we don't have to worry about enospc, so lets make it as simple as possible. Thanks,

Josef

Reviewed-by
#4 lore raw
Quoted 7 lines · Josef Bacik
Quoted 6 lines · Miao Xie
Quoted 4 lines · Josef Bacik

Trying to reproduce a log enospc bug I hit a panic in the async reclaim code during log replay. This is because we use fs_info->fs_root as our root for shrinking and such. Technically we can use whatever root we want, but let's just not allow async reclaim while we're doing log replay. Thanks,

Quoted 6 lines
Quoted 4 lines

Why not move the code of fs_root initialization to the front of log replay? I think it is better than the fix way in this patch because the async reclaimer can help us do some work.

Because this is simpler. We could move the initialization forward, but then say somebody comes and adds some other dependency to the async reclaim stuff in the future and doesn't think about log replay and suddenly some poor sap's box panics on mount. Log replay is a known quantity, we don't have to worry about enospc, so lets make it as simple as possible. Thanks,

Yes, you are right.

So this patch looks good.