[PATCH] Fix SG_IO timeout jiffy conversion
authorMike Christie <michaelc@cs.wisc.edu>
Tue, 30 Jan 2007 02:18:38 +0000 (21:18 -0500)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 30 Jan 2007 04:32:03 +0000 (20:32 -0800)
Commit 85e04e371b5a321b5df2bc3f8e0099a64fb087d7 cleaned up the timeout
conversion, but did it exactly the wrong way.  We get msecs from user
space, and should convert them into jiffies. Not the other way around.

Here is a fix with the overflow check sg.c has added in.  This fixes DVD
burnign with Nero.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
[ "you'll be wanting a comma there" - Andrew ]
Cc: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
block/scsi_ioctl.c

index 2528a0c0dec8bc906533d1b62163f6404d1c697c..65c6a3cba6d6e85d31d345dd75b322f7196889a5 100644 (file)
@@ -223,7 +223,7 @@ static int verify_command(struct file *file, unsigned char *cmd)
 static int sg_io(struct file *file, request_queue_t *q,
                struct gendisk *bd_disk, struct sg_io_hdr *hdr)
 {
-       unsigned long start_time;
+       unsigned long start_time, timeout;
        int writing = 0, ret = 0;
        struct request *rq;
        char sense[SCSI_SENSE_BUFFERSIZE];
@@ -271,7 +271,8 @@ static int sg_io(struct file *file, request_queue_t *q,
 
        rq->cmd_type = REQ_TYPE_BLOCK_PC;
 
-       rq->timeout = jiffies_to_msecs(hdr->timeout);
+       timeout = msecs_to_jiffies(hdr->timeout);
+       rq->timeout = (timeout < INT_MAX) ? timeout : INT_MAX;
        if (!rq->timeout)
                rq->timeout = q->sg_timeout;
        if (!rq->timeout)