From: Hannes Reinecke <hare@suse.de>
To: linux-scsi@vger.kernel.org
Cc: "Hannes Reinecke" <hare@suse.de>,
"James Bottomley" <jbottomley@parallels.com>,
"Kai Mäkisara" <Kai.Makisara@kolumbus.fi>,
"Lee Duncan" <lduncan@suse.com>
Subject: [PATCH] st: unblock concurrent access in st_open()
Date: Wed, 15 Aug 2012 16:24:49 +0200 [thread overview]
Message-ID: <1345040689-29362-1-git-send-email-hare@suse.de> (raw)
st_open() is taking a global mutex 'st_mutex' to protect
against concurrent calls to st_open(). However, as
st_open() might take quite some time before returning,
_any_ open to _any_ st device will be blocked during
that time.
Seeing that all critical sections are already protected
by individual spinlocks 'st_mutex' doesn't serve any
purpose and can be removed, unblocking concurrent
accesses.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Cc: James Bottomley <jbottomley@parallels.com>
Cc: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Cc: Lee Duncan <lduncan@suse.com>
---
drivers/scsi/st.c | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index e41998c..c6c172e 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -74,7 +74,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;
@@ -1188,7 +1187,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
@@ -1197,7 +1195,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;
}
@@ -1208,7 +1205,6 @@ static int st_open(struct inode *inode, struct file *filp)
if (STp->in_use) {
write_unlock(&st_dev_arr_lock);
scsi_tape_put(STp);
- mutex_unlock(&st_mutex);
DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); )
return (-EBUSY);
}
@@ -1262,16 +1258,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);
+ write_lock(&st_dev_arr_lock);
STp->in_use = 0;
+ write_unlock(&st_dev_arr_lock);
scsi_tape_put(STp);
if (resumed)
scsi_autopm_put_device(STp->device);
- mutex_unlock(&st_mutex);
return retval;
}
--
1.7.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2012-08-15 14:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-15 14:24 Hannes Reinecke [this message]
2012-08-15 20:14 ` [PATCH] st: unblock concurrent access in st_open() Kai Makisara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1345040689-29362-1-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=Kai.Makisara@kolumbus.fi \
--cc=jbottomley@parallels.com \
--cc=lduncan@suse.com \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox