linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@suse.de>
To: Robert Love <robert.w.love@intel.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [RFC PATCH] libfcoe: Replace module state checking with global flag checking
Date: Sat, 19 Mar 2011 10:58:31 -0400	[thread overview]
Message-ID: <1300546711.12679.11.camel@mulgrave.site> (raw)
In-Reply-To: <20110312020737.21655.31389.stgit@localhost6.localdomain6>

On Fri, 2011-03-11 at 18:07 -0800, Robert Love wrote:
> libfcoe uses module parameters for its create, destroy,
> etc... interfaces. The user land application will write
> the name of the netdevice to these interface files to
> trigger the kernel to take some action.
> 
> Module parameter sysfs files are both present and writable
> before the module has completed its initialization routine.
> This means that the user could call 'create' before
> libfcoe's global data structures have been initialized.
> 
> The current solution is to check the module's state in
> the sysfs store functions and if the module is not
> MODULE_STATE_LIVE the sysfs store routine will immediately
> exit, thus not doing anything if the module has not
> completed initialization. This solution is not sufficient
> because it expects THIS_MODULE to have been initialized,
> which is not guaranteed.
> 
> This patch adds a global (to libfcoe) atomic variable
> which is used to track the modules initialization state.
> In other words, this patch uses a flag to indicate
> whether the module has completed initialization or not.

OK, so this isn't really the way to do it, because you've just replaced
one race condition with another: The race is that the module can go dead
immediately after you make your liveness checks.  The fix is that you
want the correct lifetime rules on the objects.

For the sysfs files, that means using them properly, so they don't
appear until the module is ready to begin processing calls and they
disappear *before* you begin teardown.

James



      reply	other threads:[~2011-03-19 14:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-12  2:07 [RFC PATCH] libfcoe: Replace module state checking with global flag checking Robert Love
2011-03-19 14:58 ` James Bottomley [this message]

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=1300546711.12679.11.camel@mulgrave.site \
    --to=james.bottomley@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=robert.w.love@intel.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;
as well as URLs for NNTP newsgroup(s).