Re: [md PATCH] md: handle read-only member devices better.

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

 



On Sat, Apr 15 2017, Anthony Youngman wrote:

> On 15/04/17 05:45, NeilBrown wrote:
>> So at present, callers of blkdev_get_by_dev() need to do their own
>> bdev_read_only() tests before writing.
>> We could discuss where in md.c is the best place to put them, but unless
>> you want to take on a largish project to 'fix' (or audit) all callers of
>> blkdev_get_by_dev(), they need to go in md somewhere.
>
> anthony@crappit:~/gitstuff/linux-stable> git grep -a blkdev_get_by_dev > 
> blkdev_get_by_dev.txt
> anthony@crappit:~/gitstuff/linux-stable> cat blkdev_get_by_dev.txt
> drivers/block/xen-blkback/xenbus.c:     bdev = 
> blkdev_get_by_dev(vbd->pdevice, vbd->readonly ?
> drivers/md/dm.c:        bdev = blkdev_get_by_dev(dev, td->dm_dev.mode | 
> FMODE_EXCL, _claim_ptr);
> drivers/md/md.c:        bdev = blkdev_get_by_dev(dev, 
> FMODE_READ|FMODE_WRITE|FMODE_EXCL,
> drivers/mtd/devices/block2mtd.c:                bdev = 
> blkdev_get_by_dev(devt, mode, dev);
> fs/block_dev.c: * blkdev_get_by_dev - open a block device by device number
> fs/block_dev.c:struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t 
> mode, void *holder)
> fs/block_dev.c:EXPORT_SYMBOL(blkdev_get_by_dev);
> fs/ext4/super.c:        bdev = blkdev_get_by_dev(dev, 
> FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb);
> fs/f2fs/super.c: 
> blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev,
> fs/jfs/jfs_logmgr.c:    bdev = blkdev_get_by_dev(sbi->logdev, 
> FMODE_READ|FMODE_WRITE|FMODE_EXCL,
> fs/nfs/blocklayout/dev.c:       bdev = blkdev_get_by_dev(dev, FMODE_READ 
> | FMODE_WRITE, NULL);
> fs/reiserfs/journal.c:          journal->j_dev_bd = 
> blkdev_get_by_dev(jdev, blkdev_mode,
> include/linux/fs.h:extern struct block_device *blkdev_get_by_dev(dev_t 
> dev, fmode_t mode,
> kernel/power/swap.c:    hib_resume_bdev = 
> blkdev_get_by_dev(swsusp_resume_device,
> anthony@crappit:~/gitstuff/linux-stable>
>
> So, if I'm mad enough to take this on, does that mean going through all 
> of these checking/fixing them to test for a return code of -EACCESS?

Yes, where "fixing" means understanding how the bdev is used in
each case, and what mode is really required and making it behave
correctly in all circumstances.
Maybe that means just propagating the error upwards.
Maybe it means retrying with only FMODE_READ, and recording that no
write access was available.  At the very least, this fact would be used
to pass the right fmode_t to blkdev_put.
Maybe it means always using FMODE_READ because FMODE_WRITE isn't
actually needed (though that seems unlikely).

Maybe it also means bd_write_holder could be changed to a counter
instead of a flag, if we can convince ourselves that the use of @mode
in blkdev_get/put() is no longer "too fragile".

NeilBrown

>
> No promises that I will, I keep on wanting to do this sort of stuff and 
> then life gets in the way, but if I can't do it it'll go on the list of 
> projects on the raid wiki.
>
> Cheers,
> Wol

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux