From patchwork Wed Jan 27 10:57:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 8132331 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D9A529F818 for ; Wed, 27 Jan 2016 10:57:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E02BB202F8 for ; Wed, 27 Jan 2016 10:57:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB7C220259 for ; Wed, 27 Jan 2016 10:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754710AbcA0K5p (ORCPT ); Wed, 27 Jan 2016 05:57:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:45629 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754044AbcA0K5n (ORCPT ); Wed, 27 Jan 2016 05:57:43 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 833DFACF7; Wed, 27 Jan 2016 10:57:39 +0000 (UTC) Subject: Re: [PATCH-v2 11/12] xen-scsiback: Convert to percpu_ida tag allocation To: "Nicholas A. Bellinger" References: <1453709466-6308-1-git-send-email-nab@daterainc.com> <1453709466-6308-12-git-send-email-nab@daterainc.com> <56A7401E.7070005@suse.com> <1453876090.6746.123.camel@haakon3.risingtidesystems.com> Cc: "Nicholas A. Bellinger" , target-devel , linux-scsi , Christoph Hellwig , Hannes Reinecke , Mike Christie , Sagi Grimberg , Andy Grover , Sebastian Andrzej Siewior , Andrzej Pietrasiewicz , Chris Boot , David Vrabel From: Juergen Gross X-Enigmail-Draft-Status: N1110 Message-ID: <56A8A2A3.30407@suse.com> Date: Wed, 27 Jan 2016 11:57:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <1453876090.6746.123.camel@haakon3.risingtidesystems.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_BRBL_LASTEXT, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 >>> >>> Cc: Juergen Gross >>> Cc: Hannes Reinecke >>> Cc: David Vrabel >>> Signed-off-by: Nicholas Bellinger >>> --- >>> 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: 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 --- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;