Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Yingjie Gao <gaoyingjie@uniontech.com>
Cc: linux-xfs@vger.kernel.org, cem@kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 1/2] xfs: fix inode ref leak in attr intent recovery
Date: Tue, 9 Jun 2026 07:57:40 -0700	[thread overview]
Message-ID: <20260609145740.GC6078@frogsfrogsfrogs> (raw)
In-Reply-To: <20260609111619.1866748-2-gaoyingjie@uniontech.com>

On Tue, Jun 09, 2026 at 07:16:18PM +0800, Yingjie Gao wrote:
> xfs_attri_recover_work() grabs the target inode, attaches it to the
> reconstructed attr work item, and adds that work item to the defer
> pending list.
> 
> If xfs_attr_recover_work() fails to allocate the recovery transaction,
> it returns immediately without dropping the inode reference.  The later
> cancel path only frees the attr work item state, so the inode reference
> leaks.
> 
> Release the inode before returning the transaction allocation failure.
> 
> Fixes: e70fb328d527 ("xfs: recreate work items when recovering intent items")
> Cc: <stable@vger.kernel.org> # v6.8
> Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
> ---
>  fs/xfs/xfs_attr_item.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
> index deab14f31b38..c3d96c7a5bca 100644
> --- a/fs/xfs/xfs_attr_item.c
> +++ b/fs/xfs/xfs_attr_item.c
> @@ -773,8 +773,10 @@ xfs_attr_recover_work(
>  	}
>  	resv = xlog_recover_resv(&resv);
>  	error = xfs_trans_alloc(mp, &resv, total, 0, XFS_TRANS_RESERVE, &tp);
> -	if (error)
> +	if (error) {
> +		xfs_irele(ip);

Seems fine but I wonder why you don't just add an out_rele label on the
line above the existing xfs_irele() call and make this goto there?

--D

>  		return error;
> +	}
>  	args->trans = tp;
>  
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
> -- 
> 2.20.1
> 
> 

  reply	other threads:[~2026-06-09 14:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09 11:16 [PATCH 0/2] xfs: fix inode leak and clean up attr intent recovery Yingjie Gao
2026-06-09 11:16 ` [PATCH 1/2] xfs: fix inode ref leak in " Yingjie Gao
2026-06-09 14:57   ` Darrick J. Wong [this message]
2026-06-10  1:54     ` Yingjie Gao
2026-06-09 11:16 ` [PATCH 2/2] xfs: clean up attr intent recovery error paths Yingjie Gao
2026-06-10  2:20 ` [PATCH v2 0/2] xfs: fix inode leak and clean up attr intent recovery Yingjie Gao
2026-06-10  2:20   ` [PATCH v2 1/2] xfs: fix inode ref leak in " Yingjie Gao
2026-06-10  5:00     ` Darrick J. Wong
2026-06-10  2:20   ` [PATCH v2 2/2] xfs: clean up attr intent recovery error paths Yingjie Gao
2026-06-10  5:12     ` Darrick J. Wong
2026-06-10  5:38       ` Yingjie Gao
2026-06-10  6:30   ` [PATCH v2 0/2] xfs: fix inode leak and clean up attr intent recovery Carlos Maiolino
2026-06-10  6:52     ` Yingjie Gao

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=20260609145740.GC6078@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=gaoyingjie@uniontech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=stable@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