Skip to content

Commit

Permalink
[PATCH 1/2] kill FMODE_NDELAY_NOW
Browse files Browse the repository at this point in the history
Update FMODE_NDELAY before each ioctl call so that we can kill the
magic FMODE_NDELAY_NOW.  It would be even better to do this directly
in setfl(), but for that we'd need to have FMODE_NDELAY for all files,
not just block special files.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Dec 4, 2008
1 parent ebbefc0 commit fd4ce1a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
8 changes: 7 additions & 1 deletion block/compat_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,14 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
struct backing_dev_info *bdi;
loff_t size;

/*
* 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_NOW;
mode |= FMODE_NDELAY;
else
mode &= ~FMODE_NDELAY;

switch (cmd) {
case HDIO_GETGEO:
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,
* access to the device is prohibited.
*/
error = scsi_nonblockable_ioctl(sdp, cmd, p,
(mode & FMODE_NDELAY_NOW) != 0);
(mode & FMODE_NDELAY) != 0);
if (!scsi_block_when_processing_errors(sdp) || !error)
return error;

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
* if it doesn't recognise the ioctl
*/
ret = scsi_nonblockable_ioctl(sdev, cmd, argp,
(mode & FMODE_NDELAY_NOW) != 0);
(mode & FMODE_NDELAY) != 0);
if (ret != -ENODEV)
return ret;
return scsi_ioctl(sdev, cmd, argp);
Expand Down
10 changes: 9 additions & 1 deletion fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,8 +1206,16 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
{
struct block_device *bdev = I_BDEV(file->f_mapping->host);
fmode_t mode = file->f_mode;

/*
* 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_NOW;
mode |= FMODE_NDELAY;
else
mode &= ~FMODE_NDELAY;

return blkdev_ioctl(bdev, mode, cmd, arg);
}

Expand Down
1 change: 0 additions & 1 deletion include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ extern int dir_notify_enable;
#define FMODE_NDELAY ((__force fmode_t)32)
#define FMODE_EXCL ((__force fmode_t)64)
#define FMODE_WRITE_IOCTL ((__force fmode_t)128)
#define FMODE_NDELAY_NOW ((__force fmode_t)256)

#define RW_MASK 1
#define RWA_MASK 2
Expand Down

0 comments on commit fd4ce1a

Please sign in to comment.