linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: hch <hch@lst.de>
Cc: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
	 "viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	 "djwong@kernel.org" <djwong@kernel.org>,
	"ebiggers@google.com" <ebiggers@google.com>,
	 "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: Re: [PATCH] fs: move the bdex_statx call to vfs_getattr_nosec
Date: Tue, 22 Apr 2025 10:15:48 +0200	[thread overview]
Message-ID: <20250422-angepackt-reisen-bc24fbec2702@brauner> (raw)
In-Reply-To: <20250422055149.GB29356@lst.de>

On Tue, Apr 22, 2025 at 07:51:49AM +0200, hch wrote:
> On Tue, Apr 22, 2025 at 05:03:19AM +0000, Shinichiro Kawasaki wrote:
> > I ran blktests with the kernel v6.15-rc3, and found the test case md/001 hangs.
> > The hang is recreated in stable manner. I bisected and found this patch as the
> > commit 777d0961ff95 is the trigger. When I revert the commit from v6.15-rc3
> > kernel, the hang disappeared.
> > 
> > Actions for fix will be appreciated.
> > 
> > FYI, the kernel INFO messages recorded functions relevant to the trigger commit,
> > such as bdev_statx or vfs_getattr_nosec [1].
> 
> This should fix it:
> 
> diff --git a/block/bdev.c b/block/bdev.c
> index 6a34179192c9..97d4c0ab1670 100644
> --- a/block/bdev.c
> +++ b/block/bdev.c
> @@ -1274,18 +1274,23 @@ void sync_bdevs(bool wait)
>   */
>  void bdev_statx(const struct path *path, struct kstat *stat, u32 request_mask)
>  {
> -	struct inode *backing_inode;
>  	struct block_device *bdev;
>  
> -	backing_inode = d_backing_inode(path->dentry);
> -
>  	/*
> -	 * Note that backing_inode is the inode of a block device node file,
> -	 * not the block device's internal inode.  Therefore it is *not* valid
> -	 * to use I_BDEV() here; the block device has to be looked up by i_rdev
> -	 * instead.
> +	 * Note that d_backing_inode() returnsthe inode of a block device node
> +	 * file, not the block device's internal inode.
> +	 *
> +	 * Therefore it is *not* valid to use I_BDEV() here; the block device
> +	 * has to be looked up by i_rdev instead.
> +	 *
> +	 * Only do this lookup if actually needed to avoid the performance
> +	 * overhead of the lookup, and to avoid injecting bdev lifetime issues
> +	 * into devtmpfs.
>  	 */
> -	bdev = blkdev_get_no_open(backing_inode->i_rdev);
> +	if (!(request_mask & (STATX_DIOALIGN | STATX_WRITE_ATOMIC)))
> +		return;

This leaks the block device reference if blkdev_get_no_open() succeeds.

> +
> +	bdev = blkdev_get_no_open(d_backing_inode(path->dentry)->i_rdev);
>  	if (!bdev)
>  		return;
>  

  parent reply	other threads:[~2025-04-22  8:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-17  6:40 [PATCH] fs: move the bdex_statx call to vfs_getattr_nosec Christoph Hellwig
2025-04-17  8:01 ` Christian Brauner
2025-04-17  8:14 ` Christian Brauner
2025-04-17 16:20 ` Darrick J. Wong
2025-04-22  5:03 ` Shinichiro Kawasaki
2025-04-22  5:51   ` hch
2025-04-22  7:25     ` Christian Brauner
2025-04-22  7:27       ` hch
2025-04-22  8:15     ` Christian Brauner [this message]
2025-04-22  8:17       ` hch
2025-04-22  9:29         ` Christian Brauner
2025-04-22 14:15         ` hch
2025-04-22 15:35           ` Christian Brauner
2025-04-23  1:31           ` Shinichiro Kawasaki
2025-04-23  4:30           ` Jain, Ayush
2025-04-22 10:31     ` Shinichiro Kawasaki
2025-04-22 14:18     ` Heiko Carstens
     [not found] ` <d6dc234d922d8beda65f2a1eed1e2de6a50c978f.camel@linux.ibm.com>
2025-04-25 13:39   ` Christoph Hellwig

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=20250422-angepackt-reisen-bc24fbec2702@brauner \
    --to=brauner@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=djwong@kernel.org \
    --cc=ebiggers@google.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=shinichiro.kawasaki@wdc.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).