From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, horst.hummel@de.ibm.com
Subject: Re: [patch 13/13] s390: dasd device identifiers.
Date: Tue, 25 Apr 2006 10:28:13 +0200 [thread overview]
Message-ID: <1145953693.5282.17.camel@localhost> (raw)
In-Reply-To: <20060424164907.7888c685.akpm@osdl.org>
On Mon, 2006-04-24 at 16:49 -0700, Andrew Morton wrote:
> Martin Schwidefsky <schwidefsky@de.ibm.com> wrote:
> >
> > @@ -45,6 +45,7 @@ struct dasd_devmap {
> > unsigned int devindex;
> > unsigned short features;
> > struct dasd_device *device;
> > + struct dasd_uid uid;
> > };
>
> Someone's missing a TAB key.
I have to find some script that checks for the damned tabs.
> > +static ssize_t
> > +dasd_alias_show(struct device *dev, struct device_attribute *attr, char *buf)
> > +{
> > + struct dasd_devmap *devmap;
> > + int alias;
> > +
> > + devmap = dasd_find_busid(dev->bus_id);
> > + spin_lock(&dasd_devmap_lock);
> > + if (!IS_ERR(devmap))
> > + alias = devmap->uid.alias;
> > + else
> > + alias = 0;
> > + spin_unlock(&dasd_devmap_lock);
> > +
> > + return sprintf(buf, alias ? "1\n" : "0\n");
> > +}
>
> The locking is suspicious. We take a spinlock just for a single read?
We could remove the locking for single read/writes, devmap structures
are never deleted so it is safe to access a single value after the
dasd_find_busid. But it is not so easy for the vendor and serial string,
these are not single values so we need some kind of locking. To keep
things symmetrical the lock is used for alias as well. There is a bug
though, only the pointer to the vendor/serial string is read under the
lock, the copy is done outside the lock. If that races with a
dasd_set_uid call funny things might happen. The copy needs to be done
inside the lock. Horst ?
--
blue skies,
Martin.
Martin Schwidefsky
Linux for zSeries Development & Services
IBM Deutschland Entwicklung GmbH
"Reality continues to ruin my life." - Calvin.
next prev parent reply other threads:[~2006-04-25 8:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-24 15:06 [patch 13/13] s390: dasd device identifiers Martin Schwidefsky
2006-04-24 23:49 ` Andrew Morton
2006-04-25 8:28 ` Martin Schwidefsky [this message]
2006-04-26 17:59 ` Jan Blunck
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=1145953693.5282.17.camel@localhost \
--to=schwidefsky@de.ibm.com \
--cc=akpm@osdl.org \
--cc=horst.hummel@de.ibm.com \
--cc=linux-kernel@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