linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Juergen Gross <jgross@suse.com>,
	linux-kernel@vger.kernel.org, xen-devel@lists.xen.org,
	konrad.wilk@oracle.com, david.vrabel@citrix.com
Cc: stable@vger.kernel.org
Subject: Re: [PATCH 2/2] xen/scsiback: avoid warnings when adding multiple LUNs to a domain
Date: Fri, 5 Feb 2016 10:50:47 -0500	[thread overview]
Message-ID: <56B4C4D7.90202@oracle.com> (raw)
In-Reply-To: <1454678503-7999-2-git-send-email-jgross@suse.com>



On 02/05/2016 08:21 AM, Juergen Gross wrote:
> When adding more than one LUN to a frontend a warning for a failed
> assignment is issued in dom0 for each already existing LUN. Avoid this
> warning.

Aren't you just factoring out the check? The warning is still printed 
for each scsiback_add_translation_entry() invocation, no?


>
> Signed-off-by: Juergen Gross <jgross@suse.com>
> Cc: stable@vger.kernel.org
> ---
>   drivers/xen/xen-scsiback.c | 65 ++++++++++++++++++++++++++--------------------
>   1 file changed, 37 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
> index 51387d7..69de879 100644
> --- a/drivers/xen/xen-scsiback.c
> +++ b/drivers/xen/xen-scsiback.c
> @@ -849,15 +849,31 @@ static int scsiback_map(struct vscsibk_info *info)
>   }
>   
>   /*
> +  Check for a translation entry being present
> +*/
> +static struct v2p_entry *scsiback_chk_translation_entry(
> +	struct vscsibk_info *info, struct ids_tuple *v)
> +{
> +	struct list_head *head = &(info->v2p_entry_lists);
> +	struct v2p_entry *entry;
> +
> +	list_for_each_entry(entry, head, l)
> +		if ((entry->v.chn == v->chn) &&
> +		    (entry->v.tgt == v->tgt) &&
> +		    (entry->v.lun == v->lun))
> +			return entry;
> +
> +	return NULL;
> +}
> +
> +/*
>     Add a new translation entry
>   */
>   static int scsiback_add_translation_entry(struct vscsibk_info *info,
>   					  char *phy, struct ids_tuple *v)
>   {
>   	int err = 0;
> -	struct v2p_entry *entry;
>   	struct v2p_entry *new;
> -	struct list_head *head = &(info->v2p_entry_lists);
>   	unsigned long flags;
>   	char *lunp;
>   	unsigned long long unpacked_lun;
> @@ -917,15 +933,10 @@ static int scsiback_add_translation_entry(struct vscsibk_info *info,
>   	spin_lock_irqsave(&info->v2p_lock, flags);
>   
>   	/* Check double assignment to identical virtual ID */
> -	list_for_each_entry(entry, head, l) {
> -		if ((entry->v.chn == v->chn) &&
> -		    (entry->v.tgt == v->tgt) &&
> -		    (entry->v.lun == v->lun)) {
> -			pr_warn("Virtual ID is already used. Assignment was not performed.\n");
> -			err = -EEXIST;
> -			goto out;
> -		}
> -
> +	if (scsiback_chk_translation_entry(info, v)) {
> +		pr_warn("Virtual ID is already used. Assignment was not performed.\n");
> +		err = -EEXIST;
> +		goto out;
>   	}
>   
>   	/* Create a new translation entry and add to the list */
> @@ -933,7 +944,7 @@ static int scsiback_add_translation_entry(struct vscsibk_info *info,
>   	new->v = *v;
>   	new->tpg = tpg;
>   	new->lun = unpacked_lun;
> -	list_add_tail(&new->l, head);
> +	list_add_tail(&new->l, &info->v2p_entry_lists);
>   
>   out:
>   	spin_unlock_irqrestore(&info->v2p_lock, flags);
> @@ -962,33 +973,31 @@ static int scsiback_del_translation_entry(struct vscsibk_info *info,
>   					  struct ids_tuple *v)
>   {
>   	struct v2p_entry *entry;
> -	struct list_head *head = &(info->v2p_entry_lists);
>   	unsigned long flags;
>   
>   	spin_lock_irqsave(&info->v2p_lock, flags);
>   	/* Find out the translation entry specified */
> -	list_for_each_entry(entry, head, l) {
> -		if ((entry->v.chn == v->chn) &&
> -		    (entry->v.tgt == v->tgt) &&
> -		    (entry->v.lun == v->lun)) {
> -			goto found;
> -		}
> -	}
> -
> -	spin_unlock_irqrestore(&info->v2p_lock, flags);
> -	return 1;
> -
> -found:
> -	/* Delete the translation entry specfied */
> -	__scsiback_del_translation_entry(entry);
> +	entry = scsiback_chk_translation_entry(info, v);
> +	if (entry)
> +		__scsiback_del_translation_entry(entry);
>   
>   	spin_unlock_irqrestore(&info->v2p_lock, flags);
> -	return 0;
> +	return entry == NULL;

Might be better to return -ENOENT instead of 1 above and -EEXISTS if 
entry!=NULL, given that this returns an int.

-boris

>   }
>   
>   static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
>   				char *phy, struct ids_tuple *vir, int try)
>   {
> +	struct v2p_entry *entry;
> +	unsigned long flags;
> +
> +	if (try) {
> +		spin_lock_irqsave(&info->v2p_lock, flags);
> +		entry = scsiback_chk_translation_entry(info, vir);
> +		spin_unlock_irqrestore(&info->v2p_lock, flags);
> +		if (entry)
> +			return;
> +	}
>   	if (!scsiback_add_translation_entry(info, phy, vir)) {
>   		if (xenbus_printf(XBT_NIL, info->dev->nodename, state,
>   				  "%d", XenbusStateInitialised)) {

  reply	other threads:[~2016-02-05 15:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-05 13:15 [PATCH 0/2] xen/scsiback: correct two issues Juergen Gross
2016-02-05 13:21 ` [PATCH 1/2] xen/scsiback: correct frontend counting Juergen Gross
2016-02-05 13:21   ` [PATCH 2/2] xen/scsiback: avoid warnings when adding multiple LUNs to a domain Juergen Gross
2016-02-05 15:50     ` Boris Ostrovsky [this message]
2016-02-05 15:55       ` Boris Ostrovsky
2016-02-05 16:59       ` Juergen Gross
2016-02-05 17:24         ` Boris Ostrovsky
2016-02-08 12:28           ` Juergen Gross
2016-02-05 15:42   ` [PATCH 1/2] xen/scsiback: correct frontend counting Boris Ostrovsky
2016-02-05 15:44     ` Juergen Gross

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=56B4C4D7.90202@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=jgross@suse.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).