Btrfs: don't do async reclaim during log replay V2
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
@@ -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
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_rootas 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
Signed-off-by Josef Bacik <[email protected]>---
V1->V2: usefs_info->log_root_recoveringinstead, 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@@ -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);
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_rootas 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_rootinitialization 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
MiaoQuoted 19 lines
Signed-off-by Josef Bacik <[email protected]>---
V1->V2: usefs_info->log_root_recoveringinstead, 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@@ -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
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_rootas 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_rootinitialization 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
Miao Xie
Reviewed-byQuoted 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_rootas 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_rootinitialization 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.