Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5559937rwd; Mon, 5 Jun 2023 05:36:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6/7l/BcMo4Q9H+FeKyTFH7sgfG5y/6hTgBNwqpiXvDeveYRk8+OkdYb62uiJebgMl2v84I X-Received: by 2002:a05:6a20:4404:b0:114:f141:733b with SMTP id ce4-20020a056a20440400b00114f141733bmr5442326pzb.15.1685968615342; Mon, 05 Jun 2023 05:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685968615; cv=none; d=google.com; s=arc-20160816; b=WVmnJ8YK3dhPt4LKJXaaGDecQcK8ADGB/isqYrCRGvqaKgRLggpzPt3YEXnruNxuuA 9dRGG8jEpshjQsiXyRhhelKcsHywuiDBNGcqcKvQDbfcqQRH32fSBjqBNhlrVbvLA7QM 0QchHfKwRwVgRyFA1kTJmlFB6SXF9kEkf1iY1PAsdhdbZjCFSokMZW7yozJv0qXNu5ku ALQDx3azRlx/i5SohKZXBmDZbab316DJvGd5b8iYglToMK1RFBfHxCzvzfoaQ62UEbK2 5e+cHpUt6OibP42dK1sDF3QHmNqcU6Zkwz4/bIi8dRcpuFCYosb2WvkktEb/vRgAfehL Ubug== 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=H1PdiFvQZD1R853saHzyRCE8capZ0U3aPv5cQi8i5WE=; b=XhSm14u1YyViTvu3OyVDlANd7ix+mQbsualwjCagrPMcW0wYTWCgT+2/AYg/2Or03Y eK0x3YSnofeV0992niqa3NnB5ORhF37WB+2y3LqaZVf7sp1LaEo1PM3cisTB3FEu3t92 HrP5wBDKEwCxoOqni/4Ak1ffD29O4VxY+1y69659UvF+DmpEcCvobmEgoIvvmX9yDV9H DSjYFDb3NTnOkjzHiTgcUDU0ZsU6G6M7ZU6fpWZTE8uoaz0TeduA+8/alfENTiuNYFbF p0DYkrbSup4l6bdoSJKeUAbyYP/NVqg/KBPlwy5Xq1bvZfHliUFXba7ctRGubxceD8M+ JbMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=lCuHr4EK; 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 y62-20020a638a41000000b00524ecf898a2si5248988pgd.359.2023.06.05.05.36.42; Mon, 05 Jun 2023 05:36:55 -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=lCuHr4EK; 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 S233511AbjFEMaU (ORCPT + 99 others); Mon, 5 Jun 2023 08:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233621AbjFEM36 (ORCPT ); Mon, 5 Jun 2023 08:29:58 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAAE1DB for ; Mon, 5 Jun 2023 05:29:52 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230605122951epoutp013666cc53e2dee8c3f2c983526625a2ff~lwyMaCMo01441814418epoutp01N for ; Mon, 5 Jun 2023 12:29:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230605122951epoutp013666cc53e2dee8c3f2c983526625a2ff~lwyMaCMo01441814418epoutp01N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685968191; bh=H1PdiFvQZD1R853saHzyRCE8capZ0U3aPv5cQi8i5WE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lCuHr4EKm8alYf4gZ75wfkT7o9JhJG88K/v06hB7cvw9R1Mz8rVxWfA9VvN4jCW/k hrmBCbCDRZojjdnWTqHXh8+jGF0sKdagpSZmZyf555Whu3y6LvAGbz3e+OhWjoCChJ ydnbxwtYi0dwArlwODWI4llgqMcksiB+cz3G05tU= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20230605122950epcas5p136d93b014386a849cfd5869aaec685f3~lwyLul6So0215902159epcas5p1h; Mon, 5 Jun 2023 12:29:50 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.174]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4QZXx91CgYz4x9Pv; Mon, 5 Jun 2023 12:29:49 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 8C.5D.16380.D35DD746; Mon, 5 Jun 2023 21:29:49 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20230605122349epcas5p2de6c758bc38194ebfb1fd8c700e45608~lws7aUZgZ3244532445epcas5p2G; Mon, 5 Jun 2023 12:23:49 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230605122349epsmtrp29f7a21e8ed8ea1907e7bb327a40f384c~lws7ZGsem1056310563epsmtrp2Z; Mon, 5 Jun 2023 12:23:49 +0000 (GMT) X-AuditID: b6c32a4b-7dffd70000013ffc-11-647dd53dac52 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 09.D5.28392.5D3DD746; Mon, 5 Jun 2023 21:23:49 +0900 (KST) Received: from green245.sa.corp.samsungelectronics.net (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230605122343epsmtip245dddb1bc0bcc26599c570b39b4b9fcb~lws2FYJfX2527325273epsmtip2l; Mon, 5 Jun 2023 12:23:43 +0000 (GMT) From: Nitesh Shetty To: Jens Axboe , Jonathan Corbet , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Keith Busch , Christoph Hellwig , Sagi Grimberg , James Smart , 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 v12 7/9] dm: Add support for copy offload Date: Mon, 5 Jun 2023 17:47:23 +0530 Message-Id: <20230605121732.28468-8-nj.shetty@samsung.com> X-Mailer: git-send-email 2.35.1.500.gb896f729e2 In-Reply-To: <20230605121732.28468-1-nj.shetty@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Te0xTVxzHPfe2t8Ws7AISDw+32k0IGB6dpTtVGWQjcjPcVrdlEXErHVwe AdqutwwHWYCBOjSCwJihOB5KeG4ghUEBYVJRxnuOh5MBGkLjJl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JxcEo1MIkbP1hnzBXvn/7r08Hs PyxMm8T0AyI23dS9++JZ7gGm9Vou2mt3WV/4t0Xnzc0qfZO5U75qesgEzp1RVXd5s8gBF/ue E2dnPb+9KEssXMjrbVOVpf0XPpf1tY01RdtKTqXZmlfo5r8T3P5DMs3GXit3qd7XtfwxG1NL LM5apX/9sf3Xq1+iKkLzmb0/Rnav+9Z5bt+8xkuLDbnEnphtylaPdPI9utGco8uFZ/eC2Q9C 7qh9Ut46pVeJ5WfBtpyjupVT2mPU7sTLu2Umz74jdd1D79Ck73dj8jn+Hbq6Lif6ftcRbSZP /ozlp38HKzDbsnrO3byYd9bUevMbLE59sssr51+XOd9npt3b991mthJLcUaioRZzUXEiAC14 gQpuAwAA X-CMS-MailID: 20230605122349epcas5p2de6c758bc38194ebfb1fd8c700e45608 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: 20230605122349epcas5p2de6c758bc38194ebfb1fd8c700e45608 References: <20230605121732.28468-1-nj.shetty@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, T_SCC_BODY_TEXT_LINE 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 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 1398f1d6e83e..b3269271e761 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1867,6 +1867,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) { @@ -1949,6 +1982,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 4361a01bff3a..d9f45a1f0a77 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1720,6 +1720,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 a52d2b9a6846..04016bd76e73 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -398,6 +398,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