On Fri, Mar 22, 2024 at 03:43:47PM +0000, Al Viro wrote: > On Fri, Mar 22, 2024 at 02:52:16PM +0800, Yu Kuai wrote: > > Hi, > > > > 在 2024/03/22 14:39, Al Viro 写道: > > > On Fri, Mar 22, 2024 at 06:37:18AM +0000, Al Viro wrote: > > > > On Thu, Mar 21, 2024 at 08:15:06PM +0800, Yu Kuai wrote: > > > > > > > > > > blkdev_iomap_begin() etc. may be an arbitrary filesystem block device > > > > > > inode. But why can't you use I_BDEV(inode->i_mapping->host) to get to the > > > > > > block device instead of your file_bdev(inode->i_private)? I don't see any > > > > > > advantage in stashing away that special bdev_file into inode->i_private but > > > > > > perhaps I'm missing something... > > > > > > > > > > > > > > > > Because we're goning to remove the 'block_device' from iomap and > > > > > buffer_head, and replace it with a 'bdev_file'. > > > > > > > > What of that? file_inode(file)->f_mapping->host will give you bdevfs inode > > > > just fine... > > > > > > file->f_mapping->host, obviously - sorry. > > > . > > > > Yes, we already get bdev_inode this way, and use it in > > blkdev_iomap_begin() and blkdev_get_block(), the problem is that if we > > want to let iomap and buffer_head to use bdev_file for raw block fops as > > well, we need a 'bdev_file' somehow. > > Explain, please. Why would anything care whether the file is bdevfs > one or coming from devtmpfs/xfs/ext2/whatnot? Yecchhh... I see one possible reason, unfortunately, but I really doubt that your approach is workable. iomap is not a problem; nothing in there will persist past the destruction of struct file you've used; buffer_head, OTOH, is a problem. They are, by their nature, shared between various openers and we can't really withdraw them. Why do we want ->b_bdev replaced with struct file * in the first place? AFAICS, your patch tries to make it unique per opened bdev; that makes the lifetime rules really convoluted, but that aside, what's in that struct file that is not in struct block_device? I don't see any point trying to shove that down into buffer_head, or, Cthulhu forbid, bio. Details, please...