Received: by 10.213.65.68 with SMTP id h4csp1737180imn; Thu, 29 Mar 2018 10:03:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+rvhD4VrsXP2XIt6w9PmJ2LkxKK+tV9C7Y2VJJUavxVNi1GJMWrN06PtWtaJoEJJkj+A35 X-Received: by 2002:a17:902:59c9:: with SMTP id d9-v6mr9303857plj.251.1522343027144; Thu, 29 Mar 2018 10:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522343027; cv=none; d=google.com; s=arc-20160816; b=wiWM5KfJlvOHwOyCjg9gOyWE42mEv943lxhmAGWM4hybv4jkD3Fk2RbrrbIHqCxpA6 tPI35UJJgmZ0kJWispul+Jxg9gorVsCAJrmBUrNX5sR8CbHmIo19y8MDqXhCWrtlL7ht 0tQ/NGEzgM8fi402Qz6kN80xbI5jagSBQckv5XTZVfvBcQf8TAH+gSKSb/w8I2xbeunj qcgD3TpP6LlwhA4+cK0TzWGkn/DX2/uuZs4tB8J7Pos0Qzw1i6lFi0L11wYA44HHHyuu tTUhDRtbiX3bjMDk4fLVPxqELlDveTL4RYezcAoc0ThzkusROEEmbONEL3653/R7xr9R jUpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:arc-authentication-results; bh=YtLM2Jdjq+uooG1SkwVlVSYn921R9RIjhJ6XbXpV7a0=; b=Oer++97N/emtHRQ+IGom3UJUhWA6BQNuFzryt1BgeE/QDUPsAqxJspcaWNGJiBW5ff /GkrvuWx6QQkjeWnTGxrmzbdNhh71Cm411pLnsHomSNdiovVd9/luQxqxTle+eMFWDOc 56dcOxHfiDCKyxjtqL3YleWCopx+xbZ2WV8aBNOU4BzeeQoNp1sIkB4cmQdxa7FrGHKV dNpEdf7zwL9JrUL8KcqzMZs6Zp9qUvGmImQbTiHwoGOKF3Er5/sB2rv0QDhlWxrP0m7q eS9c0ptDu18Kzr8H0614TiFwgkgRLxkf5IV25DlRN3oQUiM0k1wH6zqzXEkx5lCF4KEO q6og== 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 m11-v6si6412768pla.724.2018.03.29.10.03.32; Thu, 29 Mar 2018 10:03:47 -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 S1752486AbeC2RC3 (ORCPT + 99 others); Thu, 29 Mar 2018 13:02:29 -0400 Received: from ale.deltatee.com ([207.54.116.67]:46772 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751209AbeC2RC1 (ORCPT ); Thu, 29 Mar 2018 13:02:27 -0400 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.89) (envelope-from ) id 1f1awG-0006Qb-8v; Thu, 29 Mar 2018 11:02:13 -0600 To: James Smart , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Christoph Hellwig , Sagi Grimberg References: <20180329160721.4691-1-logang@deltatee.com> <20180329160721.4691-5-logang@deltatee.com> <15f4d135-7600-02b3-f50f-ed8deddd7b98@broadcom.com> From: Logan Gunthorpe Message-ID: Date: Thu, 29 Mar 2018 11:02:10 -0600 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: <15f4d135-7600-02b3-f50f-ed8deddd7b98@broadcom.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: sagi@grimberg.me, hch@lst.de, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, james.smart@broadcom.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_FREE,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 Subject: Re: [PATCH 4/4] nvmet-fc: Use new SGL alloc/free helper for requests X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/03/18 10:52 AM, James Smart wrote: > overall - I'm a little concerned about the replacement. > > I know the code depends on the null/zero checks in > nvmet_fc_free_tgt_pgs() as there are paths that can call them twice.  > Your replacement in that routine is fine, but you've fully removed any > initialization to zero or setting to zero on free. Given the structure > containing the req structure is reused, I'd rather that that code was > left in some way... or that nvmet_req_free_sgl() or > nvmet_fc_free_tgt_pgs() was updated to set req->sg to null and (not sure > necessary if req->sg is null) set req->sg_cnt to 0. Ok, I can ensure we zero and NULL those in nvmet_req_free_sgl(). > also - sg_cnt isn't referenced as there is an assumption that: transfer > length meant there would be (transfer length / PAGESIZE + 1 if partial > page) pages allocated and sg_cnt would always equal that page cnt  thus > the fcpreq->sgXXX setting behavior in nvmet_fc_transfer_fcp_data().   Is > that no longer valid ?   I may not have watched closely enough when the > sgl_alloc() common routine was introduced as it may have invalidated > these assumptions that were true before. Per the bug in the previous patch, I don't think that was ever a valid assumption. It doesn't have anything to do with the sgl_alloc change either. The dma_map interface is allowed to merge SGLs and that's why it can return fewer nents than it was passed. I'm not sure how many or which DMA ops actually do this which is why it hasn't actually manifested itself as a bug; but it is part of how the interface is specified to work. I think we need to store the sg_map_cnt separately and use it instead of the calculation based on the transfer length. But this is really a fix that should be rolled in with the previous patch. If you can point me to where this needs to change I can update my patch, or if you want to fix it yourself go ahead. Thanks, Logan