Skip to content

Commit

Permalink
block: mark bdev files as FMODE_NOWAIT if underlying device supports it
Browse files Browse the repository at this point in the history
We set this unconditionally, but it really should be dependent on if
the underlying device is nowait compliant.

Cc: linux-block@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230509151910.183637-3-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Jens Axboe committed May 15, 2023
1 parent fe34db0 commit e9833d8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion block/fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ static int blkdev_open(struct inode *inode, struct file *filp)
* during an unstable branch.
*/
filp->f_flags |= O_LARGEFILE;
filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC;
filp->f_mode |= FMODE_BUF_RASYNC;

if (filp->f_flags & O_NDELAY)
filp->f_mode |= FMODE_NDELAY;
Expand All @@ -494,6 +494,9 @@ static int blkdev_open(struct inode *inode, struct file *filp)
if (IS_ERR(bdev))
return PTR_ERR(bdev);

if (bdev_nowait(bdev))
filp->f_mode |= FMODE_NOWAIT;

filp->private_data = bdev;
filp->f_mapping = bdev->bd_inode->i_mapping;
filp->f_wb_err = filemap_sample_wb_err(filp->f_mapping);
Expand Down

0 comments on commit e9833d8

Please sign in to comment.