From: Asias He <asias@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: kvm@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>,
virtualization@lists.linux-foundation.org,
target-devel@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 2/5] tcm_vhost: Introduce tcm_vhost_check_feature()
Date: Thu, 7 Mar 2013 08:35:32 +0800 [thread overview]
Message-ID: <20130307003532.GB8785@hj.localdomain> (raw)
In-Reply-To: <20130306090620.GA32480@stefanha-thinkpad.muc.redhat.com>
On Wed, Mar 06, 2013 at 10:06:20AM +0100, Stefan Hajnoczi wrote:
> On Wed, Mar 06, 2013 at 02:16:27PM +0800, Asias He wrote:
> > This helper is useful to check if a feature is supported.
> >
> > Signed-off-by: Asias He <asias@redhat.com>
> > ---
> > drivers/vhost/tcm_vhost.c | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
> > index b3e50d7..fdbf986 100644
> > --- a/drivers/vhost/tcm_vhost.c
> > +++ b/drivers/vhost/tcm_vhost.c
> > @@ -91,6 +91,20 @@ static int iov_num_pages(struct iovec *iov)
> > ((unsigned long)iov->iov_base & PAGE_MASK)) >> PAGE_SHIFT;
> > }
> >
> > +static bool tcm_vhost_check_feature(struct vhost_scsi *vs, u64 feature)
> > +{
> > + u64 acked_features;
> > + bool ret = false;
> > +
> > + mutex_lock(&vs->dev.mutex);
> > + acked_features = vs->dev.acked_features;
> > + if (acked_features & 1ULL << feature)
> > + ret = true;
> > + mutex_unlock(&vs->dev.mutex);
> > +
> > + return ret;
> > +}
>
> This is like vhost_has_feature() except it acquires dev.mutex?
>
> In any case it isn't tcm_vhost-specific and could be in vhost.c.
tcm_vhost_check_feature() is called outside the vhost worker thread. So
the dev.mutex is needed.
Mst, what's your preference here? Add vhost_has_feature_locked() in
vhost.c or I use vhost_has_feature() in tcm_vhost_check_feature().
Thanks.
--
Asias
next prev parent reply other threads:[~2013-03-07 0:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-06 6:16 [PATCH 0/5] tcm_vhost hotplug/hotunplug support and locking fix Asias He
2013-03-06 6:16 ` [PATCH 1/5] tcm_vhost: Add missed lock in vhost_scsi_clear_endpoint() Asias He
2013-03-06 6:16 ` [PATCH 2/5] tcm_vhost: Introduce tcm_vhost_check_feature() Asias He
2013-03-06 9:06 ` Stefan Hajnoczi
2013-03-07 0:35 ` Asias He [this message]
2013-03-06 6:16 ` [PATCH 3/5] tcm_vhost: Introduce tcm_vhost_check_endpoint() Asias He
2013-03-06 6:16 ` [PATCH 4/5] tcm_vhost: Fix vs->vs_endpoint checking in vhost_scsi_handle_vq() Asias He
2013-03-06 6:16 ` [PATCH 5/5] tcm_vhost: Add hotplug/hotunplug support Asias He
[not found] ` <1362550590-3534-6-git-send-email-asias@redhat.com>
2013-03-06 9:21 ` Stefan Hajnoczi
2013-03-07 0:26 ` Asias He
2013-03-07 8:58 ` Stefan Hajnoczi
2013-03-07 9:47 ` Asias He
2013-03-07 12:53 ` Stefan Hajnoczi
2013-03-08 2:11 ` Asias He
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=20130307003532.GB8785@hj.localdomain \
--to=asias@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=stefanha@redhat.com \
--cc=target-devel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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