On Fri, Aug 11, 2023 at 01:04:33PM +0200, Jan Kara wrote: > @@ -478,7 +478,7 @@ blk_mode_t file_to_blk_mode(struct file *file) > mode |= BLK_OPEN_READ; > if (file->f_mode & FMODE_WRITE) > mode |= BLK_OPEN_WRITE; > - if (file->private_data) > + if (file->f_flags & O_EXCL) > mode |= BLK_OPEN_EXCL; > if (file->f_flags & O_NDELAY) > mode |= BLK_OPEN_NDELAY; > index 3be11941fb2d..47f216d8697f 100644 > --- a/block/ioctl.c > +++ b/block/ioctl.c > @@ -575,7 +575,7 @@ long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) > { > struct block_device *bdev = I_BDEV(file->f_mapping->host); > void __user *argp = (void __user *)arg; > - blk_mode_t mode = file_to_blk_mode(file); > + blk_mode_t mode = ((struct bdev_handle *)file->private_data)->mode; Take a look at sd_ioctl() and note that fcntl(2) can be used to set/clear O_NDELAY. The current variant works since we recalculate mode every time; this one will end up stuck with whatever we had at open time. Note that Christoph's series could do this in blkdev_ioctl() - /* - * O_NDELAY can be altered using fcntl(.., F_SETFL, ..), so we have - * to updated it before every ioctl. - */ - if (file->f_flags & O_NDELAY) - mode |= FMODE_NDELAY; - else - mode &= ~FMODE_NDELAY; precisely because his file_to_blk_mode() picks O_NDELAY from flags when blkdev_ioctl() calls it. The same goes for compat counterpart of that thing. Both need to deal with that scenario - you need something that would pick the O_NDELAY updates from ->f_flags. Al, trying to catch up on the awful pile of mail that has accumulated over the 3 months of being net.dead...