Linux block layer
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>, Christoph Hellwig <hch@lst.de>,
	linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] fs,block: yield devices early
Date: Wed, 27 Mar 2024 12:07:40 +0100	[thread overview]
Message-ID: <20240327110740.dgdp5fclsa4yvw2j@quack3> (raw)
In-Reply-To: <20240327-befanden-morsen-9f691f5624f9@brauner>

On Wed 27-03-24 09:56:59, Christian Brauner wrote:
> On Tue, Mar 26, 2024 at 11:32:13PM +0100, Jan Kara wrote:
> > On Tue 26-03-24 13:47:22, Christian Brauner wrote:
> > > Currently a device is only really released once the umount returns to
> > > userspace due to how file closing works. That ultimately could cause
> > > an old umount assumption to be violated that concurrent umount and mount
> > > don't fail. So an exclusively held device with a temporary holder should
> > > be yielded before the filesystem is gone. Add a helper that allows
> > > callers to do that. This also allows us to remove the two holder ops
> > > that Linus wasn't excited about.
> > > 
> > > Fixes: f3a608827d1f ("bdev: open block device as files") # mainline only
> > > Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> > > Signed-off-by: Christian Brauner <brauner@kernel.org>
> > ...
> > > @@ -1012,6 +1005,29 @@ struct file *bdev_file_open_by_path(const char *path, blk_mode_t mode,
> > >  }
> > >  EXPORT_SYMBOL(bdev_file_open_by_path);
> > >  
> > > +static inline void bd_yield_claim(struct file *bdev_file)
> > > +{
> > > +	struct block_device *bdev = file_bdev(bdev_file);
> > > +	struct bdev_inode *bd_inode = BDEV_I(bdev_file->f_mapping->host);
> > > +	void *holder = bdev_file->private_data;
> > > +
> > > +	lockdep_assert_held(&bdev->bd_disk->open_mutex);
> > > +
> > > +	if (WARN_ON_ONCE(IS_ERR_OR_NULL(holder)))
> > > +		return;
> > > +
> > > +	if (holder != bd_inode) {
> > > +		bdev_yield_write_access(bdev_file);
> > 
> > Hum, what if we teached bdev_yield_write_access() about special bd_inode
> > holder and kept bdev_yield_write_access() and bd_yield_claim() separate as
> > they were before this patch? IMHO it would make code a bit more
> > understandable. Otherwise the patch looks good.
> 
> Ok, see appended patch where I folded in your suggestion.

Thanks. The patch looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2024-03-27 11:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26 12:47 [PATCH] fs,block: yield devices early Christian Brauner
2024-03-26 17:25 ` Christoph Hellwig
2024-03-26 22:32 ` Jan Kara
2024-03-27  8:56   ` Christian Brauner
2024-03-27 11:07     ` Jan Kara [this message]
2024-03-27 12:00 ` Christian Brauner

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=20240327110740.dgdp5fclsa4yvw2j@quack3 \
    --to=jack@suse.cz \
    --cc=brauner@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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