Skip to contentSkip to conversation

st: remove st_mutex

PATCH Superseded Lee Duncan 1 participant 2 messages Sep 10, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Lee Duncan

author
#0 lore raw

PATCH 1/1 st: remove st_mutex

This patch is based on the "misc" branch of the SCSI tree and the 5-patch series for st sent by Jeff Mahoney 8/18/2012 and Ack-ed by Kai on 8/20.

From: Jeff Mahoney <[email protected]>

The st_mutex was created when the BKL was removed, and prevents simultaneous st_open calls. It is better to protect just the necessary data.

---
 drivers/scsi/st.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/st.c +0 -1
index ceca095..98156a9 100644
@@ -75,7 +75,6 @@ static const char *verstr = "20101219";
 #include "st_options.h"
 #include "st.h"
 
-static DEFINE_MUTEX(st_mutex);
 static int buffer_kbs;
 static int max_sg_segs;
 static int try_direct_io = TRY_DIRECT_IO;
@@ -1185,7 +1184,6 @@ static int st_open(struct inode *inode, struct

file *filp)
int dev = TAPE_NR(inode);
char *name;

- mutex_lock(&st_mutex);
/*
* We really want to do nonseekable_open(inode, filp); here, but some
* versions of tar incorrectly call lseek on tapes and bail out if that
@@ -1194,7 +1192,6 @@ static int st_open(struct inode *inode, struct file *filp)
filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE);

if (!(STp = scsi_tape_get(dev))) {
- mutex_unlock(&st_mutex);
return -ENXIO;
}

@@ -1205,7 +1202,6 @@ static int st_open(struct inode *inode, struct file *filp)
if (STp->in_use) {
spin_unlock(&st_use_lock);
scsi_tape_put(STp);
- mutex_unlock(&st_mutex);
DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) return (-EBUSY);
}
@@ -1259,16 +1255,16 @@ static int st_open(struct inode *inode, struct file *filp)
retval = (-EIO);
goto err_out;
}
- mutex_unlock(&st_mutex);
return 0;

err_out:
normalize_buffer(STp->buffer);
+ spin_lock(&st_use_lock);
STp->in_use = 0;
+ spin_unlock(&st_use_lock);
scsi_tape_put(STp);
if (resumed)
scsi_autopm_put_device(STp->device);
- mutex_unlock(&st_mutex);
return retval;

}

Signature · 1 line
1.7.11.5
author
#1 lore raw

Please disregard this patch -- I have the meta-data wrong.

I'll resubmit.

Quoted 76 lines · Lee Duncan

This patch is based on the "misc" branch of the SCSI tree and the 5-patch series for st sent by Jeff Mahoney 8/18/2012 and Ack-ed by Kai on 8/20.

From: Jeff Mahoney <[email protected]>

The st_mutex was created when the BKL was removed, and prevents simultaneous st_open calls. It is better to protect just the necessary data.

---
 drivers/scsi/st.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/st.c +0 -2
index ceca095..98156a9 100644
@@ -75,7 +75,6 @@ static const char *verstr = "20101219";
 #include "st_options.h"
 #include "st.h"
 
-static DEFINE_MUTEX(st_mutex);
 static int buffer_kbs;
 static int max_sg_segs;
 static int try_direct_io = TRY_DIRECT_IO;
@@ -1185,7 +1184,6 @@ static int st_open(struct inode *inode, struct
 file *filp)
 	int dev = TAPE_NR(inode);
 	char *name;
 
-	mutex_lock(&st_mutex);
 	/*
 	 * We really want to do nonseekable_open(inode, filp); here, but some
drivers/scsi/st.c +0 -2
 	 * versions of tar incorrectly call lseek on tapes and bail out if that
@@ -1194,7 +1192,6 @@ static int st_open(struct inode *inode, struct
 file *filp)
 	filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE);
 
 	if (!(STp = scsi_tape_get(dev))) {
-		mutex_unlock(&st_mutex);
 		return -ENXIO;
 	}
@@ -1205,7 +1202,6 @@ static int st_open(struct inode *inode, struct
 file *filp)
 	if (STp->in_use) {
 		spin_unlock(&st_use_lock);
 		scsi_tape_put(STp);
-		mutex_unlock(&st_mutex);
 		DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); )
 		return (-EBUSY);
drivers/scsi/st.c +2 -2
 	}
@@ -1259,16 +1255,16 @@ static int st_open(struct inode *inode, struct
 file *filp)
 			retval = (-EIO);
 		goto err_out;
 	}
-	mutex_unlock(&st_mutex);
 	return 0;
 
  err_out:
 	normalize_buffer(STp->buffer);
+	spin_lock(&st_use_lock);
 	STp->in_use = 0;
+	spin_unlock(&st_use_lock);
 	scsi_tape_put(STp);
 	if (resumed)
 		scsi_autopm_put_device(STp->device);
-	mutex_unlock(&st_mutex);
 	return retval;
 

}

Signature · 2 lines
Lee Duncan
SUSE Labs