Re: [PATCH] fs,block: yield devices early

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
...
> @@ -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.

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux