diff mbox

[2/2] btrfs: try to write enough delalloc bytes when reclaiming metadata space

Message ID 1474441173-31049-2-git-send-email-wangxg.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xiaoguang Wang Sept. 21, 2016, 6:59 a.m. UTC
Indeed as long as we have delalloc bytes and if we fail to reclaim
requested metadata space, we should write these delalloc bytes and
have one more try, this can fix some false enospc errors in some
extreme cases.

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
---
 fs/btrfs/extent-tree.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Josef Bacik Oct. 7, 2016, 1:17 p.m. UTC | #1
On 09/21/2016 02:59 AM, Wang Xiaoguang wrote:
> Indeed as long as we have delalloc bytes and if we fail to reclaim
> requested metadata space, we should write these delalloc bytes and
> have one more try, this can fix some false enospc errors in some
> extreme cases.
>
> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
> ---
>  fs/btrfs/extent-tree.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index fdfc97f..46c2a37 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -4794,6 +4794,15 @@ static int may_commit_transaction(struct btrfs_root *root,
>  {
>  	struct btrfs_block_rsv *delayed_rsv = &root->fs_info->delayed_block_rsv;
>  	struct btrfs_trans_handle *trans;
> +	struct btrfs_fs_info *fs_info = root->fs_info;
> +
> +	/*
> +	 * shrink_delalloc() may not write enough delalloc bytes, so here we
> +	 * have a last try. Please don't remove these, because these can fix
> +	 * some false enospc error in some extreme cases.
> +	 */
> +	btrfs_start_delalloc_roots(fs_info, 0, -1);
> +	btrfs_wait_ordered_roots(fs_info, -1, 0, (u64)-1);
>
>  	trans = (struct btrfs_trans_handle *)current->journal_info;
>  	if (trans)
>

This will deadlock.

Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index fdfc97f..46c2a37 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4794,6 +4794,15 @@  static int may_commit_transaction(struct btrfs_root *root,
 {
 	struct btrfs_block_rsv *delayed_rsv = &root->fs_info->delayed_block_rsv;
 	struct btrfs_trans_handle *trans;
+	struct btrfs_fs_info *fs_info = root->fs_info;
+
+	/*
+	 * shrink_delalloc() may not write enough delalloc bytes, so here we
+	 * have a last try. Please don't remove these, because these can fix
+	 * some false enospc error in some extreme cases.
+	 */
+	btrfs_start_delalloc_roots(fs_info, 0, -1);
+	btrfs_wait_ordered_roots(fs_info, -1, 0, (u64)-1);
 
 	trans = (struct btrfs_trans_handle *)current->journal_info;
 	if (trans)