Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2395085lqo; Mon, 20 May 2024 04:48:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmOqse6OWeNzHDlAL3qnx2teCEqkUmaHMYta1tb0DiKBASRY6QfuFkpP7DqcjyptiwFBWeyRGtc5excgMODg+b/2t/ZR3DHKS/XjYkjQ== X-Google-Smtp-Source: AGHT+IGFI5R9j16nelR8ojYfMDNGjMf6HFxsxpEe9IdUzBqdsizSHznzxy+vR1vkxae+2m4lhsqc X-Received: by 2002:a05:6a20:3c91:b0:1af:f88d:9efe with SMTP id adf61e73a8af0-1b1ca3ada42mr8543222637.3.1716205688269; Mon, 20 May 2024 04:48:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716205688; cv=pass; d=google.com; s=arc-20160816; b=r8HyEYBpp/nQRPOCUTipcFO9n+U72t7UIw1AIyPGfMgU/+9nZ0nDIhb0C8GR8YWlys v1zupan/AElzbqWfRQTNZGiPcPmreWEellISBTuANf/AHif5CPbpTzxRTCnkX6VGRT8o Ld/tur+RYDUMMp3nbKAZltSIfVpdNA5iHtKa3+mOJ6EW/1f2X4DSUoFAu9fZ0ghqcH63 Iw1DGp4RDEi1/bCMy6hmoqDCCU8/NDxRfUPLbjjIJvea/CsJ1QSsdaBanzWOGYK1XTng 9sKrrh39uboHAnouVCPACgrC7AoPJTiN+3GILirDdzaJitAzYiwiIdlWd7RdapKofPef DyUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :dlp-filter:cms-type:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=k3ZzCJqgdNN/MTkGUl0/6z5ZTfmIadxi7gg3Kolrnkk=; fh=c9WQN21Db5gXOJEpRfIVP9+rw/2eDGhIcv7l5f7XKYU=; b=eXDDhhzyKJais5hWJUjCheNcyeaAXw7re+SyXEuHRmUWyAWSz188SPvhvYHi3i5BG8 le4KeE8aB7PQ0txE7lG6TnXQOQ1fGgl4WNYw1x5azAwMFJZjL++wKZAAFuW/7LvWJlC1 8qu3DjP/rTQ2YeILPneXbRx46y9M301NzY/AXa6hTMj/Q9WBHFB4dLpAtHRCPxT2FtFF kTacH/63HefmwX1b14f0gfnrRuErrLmcjs/az5QjXXeihWG1ALbzPG3g299uyWQsP4lr Pjz/ZqwSyHso7pA54w473fT/vzDiqW9rL+CTSN35tYC7lN4WeOsVCJZBTDlZoA9O3h20 jxjA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=HDoz4gJw; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-183681-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183681-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6580f9e28d9si2257624a12.575.2024.05.20.04.48.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 04:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183681-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=HDoz4gJw; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-183681-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183681-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D9463283232 for ; Mon, 20 May 2024 11:48:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F33A76025; Mon, 20 May 2024 11:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="HDoz4gJw" Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58BB474BF0 for ; Mon, 20 May 2024 11:45:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716205526; cv=none; b=LfpGAfQntBdtxlOSqZqtK0fBOe5vMxHL5XS9dYe1F+kUqq4k58kQA0KxTtV1oxaAQ+ALHz+7XiVol3pTdgNsts+f4ncUk8GLdMwrSkDgBd1qdBAfka/QYfV5C/VyJxY2Mh1mDWpJ2HJxZ+DPG68G/REhPnJTW3hoenEvf1Fkbt8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716205526; c=relaxed/simple; bh=j3MX9uE/to6vHmgEXOSBH9WWWHt04pmktDS08ErKkqk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:Content-Type: References; b=Ht10e4/ZDXll8lxyhcT/KJJ0yfA0xREdyfEQdyiWoKq6fV6LqTA7xhPDu83ecMB6QH6G4QzYRr7mv6rqE+0bJpRg3A8+6XRzf3MGvI+v2jvKQPe3nuLpnOUy+KR2RbKiXNI82fWRsIMifHY6GPpi3RnGSwBrd7XgmH+rAo4ew7c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=HDoz4gJw; arc=none smtp.client-ip=203.254.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240520114522epoutp04eb4408d4915cd46737e5c13f18843d61~RL9RqB_t42442124421epoutp04c for ; Mon, 20 May 2024 11:45:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240520114522epoutp04eb4408d4915cd46737e5c13f18843d61~RL9RqB_t42442124421epoutp04c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1716205522; bh=k3ZzCJqgdNN/MTkGUl0/6z5ZTfmIadxi7gg3Kolrnkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HDoz4gJws/cBVq8ODqtGB+kpjj9iMTiZhBNzcNn5uOZ+M1WXy85aCppjWBbQDTV3R W53Fe9K8UszdxqG2p5t4d10QhDuH2qWfVf7XbngwZI5qlNUmKJgMwx7Ve1zrv1gXJ8 gFz/KrepcbBLAqTgMkV+1IkQ4KlfmYmoTwqsfvBw= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240520114521epcas5p2e48ea1278eee17e99710573981dce0eb~RL9RCh5a93085730857epcas5p21; Mon, 20 May 2024 11:45:21 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4VjbNJ2y4Tz4x9Pw; Mon, 20 May 2024 11:45:20 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 6E.3D.09666.0D73B466; Mon, 20 May 2024 20:45:20 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240520103004epcas5p4a18f3f6ba0f218d57b0ab4bb84c6ff18~RK7iKHGbB1831418314epcas5p4t; Mon, 20 May 2024 10:30:04 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240520103004epsmtrp1decb440a9d79f03d4fd2c7882c043635~RK7iJLyfK2107921079epsmtrp1C; Mon, 20 May 2024 10:30:04 +0000 (GMT) X-AuditID: b6c32a49-f53fa700000025c2-0a-664b37d00754 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id BB.78.08924.C262B466; Mon, 20 May 2024 19:30:04 +0900 (KST) Received: from green245.sa.corp.samsungelectronics.net (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240520103000epsmtip2f410f05b749878c57352c028ac2515be~RK7ee83R-2248422484epsmtip27; Mon, 20 May 2024 10:30:00 +0000 (GMT) From: Nitesh Shetty To: Jens Axboe , Jonathan Corbet , Alasdair Kergon , Mike Snitzer , Mikulas Patocka , Keith Busch , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Alexander Viro , Christian Brauner , Jan Kara Cc: martin.petersen@oracle.com, bvanassche@acm.org, david@fromorbit.com, hare@suse.de, damien.lemoal@opensource.wdc.com, anuj20.g@samsung.com, joshi.k@samsung.com, nitheshshetty@gmail.com, gost.dev@samsung.com, Nitesh Shetty , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, dm-devel@lists.linux.dev, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v20 09/12] dm: Add support for copy offload Date: Mon, 20 May 2024 15:50:22 +0530 Message-Id: <20240520102033.9361-10-nj.shetty@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240520102033.9361-1-nj.shetty@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WTe1BUdRTH+927e1mYFi8LxQ8kwutAPAJ3E9Yf8hCL6hI9aGpsNBvagcsj 2MfsQ0v/kFVW5C0SYasEkQjsEpsLuDykdhZ1DQUCXByZwJogAqYkNHvwatmF+u9zvr/zPefM +c3h4LwVwpeTLVEycokolyLcWJf7QkLCv9uVnMG3NZLI0H8dR8dPr+BIP1FOoPm+RYA+Wfgb R1PmAoCWBoZw1H59EqC6+hoWumvuwtCV+jMYatZfw9C56hMYurb2K4HOWMYAmrZpMdQ7HoY+ P3mBha70fstCo93nCVR7cdoFNVpXMVRxyoahzik1QJeXanHUOn+fhW6Mb0VDK1Z2gh89ejuZ 7q+HdJd2woUemrzEokcHVLRRV0jQbReO0b+0fQronrt5BP1FWSWbLj3xG0F3ae6x6d+nx1n0 /a9tBF3WrgP0rbqrLimeB3JisxhROiMPYCRp0vRsSWYclfxW6gupUUK+IFwQjXZRARKRmImj El9NCX8pO9e+ISrgkChXZZdSRAoFtSM+Vi5VKZmALKlCGUcxsvRcWaQsQiESK1SSzAgJo9wt 4POfi7Invp+T9b3JgslafD4smjlL5IFBryLgyoFkJPzm7CRWBNw4PLIHQE1DAXAGiwBaH7aw 17N45CMAbff4m44iUzHLmdQL4NypbsIZaDA4Ot9ir8XhEGQYvLnGWde9SD0Oi9sqHA6cbMOh us+MrZfyJGNgY0GTyzqzyED4z4NaRzsuuRvWVH+JO9s9DfVfmR3satfNHQuO+SCpd4XLD2dZ zqRE2FDa6OJkTzhnbd9gXzhbfnKDD8Pmj5sIpzk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SWc2i1XGC3W/q7Zi6KihNN3CJTAftgTrApxh6CaOrP03ogIAS0Q2AcbjzeJNG EFM+3oxPcgBj+DXAmwxlYkzFiyFSByiKpEOYp78pnx5I1+PMSOZpzHeA0y0487wK+jiAjmAq Tt6ceErQcxjv12Kuj4X0CkZfeOtfwSym8q5tgvl/dVutB/hYRC9ners8ZD7wLwEcIwhi1Vpl klIbrg5XsQdkWrlSm6JKksXvV5rAxKzBCyyg3uiR2QFGATtgKFwaKDTVbEgUCRPkBw+xmv07 NSkKVmsHMylCOl04fTA3QUQnyZPZfSyrZjX/XYziz0jH8BD9q1pLR2Qv/0dauSRVFepvLi9c uCUlTLH2RsGhpVaJX3RJarcjXTmmaUWHw3OPRls/btjWNM3/msP7wS08ggbmfT/sp29T7x0O W7BRlLV9IO77wa5VCtvZK/P4GdFe7dIGu8FrHqmEzsFTkbGzY72r+4xTN6WdcfKMzYteRCgk ncP9MaY2xZocR+j6rbJ4Y36EuT1qyrn2iqeN4g+Jb/ra8j3i+ETxGPVNnD3auTfmoysrdZ3h h+yVX0t/8LTargLOeZdkyxT2rjVuccdOTkxdZHZuFWdQX3vMmIzdeT3/nqVz9HiGY7RYQgv6 cqovcJfRBGdH9c0lPbv6DR1SQrtbHh6Ma7TyP0LTr7VFAwAA X-CMS-MailID: 20240520103004epcas5p4a18f3f6ba0f218d57b0ab4bb84c6ff18 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: 20240520103004epcas5p4a18f3f6ba0f218d57b0ab4bb84c6ff18 References: <20240520102033.9361-1-nj.shetty@samsung.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 | 37 +++++++++++++++++++++++++++++++++++ drivers/md/dm.c | 7 +++++++ include/linux/device-mapper.h | 3 +++ 3 files changed, 47 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index cc66a27c363a..d58c67ecd794 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1899,6 +1899,38 @@ 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 !q->limits.max_copy_sectors; +} + +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) { @@ -1975,6 +2007,11 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, limits->discard_misaligned = 0; } + if (!dm_table_supports_copy(t)) { + limits->max_copy_sectors = 0; + limits->max_copy_hw_sectors = 0; + } + if (!dm_table_supports_write_zeroes(t)) limits->max_write_zeroes_sectors = 0; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 597dd7a25823..070b41b83a97 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1717,6 +1717,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 82b2195efaca..6868941bc7d9 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -397,6 +397,9 @@ 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.17.1