From: Andrew Patterson <andrew.patterson@hp.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, linux-scsi@vger.kernel.org,
mike.miller@hp.com, jens.axboe@oracle.com
Subject: [PATCH 2 2/4] cciss: use mutex instead of flag to indicate busy initializing
Date: Tue, 21 Jul 2009 13:55:27 -0600 [thread overview]
Message-ID: <20090721195527.20740.1301.stgit@bob.kio> (raw)
In-Reply-To: <20090721195517.20740.18994.stgit@bob.kio>
cciss: use mutex instead of flag to indicate busy initializing
Convert busy_initializing from simple integer flag to mutex, so we
can use it to block and thus avoid some race conditions.
Acked-by: Mike Miller <mike.miller@hp.com>
Signed-off-by: Andrew Patterson <andrew.patterson@hp.com>
---
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 970c896..085ab11 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -751,7 +751,7 @@ static int cciss_open(struct block_device *bdev, fmode_t mode)
printk(KERN_DEBUG "cciss_open %s\n", bdev->bd_disk->disk_name);
#endif /* CCISS_DEBUG */
- if (host->busy_initializing || drv->busy_configuring)
+ if (mutex_is_locked(&host->busy_initializing) || drv->busy_configuring)
return -EBUSY;
/*
* Root is allowed to open raw volume zero even if it's not configured
@@ -3915,7 +3915,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
if (i < 0)
return -1;
- hba[i]->busy_initializing = 1;
+ mutex_init(&hba[i]->busy_initializing);
+ mutex_lock(&hba[i]->busy_initializing);
INIT_HLIST_HEAD(&hba[i]->cmpQ);
INIT_HLIST_HEAD(&hba[i]->reqQ);
@@ -4034,7 +4035,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
hba[i]->cciss_max_sectors = 2048;
- hba[i]->busy_initializing = 0;
+ mutex_unlock(&hba[i]->busy_initializing);
rebuild_lun_table(hba[i], 1);
hba[i]->cciss_scan_thread = kthread_run(scan_thread, hba[i],
@@ -4062,7 +4063,7 @@ clean2:
clean1:
cciss_destroy_hba_sysfs_entry(hba[i]);
clean0:
- hba[i]->busy_initializing = 0;
+ mutex_unlock(&hba[i]->busy_initializing);
/* cleanup any queues that may have been initialized */
for (j=0; j <= hba[i]->highest_lun; j++){
drive_info_struct *drv = &(hba[i]->drv[j]);
diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
index 06a5db2..bf1699c 100644
--- a/drivers/block/cciss.h
+++ b/drivers/block/cciss.h
@@ -107,7 +107,7 @@ struct ctlr_info
int nr_allocs;
int nr_frees;
int busy_configuring;
- int busy_initializing;
+ struct mutex busy_initializing;
/* This element holds the zero based queue number of the last
* queue to be started. It is used for fairness.
next prev parent reply other threads:[~2009-07-21 19:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-21 19:55 [PATCH 2 0/4] cciss rmmod/scan-thread fixes Andrew Patterson
2009-07-21 19:55 ` [PATCH 2 1/4] cciss: remove logical drive sysfs entries during driver cleanup Andrew Patterson
2009-07-21 19:55 ` Andrew Patterson [this message]
2009-07-24 0:32 ` [PATCH 2 2/4] cciss: use mutex instead of flag to indicate busy initializing Andrew Morton
2009-07-21 19:55 ` [PATCH 2 3/4] cciss: use only one scan thread Andrew Patterson
2009-07-21 19:55 ` [PATCH 2 4/4] cciss: kick off logical drive topology rescan through sysfs Andrew Patterson
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=20090721195527.20740.1301.stgit@bob.kio \
--to=andrew.patterson@hp.com \
--cc=akpm@linux-foundation.org \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mike.miller@hp.com \
/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