On Sat, Apr 06, 2024 at 05:09:08PM +0800, Yu Kuai wrote: > @@ -669,7 +669,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) > { > struct file *file = iocb->ki_filp; > struct block_device *bdev = I_BDEV(file->f_mapping->host); > - struct inode *bd_inode = bdev->bd_inode; > + struct inode *bd_inode = bdev_inode(bdev); What you want here is this: struct inode *bd_inode = file->f_mapping->host; struct block_device *bdev = I_BDEV(bd_inode); > --- a/block/ioctl.c > +++ b/block/ioctl.c > @@ -97,7 +97,7 @@ static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode, > { > uint64_t range[2]; > uint64_t start, len; > - struct inode *inode = bdev->bd_inode; > + struct inode *inode = bdev_inode(bdev); > int err; The uses of 'inode' in this function are filemap_invalidate_lock(inode->i_mapping); and filemap_invalidate_unlock(inode->i_mapping); IOW, you want bdev_mapping(bdev), not bdev_inode(bdev). > @@ -166,7 +166,7 @@ static int blk_ioctl_zeroout(struct block_device *bdev, blk_mode_t mode, > { > uint64_t range[2]; > uint64_t start, end, len; > - struct inode *inode = bdev->bd_inode; > + struct inode *inode = bdev_inode(bdev); Same story.