From: Andrew Morton <akpm@linux-foundation.org>
To: "Stephen M. Cameron" <scameron@beardog.cce.hp.com>
Cc: James.Bottomley@HansenPartnership.com,
linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
mikem@beardog.cce.hp.com
Subject: Re: [PATCH 09/17] Add thread to allow controllers to register for rescan for new devices
Date: Thu, 12 Nov 2009 14:50:13 -0800 [thread overview]
Message-ID: <20091112145013.b1172579.akpm@linux-foundation.org> (raw)
In-Reply-To: <20091111165109.17754.12015.stgit@beardog.cce.hp.com>
On Wed, 11 Nov 2009 10:51:09 -0600
"Stephen M. Cameron" <scameron@beardog.cce.hp.com> wrote:
> Add thread to allow controllers to register for rescan for new devices
> (borrowed code from cciss.)
>
> + * add_to_scan_list() - add controller to rescan queue
> + * @h: Pointer to the controller.
> + *
> + * Adds the controller to the rescan queue if not already on the queue.
> + *
> + * returns 1 if added to the queue, 0 if skipped (could be on the
> + * queue already, or the controller could be initializing or shutting
> + * down).
> + **/
> +static int add_to_scan_list(struct ctlr_info *h)
> +{
> + struct ctlr_info *test_h;
> + int found = 0;
> + int ret = 0;
> +
> + if (h->busy_initializing)
> + return 0;
> +
> + if (!mutex_trylock(&h->busy_shutting_down))
> + return 0;
Generally a trylock needs a comment explaining wtf it's there for.
This one certainly does.
> + mutex_lock(&scan_mutex);
> + list_for_each_entry(test_h, &scan_q, scan_list) {
> + if (test_h == h) {
> + found = 1;
> + break;
> + }
> + }
> + if (!found && !h->busy_scanning) {
> + INIT_COMPLETION(h->scan_wait);
> + list_add_tail(&h->scan_list, &scan_q);
> + ret = 1;
> + }
> + mutex_unlock(&scan_mutex);
> + mutex_unlock(&h->busy_shutting_down);
> +
> + return ret;
> +}
>
> ...
>
> +/* scan_thread() - kernel thread used to rescan controllers
> + * @data: Ignored.
> + *
> + * A kernel thread used scan for drive topology changes on
> + * controllers. The thread processes only one controller at a time
> + * using a queue. Controllers are added to the queue using
> + * add_to_scan_list() and removed from the queue either after done
> + * processing or using remove_from_scan_list().
> + *
> + * returns 0.
> + **/
> +static int scan_thread(__attribute__((unused)) void *data)
Is the attribute actually needed?
We have various helper macros, such as __always_unused.
> +{
> + struct ctlr_info *h;
> + int host_no;
> +
> + while (1) {
> + set_current_state(TASK_INTERRUPTIBLE);
> + schedule();
> + if (kthread_should_stop())
> + break;
Looks wrong. If a kthread_stop() comes in just before the
set_current_state(), I think the thread will sleep forever?
> + while (1) {
> + mutex_lock(&scan_mutex);
> + if (list_empty(&scan_q)) {
> + mutex_unlock(&scan_mutex);
> + break;
> + }
> + h = list_entry(scan_q.next, struct ctlr_info,
> + scan_list);
> + list_del(&h->scan_list);
> + h->busy_scanning = 1;
> + mutex_unlock(&scan_mutex);
> + host_no = h->scsi_host ? h->scsi_host->host_no : -1;
> + hpsa_update_scsi_devices(h, host_no);
> + complete_all(&h->scan_wait);
> + mutex_lock(&scan_mutex);
> + h->busy_scanning = 0;
> + mutex_unlock(&scan_mutex);
> + }
> + }
> + return 0;
> +}
> +
>
> ...
>
next prev parent reply other threads:[~2009-11-12 22:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-11 16:50 [PATCH 00/17] hpsa driver updates Stephen M. Cameron
2009-11-11 16:50 ` [PATCH 01/17] Add hpsa driver for HP Smart Array controllers Stephen M. Cameron
2009-11-11 16:50 ` [PATCH 02/17] avoid helpful cleanup patches Stephen M. Cameron
2009-11-11 16:50 ` [PATCH 03/17] hpsa: Fix vendor id check Stephen M. Cameron
2009-11-11 16:50 ` [PATCH 04/17] Fix use of unallocated memory for MSA2xxx enclosure device data Stephen M. Cameron
2009-11-12 22:45 ` Andrew Morton
2009-11-11 16:50 ` [PATCH 05/17] hpsa: Allocate the correct amount of extra space for the scsi host Stephen M. Cameron
2009-11-11 16:50 ` [PATCH 06/17] hpsa: Use shost_priv instead of accessing host->hostdata[0] directly Stephen M. Cameron
2009-11-11 16:50 ` [PATCH 07/17] hpsa: Factor out command submission sequence Stephen M. Cameron
2009-11-11 16:51 ` [PATCH 08/17] hpsa: Factor out some pci_unmap code Stephen M. Cameron
2009-11-11 16:51 ` [PATCH 09/17] Add thread to allow controllers to register for rescan for new devices Stephen M. Cameron
2009-11-12 22:50 ` Andrew Morton [this message]
2009-11-11 16:51 ` [PATCH 10/17] hpsa: Allow device rescan to be triggered via sysfs Stephen M. Cameron
2009-11-12 22:51 ` Andrew Morton
2009-11-11 16:51 ` [PATCH 11/17] hpsa: Make hpsa_sdev_attrs static Stephen M. Cameron
2009-11-11 16:51 ` [PATCH 12/17] hpsa: decode unit attention condition and retry commands Stephen M. Cameron
2009-11-11 16:51 ` [PATCH 13/17] hpsa: Retry driver initiated commands on unit attention Stephen M. Cameron
2009-11-12 22:52 ` Andrew Morton
2009-11-11 16:51 ` [PATCH 14/17] hpsa: Flush cache with interrupts still enabled Stephen M. Cameron
2009-11-11 16:51 ` [PATCH 15/17] hpsa: Remove sendcmd, in no case are we required to poll for completions Stephen M. Cameron
2009-11-11 16:51 ` [PATCH 16/17] hpsa: Make fill_cmd() return void Stephen M. Cameron
2009-11-11 16:51 ` [PATCH 17/17] hpsa: fix typo that causes scsi status to be lost Stephen M. Cameron
2009-11-16 21:06 ` [PATCH 00/17] hpsa driver updates James Bottomley
2009-11-16 21:32 ` Andrew Morton
2009-11-16 21:54 ` scameron
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=20091112145013.b1172579.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mikem@beardog.cce.hp.com \
--cc=scameron@beardog.cce.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