All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix leaked plug after falilure syncing log on zoned filesystems
@ 2022-04-06 11:52 fdmanana
  2022-04-06 16:08   ` fdmanana
  0 siblings, 1 reply; 5+ messages in thread
From: fdmanana @ 2022-04-06 11:52 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

On a zoned filesystem, if we fail to allocate the root node for the log
root tree while syncing the log, we end up returning without finishing
the IO plug we started before, resulting in leaking resources as we
have started writeback for extent buffers of a log tree before. That
allocation failure is typically either -ENOMEM or -ENOSPC.

So release the IO plug if we fail to allocate the extent buffer for the
root of the log root tree when syncing the log on a zoned filesystem.

Fixes: 3ddebf27fcd3a9 ("btrfs: zoned: reorder log node allocation on zoned filesystem")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/tree-log.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 273998153fcc..6533329e5fd7 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3187,6 +3187,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
 		if (!log_root_tree->node) {
 			ret = btrfs_alloc_log_tree_node(trans, log_root_tree);
 			if (ret) {
+				blk_finish_plug(&plug);
 				mutex_unlock(&fs_info->tree_root->log_mutex);
 				goto out;
 			}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2] btrfs: fix leaked plug after failure syncing log on zoned filesystems
@ 2022-04-06 16:08   ` fdmanana
  0 siblings, 0 replies; 5+ messages in thread
From: fdmanana @ 2022-04-06 16:07 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

On a zoned filesystem, if we fail to allocate the root node for the log
root tree while syncing the log, we end up returning without finishing
the IO plug we started before, resulting in leaking resources as we
have started writeback for extent buffers of a log tree before. That
allocation failure, which typically is either -ENOMEM or -ENOSPC, is not
fatal and the fsync can safely fallback to a full transaction commit.

So release the IO plug if we fail to allocate the extent buffer for the
root of the log root tree when syncing the log on a zoned filesystem.

Fixes: 3ddebf27fcd3a9 ("btrfs: zoned: reorder log node allocation on zoned filesystem")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---

V2: Fixed typo in the subject, updated changelog.

 fs/btrfs/tree-log.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 273998153fcc..1fa21cfe059d 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3188,6 +3188,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
 			ret = btrfs_alloc_log_tree_node(trans, log_root_tree);
 			if (ret) {
 				mutex_unlock(&fs_info->tree_root->log_mutex);
+				blk_finish_plug(&plug);
 				goto out;
 			}
 		}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2] btrfs: fix leaked plug after failure syncing log on zoned filesystems
@ 2022-04-06 16:08   ` fdmanana
  0 siblings, 0 replies; 5+ messages in thread
From: fdmanana @ 2022-04-06 16:08 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

On a zoned filesystem, if we fail to allocate the root node for the log
root tree while syncing the log, we end up returning without finishing
the IO plug we started before, resulting in leaking resources as we
have started writeback for extent buffers of a log tree before. That
allocation failure, which typically is either -ENOMEM or -ENOSPC, is not
fatal and the fsync can safely fallback to a full transaction commit.

So release the IO plug if we fail to allocate the extent buffer for the
root of the log root tree when syncing the log on a zoned filesystem.

Fixes: 3ddebf27fcd3a9 ("btrfs: zoned: reorder log node allocation on zoned filesystem")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---

V2: Fixed typo in the subject, updated changelog.

 fs/btrfs/tree-log.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 273998153fcc..1fa21cfe059d 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3188,6 +3188,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
 			ret = btrfs_alloc_log_tree_node(trans, log_root_tree);
 			if (ret) {
 				mutex_unlock(&fs_info->tree_root->log_mutex);
+				blk_finish_plug(&plug);
 				goto out;
 			}
 		}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] btrfs: fix leaked plug after failure syncing log on zoned filesystems
  2022-04-06 16:08   ` fdmanana
  (?)
@ 2022-04-07  6:36   ` Johannes Thumshirn
  -1 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2022-04-07  6:36 UTC (permalink / raw)
  To: fdmanana, linux-btrfs

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] btrfs: fix leaked plug after failure syncing log on zoned filesystems
  2022-04-06 16:08   ` fdmanana
  (?)
  (?)
@ 2022-04-07 14:56   ` David Sterba
  -1 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2022-04-07 14:56 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

On Wed, Apr 06, 2022 at 05:07:54PM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> On a zoned filesystem, if we fail to allocate the root node for the log
> root tree while syncing the log, we end up returning without finishing
> the IO plug we started before, resulting in leaking resources as we
> have started writeback for extent buffers of a log tree before. That
> allocation failure, which typically is either -ENOMEM or -ENOSPC, is not
> fatal and the fsync can safely fallback to a full transaction commit.
> 
> So release the IO plug if we fail to allocate the extent buffer for the
> root of the log root tree when syncing the log on a zoned filesystem.
> 
> Fixes: 3ddebf27fcd3a9 ("btrfs: zoned: reorder log node allocation on zoned filesystem")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
> 
> V2: Fixed typo in the subject, updated changelog.

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-07 15:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06 11:52 [PATCH] btrfs: fix leaked plug after falilure syncing log on zoned filesystems fdmanana
2022-04-06 16:07 ` [PATCH v2] btrfs: fix leaked plug after failure " fdmanana
2022-04-06 16:08   ` fdmanana
2022-04-07  6:36   ` Johannes Thumshirn
2022-04-07 14:56   ` David Sterba

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.