Re: [PATCH 1/2] block: make __register_blkdev() return an error

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

 



On Mon, Sep 06, 2021 at 02:59:38PM +0900, Tetsuo Handa wrote:
> On 2021/09/06 3:11, Luis Chamberlain wrote:
> > On Sat, Sep 04, 2021 at 11:49:06AM +0900, Tetsuo Handa wrote:
> >> On 2021/09/04 10:39, Luis Chamberlain wrote:
> >>> diff --git a/fs/block_dev.c b/fs/block_dev.c
> >>> index 45df6cbccf12..81a4738910a8 100644
> >>> --- a/fs/block_dev.c
> >>> +++ b/fs/block_dev.c
> >>> @@ -1144,10 +1144,13 @@ struct block_device *blkdev_get_no_open(dev_t dev)
> >>>  {
> >>>  	struct block_device *bdev;
> >>>  	struct inode *inode;
> >>> +	int ret;
> >>>  
> >>>  	inode = ilookup(blockdev_superblock, dev);
> >>>  	if (!inode) {
> >>> -		blk_request_module(dev);
> >>> +		ret = blk_request_module(dev);
> >>> +		if (ret)
> >>> +			return NULL;
> >>
> >> Since e.g. loop_add() from loop_probe() returns -EEXIST when /dev/loop$num already
> >> exists (e.g. raced with ioctl(LOOP_CTL_ADD)), isn't unconditionally failing an over-failing?
> > 
> > It's not clear to me how. What do we loose by capturing the failure on
> > blk_request_module()?
> > 
> 
> We loose ability to handle concurrent request.
> If blk_request_module() does not ignore -EEXIST error, only the first
> open() request would succeed because loop_add() returns 0 and all
> other concurrent requests would fail because loop_add() returns
> -EEXIST.

Yes I see that now thanks!

> Actually, blk_request_module() failures should be ignored, for
> subsequent ilookup() will fail if blk_request_module() failed to
> create the requested block device.

Then how about this:

Since we would like to use __must_check for add_disk() we proceed with
the change to capture the errors and propagate them and we just document on
fs/block_dev.c's use of blk_request_module() about the above issue and
how we prefer the errror that ilookup() would return.

  Luis



[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