@@ -172,6 +172,7 @@ typedef struct sg_fd { /* holds the state of a file descriptor */
172
172
173
173
typedef struct sg_device { /* holds the state of each scsi generic device */
174
174
struct scsi_device * device ;
175
+ struct mutex open_rel_lock ;
175
176
wait_queue_head_t o_excl_wait ; /* queue open() when O_EXCL in use */
176
177
struct mutex open_rel_lock ; /* held when in open() or release() */
177
178
int sg_tablesize ; /* adapter's max scatter-gather table size */
@@ -407,7 +408,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
407
408
retval = 0 ; /* following macro beats race condition */
408
409
__wait_event_interruptible (sfp -> read_wait ,
409
410
(sdp -> detached ||
410
- (srp = sg_get_rq_mark (sfp , req_pack_id ))),
411
+ (srp = sg_get_rq_mark (sfp , req_pack_id ))),
411
412
retval );
412
413
if (sdp -> detached ) {
413
414
retval = - ENODEV ;
@@ -467,7 +468,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
467
468
old_hdr -> result = EIO ;
468
469
break ;
469
470
case DID_ERROR :
470
- old_hdr -> result = (srp -> sense_b [0 ] == 0 &&
471
+ old_hdr -> result = (srp -> sense_b [0 ] == 0 &&
471
472
hp -> masked_status == GOOD ) ? 0 : EIO ;
472
473
break ;
473
474
default :
@@ -994,8 +995,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
994
995
if (srp ) {
995
996
rinfo [val ].req_state = srp -> done + 1 ;
996
997
rinfo [val ].problem =
997
- srp -> header .masked_status &
998
- srp -> header .host_status &
998
+ srp -> header .masked_status &
999
+ srp -> header .host_status &
999
1000
srp -> header .driver_status ;
1000
1001
if (srp -> done )
1001
1002
rinfo [val ].duration =
@@ -1016,7 +1017,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
1016
1017
}
1017
1018
}
1018
1019
read_unlock_irqrestore (& sfp -> rq_list_lock , iflags );
1019
- result = __copy_to_user (p , rinfo ,
1020
+ result = __copy_to_user (p , rinfo ,
1020
1021
SZ_SG_REQ_INFO * SG_MAX_QUEUE );
1021
1022
result = result ? - EFAULT : 0 ;
1022
1023
kfree (rinfo );
@@ -1130,14 +1131,14 @@ static long sg_compat_ioctl(struct file *filp, unsigned int cmd_in, unsigned lon
1130
1131
return - ENXIO ;
1131
1132
1132
1133
sdev = sdp -> device ;
1133
- if (sdev -> host -> hostt -> compat_ioctl ) {
1134
+ if (sdev -> host -> hostt -> compat_ioctl ) {
1134
1135
int ret ;
1135
1136
1136
1137
ret = sdev -> host -> hostt -> compat_ioctl (sdev , cmd_in , (void __user * )arg );
1137
1138
1138
1139
return ret ;
1139
1140
}
1140
-
1141
+
1141
1142
return - ENOIOCTLCMD ;
1142
1143
}
1143
1144
#endif
@@ -1416,6 +1417,7 @@ static Sg_device *sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1416
1417
disk -> first_minor = k ;
1417
1418
sdp -> disk = disk ;
1418
1419
sdp -> device = scsidp ;
1420
+ mutex_init (& sdp -> open_rel_lock );
1419
1421
INIT_LIST_HEAD (& sdp -> sfds );
1420
1422
init_waitqueue_head (& sdp -> o_excl_wait );
1421
1423
sdp -> sg_tablesize = queue_max_segments (q );
@@ -1603,7 +1605,7 @@ init_sg(void)
1603
1605
else
1604
1606
def_reserved_size = sg_big_buff ;
1605
1607
1606
- rc = register_chrdev_region (MKDEV (SCSI_GENERIC_MAJOR , 0 ),
1608
+ rc = register_chrdev_region (MKDEV (SCSI_GENERIC_MAJOR , 0 ),
1607
1609
SG_MAX_DEVS , "sg" );
1608
1610
if (rc )
1609
1611
return rc ;
@@ -2256,7 +2258,7 @@ static const struct file_operations adio_fops = {
2256
2258
};
2257
2259
2258
2260
static int sg_proc_single_open_dressz (struct inode * inode , struct file * file );
2259
- static ssize_t sg_proc_write_dressz (struct file * filp ,
2261
+ static ssize_t sg_proc_write_dressz (struct file * filp ,
2260
2262
const char __user * buffer , size_t count , loff_t * off );
2261
2263
static const struct file_operations dressz_fops = {
2262
2264
.owner = THIS_MODULE ,
@@ -2396,7 +2398,7 @@ static int sg_proc_single_open_adio(struct inode *inode, struct file *file)
2396
2398
return single_open (file , sg_proc_seq_show_int , & sg_allow_dio );
2397
2399
}
2398
2400
2399
- static ssize_t
2401
+ static ssize_t
2400
2402
sg_proc_write_adio (struct file * filp , const char __user * buffer ,
2401
2403
size_t count , loff_t * off )
2402
2404
{
@@ -2417,7 +2419,7 @@ static int sg_proc_single_open_dressz(struct inode *inode, struct file *file)
2417
2419
return single_open (file , sg_proc_seq_show_int , & sg_big_buff );
2418
2420
}
2419
2421
2420
- static ssize_t
2422
+ static ssize_t
2421
2423
sg_proc_write_dressz (struct file * filp , const char __user * buffer ,
2422
2424
size_t count , loff_t * off )
2423
2425
{
@@ -2574,7 +2576,7 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp)
2574
2576
hp = & srp -> header ;
2575
2577
new_interface = (hp -> interface_id == '\0' ) ? 0 : 1 ;
2576
2578
if (srp -> res_used ) {
2577
- if (new_interface &&
2579
+ if (new_interface &&
2578
2580
(SG_FLAG_MMAP_IO & hp -> flags ))
2579
2581
cp = " mmap>> " ;
2580
2582
else
@@ -2588,7 +2590,7 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp)
2588
2590
seq_printf (s , cp );
2589
2591
blen = srp -> data .bufflen ;
2590
2592
usg = srp -> data .k_use_sg ;
2591
- seq_printf (s , srp -> done ?
2593
+ seq_printf (s , srp -> done ?
2592
2594
((1 == srp -> done ) ? "rcv:" : "fin:" )
2593
2595
: "act:" );
2594
2596
seq_printf (s , " id=%d blen=%d" ,
0 commit comments