Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2289593rwl; Thu, 13 Apr 2023 04:35:50 -0700 (PDT) X-Google-Smtp-Source: AKy350Zm1tsGspO+kEIh9GSBeDhENXRWGUAfXvJ52HJFXBgX89CDM0jl3gebxG+3ObdR6JxwVGZi X-Received: by 2002:a05:6a00:c94:b0:63b:5609:3bb5 with SMTP id a20-20020a056a000c9400b0063b56093bb5mr1388428pfv.18.1681385750010; Thu, 13 Apr 2023 04:35:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681385749; cv=none; d=google.com; s=arc-20160816; b=m1VI9ttK969fXykBVxl4VS04tG5s2OWGfKANPj8fJzCh/8obOVkRVIe0Sq/2A1jB1i Xtu2niNj+xxkUGohbLm7x0cvMC8yQBYRZuCo5Z2zZ1V0KHmfdKdLD55pUzkq1X1Hw64e KrDRD8ATE67OzmSLPHQsV8oDPyUw/A9gyPrtk8HV/JpuRPHqXr6CmTBBuHKI/pwe/XZ2 5dip12exM4YX2HXSgf7aPekeGxNKbtJgKw2S38JRnNxs6omBU9Q+E0TLAEuTP42KIk5L QUdCWZXeOUGIiBLu6NJs47HR1wiI0lj90ppk+moUAzSlJjvvj46CqrnPUYz+X1JuQb65 HmrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:user-agent :in-reply-to:mime-version:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=glqAy4lf9MYSJmrJ1JVo6PRBwerdleu811pPQw5fUts=; b=qVo0hjO0erBMjN6EGp2mnOwtyTbXGl0SAKS9+nLRRH7OGKCChSlyC0RLaFIC0qHAUy WJa0I5r92a+v3nH+CNbgbpmk7Mgj4uCUVQvzdaf9JQoAZCoA8cbn5OX1QvT+iNDQXume QXzpKF9OCdLKKbtiMYn1cuOGiMWKqDndOyeyB/RzHqVRlQ1Bz8q7Xnbgn2zt1rufxrH2 m7lz9+H4ZgxyI6wL3/54s8exzgunta2KDx3A7AvPbJO9+tzMlxzIQvSdKoWUN0TzeHRt vd+wukVSrIrnaADY1GlVWd04gQQJjQO9AEQNGMa5i8bVkOmOXnjJgzjbXXfhBEV2XjdK qUyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Z7htm0RY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a621d05000000b00634f003cfddsi1561215pfd.205.2023.04.13.04.35.37; Thu, 13 Apr 2023 04:35:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Z7htm0RY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230383AbjDMLQP (ORCPT + 99 others); Thu, 13 Apr 2023 07:16:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbjDMLQK (ORCPT ); Thu, 13 Apr 2023 07:16:10 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C61BF7687 for ; Thu, 13 Apr 2023 04:16:06 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230413111600epoutp04ecb0c1b72563d47cdb0b53ef16bb8d3d~VelloPHoG2660026600epoutp04x for ; Thu, 13 Apr 2023 11:16:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230413111600epoutp04ecb0c1b72563d47cdb0b53ef16bb8d3d~VelloPHoG2660026600epoutp04x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1681384560; bh=glqAy4lf9MYSJmrJ1JVo6PRBwerdleu811pPQw5fUts=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Z7htm0RYV4XNcnGNTeqmk2oIjmILAgPjXvL8k8XsXOnZdrWDwTne8ADFQazsqw8Er 1WNi58zmT5ETsdYDSLNV1tracSB1U/PtRvKVNfXhezZ2V/NeWDdZnvM5sA6cx4MCaO gTXgv5lqmbVwFRhO0r5RqSNy7eG5BBgq7/C1un6I= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20230413111559epcas5p44e3b2edfa28e5aee23828bd90fec750e~VelkxVttL1206612066epcas5p4Z; Thu, 13 Apr 2023 11:15:59 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.174]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4PxxpP3RlSz4x9Px; Thu, 13 Apr 2023 11:15:57 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 63.8C.09540.D64E7346; Thu, 13 Apr 2023 20:15:57 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20230413103704epcas5p4b868a2dd068a55331184448295406dfe~VeDmbfxlQ3038930389epcas5p4c; Thu, 13 Apr 2023 10:37:04 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230413103704epsmtrp157f17057d84c4dd43d1281d70f88e63f~VeDmZGjAs1222712227epsmtrp18; Thu, 13 Apr 2023 10:37:04 +0000 (GMT) X-AuditID: b6c32a4a-70dfa70000002544-19-6437e46d8a7d Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 52.B6.08609.05BD7346; Thu, 13 Apr 2023 19:37:04 +0900 (KST) Received: from green5 (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230413103658epsmtip18caf75d4eafcf8a906d1cc18f558aa84~VeDgik2G21368713687epsmtip1i; Thu, 13 Apr 2023 10:36:58 +0000 (GMT) Date: Thu, 13 Apr 2023 16:06:10 +0530 From: Nitesh Shetty To: Chaitanya Kulkarni Cc: Anuj Gupta , Jens Axboe , Alasdair Kergon , Mike Snitzer , "dm-devel@redhat.com" , Keith Busch , Christoph Hellwig , Sagi Grimberg , James Smart , Alexander Viro , Christian Brauner , "bvanassche@acm.org" , "hare@suse.de" , "ming.lei@redhat.com" , "dlemoal@kernel.org" , "joshi.k@samsung.com" , "nitheshshetty@gmail.com" , "gost.dev@samsung.com" , Damien Le Moal , Vincent Fu , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-nvme@lists.infradead.org" , "linux-fsdevel@vger.kernel.org" Subject: Re: [PATCH v9 9/9] null_blk: add support for copy offload Message-ID: <20230413103610.3calcy37ogf72y6q@green5> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20171215 X-Brightmail-Tracker: H4sIAAAAAAAAA02Te0xTdxTH97u3T7PqFUV/gFNWXxEHtNrCD7GojC03Y2a4LRnZ5rCj18Io bdMWcC7LQHQD5CE4XpU55mu8pKMQAxQmDxlCqUyewng5MQNNpSAOCVHX9uLif5/zPef8zis/ Du5SzHbnRCt1lEYpVfBZKxjXWnds946d9JcJ5kdckKHzDxydOPMMR+W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fyCepTnDY8nr 4rtd0wKdL+o3B0/uDL7ZsfHKOdqDto9s9n8OJCRpR0SWnJSU4uSf+LhrnadgeUzHz4WiQ/es ocvqkf7UF1lKGXn4Ur/d/FSQFVeujSo0TOUeLahzBrPT/nGKt3tzBsSEy9fkKJvxSrdlessG 7+9n3Pq8oRhU9GmsIothjXqUVF2SlzKYqTlao6ha1+QI6JQe82ibOJf8VNe4oXA0DWbE2pxN fZ4T5URZzv2TIeFVtz63oee4ydu6k3tp+9A8u8G+1aqYJ5AQXIY8SYprOPn/ylj8s3QDAAA= X-CMS-MailID: 20230413103704epcas5p4b868a2dd068a55331184448295406dfe X-Msg-Generator: CA Content-Type: multipart/mixed; boundary="----PdhGkLDwNmEstpipWwkisvJIpjwP47YWkcBE-d9KzOb1cur7=_14869_" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230411081400epcas5p151186138b36daf361520b08618300502 References: <20230411081041.5328-1-anuj20.g@samsung.com> <20230411081041.5328-10-anuj20.g@samsung.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ------PdhGkLDwNmEstpipWwkisvJIpjwP47YWkcBE-d9KzOb1cur7=_14869_ Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Disposition: inline On 23/04/13 06:28AM, Chaitanya Kulkarni wrote: >On 4/11/23 01:10, Anuj Gupta wrote: >> From: Nitesh Shetty >> >> Implementaion is based on existing read and write infrastructure. >> copy_max_bytes: A new configfs and module parameter is introduced, which >> can be used to set hardware/driver supported maximum copy limit. >> >> Suggested-by: Damien Le Moal >> Signed-off-by: Anuj Gupta >> Signed-off-by: Nitesh Shetty >> Signed-off-by: Vincent Fu >> --- >> drivers/block/null_blk/main.c | 101 ++++++++++++++++++++++++++++++ >> drivers/block/null_blk/null_blk.h | 8 +++ >> 2 files changed, 109 insertions(+) >> >> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c >> index bc2c58724df3..e273e18ace74 100644 >> --- a/drivers/block/null_blk/main.c >> +++ b/drivers/block/null_blk/main.c >> @@ -157,6 +157,10 @@ static int g_max_sectors; >> module_param_named(max_sectors, g_max_sectors, int, 0444); >> MODULE_PARM_DESC(max_sectors, "Maximum size of a command (in 512B sectors)"); >> >> +static int g_copy_max_bytes = COPY_MAX_BYTES; > >how about following ? matches nullb_device->copy_max_bytes type .. > >-static int g_copy_max_bytes = COPY_MAX_BYTES; >-module_param_named(copy_max_bytes, g_copy_max_bytes, int, 0444); >+static unsigned long g_copy_max_bytes = COPY_MAX_BYTES; >+module_param_named(copy_max_bytes, g_copy_max_bytes, ulong, 0444); > >[...] > acked >> @@ -631,6 +637,7 @@ static ssize_t memb_group_features_show(struct config_item *item, char *page) >> "badblocks,blocking,blocksize,cache_size," >> "completion_nsec,discard,home_node,hw_queue_depth," >> "irqmode,max_sectors,mbps,memory_backed,no_sched," >> + "copy_max_bytes," >> "poll_queues,power,queue_mode,shared_tag_bitmap,size," >> "submit_queues,use_per_node_hctx,virt_boundary,zoned," >> "zone_capacity,zone_max_active,zone_max_open," > >why not ? > >@@ -637,11 +637,12 @@ static ssize_t memb_group_features_show(struct config_item *item, char *page) > "badblocks,blocking,blocksize,cache_size," > "completion_nsec,discard,home_node,hw_queue_depth," > "irqmode,max_sectors,mbps,memory_backed,no_sched," >- "copy_max_bytes," > "poll_queues,power,queue_mode,shared_tag_bitmap,size," > "submit_queues,use_per_node_hctx,virt_boundary,zoned," > "zone_capacity,zone_max_active,zone_max_open," >- "zone_nr_conv,zone_offline,zone_readonly,zone_size\n"); >+ "zone_nr_conv,zone_offline,zone_readonly,zone_size" >+ "copy_max_bytes\n"); > } > >[...] > acked, one doubt I see checkpatch complains "WARNING: quoted string split across lines". Is there any graceful way to avoid this warning ? >+static inline int nullb_setup_copy_read(struct nullb *nullb, >+ struct bio *bio) >+{ >+ struct nullb_copy_token *token = bvec_kmap_local(&bio->bi_io_vec[0]); >+ >+ memcpy(token->subsys, "nullb", 5); > >do you really need to use memcpy here ? can token->subsys be a pointer >and use with assignment token->subsys = nullb ? > We do have token->nullb, which stores this device. Idea behind token->subsys is to differentiate between different types of copies. Like copy between namespace, across namespace etc. >+ token->sector_in = bio->bi_iter.bi_sector; >+ token->nullb = nullb; >+ token->sectors = bio->bi_iter.bi_size >> SECTOR_SHIFT; >+ >+ return 0; >+} >+ > >no point in return 1 , use local bool for fua instead of repeating >expression and no need to fold line for nullb_setup_copy_read() >makes is easy to read and removes extra lines and indentation see below :- > acked. >-static inline int nullb_setup_copy_read(struct nullb *nullb, >- struct bio *bio) >+static inline void nullb_setup_copy_read(struct nullb *nullb, struct bio *bio) > { > struct nullb_copy_token *token = bvec_kmap_local(&bio->bi_io_vec[0]); > >- memcpy(token->subsys, "nullb", 5); >+ token->subsys = "nullb; if you meant, token->subsys = "nullb", yeah we can add this in next version. > token->sector_in = bio->bi_iter.bi_sector; > token->nullb = nullb; > token->sectors = bio->bi_iter.bi_size >> SECTOR_SHIFT; >- >- return 0; > } > > static inline int nullb_setup_copy_write(struct nullb *nullb, >@@ -1334,20 +1331,21 @@ static int null_handle_rq(struct nullb_cmd *cmd) > sector_t sector = blk_rq_pos(rq); > struct req_iterator iter; > struct bio_vec bvec; >+ bool fua = rq->cmd_flags & REQ_FUA; > > if (rq->cmd_flags & REQ_COPY) { > if (op_is_write(req_op(rq))) >- return nullb_setup_copy_write(nullb, rq->bio, >- rq->cmd_flags & REQ_FUA); >- return nullb_setup_copy_read(nullb, rq->bio); >+ return nullb_setup_copy_write(nullb, rq->bio, fua); >+ >+ nullb_setup_copy_read(nullb, rq->bio); >+ return 0; > } > > spin_lock_irq(&nullb->lock); > rq_for_each_segment(bvec, rq, iter) { > len = bvec.bv_len; > err = null_transfer(nullb, bvec.bv_page, len, bvec.bv_offset, >- op_is_write(req_op(rq)), sector, >- rq->cmd_flags & REQ_FUA); >+ op_is_write(req_op(rq)), sector, fua); > if (err) { > spin_unlock_irq(&nullb->lock); > return err; >@@ -1368,12 +1366,13 @@ static int null_handle_bio(struct nullb_cmd *cmd) > sector_t sector = bio->bi_iter.bi_sector; > struct bio_vec bvec; > struct bvec_iter iter; >+ bool fua = bio->bi_opf & REQ_FUA > > if (bio->bi_opf & REQ_COPY) { > if (op_is_write(bio_op(bio))) >- return nullb_setup_copy_write(nullb, bio, >- bio->bi_opf & REQ_FUA); >- return nullb_setup_copy_read(nullb, bio); >+ return nullb_setup_copy_write(nullb, bio, fua); >+ nullb_setup_copy_read(nullb, bio); >+ return 0; > } > > > > >[...] > acked >+struct nullb_copy_token { >+ char subsys[5]; >+ struct nullb *nullb; >+ u64 sector_in; >+ u64 sectors; >+}; >+ > >why not use sector_t ? > >diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h >index c67c098d92fa..ffa4b6a6d19b 100644 >--- a/drivers/block/null_blk/null_blk.h >+++ b/drivers/block/null_blk/null_blk.h >@@ -70,8 +70,8 @@ enum { > struct nullb_copy_token { > char subsys[5]; > struct nullb *nullb; >- u64 sector_in; >- u64 sectors; >+ sector_t sector_in; >+ sector_t sectors; > }; > > acked -- Thank you, -- Nitesh Shetty ------PdhGkLDwNmEstpipWwkisvJIpjwP47YWkcBE-d9KzOb1cur7=_14869_ Content-Type: text/plain; charset="utf-8" ------PdhGkLDwNmEstpipWwkisvJIpjwP47YWkcBE-d9KzOb1cur7=_14869_--