From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D7C4C6FA82 for ; Fri, 23 Sep 2022 15:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232442AbiIWPiZ (ORCPT ); Fri, 23 Sep 2022 11:38:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229810AbiIWPiY (ORCPT ); Fri, 23 Sep 2022 11:38:24 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CF97145959; Fri, 23 Sep 2022 08:38:23 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id A093767373; Fri, 23 Sep 2022 17:38:19 +0200 (CEST) Date: Fri, 23 Sep 2022 17:38:19 +0200 From: Christoph Hellwig To: Kanchan Joshi Cc: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com Subject: Re: [PATCH for-next v8 3/5] nvme: refactor nvme_alloc_user_request Message-ID: <20220923153819.GC21275@lst.de> References: <20220923092854.5116-1-joshi.k@samsung.com> <20220923092854.5116-4-joshi.k@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220923092854.5116-4-joshi.k@samsung.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org > -static void *nvme_add_user_metadata(struct bio *bio, void __user *ubuf, > - unsigned len, u32 seed, bool write) > +static void *nvme_add_user_metadata(struct request *req, void __user *ubuf, > + unsigned len, u32 seed) Please split out a separate patch just for the changes to nvme_add_user_metadata. > - if (ret == len) > + if (ret == len) { > + req->cmd_flags |= REQ_INTEGRITY; > return buf; > + } > ret = -ENOMEM; Nit: Please keep the successful path in line and branch out for the errors, i.e. if (ret != len) { ret = -ENOMEM; goto out_free_meta; } req->cmd_flags |= REQ_INTEGRITY; return buf; We should have done this already with the old code, but now that more is added to the success path it becomes even more important:. > + else { > + struct iovec fast_iov[UIO_FASTIOV]; > + struct iovec *iov = fast_iov; > + struct iov_iter iter; > + > + ret = import_iovec(rq_data_dir(req), ubuffer, bufflen, > + UIO_FASTIOV, &iov, &iter); > + if (ret < 0) > goto out; > + ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL); > + kfree(iov); > + } While you touch this: I think thi block of code would also be a good separate helper. Maybe even in the block layer given the the scsi ioctl code and sg duplicate it, and already missed the fast_iov treatment due to the duplication. Having this in a separate function is also nice to keep the fast_iov stack footprint isolated. > + if (ret) > + goto out; > + bio = req->bio; I think we can also do away with this bio local variable now. > + if (bdev) > + bio_set_dev(bio, bdev); We don't need the bio_set_dev here as mentioned last time, so I think we should remove it in a prep patch. > + ret = nvme_map_user_request(req, ubuffer, bufflen, meta_buffer, > + meta_len, meta_seed, &meta, vec); Nit: Add an extra tab for indentation here please. > if (IS_ERR(req)) > return PTR_ERR(req); > + req->timeout = d.timeout_ms ? msecs_to_jiffies(d.timeout_ms) : 0; if (d.timeout_ms) req->timeout = msecs_to_jiffies(d.timeout_ms);