All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: "Nicholas A. Bellinger" <nab@daterainc.com>,
	target-devel <target-devel@vger.kernel.org>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	Christoph Hellwig <hch@lst.de>, Hannes Reinecke <hare@suse.de>,
	Mike Christie <mchristi@redhat.com>,
	Sagi Grimberg <sagig@mellanox.com>,
	Andy Grover <agrover@redhat.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
	Chris Boot <bootc@bootc.net>,
	David Vrabel <david.vrabel@citrix.com>
Subject: Re: [PATCH-v2 11/12] xen-scsiback: Convert to percpu_ida tag allocation
Date: Wed, 27 Jan 2016 11:57:39 +0100	[thread overview]
Message-ID: <56A8A2A3.30407@suse.com> (raw)
In-Reply-To: <1453876090.6746.123.camel@haakon3.risingtidesystems.com>

On 27/01/16 07:28, Nicholas A. Bellinger wrote:
> On Tue, 2016-01-26 at 10:45 +0100, Juergen Gross wrote:
>> On 25/01/16 09:11, Nicholas A. Bellinger wrote:
>>> From: Nicholas Bellinger <nab@linux-iscsi.org>
>>>
>>> Cc: Juergen Gross <jgross@suse.com>
>>> Cc: Hannes Reinecke <hare@suse.de>
>>> Cc: David Vrabel <david.vrabel@citrix.com>
>>> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
>>> ---
>>>  drivers/xen/xen-scsiback.c | 163 ++++++++++++++++++++++++---------------------
>>>  1 file changed, 87 insertions(+), 76 deletions(-)
>>>
>>> diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
>>> index 594f8a7..640fb22 100644
>>> --- a/drivers/xen/xen-scsiback.c
>>> +++ b/drivers/xen/xen-scsiback.c
>>> @@ -190,7 +190,6 @@ module_param_named(max_buffer_pages, scsiback_max_buffer_pages, int, 0644);
>>>  MODULE_PARM_DESC(max_buffer_pages,
>>>  "Maximum number of free pages to keep in backend buffer");
>>>  
>>> -static struct kmem_cache *scsiback_cachep;
>>>  static DEFINE_SPINLOCK(free_pages_lock);
>>>  static int free_pages_num;
>>>  static LIST_HEAD(scsiback_free_pages);
>>> @@ -322,7 +321,8 @@ static void scsiback_free_translation_entry(struct kref *kref)
>>>  }
>>>  
>>>  static void scsiback_do_resp_with_sense(char *sense_buffer, int32_t result,
>>> -			uint32_t resid, struct vscsibk_pend *pending_req)
>>> +			uint32_t resid, struct vscsibk_pend *pending_req,
>>> +			uint16_t rqid)
>>>  {
>>>  	struct vscsiif_response *ring_res;
>>>  	struct vscsibk_info *info = pending_req->info;
>>
>> pending_req might be NULL now, so this will panic the system.
>>
> 
> Thanks for the review.
> 
> Added the following to propagate up original *info into
> scsiback_do_resp_with_sense() to address the early pending_req
> failure case.
> 
> https://git.kernel.org/cgit/linux/kernel/git/nab/target-pending.git/commit/?h=queue-next&id=5873f22a9b7c7aa16ff9a85074a07b739f1d06a5

Hmm, wouldn't it make more sense to split scsiback_do_resp_with_sense()
into two functions now? Something like:


diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index ad4eb10..0d71467 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -321,11 +321,10 @@ static void scsiback_free_translation_entry(struct
kref *kref)
        kfree(entry);
 }

-static void scsiback_do_resp_with_sense(char *sense_buffer, int32_t result,
-                       uint32_t resid, struct vscsibk_pend *pending_req)
+static void scsiback_send_response(struct vscsibk_info *info,
+       char *sense_buffer, int32_t result, uint32_t resid, uint16_t rqid)
 {
        struct vscsiif_response *ring_res;
-       struct vscsibk_info *info = pending_req->info;
        int notify;
        struct scsi_sense_hdr sshdr;
        unsigned long flags;
@@ -337,7 +336,7 @@ static void scsiback_do_resp_with_sense(char
*sense_buffer, int32_t result,
        info->ring.rsp_prod_pvt++;

        ring_res->rslt   = result;
-       ring_res->rqid   = pending_req->rqid;
+       ring_res->rqid   = rqid;

        if (sense_buffer != NULL &&
            scsi_normalize_sense(sense_buffer, VSCSIIF_SENSE_BUFFERSIZE,
@@ -357,6 +356,13 @@ static void scsiback_do_resp_with_sense(char
*sense_buffer, int32_t result,

        if (notify)
                notify_remote_via_irq(info->irq);
+}
+
+static void scsiback_do_resp_with_sense(char *sense_buffer, int32_t result,
+                       uint32_t resid, struct vscsibk_pend *pending_req)
+{
+       scsiback_send_response(pending_req->info, sense_buffer, result,
+                              resid, pending_req->rqid);

        if (pending_req->v2p)
                kref_put(&pending_req->v2p->kref,


And then call scsiback_send_response() directly in case pending_req
is NULL.


Juergen

  reply	other threads:[~2016-01-27 10:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-25  8:10 [PATCH-v2 00/12] target: target_alloc_session w/ percpu_ida+ACK_KREF conversion Nicholas A. Bellinger
2016-01-25  8:10 ` [PATCH-v2 01/12] target: Add target_alloc_session() helper function Nicholas A. Bellinger
2016-01-25  8:10 ` [PATCH-v2 02/12] target: Convert demo-mode only drivers to target_alloc_session Nicholas A. Bellinger
2016-01-26  9:45   ` Juergen Gross
2016-01-25  8:10 ` [PATCH-v2 03/12] vhost/scsi: Convert to target_alloc_session usage Nicholas A. Bellinger
2016-01-25  8:10 ` [PATCH-v2 04/12] tcm_qla2xxx: " Nicholas A. Bellinger
2016-01-25  8:10 ` [PATCH-v2 05/12] tcm_fc: " Nicholas A. Bellinger
2016-01-25  8:11 ` [PATCH-v2 06/12] ib_srpt: " Nicholas A. Bellinger
2016-01-25  8:11 ` [PATCH-v2 07/12] sbp-target: Conversion to percpu_ida tag pre-allocation Nicholas A. Bellinger
2016-01-25  8:11 ` [PATCH-v2 08/12] sbp-target: Convert to TARGET_SCF_ACK_KREF I/O krefs Nicholas A. Bellinger
2016-01-25  8:11 ` [PATCH-v2 09/12] usb-gadget/tcm: Conversion to percpu_ida tag pre-allocation Nicholas A. Bellinger
2016-01-25  8:11 ` [PATCH-v2 10/12] usb-gadget/tcm: Convert to TARGET_SCF_ACK_KREF I/O krefs Nicholas A. Bellinger
2016-01-25  8:11 ` [PATCH-v2 11/12] xen-scsiback: Convert to percpu_ida tag allocation Nicholas A. Bellinger
2016-01-25 15:42   ` Juergen Gross
2016-01-26  5:15     ` Nicholas A. Bellinger
2016-01-26  9:45   ` Juergen Gross
2016-01-27  6:28     ` Nicholas A. Bellinger
2016-01-27 10:57       ` Juergen Gross [this message]
2016-01-28  5:13         ` Nicholas A. Bellinger
2016-01-25  8:11 ` [PATCH-v2 12/12] xen-scsiback: Convert to TARGET_SCF_ACK_KREF I/O krefs Nicholas A. Bellinger
2016-01-26  9:49   ` Juergen Gross
2016-01-27  6:29     ` Nicholas A. Bellinger

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=56A8A2A3.30407@suse.com \
    --to=jgross@suse.com \
    --cc=agrover@redhat.com \
    --cc=andrzej.p@samsung.com \
    --cc=bigeasy@linutronix.de \
    --cc=bootc@bootc.net \
    --cc=david.vrabel@citrix.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mchristi@redhat.com \
    --cc=nab@daterainc.com \
    --cc=nab@linux-iscsi.org \
    --cc=sagig@mellanox.com \
    --cc=target-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.