LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/2] kill FMODE_NDELAY_NOW
@ 2008-11-05 13:58 Christoph Hellwig
  2008-11-30 13:07 ` Al Viro
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2008-11-05 13:58 UTC (permalink / raw)
  To: viro; +Cc: linux-kernel

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>

Index: linux-2.6/block/compat_ioctl.c
===================================================================
--- linux-2.6.orig/block/compat_ioctl.c	2008-11-02 19:47:40.000000000 +0100
+++ linux-2.6/block/compat_ioctl.c	2008-11-02 19:48:07.000000000 +0100
@@ -699,8 +699,14 @@ long compat_blkdev_ioctl(struct file *fi
 	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:
Index: linux-2.6/drivers/scsi/sd.c
===================================================================
--- linux-2.6.orig/drivers/scsi/sd.c	2008-11-02 19:47:20.000000000 +0100
+++ linux-2.6/drivers/scsi/sd.c	2008-11-02 19:48:11.000000000 +0100
@@ -757,7 +757,7 @@ static int sd_ioctl(struct block_device 
 	 * 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;
 
Index: linux-2.6/drivers/scsi/sr.c
===================================================================
--- linux-2.6.orig/drivers/scsi/sr.c	2008-11-02 19:47:03.000000000 +0100
+++ linux-2.6/drivers/scsi/sr.c	2008-11-02 19:47:18.000000000 +0100
@@ -521,7 +521,7 @@ static int sr_block_ioctl(struct block_d
 	 * 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);
Index: linux-2.6/fs/block_dev.c
===================================================================
--- linux-2.6.orig/fs/block_dev.c	2008-11-02 19:45:01.000000000 +0100
+++ linux-2.6/fs/block_dev.c	2008-11-02 19:48:05.000000000 +0100
@@ -1207,8 +1207,16 @@ static long block_ioctl(struct file *fil
 {
 	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);
 }
 
Index: linux-2.6/include/linux/fs.h
===================================================================
--- linux-2.6.orig/include/linux/fs.h	2008-11-02 19:48:13.000000000 +0100
+++ linux-2.6/include/linux/fs.h	2008-11-02 19:48:24.000000000 +0100
@@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] kill FMODE_NDELAY_NOW
  2008-11-05 13:58 [PATCH 1/2] kill FMODE_NDELAY_NOW Christoph Hellwig
@ 2008-11-30 13:07 ` Al Viro
  0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2008-11-30 13:07 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-kernel

On Wed, Nov 05, 2008 at 02:58:42PM +0100, Christoph Hellwig wrote:
> 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.

We _can't_ do that in setfl() - not unless you such bdev method.
Note that there's a bunch of cases where O_NDELAY at open() is used
to get very different semantics and we want ->release() to see the
matching value.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-11-30 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-05 13:58 [PATCH 1/2] kill FMODE_NDELAY_NOW Christoph Hellwig
2008-11-30 13:07 ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).