Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13728287pxu; Mon, 4 Jan 2021 02:50:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJEd0QhL8ZFdFxViT+fnn+VwHrSREflMys37fwu+uyuK/bWlEsLBzrDgpmM/yBPEWBtBZN X-Received: by 2002:a17:906:2898:: with SMTP id o24mr65325103ejd.215.1609757400061; Mon, 04 Jan 2021 02:50:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609757400; cv=none; d=google.com; s=arc-20160816; b=gFao/X1QlRJmeh5ib5+i71b+mg2cttKPO6YIkoECZ3Fdc3c4pFWqXr7Wvu1v9NYqgT X5Z25iVcF70Xj8+CWtN6vlEBa781u4CYMB2Gv7d7yXskQscIUqwdUbkSPTLOetf2sqZs 974B5roIhekumRmWWvFQvSxBNr8fNqMRXi8qdvZAuBs4kwckq9nt7gsAdKSliWDXlC7K 3FfZqD49mD3gVvgO8JQSBESZ/5eXNHWhLwNEwvxyR5eNSP70AuCj38qli/YfbLWLm7Q5 L/06+d8M15DS+5xtC0TCxiqZIlSvvaRG5YHDx8SfLkhzea0FU1mGXxPFMqcYwbap0RFt bo+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=Go/clYggiEyM6zQDZcFotUEs/WoFOIkWSvwzSQH2jhw=; b=V+UIqQie2wvKNTykSJF6+blc/hKOazsm7mFR2K+eIFi6Ueewgj7nS4nygdTuUPnpvS /qdmFqBkSJaqNyMSmkV5FlMmlXStN2/vRQQ5NUCBV2l9gh+Lbe9dSUXsN1AKzLzZVex7 YCMrF7UFJuda5Fu8K5O4HZrigLtTbPUvzJyAA/b7FKAS8pHp6d84ddliPDvfU2R+hayE 0O2JvE36Mkt8C8w97c9ZfSOoEMjxYjNzsHcPY8bu0BnMJHJMIjFxRSnJQiSYy+106k5h u5YRJrwed32UdGpxt31O6V8UMRfbrKV1vWOTaKTVq8QznppSlMsL8GSWx2hqj5LZ0Vh5 52Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="OBs5f/tK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly10si28760218ejb.84.2021.01.04.02.49.36; Mon, 04 Jan 2021 02:50:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="OBs5f/tK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726918AbhADKsi (ORCPT + 99 others); Mon, 4 Jan 2021 05:48:38 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:55423 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbhADKsc (ORCPT ); Mon, 4 Jan 2021 05:48:32 -0500 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20210104104748epoutp03db1853ede21e0f9bb077ab1ba5bd7a4f~XAbUI5uor3125431254epoutp03j for ; Mon, 4 Jan 2021 10:47:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20210104104748epoutp03db1853ede21e0f9bb077ab1ba5bd7a4f~XAbUI5uor3125431254epoutp03j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1609757268; bh=Go/clYggiEyM6zQDZcFotUEs/WoFOIkWSvwzSQH2jhw=; h=From:To:Cc:Subject:Date:References:From; b=OBs5f/tK7eWNka3cYwngkJAhm+iE2KZ9tlXpjUh66m/81zee6RuYmwiu9Kr/mR+34 OcqB5zIt13D5MV6yhe1NL4yBc/Rsss7XcBZaCcpthr4q++PHs3o5oWxu0PuG5EeLIZ OZL4Z+uJIeerFNgawJeDQ2JI1K4JIfI6Zzxu6SRk= Received: from epsmges5p1new.samsung.com (unknown [182.195.42.73]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20210104104748epcas5p35140f9de7456e26b75523b7131b32c20~XAbTXt3_F0252202522epcas5p3-; Mon, 4 Jan 2021 10:47:48 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 1E.DB.15682.352F2FF5; Mon, 4 Jan 2021 19:47:47 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20210104104237epcas5p1ed2d167f50060eb0567ade5d9a1df701~XAWydkdLf2312423124epcas5p1z; Mon, 4 Jan 2021 10:42:37 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210104104237epsmtrp287e4dee44b7d8db23bbf16ad41c2100a~XAWycdM_m2765327653epsmtrp2N; Mon, 4 Jan 2021 10:42:37 +0000 (GMT) X-AuditID: b6c32a49-8bfff70000013d42-da-5ff2f2534d7b Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 35.49.13470.D11F2FF5; Mon, 4 Jan 2021 19:42:37 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210104104233epsmtip1173332a6b503fc6f3517b19376a68251~XAWuBs05c1774617746epsmtip1T; Mon, 4 Jan 2021 10:42:32 +0000 (GMT) From: SelvaKumar S To: linux-nvme@lists.infradead.org Cc: kbusch@kernel.org, axboe@kernel.dk, damien.lemoal@wdc.com, Johannes.Thumshirn@wdc.com, hch@lst.de, sagi@grimberg.me, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, martin.petersen@oracle.com, bvanassche@acm.org, mpatocka@redhat.com, hare@suse.de, dm-devel@redhat.com, snitzer@redhat.com, selvajove@gmail.com, nj.shetty@samsung.com, joshi.k@samsung.com, javier.gonz@samsung.com, SelvaKumar S Subject: [RFC PATCH v4 0/3] add simple copy support Date: Mon, 4 Jan 2021 16:11:56 +0530 Message-Id: <20210104104159.74236-1-selvakuma.s1@samsung.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGKsWRmVeSWpSXmKPExsWy7bCmum7wp0/xBg++m1qsvtvPZjHtw09m i9b2b0wWe9/NZrXYs2gSk8XK1UeZLB7f+cxu8bfrHpPF0f9v2SwmHbrGaLH3lrbF5V1z2Czm L3vKbtF9fQebxfLj/5gsJnZcZbLY9ns+s8WVKYuYLda9fs9i8eD9dXaL1z9Oslm0bfzK6CDm cfmKt8fOWXfZPc7f28jicflsqcemVZ1sHpuX1HvsvtnA5vHx6S0Wj/f7rrJ59G1Zxeix+XS1 x+dNch7tB7qZAnijuGxSUnMyy1KL9O0SuDIa9txlK9itVHG8bzJ7A+Nx6S5GTg4JAROJ/hM/ 2LsYuTiEBHYzSvxcv5wFwvnEKPF77ieozDdGifV717LDtDzvXMoMkdjLKDFrwls2COczo8TZ /ddZQKrYBHQlri3ZBGaLCChJ/F3fBDaXWeAms8SlX5/ARgkLGEsc6rnKCmKzCKhK3N+0HqyB V8BW4snf20wQ6+QlZl76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4dBcjJ4eEgInE886l zF2MXBxCArsZJf61djBCJGQk1t7tZIOwhSVW/nvODlH0kVHi2c79rCAJNgFdiWtLNrGA2CIC ShJ/1zexgBQxC3xmlpi/qw0sISxgLHGo5ypYA4uAqsT9TevB4rwCthJP/t5mgtggLzHz0nd2 iLigxMmZT4BqOIAGqUusnycEEmYGKmneOpt5AiP/LCRVsxCqZiGpWsDIvIpRMrWgODc9t9iw wDAvtVyvODG3uDQvXS85P3cTIzhitTR3MG5f9UHvECMTB+MhRgkOZiUR3ooLH+KFeFMSK6tS i/Lji0pzUosPMUpzsCiJ817oOhkvJJCeWJKanZpakFoEk2Xi4JRqYDp+rChxU5rf+8YrE1Zv OPq1auO5+x1/fY85LElo2Fm6STOnsHlhaOkp+7k5bl96hK5f2rlK7373stWfeJ0nXf0uLns+ u9smanvCHPll/it2x4nf2LKjebKa5YXZJ0raeY8nVGS7dX6oWNay3eEDS7K/Tdj1rLmtmk0v /Jv2MfROvBpht01VpertK52jV6O9njR/V656uvNqUUd41Aqlin+MW+duWPyK43u2+Y6J/n/5 OBiyWK2br+RvVDR+4bl70d+DCi6JJ/5svn+WTyHDlf/6df01gTfXv+pedMmFK5PBzYJ/wZV7 UzW3LKjI1zZwORO7M9v6yRWfL8v3SMle1AupnLTTdfNpCSHf+oilHUZKLMUZiYZazEXFiQCj gKFmRwMAAA== X-CMS-MailID: 20210104104237epcas5p1ed2d167f50060eb0567ade5d9a1df701 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20210104104237epcas5p1ed2d167f50060eb0567ade5d9a1df701 References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patchset tries to add support for TP4065a ("Simple Copy Command"), v2020.05.04 ("Ratified") The Specification can be found in following link. https://nvmexpress.org/wp-content/uploads/NVM-Express-1.4-Ratified-TPs-1.zip Simple copy command is a copy offloading operation and is used to copy multiple contiguous ranges (source_ranges) of LBA's to a single destination LBA within the device reducing traffic between host and device. This implementation doesn't add native copy offload support for stacked devices rather copy offload is done through emulation. Possible use cases are F2FS gc and BTRFS relocation/balance. *blkdev_issue_copy* takes source bdev, no of sources, array of source ranges(values are in bytes), destination bdev and destination offset(in bytes). If both source and destination block devices are same and copy_offload = 1, then copy is done through native copy offloading. Copy emulation is used in other cases. As SCSI XCOPY can take two different block devices and no of source range is equal to 1, this interface can be extended in future to support SCSI XCOPY. For devices supporting native simple copy, attach the control information as payload to the bio and submit to the device. For devices without native copy support, copy emulation is done by reading each source range into memory and writing it to the destination. Following limits are added to queue limits and are exposed in sysfs to userspace - *copy_offload* controls copy_offload. set 0 to disable copy offload, 1 to enable native copy offloading support. - *max_copy_sectors* limits the sum of all source_range length - *max_copy_nr_ranges* limits the number of source ranges - *max_copy_range_sectors* limit the maximum number of sectors that can constitute a single source range. max_copy_sectors = 0 indicates the device doesn't support copy offloading. *copy offload* sysfs entry is configurable and can be used toggle between emulation and native support depending upon the usecase. Changes from v3 1. gfp_flag fixes. 2. Export bio_map_kern() and use it to allocate and add pages to bio. 3. Move copy offload, reading to buf, writing from buf to separate functions. 4. Send read bio of copy offload by chaining them and submit asynchronously. 5. Add gendisk->part0 and part->bd_start_sect changes to blk_check_copy(). 6. Move single source range limit check to blk_check_copy() 7. Rename __blkdev_issue_copy() to blkdev_issue_copy and remove old helper. 8. Change blkdev_issue_copy() interface generic to accepts destination bdev to support XCOPY as well. 9. Add invalidate_kernel_vmap_range() after reading data for vmalloc'ed memory. 10. Fix buf allocoation logic to allocate buffer for the total size of copy. 11. Reword patch commit description. Changes from v2 1. Add emulation support for devices not supporting copy. 2. Add *copy_offload* sysfs entry to enable and disable copy_offload in devices supporting simple copy. 3. Remove simple copy support for stacked devices. Changes from v1: 1. Fix memory leak in __blkdev_issue_copy 2. Unmark blk_check_copy inline 3. Fix line break in blk_check_copy_eod 4. Remove p checks and made code more readable 5. Don't use bio_set_op_attrs and remove op and set bi_opf directly 6. Use struct_size to calculate total_size 7. Fix partition remap of copy destination 8. Remove mcl,mssrl,msrc from nvme_ns 9. Initialize copy queue limits to 0 in nvme_config_copy 10. Remove return in QUEUE_FLAG_COPY check 11. Remove unused OCFS SelvaKumar S (3): block: export bio_map_kern() block: add simple copy support nvme: add simple copy support block/blk-core.c | 94 ++++++++++++++-- block/blk-lib.c | 223 ++++++++++++++++++++++++++++++++++++++ block/blk-map.c | 3 +- block/blk-merge.c | 2 + block/blk-settings.c | 10 ++ block/blk-sysfs.c | 50 +++++++++ block/blk-zoned.c | 1 + block/bounce.c | 1 + block/ioctl.c | 43 ++++++++ drivers/nvme/host/core.c | 87 +++++++++++++++ include/linux/bio.h | 1 + include/linux/blk_types.h | 15 +++ include/linux/blkdev.h | 15 +++ include/linux/nvme.h | 43 +++++++- include/uapi/linux/fs.h | 13 +++ 15 files changed, 589 insertions(+), 12 deletions(-) -- 2.25.1