Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0644f539 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by James Bottomley
Browse files

[SCSI] st: remove st_mutex



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.

Signed-off-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarLee Duncan <lduncan@suse.com>
Acked-by: default avatarKai Mäkisara <Kai.Makisara@kolumbus.fi>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent fe542396
Loading
Loading
Loading
Loading
+2 −6
Original line number Original line Diff line number Diff line
@@ -75,7 +75,6 @@ static const char *verstr = "20101219";
#include "st_options.h"
#include "st_options.h"
#include "st.h"
#include "st.h"


static DEFINE_MUTEX(st_mutex);
static int buffer_kbs;
static int buffer_kbs;
static int max_sg_segs;
static int max_sg_segs;
static int try_direct_io = TRY_DIRECT_IO;
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);
	int dev = TAPE_NR(inode);
	char *name;
	char *name;


	mutex_lock(&st_mutex);
	/*
	/*
	 * We really want to do nonseekable_open(inode, filp); here, but some
	 * 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
	 * 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);
	filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE);


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


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


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


}
}