xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: Joe Jin <joe.jin@oracle.com>
Cc: Keir Fraser <keir.fraser@citrix.com>,
	xen-devel@lists.xensource.com, deepak.patel@oracle.com,
	greg.marsden@oracle.com
Subject: Re: [PATCH] Fix blkback/blktap sysfs read bug.
Date: Wed, 20 Jan 2010 07:46:19 +0000	[thread overview]
Message-ID: <4B56C2DB020000780002AE45@vpn.id2.novell.com> (raw)
In-Reply-To: <20100120020605.GA25697@joejin-pc.cn.oracle.com>

>>> "Joe Jin" <joe.jin@oracle.com> 20.01.10 03:06 >>>
>sysfs did not provide lock to handle this, not sure if developer
>think it is not necessary or they'd like to caller to handled it.

A lock is probably not the usual way to deal with this; ref-counting
would seem more common. Nevertheless I think adding a lock will
take care of the issue here.

>--- a/drivers/xen/blktap/xenbus.c	Fri Jan 08 13:07:17 2010 +0000
>+++ b/drivers/xen/blktap/xenbus.c	Wed Jan 20 10:00:53 2010 +0800
>...
>@@ -122,10 +123,15 @@
> 				   struct device_attribute *attr,	\
> 				   char *buf)				\
> 	{								\
>+		ssize_t ret = -ENODEV;					\
> 		struct xenbus_device *dev = to_xenbus_device(_dev);	\

The use of to_xenbus_device() here makes ...

>-		struct backend_info *be = dev->dev.driver_data;		\
>+		struct backend_info *be;				\
> 									\
>-		return sprintf(buf, format, ##args);			\
>+		read_lock(&sysfs_read_lock);				\
>+		if (dev && (be = dev->dev.driver_data) && be->blkif)	\

... the checking of dev here useless (and the blkback part of the patch
doesn't do the same).

>+			ret = sprintf(buf, format, ##args);		\
>+		read_unlock(&sysfs_read_lock);				\
>+		return ret;						\
> 	}								\
> 	static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
> 

And btw., in both cases with the lock added there's no need to check
both 'be' and 'be->blkif', since be->blkif can't be NULL when be is
non-NULL.

Jan

  reply	other threads:[~2010-01-20  7:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-19  9:52 [PATCH] Fix blkback/blktap sysfs read bug Joe Jin
2010-01-19 10:25 ` Jan Beulich
2010-01-19 11:32   ` Joe Jin
2010-01-19 12:06     ` Jan Beulich
2010-01-19 14:13       ` Joe Jin
2010-01-19 16:20         ` Jan Beulich
2010-01-20  2:06           ` Joe Jin
2010-01-20  7:46             ` Jan Beulich [this message]
2010-01-20 10:51               ` Joe Jin
2010-01-20 11:06                 ` Jan Beulich
2010-01-20 11:45                   ` Joe Jin
2010-01-20 20:25                     ` Keir Fraser
2010-01-21  2:16                     ` Daniel Stodden
2010-01-21  3:13                       ` Joe Jin
2010-01-21  7:26                         ` Daniel Stodden
2010-01-21  7:49                           ` Joe Jin
2010-01-21 18:01                             ` Daniel Stodden

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=4B56C2DB020000780002AE45@vpn.id2.novell.com \
    --to=jbeulich@novell.com \
    --cc=deepak.patel@oracle.com \
    --cc=greg.marsden@oracle.com \
    --cc=joe.jin@oracle.com \
    --cc=keir.fraser@citrix.com \
    --cc=xen-devel@lists.xensource.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).