Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18875106rwd; Wed, 28 Jun 2023 01:45:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Hyv+ht1j6VXPiW3tmYwapi8Ij5xBLYUrvHMi7TZd9ISEfH9RaQi0RCsORS7S5ieSbcIR6 X-Received: by 2002:a17:906:5a59:b0:98d:f11e:4816 with SMTP id my25-20020a1709065a5900b0098df11e4816mr9729143ejc.29.1687941901053; Wed, 28 Jun 2023 01:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687941901; cv=none; d=google.com; s=arc-20160816; b=Dw9PEShoQYTKeja733F/BvA7EatpafImgyijdH0gC2xwiupGKhpIj+UZVkEggNZL67 lKOw2ktwSJkkR+U3vzEJ0lYZOeQep3VqkYUheF1Yl4tPOR6HHjkns2/ke0fdqcx/0yWh RY5LwD00fXqvNZErCboJTTPh0m/kOI8YjZbHcmwcIylWCdrZ/bRIJBt7Rq+BdVdcOmsD tRrxX5Z0Vcnc1xQbm48tH49vPLJ6q1rThPkqgXa0sdgKAUA4nutuq29L8naqWVHGaSqE joHXdNDNqoy4wRIgbqfN26wolqmQtOu68Q23BsK80X9t2Z7tQaOSBHu5hpg28uESi7D6 86MQ== 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 :content-transfer-encoding:mime-version:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=HaM5wl7d6XlAT/Tg8+7Uibwdp6IRklJIPzVlJl8O1BY=; fh=OfBFM00WeJK6bR1TA0EHwvCVroKbEbX2NJp+Gh5QBEw=; b=YFM2BpN8xfjwRJ4GJlHe49cSHr0RV/HmYWxcAyzCGCAb0SH8ZKEka4hFczVrAZnxOK NiZg7OJxcVyQqkOzU6oJbu1aXFtn8iNg04iT3UuN/VxL2MvQrD9lSFC58jaK/kWrHHPv 63moi2rR6Hb2OiJOOfjdYDybb0h3Kz/2i60VVTwcxp4DMKg7v97J9t8K7A8R6rb8sa3k hjUWyngw+pOnmB2A2AOwyrS6Ao5qzpIw/x2RdjC5OsshMdbJfZ3ixAK1wIkhGaQk4sRa Isubamktakh+1/IvBu3ulyYUo8+yvK95Pfuk/jfCHIWUIPX99fG69+LcDdyaGnHK0PXI 4DGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=s54d1Luj; 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 k25-20020a1709061c1900b0098c9432ad22si5181646ejg.45.2023.06.28.01.44.37; Wed, 28 Jun 2023 01:45:01 -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=s54d1Luj; 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 S232876AbjF1IGb (ORCPT + 99 others); Wed, 28 Jun 2023 04:06:31 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:16847 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232958AbjF1IDf (ORCPT ); Wed, 28 Jun 2023 04:03:35 -0400 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20230628064450epoutp0393745281cf5edba19623881f05d8d00b~sv6iMoQ3n0225402254epoutp03I for ; Wed, 28 Jun 2023 06:44:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20230628064450epoutp0393745281cf5edba19623881f05d8d00b~sv6iMoQ3n0225402254epoutp03I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687934691; bh=HaM5wl7d6XlAT/Tg8+7Uibwdp6IRklJIPzVlJl8O1BY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s54d1LujHUFBcUdjgIC0OYg7Gh+sKKoOyaPXMQnxP++sNbaXZ3tsMeSWaqWTFlzvv /udaIDrvOsCaUQDLVfmX6zG23k2GJrKmyECAZJ+JzA3xNQ0sbdt61tmMx8FPP3YLHe UvGsxRPVhAkzSwhj5Gk5f4nXJ+pZFGo+8RAdGR2Q= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20230628064450epcas5p27072c59c3f70a29396a8ecdc75477e06~sv6hUlEmG1602616026epcas5p2A; Wed, 28 Jun 2023 06:44:50 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.177]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4QrXBS6H7Lz4x9Q6; Wed, 28 Jun 2023 06:44:48 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 9E.28.55173.0E6DB946; Wed, 28 Jun 2023 15:44:48 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20230627184058epcas5p2226835b15381b856859b162e58572d63~smCgdzRC72124021240epcas5p2b; Tue, 27 Jun 2023 18:40:58 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230627184058epsmtrp1a67c7afb9091feee7c469eb5c89a9c8e~smCgcr4Fd1856518565epsmtrp1Y; Tue, 27 Jun 2023 18:40:58 +0000 (GMT) X-AuditID: b6c32a50-df1ff7000001d785-66-649bd6e04566 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 73.18.30535.A3D2B946; Wed, 28 Jun 2023 03:40:58 +0900 (KST) Received: from green245.sa.corp.samsungelectronics.net (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230627184054epsmtip2c141669cc20c09e0780a9f2f3970ed70~smCc5nDIq0374003740epsmtip2p; Tue, 27 Jun 2023 18:40:54 +0000 (GMT) From: Nitesh Shetty To: Jens Axboe , Jonathan Corbet , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Keith Busch , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Alexander Viro , Christian Brauner Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, willy@infradead.org, hare@suse.de, djwong@kernel.org, bvanassche@acm.org, ming.lei@redhat.com, dlemoal@kernel.org, nitheshshetty@gmail.com, gost.dev@samsung.com, Nitesh Shetty , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v13 7/9] dm: Add support for copy offload Date: Wed, 28 Jun 2023 00:06:21 +0530 Message-Id: <20230627183629.26571-8-nj.shetty@samsung.com> X-Mailer: git-send-email 2.35.1.500.gb896f729e2 In-Reply-To: <20230627183629.26571-1-nj.shetty@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA01Te0xTVxzeube9LWR116Lu2CprLi4RWKXVgqcoYjKid3HZyPyDzU1Zbe8A oY/1gW5mG4g8rOExQBzVWBGC1KogD1MF1BQQKVMTQRhM0JAyM2WoOBFkwigXNv/7vu/3/k4O HxdW8ET8JJ2ZMepUK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cND5iBrxvmfymkzmLeJz3yyYVJaYz6Zo3CNu pSQ+f8OqhP87T0W2nPLU+7rpnu6N0trEhz+mFAcpVFvJmSp4hGXO//1R60XZoYfnNWsFXOS1 DieIFtz957U1bU+N5wzHA4XRjvfTT6zfd+T6n2m6kyJO2Tt+qHxiEjb3r+gKP6uk4oP13yWM LiX1rTZPcIndaiw9oXWVl5Tkgbu81/OOqN65xNBR/i006xW3/qV95dXXJ5zz6g6f4nSb/dvP Bwm/pr5adl3llvHvU49M3wfc2+G1p1O9xvLMTmfmK3b3bimxFGckGmoxFxUnAgD68nK/awMA AA== X-CMS-MailID: 20230627184058epcas5p2226835b15381b856859b162e58572d63 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230627184058epcas5p2226835b15381b856859b162e58572d63 References: <20230627183629.26571-1-nj.shetty@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before enabling copy for dm target, check if underlying devices and dm target support copy. Avoid split happening inside dm target. Fail early if the request needs split, currently splitting copy request is not supported. Signed-off-by: Nitesh Shetty --- drivers/md/dm-table.c | 41 +++++++++++++++++++++++++++++++++++ drivers/md/dm.c | 7 ++++++ include/linux/device-mapper.h | 5 +++++ 3 files changed, 53 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 7d208b2b1a19..2d08a890d7e1 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1862,6 +1862,39 @@ static bool dm_table_supports_nowait(struct dm_table *t) return true; } +static int device_not_copy_capable(struct dm_target *ti, struct dm_dev *dev, + sector_t start, sector_t len, void *data) +{ + struct request_queue *q = bdev_get_queue(dev->bdev); + + return !blk_queue_copy(q); +} + +static bool dm_table_supports_copy(struct dm_table *t) +{ + struct dm_target *ti; + unsigned int i; + + for (i = 0; i < t->num_targets; i++) { + ti = dm_table_get_target(t, i); + + if (!ti->copy_offload_supported) + return false; + + /* + * target provides copy support (as implied by setting + * 'copy_offload_supported') + * and it relies on _all_ data devices having copy support. + */ + if (!ti->type->iterate_devices || + ti->type->iterate_devices(ti, + device_not_copy_capable, NULL)) + return false; + } + + return true; +} + static int device_not_discard_capable(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { @@ -1944,6 +1977,14 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, q->limits.discard_misaligned = 0; } + if (!dm_table_supports_copy(t)) { + blk_queue_flag_clear(QUEUE_FLAG_COPY, q); + q->limits.max_copy_sectors = 0; + q->limits.max_copy_sectors_hw = 0; + } else { + blk_queue_flag_set(QUEUE_FLAG_COPY, q); + } + if (!dm_table_supports_secure_erase(t)) q->limits.max_secure_erase_sectors = 0; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index f0f118ab20fa..6245e16bf066 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1732,6 +1732,13 @@ static blk_status_t __split_and_process_bio(struct clone_info *ci) if (unlikely(ci->is_abnormal_io)) return __process_abnormal_io(ci, ti); + if ((unlikely(op_is_copy(ci->bio->bi_opf)) && + max_io_len(ti, ci->sector) < ci->sector_count)) { + DMERR("Error, IO size(%u) > max target size(%llu)\n", + ci->sector_count, max_io_len(ti, ci->sector)); + return BLK_STS_IOERR; + } + /* * Only support bio polling for normal IO, and the target io is * exactly inside the dm_io instance (verified in dm_poll_dm_io) diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 69d0435c7ebb..8ffee7e8cd06 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -396,6 +396,11 @@ struct dm_target { * bio_set_dev(). NOTE: ideally a target should _not_ need this. */ bool needs_bio_set_dev:1; + + /* + * copy offload is supported + */ + bool copy_offload_supported:1; }; void *dm_per_bio_data(struct bio *bio, size_t data_size); -- 2.35.1.500.gb896f729e2