Received: by 10.213.65.68 with SMTP id h4csp690829imn; Wed, 4 Apr 2018 05:46:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx480D/mtnVJkLscNVaFLP7uoa20rualM1SwmXg2dFRyu9L/3wPHv+nTAtVFoq5rDQoiQTGmv X-Received: by 2002:a17:902:5066:: with SMTP id f35-v6mr18660553plh.14.1522845968771; Wed, 04 Apr 2018 05:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522845968; cv=none; d=google.com; s=arc-20160816; b=cAWexdiCPmZLz2dALaVSdVEKbE4ErMpVzOhMhLAwwzhxXfFODQ2+UuQwFuaUWpfA3M qCVSk2uav36DZVTgqKrp12QQd55kJX4skqSrbjPedpMu7C5exvNmP+Si6bPZpQ8CET57 JGNHWcssgsFfV4HRkGJIIbp1Xku9q3M8vwkvAKVXj6jUxh544imv/sL4NwZs6ceXd9m8 TKHOOh2VXpvnPN5hJN3x2BcIqG1KK0u+nMzDZmKYghRoGe852gt0AURM14MTxPP0idUO lms6auZrINqLgz60fCYfUIC7Lq2e+8Zj1cgKwATBb40lL9YZcPLRyXMenzd0bL2WD4Pi xP7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Y0Vg7d0LFdGXc7zKLAbg9O68wNXotV7zuGf6WRSysSQ=; b=sAPK5Xyjlxyym2Mru43fxjan8+g5ZorjU0UbgU5/LMB0xdwGUanDtv8Nn4kWHDSAhE 2hll2QEueIjMGc+W46onxpjhyL1MG+0u51wFWQ/sKQsetVr+nwdfggsVBZJHEejltJYd nR0fHin+ErEvkgoBFfxJNUrv3L80R+daZRq8Y1LN8u8P9VwZaqkt9jjrbgNRXgxyYQ3T mlAVhkGUd7VY9dOkrj5KiE+R9A7D3SoOSbaOZcA4VgYHCs9oelJNsTGYOcUHZ155/XC6 nYFrF09TBf9K8JAqJMTo5jKm6aRjSa57cEeHvjEP2LoXtiSMYpEs/YSvGzUV93jlS0lr CQlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3-v6si2981273pld.241.2018.04.04.05.45.51; Wed, 04 Apr 2018 05:46:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751723AbeDDMnd (ORCPT + 99 others); Wed, 4 Apr 2018 08:43:33 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:36439 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751591AbeDDMn3 (ORCPT ); Wed, 4 Apr 2018 08:43:29 -0400 Received: by mail-wr0-f195.google.com with SMTP id y55so22432221wry.3 for ; Wed, 04 Apr 2018 05:43:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Y0Vg7d0LFdGXc7zKLAbg9O68wNXotV7zuGf6WRSysSQ=; b=mNaKBf9/2frkJfn0MIXnluDn0avlAFGWnxujGOx+qv2ylnBk4oS8yB3MbWxp/NltTH KSrsKk6IoT2OP19sS71kS4D3tlje183Uy9FnssjznVBaUD0W80j5OWerLbS9Gu5xcWda HxxyQ5KwsPVLcCF8tsr6jevxOvehiIz3B4/peZruYfvqZM8s3ZYsE8AsJrrHVOU2RTp2 ie6+b2qWWG6eDDNOZso8yyKCQz54Utu6YaLR077qyy7Yjz6HWMnPj/XXX7m9gaOtVaBC EjToZvzVwWfkbSIlGa1nfDG+ZuGVOMHt4d1hwl3sCYCXFrdewTiZeC3vOJiJGlkvhNaI 7N+Q== X-Gm-Message-State: AElRT7Em734l/yjF+iS73oUazavdOy5LHp4eHp8CINP6qci96EEIzgtJ E379mWkFVYHd0Mxe9QeOA3g= X-Received: by 10.223.209.132 with SMTP id h4mr13448170wri.12.1522845807962; Wed, 04 Apr 2018 05:43:27 -0700 (PDT) Received: from [192.168.64.169] (bzq-219-42-90.isdn.bezeqint.net. [62.219.42.90]) by smtp.gmail.com with ESMTPSA id q127sm10538461wmd.3.2018.04.04.05.43.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Apr 2018 05:43:27 -0700 (PDT) Subject: Re: [PATCH 2/4] nvmet-rdma: Use new SGL alloc/free helper for requests To: Logan Gunthorpe , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Christoph Hellwig , James Smart References: <20180329160721.4691-1-logang@deltatee.com> <20180329160721.4691-3-logang@deltatee.com> From: Sagi Grimberg Message-ID: <2fbc3260-6682-f789-9500-2961293ff3b4@grimberg.me> Date: Wed, 4 Apr 2018 15:43:26 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180329160721.4691-3-logang@deltatee.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > @@ -565,24 +565,24 @@ static u16 nvmet_rdma_map_sgl_keyed(struct nvmet_rdma_rsp *rsp, > { > struct rdma_cm_id *cm_id = rsp->queue->cm_id; > u64 addr = le64_to_cpu(sgl->addr); > - u32 len = get_unaligned_le24(sgl->length); > u32 key = get_unaligned_le32(sgl->key); > int ret; > > + rsp->req.transfer_len = get_unaligned_le24(sgl->length); > + IIRC, this might result in nvmet-rdma executing data-transfer even for failed requests in some error cases. I'm not sure this is the only case, but have you tested what happens in error cases? See nvmet_rdma_need_data_in()/nvmet_rdma_need_data_out() which look at transfer_len. > /* no data command? */ > - if (!len) > + if (!rsp->req.transfer_len) > return 0; > > - rsp->req.sg = sgl_alloc(len, GFP_KERNEL, &rsp->req.sg_cnt); > - if (!rsp->req.sg) > - return NVME_SC_INTERNAL; > + ret = nvmet_req_alloc_sgl(&rsp->req, &rsp->queue->nvme_sq); > + if (ret < 0) > + goto error_out; > > ret = rdma_rw_ctx_init(&rsp->rw, cm_id->qp, cm_id->port_num, > rsp->req.sg, rsp->req.sg_cnt, 0, addr, key, > nvmet_data_dir(&rsp->req)); > if (ret < 0) > - return NVME_SC_INTERNAL; > - rsp->req.transfer_len += len; > + goto error_out; > rsp->n_rdma += ret; > > if (invalidate) { > @@ -591,6 +591,10 @@ static u16 nvmet_rdma_map_sgl_keyed(struct nvmet_rdma_rsp *rsp, > } > > return 0; > + > +error_out: > + rsp->req.transfer_len = 0; > + return NVME_SC_INTERNAL; > } > > static u16 nvmet_rdma_map_sgl(struct nvmet_rdma_rsp *rsp) >