mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Jeff Layton <jlayton@kernel.org>, Chris Mason <clm@fb.com>,
	David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@fb.com
Subject: Re: [PATCH v2 1/5] btrfs: use an on-stack path in btrfs_insert_orphan_item()
Date: Wed, 5 Aug 2026 08:48:12 +0930	[thread overview]
Message-ID: <9df1c3fd-b647-4460-88e4-1930ae85b440@suse.com> (raw)
In-Reply-To: <20260804-btrfs-enomem-v2-1-4d923170e8c1@kernel.org>



在 2026/8/5 01:14, Jeff Layton 写道:
> btrfs_insert_orphan_item() allocated a btrfs_path with btrfs_alloc_path()
> which returns -ENOMEM on failure. It is called from btrfs_orphan_add(),
> so a path allocation failure there turns a recoverable error into a
> transaction abort.
> 
> btrfs_path is only ~112 bytes, so allocate it on the stack instead.
> 
> Assisted-by: LLM
> Suggested-by: Qu Wenruo <wqu@suse.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>   fs/btrfs/orphan.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/btrfs/orphan.c b/fs/btrfs/orphan.c
> index 9f3ad124104f..72e1adec39d8 100644
> --- a/fs/btrfs/orphan.c
> +++ b/fs/btrfs/orphan.c
> @@ -9,18 +9,17 @@
>   int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
>   			     struct btrfs_root *root, u64 offset)
>   {
> -	BTRFS_PATH_AUTO_FREE(path);
> +	struct btrfs_path path = { 0 };
>   	struct btrfs_key key;
> +	int ret;
>   
>   	key.objectid = BTRFS_ORPHAN_OBJECTID;
>   	key.type = BTRFS_ORPHAN_ITEM_KEY;
>   	key.offset = offset;
>   
> -	path = btrfs_alloc_path();
> -	if (!path)
> -		return -ENOMEM;
> -
> -	return btrfs_insert_empty_item(trans, root, path, &key, 0);
> +	ret = btrfs_insert_empty_item(trans, root, &path, &key, 0);
> +	btrfs_release_path(&path);
> +	return ret;
>   }
>   
>   int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
> 


  reply	other threads:[~2026-08-04 23:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 15:44 [PATCH v2 0/5] btrfs: handle -ENOMEM errors in some synchronous dirops without aborting Jeff Layton
2026-08-04 15:44 ` [PATCH v2 1/5] btrfs: use an on-stack path in btrfs_insert_orphan_item() Jeff Layton
2026-08-04 23:18   ` Qu Wenruo [this message]
2026-08-04 15:44 ` [PATCH v2 2/5] btrfs: split btrfs_insert_delayed_dir_index() into prealloc and commit phases Jeff Layton
2026-08-04 23:14   ` Qu Wenruo
2026-08-05 11:54     ` Jeff Layton
2026-08-05 22:34       ` Qu Wenruo
2026-08-05 22:43         ` Jeff Layton
2026-08-04 15:44 ` [PATCH v2 3/5] btrfs: pre-allocate delayed dir index before btree modification Jeff Layton
2026-08-04 23:51   ` Qu Wenruo
2026-08-05 12:09     ` Jeff Layton
2026-08-04 15:44 ` [PATCH v2 4/5] btrfs: handle ENOMEM from btrfs_insert_dir_item() without aborting Jeff Layton
2026-08-04 15:44 ` [PATCH v2 5/5] btrfs: pre-allocate delayed dir index for non-overwrite rename Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9df1c3fd-b647-4460-88e4-1930ae85b440@suse.com \
    --to=wqu@suse.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=jlayton@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®