From patchwork Wed Sep 11 20:12:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13801034 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (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 04B381BB684 for ; Wed, 11 Sep 2024 20:12:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085571; cv=none; b=qDAR3GQ4LSLBU8kT3b6zmrp6g4dQBXqpjcByKH8vs0/94pvvteNZdJsW2ipYN2Ik1KDw9K4LzkDuuqHlW7bDCoxn2lXu/tPsOZHJszIlo4psGWEPM72bbtk3OJns2SYTfZvKCz4TUxvpTHp66rVoV8ZnK6JJQh1Mz7+ZDJpMw2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085571; c=relaxed/simple; bh=WHQPzewD65Yh+IZ0arekLAOtx01ofE6B+C9ms79J1Bc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U/LLneCBxoj+3hS+PdNQ1MofzOIVYsj5uJCdLt3dFvv5MOIlP8OhmyQFytLwdDEF2vwitmi6mnhCwp7efdSWecK8rKafa/QwNWKRytYI/iIqYvvyhB4hClvUAMzXuTX2Z+zhoFi1y/RX93xb3nwEsahwPTNjwVDn10BygzJYbTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=DNZV5ZR4; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="DNZV5ZR4" Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48BHja1G023861 for ; Wed, 11 Sep 2024 13:12:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=vsWJ1tyzQEJgxec9rmC6OH4EJf2VkiCpPCBFVPp8kHY=; b= DNZV5ZR4Zrg9sf9ap/zFilwq+iA2YPhe/8du1eZ2sdeaA/ab56r+pVyOFJjIuFOd l35xrfT7kL3P/MQtH2CukPbv58YkO2z8W3JxsRD/gmMWQrc6uMQ9YU/mIdHHDpw1 /49iQoP3J75bq+60b57JSbdCaCBiLrHLERnLubj/rv8DAbZnZW2tCsipUwptCjJI 7sH1pk+ueNtCCI796H/bec/EYkZfBjRkDuJIW4Lo9IRntF+WQHqNmWDuStLXQwxa 1q+e1PIox20+TWq8bPdgC5/NDxx5B6aHd7yjR8QQb5J5G5NJgHZZxUPXo9WKf5HD x5ceSlSCxerVvktgXzNsYw== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41k87cmcqt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 11 Sep 2024 13:12:49 -0700 (PDT) Received: from twshared25838.31.frc3.facebook.com (2620:10d:c0a8:1c::11) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 11 Sep 2024 20:12:47 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id BE5DA12E5EDA5; Wed, 11 Sep 2024 13:12:41 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv4 01/10] blk-mq: unconditional nr_integrity_segments Date: Wed, 11 Sep 2024 13:12:31 -0700 Message-ID: <20240911201240.3982856-2-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240911201240.3982856-1-kbusch@meta.com> References: <20240911201240.3982856-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: VLT6IV7FPwFN_lKEmjNuxeBqukdOnYLF X-Proofpoint-ORIG-GUID: VLT6IV7FPwFN_lKEmjNuxeBqukdOnYLF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-11_01,2024-09-09_02,2024-09-02_01 From: Keith Busch Always defining the field will make using it easier and less error prone in future patches. There shouldn't be any downside to this: the field fits in what would otherwise be a 2-byte hole, so we're not saving space by conditionally leaving it out. Suggested-by: Christoph Hellwig Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- block/blk-mq.c | 2 -- include/linux/blk-mq.h | 3 --- 2 files changed, 5 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 3f1f7d0b3ff35..ef3a2ed499563 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -376,9 +376,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, rq->io_start_time_ns = 0; rq->stats_sectors = 0; rq->nr_phys_segments = 0; -#if defined(CONFIG_BLK_DEV_INTEGRITY) rq->nr_integrity_segments = 0; -#endif rq->end_io = NULL; rq->end_io_data = NULL; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 8d304b1d16b15..4fecf46ef681b 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -149,10 +149,7 @@ struct request { * physical address coalescing is performed. */ unsigned short nr_phys_segments; - -#ifdef CONFIG_BLK_DEV_INTEGRITY unsigned short nr_integrity_segments; -#endif #ifdef CONFIG_BLK_INLINE_ENCRYPTION struct bio_crypt_ctx *crypt_ctx; From patchwork Wed Sep 11 20:12:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13801039 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) (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 5AED51BBBC7 for ; Wed, 11 Sep 2024 20:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.153.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085575; cv=none; b=O3rvQc494UWtKjtW3wMXUnDhikkSvza4BCX/JWcRxS6XFueHJE+lizi7UqoFPqyzbnNXrZ7bVhqJCgVA1/5+SiYVgk8al8t9xa1IrZ43MG7CzjwKax9p/HBtJTtI4j+E/U8aSnuE3sQWzUb8cdt8ciF+4p4AmYNwAzI4pMUCueA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085575; c=relaxed/simple; bh=ojgUxIzyLa6j2aHms0PJDxM1OGnIF7WDibMNmTNwnTE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PzkKyUQz4BXsLTJhIim8i7T0sEaEKKP1ZwPtitRbuil/O2NwKruXfHZgFYuraopRtJD3QgPnedPMRnQhE9hrLoua3Dx4j1BourdhNx5vbBoPNOrLOG8BixSamfzP0ETSFkB6XI9Hj5gOSnOLjM6lKgKGH4+0Y5CWnoYyT0VH+pc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=kagZ2l1M; arc=none smtp.client-ip=67.231.153.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="kagZ2l1M" Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.18.1.2/8.18.1.2) with ESMTP id 48BHjWc6004157 for ; Wed, 11 Sep 2024 13:12:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=MMy4GT/2WxENY3dYTa/eDihiGlxScK9w4eG6NktGWso=; b= kagZ2l1MdOU9Sv+j1uT1Ge9kCNygIQUqqV/OCWrnxlPLSDlFNL1k3mN+NCsvba7b 6ZMga5xh/pgywTZ/H/42SgSOThEpZtaQyIG+08zwe34wNPp9DoSehyOMmORGyJ1p 4MF9QD/lmudAZXuyNeutIXiKJmS30rYe+NuKLNHllyK18Gp4vGd9bVMDBlLX5Sx9 RgpNWyC98VPJe2Rxj6l6rRBAVuPWdSXMlf6aqfrxXiVSeN+1x/IsGCB7L4zamqxn zqacx6C4iDo55nBb4ufQWzkuQMDxhmw+GoTTXq4gjl7FaMjSLiWbivr4OOB7ZHuh fbjwyPeKIrz0GMQUXQnKzA== Received: from maileast.thefacebook.com ([163.114.130.16]) by m0001303.ppops.net (PPS) with ESMTPS id 41k44nnb2x-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 11 Sep 2024 13:12:52 -0700 (PDT) Received: from twshared57535.03.ash8.facebook.com (2620:10d:c0a8:1b::2d) by mail.thefacebook.com (2620:10d:c0a9:6f::8fd4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 11 Sep 2024 20:12:47 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id CD5BB12E5EDA7; Wed, 11 Sep 2024 13:12:41 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv4 02/10] blk-mq: set the nr_integrity_segments from bio Date: Wed, 11 Sep 2024 13:12:32 -0700 Message-ID: <20240911201240.3982856-3-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240911201240.3982856-1-kbusch@meta.com> References: <20240911201240.3982856-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: Hn-HB9Y5juVDDXd7gLlZmgoJ2zfEGVpk X-Proofpoint-GUID: Hn-HB9Y5juVDDXd7gLlZmgoJ2zfEGVpk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-11_01,2024-09-09_02,2024-09-02_01 From: Keith Busch This value is used for merging considerations, so it needs to be accurate. Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Reviewed-by: Martin K. Petersen --- v3->v4: Removed the "#if defined" condition. Replaced the 'bi_opf & REQ_INTEGRITY' check with bio_integrity(). If CONFIG_BLK_DEV_INTEGRITY is not set, the stub function will return NULL inline, so the compiler will optimize the setting without adding runtime overhead. block/blk-mq.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index ef3a2ed499563..82219f0e9a256 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2544,6 +2544,9 @@ static void blk_mq_bio_to_request(struct request *rq, struct bio *bio, rq->__sector = bio->bi_iter.bi_sector; rq->write_hint = bio->bi_write_hint; blk_rq_bio_prep(rq, bio, nr_segs); + if (bio_integrity(bio)) + rq->nr_integrity_segments = blk_rq_count_integrity_sg(rq->q, + bio); /* This can't fail, since GFP_NOIO includes __GFP_DIRECT_RECLAIM. */ err = blk_crypto_rq_bio_prep(rq, bio, GFP_NOIO); From patchwork Wed Sep 11 20:12:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13801044 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (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 338AC1BC06B for ; Wed, 11 Sep 2024 20:12:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085580; cv=none; b=KpDKEzzPIGj5ZbX0gJ92Mzn2ACjLAUV9EXaKecikzeGq0UsS/ax+PkMRuV3LKL6sRY91ZreO+X3lm0h9SUERj+27EQc5aKF2KcMraDWEv+ya64S1cIDR9Wgr7KLbB3WvuUWAxyWDvdrtbZnHIFhmuUzRgJCm/0Ze1+enDKv3qFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085580; c=relaxed/simple; bh=MtL+xMdWtX3zmGfgV5OZol7dT1a/qLsRdJ7ZFkY35OU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l/NNLu79HbH2lrE3CZgh+lZcblb0+aO6RdFO3Qn8r0OrIgmpnZwqBKAe0tYnmesV+4g/hdCAdEKgJSTzxOWVUrhoTRBJyUcOeq07bZcNFbO9asO9x5up9kgOixOuAE0sUx0SI5Bd308fMq2hns9l6fw90FnwsNgPxJHr1hdkGLE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=k17NauQx; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="k17NauQx" Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48BHjGDx027790 for ; Wed, 11 Sep 2024 13:12:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=5n0At+8tCXW+reOy0jr/4TaG/eg7u6AwzViidtavUks=; b= k17NauQxxl8y7vD3mV5XJfokHvdYrDijzNQDIGGBsP9et9Xm3RgT8Vo4ieQf454D Qi0QTRkuF3vRT1uzVOZOwUzVTr8NYLH3oKyUa3Vxqk0WsZmIiSbV6lBidHieZ4nc V4kcIYAHG78+11NpAeKaxtQ12CAerlK8W/E9ArN2Z0nwjAgOXJadwaqXUHef7B92 Lohpkfqy6fPye/o+xRhfhMDbHxg5TY8Q512+kdiQlol4BixAF7P+5Jtskhv/c1uU E3K6Wr92hfjxPZUTTylVZSoxC7ChnSSNwEQ22Ay+uEYPw2j7xnzT/S0FZj9zO7Q4 gkUgWYjWVSZcXEC0JRYQow== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41k61wn0k0-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 11 Sep 2024 13:12:58 -0700 (PDT) Received: from twshared10900.35.frc1.facebook.com (2620:10d:c0a8:1b::30) by mail.thefacebook.com (2620:10d:c0a9:6f::8fd4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 11 Sep 2024 20:12:57 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id DFB9712E5EDAA; Wed, 11 Sep 2024 13:12:41 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv4 03/10] blk-integrity: properly account for segments Date: Wed, 11 Sep 2024 13:12:33 -0700 Message-ID: <20240911201240.3982856-4-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240911201240.3982856-1-kbusch@meta.com> References: <20240911201240.3982856-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: NW8XTHOQ_ci6QcnOqoY0MRKRZYwCukT6 X-Proofpoint-GUID: NW8XTHOQ_ci6QcnOqoY0MRKRZYwCukT6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-11_01,2024-09-09_02,2024-09-02_01 From: Keith Busch Both types of merging when integrity data is used are miscounting the segments: Merging two requests wasn't accounting for the new segment count, so add the "next" segment count to the first on a successful merge to ensure this value is accurate. Merging a bio into an existing request was double counting the bio's segments, even if the merge failed later on. Move the segment accounting to the end when the merge is successful. Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Reviewed-by: Martin K. Petersen --- block/blk-integrity.c | 2 -- block/blk-merge.c | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 010decc892eaa..afd101555d3cb 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -153,8 +153,6 @@ bool blk_integrity_merge_bio(struct request_queue *q, struct request *req, q->limits.max_integrity_segments) return false; - req->nr_integrity_segments += nr_integrity_segs; - return true; } diff --git a/block/blk-merge.c b/block/blk-merge.c index 56769c4bcd799..ad763ec313b6a 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -639,6 +639,9 @@ static inline int ll_new_hw_segment(struct request *req, struct bio *bio, * counters. */ req->nr_phys_segments += nr_phys_segs; + if (bio_integrity(bio)) + req->nr_integrity_segments += blk_rq_count_integrity_sg(req->q, + bio); return 1; no_merge: @@ -731,6 +734,7 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req, /* Merge is OK... */ req->nr_phys_segments = total_phys_segments; + req->nr_integrity_segments += next->nr_integrity_segments; return 1; } From patchwork Wed Sep 11 20:12:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13801042 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) (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 9EA821BB68A for ; Wed, 11 Sep 2024 20:12:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.153.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085579; cv=none; b=QnydxS7KmYLc15zLMGqh714tClGdgxCxTsE6+VfLYtvszon6odZ/8MNa4st9rY/u/t1JeVZh7iJZ2TFkmLZaeSqvQ0b0ZZ9RAQJKXZCovvu48v6SU0tQS37Ns1zrbQXC33GzUHE1xKX9tEuaXxE7XvPUjswlTLTeKrvm8PoeLMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085579; c=relaxed/simple; bh=+PxqwvKQOdT226UPkI94Z24P05vd+OAdFhcR7k3fUg4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WtQi7CzZ40T6OiNDZjYgFjJMsKgFODSwAfD7kfTVI8eP73b/oIemjtO3C+pJglOV7oy2QeKlHnCFVjqeAhV6wbQC5a9JRO+JO577YMJtxAINf9Y7GILaP87lhssDVU9lQv8JIYEwZ5TqjCXzjinxbM5Rw9nTZwKjzlEdr8QqxFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=MLJOpA0E; arc=none smtp.client-ip=67.231.153.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="MLJOpA0E" Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.18.1.2/8.18.1.2) with ESMTP id 48BHjWcG004157 for ; Wed, 11 Sep 2024 13:12:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=vK7qovxoMZszHB6W/2udkY9+/U6Fab7VLQCU0PsTo08=; b= MLJOpA0EQF3BNWDwY6W/0omrS8KKiE7SoujZvNEnq+YxGy+pVaLzVMKSgjOj3J4X 6bKeN9j95lQ6YjYx7P8OrvHzWNo35yBn0q4dv00/c/OeAlG+hlUW7UXLy7mwt5pF xjbdbqL6NgYZkN76vUChu0ZU4imCWzyDBJoJyOZgTdun1lhXCINEC18aQxDJHk39 ZUZjFcCd0fzwi2dFy7NxJIHQsEOyy1r6jd1ipzyajdHxGLyVhPPfwe38VwB7i2oY KAODWJjmMsfCn8ZwxeQMoZKuWzxSBtl7dd7rjX1J2d4H8s/OGQcrC2HxA0e2fqpY GkI63qj9GW5CE39NqWYA+g== Received: from maileast.thefacebook.com ([163.114.130.16]) by m0001303.ppops.net (PPS) with ESMTPS id 41k44nnb2x-12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 11 Sep 2024 13:12:56 -0700 (PDT) Received: from twshared4354.35.frc1.facebook.com (2620:10d:c0a8:fe::f072) by mail.thefacebook.com (2620:10d:c0a9:6f::8fd4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 11 Sep 2024 20:12:55 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id EAB7812E5EDAC; Wed, 11 Sep 2024 13:12:41 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv4 04/10] blk-integrity: consider entire bio list for merging Date: Wed, 11 Sep 2024 13:12:34 -0700 Message-ID: <20240911201240.3982856-5-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240911201240.3982856-1-kbusch@meta.com> References: <20240911201240.3982856-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: PyVUmUxlcJQNur5cIxFii6MDrqFCCehR X-Proofpoint-GUID: PyVUmUxlcJQNur5cIxFii6MDrqFCCehR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-11_01,2024-09-09_02,2024-09-02_01 From: Keith Busch If a bio is merged to a request, the entire bio list is merged, so don't temporarily detach it from its list when counting segments. In most cases, bi_next will already be NULL, so detaching is usually a no-op. But if the bio does have a list, the current code is miscounting the segments for the resulting merge. Signed-off-by: Keith Busch --- block/blk-integrity.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index afd101555d3cb..84065691aaed0 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -134,7 +134,6 @@ bool blk_integrity_merge_bio(struct request_queue *q, struct request *req, struct bio *bio) { int nr_integrity_segs; - struct bio *next = bio->bi_next; if (blk_integrity_rq(req) == 0 && bio_integrity(bio) == NULL) return true; @@ -145,10 +144,7 @@ bool blk_integrity_merge_bio(struct request_queue *q, struct request *req, if (bio_integrity(req->bio)->bip_flags != bio_integrity(bio)->bip_flags) return false; - bio->bi_next = NULL; nr_integrity_segs = blk_rq_count_integrity_sg(q, bio); - bio->bi_next = next; - if (req->nr_integrity_segments + nr_integrity_segs > q->limits.max_integrity_segments) return false; From patchwork Wed Sep 11 20:12:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13801036 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (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 69E6D1BAEF6 for ; Wed, 11 Sep 2024 20:12:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085572; cv=none; b=fWi3kN/Phu7pqXLR7PeifTRltAE2wyxEKgCHvyMEbj4RTVWHTKvlLttgxmJxYthmXNxA5F8VPoZ7ZsWI//zFQ9giU+hBtvnDLcyO9tRP3DWVJB0U+xjS5KahlBypebGrrN3ARSCpSMtnJDtFnZcL4l4SbAJHiOI5G5BTU7GdqA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085572; c=relaxed/simple; bh=q2LF4Z4v/QKUqrt3DU+Wly8we0QQS15SL5Ny3rr2pZE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eUKDKcPypRK24NpoSksxrbPW+17dVQ3P+WOnB8zttiV0QG7yxW6pFC0MskPgFq7BojCvHjL//y0bsTv6LFc3b4gdshnSZHDnRYMS4pyslVpP/SqLJaY3rqsQSyCp3O1Ik2gWtutu0jvCEaS9ApUv93udkgknlYoMtV2evtGrGFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=mzkEnVpg; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="mzkEnVpg" Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48BHjdxY019460 for ; Wed, 11 Sep 2024 13:12:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=cI4PGri7hMTRHjnyM/50PhrK4S2rzpkniDkZMLEWhLw=; b= mzkEnVpg/vvg9ATgCufbsPPrfXMilhSs05IQdQeBTHIUrTHGYBR1p7TpPUE+raul aHjO64VLrCV7JS7whVbYN2RqQLkSaY+k2y8Actp7FdxItBXa1QSAy1lc4m67PWoq IKtUWJWsNdl/UcxQo13L5pBwRolyEuI4gUF1fVsgRs/OqWncEzSMtdCwWJfyXZus eYcyU2G3Abj2nqCzTVGdOz31xDeYaCHRXvSIA9rZWfailSRGRPd9EllbIS5uuOEA neIob9EKHTkPxeeVAfR4uL14kvo0WkScKF9/kstrAGGP6LWaPIy8Fel4aUzC3l41 i/nnzX1EFz+QuUrw/15WWA== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41kbpe38qg-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 11 Sep 2024 13:12:50 -0700 (PDT) Received: from twshared25838.31.frc3.facebook.com (2620:10d:c0a8:fe::f072) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 11 Sep 2024 20:12:47 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id 037CB12E5EDAE; Wed, 11 Sep 2024 13:12:41 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv4 05/10] block: provide a request helper for user integrity segments Date: Wed, 11 Sep 2024 13:12:35 -0700 Message-ID: <20240911201240.3982856-6-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240911201240.3982856-1-kbusch@meta.com> References: <20240911201240.3982856-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: 20E2ani9uDNN5vRf44EssN8WMVM04L3V X-Proofpoint-GUID: 20E2ani9uDNN5vRf44EssN8WMVM04L3V X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-11_01,2024-09-09_02,2024-09-02_01 From: Keith Busch Provide a helper keep the request flags and nr_integrity_segments in sync with the bio's integrity payload. This is an integrity equivalent to the normal data helper function, 'blk_rq_map_user()'. Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Kanchan Joshi --- block/bio-integrity.c | 1 - block/blk-integrity.c | 14 ++++++++++++++ drivers/nvme/host/ioctl.c | 6 ++---- include/linux/blk-integrity.h | 7 +++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 8d1fb38f745f9..357a022eed411 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -371,7 +371,6 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, kfree(bvec); return ret; } -EXPORT_SYMBOL_GPL(bio_integrity_map_user); /** * bio_integrity_prep - Prepare bio for integrity I/O diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 84065691aaed0..ddc742d58330b 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -107,6 +107,20 @@ int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio, } EXPORT_SYMBOL(blk_rq_map_integrity_sg); +int blk_rq_integrity_map_user(struct request *rq, void __user *ubuf, + ssize_t bytes, u32 seed) +{ + int ret = bio_integrity_map_user(rq->bio, ubuf, bytes, seed); + + if (ret) + return ret; + + rq->nr_integrity_segments = blk_rq_count_integrity_sg(rq->q, rq->bio); + rq->cmd_flags |= REQ_INTEGRITY; + return 0; +} +EXPORT_SYMBOL_GPL(blk_rq_integrity_map_user); + bool blk_integrity_merge_rq(struct request_queue *q, struct request *req, struct request *next) { diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 1d769c842fbf5..b9b79ccfabf8a 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -3,7 +3,6 @@ * Copyright (c) 2011-2014, Intel Corporation. * Copyright (c) 2017-2021 Christoph Hellwig. */ -#include #include #include /* for force_successful_syscall_return */ #include @@ -153,11 +152,10 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer, bio_set_dev(bio, bdev); if (has_metadata) { - ret = bio_integrity_map_user(bio, meta_buffer, meta_len, - meta_seed); + ret = blk_rq_integrity_map_user(req, meta_buffer, meta_len, + meta_seed); if (ret) goto out_unmap; - req->cmd_flags |= REQ_INTEGRITY; } return ret; diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h index de98049b7ded9..9c7029aa9c22a 100644 --- a/include/linux/blk-integrity.h +++ b/include/linux/blk-integrity.h @@ -28,6 +28,8 @@ static inline bool queue_limits_stack_integrity_bdev(struct queue_limits *t, int blk_rq_map_integrity_sg(struct request_queue *, struct bio *, struct scatterlist *); int blk_rq_count_integrity_sg(struct request_queue *, struct bio *); +int blk_rq_integrity_map_user(struct request *rq, void __user *ubuf, + ssize_t bytes, u32 seed); static inline bool blk_integrity_queue_supports_integrity(struct request_queue *q) @@ -102,6 +104,11 @@ static inline int blk_rq_map_integrity_sg(struct request_queue *q, { return 0; } +static inline int blk_rq_integrity_map_user(struct request *rq, void __user *ubuf, + ssize_t bytes, u32 seed) +{ + return -EINVAL; +} static inline struct blk_integrity *bdev_get_integrity(struct block_device *b) { return NULL; From patchwork Wed Sep 11 20:12:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13801035 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (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 4128B1BB68A for ; Wed, 11 Sep 2024 20:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085571; cv=none; b=htrx1GgPN3AXMJNQuGZtVkkzRwvxM4Ax8ud0lpzGEg3/GZn/UarbNMFwTj5NGacsLHIR5O8CPk12aVu+1ZfVdiIWR54AX404O/uvq/TID9WYfY7LKuZiVBzk2iSgndHjmKQM8hPrXN9zTl1H2s8fuSjOlQ7zUO+A2kBBPIf7K9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085571; c=relaxed/simple; bh=eLNXVaMZfIypQ554XhvmENkvl6v4iwWdPv9eF7lHh+c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D4I6VNiSmfItdB0Gzzqe3+Z81dv6TzdaEGqTmAcysXPuebKXezSfr6NrSD9hpSPO3FUPjVfOID+E6OxTEbp0Dp4agJ74fCVENrEnTzqprrCJkrKaIRy4Z2RqfvXkefYFayMFqzbktgnxQkY3M7ULHgL8+pl1SuiVvB+58/UzNaQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=iWL94cyR; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="iWL94cyR" Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48BHjclR019397 for ; Wed, 11 Sep 2024 13:12:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=qCcbzM3MMHAMV620abi92+dMJQhH3HijYO4U0ETevPE=; b= iWL94cyRzUWVIsjw9eySCKzyp26DhTVKz0SqbCxpYO5ea4n89S9DdMin69HDV5IJ et20WEKbf0mXvRZsO+Uf8cFK05GxHBgnUb2j+zb00vpifEmxrYBdlcZbGcb7MF6X EkDwJ07Wf8wrsP7FI0rWk9GRqnq2WpUmQM3zZlDA04fvm+mbSEgiRi8SHDAUP+el bKMGvb6HH7obev1iCYeeOGNeLSXQeNq6bDPQ/oNMbN6LXy8bwQ64+v0td7iBUJWj gPbjM0YY/4SZ/9BRGLsFg2GxJKHknncB8zJdJZtpz2EU1uh3IjqnaE7Bfb9ly9VS l23ch9/G7pegpSrL1z/4vg== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41kbpe38mu-20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 11 Sep 2024 13:12:49 -0700 (PDT) Received: from twshared25838.31.frc3.facebook.com (2620:10d:c0a8:1b::30) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 11 Sep 2024 20:12:47 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id 112E712E5EDB0; Wed, 11 Sep 2024 13:12:41 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv4 06/10] block: provide helper for nr_integrity_segments Date: Wed, 11 Sep 2024 13:12:36 -0700 Message-ID: <20240911201240.3982856-7-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240911201240.3982856-1-kbusch@meta.com> References: <20240911201240.3982856-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: pJUtHuQ7Cjcisb2aqTCQnOhUcIrIDdSY X-Proofpoint-GUID: pJUtHuQ7Cjcisb2aqTCQnOhUcIrIDdSY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-11_01,2024-09-09_02,2024-09-02_01 From: Keith Busch Provide an integrity equivalent to blk_rq_nr_phys_segments(). Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Reviewed-by: Martin K. Petersen Reviewed-by: Kanchan Joshi --- include/linux/blk-mq.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 4fecf46ef681b..33557af495100 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -1156,6 +1156,11 @@ static inline unsigned short blk_rq_nr_phys_segments(struct request *rq) return rq->nr_phys_segments; } +static inline unsigned short blk_rq_nr_integrity_segments(struct request *rq) +{ + return rq->nr_integrity_segments; +} + /* * Number of discard segments (or ranges) the driver needs to fill in. * Each discard bio merged into a request is counted as one segment. From patchwork Wed Sep 11 20:12:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13801040 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (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 C214A1BB68A for ; Wed, 11 Sep 2024 20:12:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085576; cv=none; b=BTlQJ1aLoH7HVNwKvaUnbs0axWqtfgvv7pvo9yxBKktqDz6el4HgUFNbVAjpFALxhXwDQ43pH4QmrXEanBL4lRqczwkd7uA7Z67F/yB/QvoZZSv6cjkNE/pK8O+UtQ0T3UTX1sIJZBMgcuvjngyycr2Aq7EpSqpaMLrVUGl/IwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085576; c=relaxed/simple; bh=y4IURVi7u6vZLSd2EucBokvUq+qxBtlzbS4k38SeeGI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EVvxnJK3Pjq6eFuke1+mwL7oICsfb7XyndiMtrLRrJ1JOsFMA5/JQlX37ImzFGZFSjEegaCromNsVro62deJX4QDzaAHCbftDEjTWnhu6+DoLG0//Chpwjgdii7rvKScmkF5zBZWpKB0YuzRLAowY7RKeeWe0/wqhkxMA5WfZc8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=cBo0sXCg; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="cBo0sXCg" Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48BHjGDp027790 for ; Wed, 11 Sep 2024 13:12:54 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=8cRKiRl5NKOm63ZSLGj0D8iymZNlBQh+9sNZDJtyFzk=; b= cBo0sXCgcTw++B7ULOzkI5aK+3vrqATygZb0dekpRVBb8kfZ84g05gM5qy0DH/qU ortDXFzhyEMjHOjMOMXRZc98hzOJwFyMShxXjUhdUZxA+YZ6h/CjKMKm397ZXfky n5zIN9CYK8Ypo8vJQQ7bhmJ7iWS8OQ/X+lFiWr7wpuSuSDTJAQntPRevjBwmNNWa Wv00tFTMNYdaUQjAwSw9T+aX5xj9SDsaicybcKJOLpYKffKFRpzztXXfy6FookKR JC9gHkUC2oYibyus/tWqWhoWHKdAGbVKbouiSgw4sYzfysRkjXQFpi24tsEUIhdu g3NH6rl9cZFXG0BQP+sqPQ== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41k61wn0k0-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 11 Sep 2024 13:12:54 -0700 (PDT) Received: from twshared22972.15.frc2.facebook.com (2620:10d:c0a8:fe::f072) by mail.thefacebook.com (2620:10d:c0a9:6f::8fd4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 11 Sep 2024 20:12:49 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id 1E58912E5EDB2; Wed, 11 Sep 2024 13:12:42 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv4 07/10] scsi: use request helper to get integrity segments Date: Wed, 11 Sep 2024 13:12:37 -0700 Message-ID: <20240911201240.3982856-8-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240911201240.3982856-1-kbusch@meta.com> References: <20240911201240.3982856-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: QZiB1jQr7fbD9RcW2q8enC3KWVa2sQPe X-Proofpoint-GUID: QZiB1jQr7fbD9RcW2q8enC3KWVa2sQPe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-11_01,2024-09-09_02,2024-09-02_01 From: Keith Busch The request tracks the integrity segments already, so no need to recount the segements again. Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Reviewed-by: Martin K. Petersen Reviewed-by: Kanchan Joshi --- drivers/scsi/scsi_lib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3958a6d14bf45..fa59b54a8f4c6 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1175,8 +1175,7 @@ blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd) goto out_free_sgtables; } - ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio); - + ivecs = blk_rq_nr_integrity_segments(rq); if (sg_alloc_table_chained(&prot_sdb->table, ivecs, prot_sdb->table.sgl, SCSI_INLINE_PROT_SG_CNT)) { From patchwork Wed Sep 11 20:12:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13801041 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) (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 AFBBE1BBBC7 for ; Wed, 11 Sep 2024 20:12:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.153.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085578; cv=none; b=UIqx6AmAU02tCEcQDsUTJdAyAepB5MYLgGxmgrN/CEre5s5f7AibaSf6tMOv3pl5eAO6pfEnD+YJ1gJO3tZTjUKK0pSZuN2QLlcsLmaU5nV+FaykiMTv22XBT696DZWWZeovmMzaowxcOfT3JxyfzuGFuhMcGuCxjLu6fwxGDRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085578; c=relaxed/simple; bh=Hios26n/3pjZEpaW4GiRlNGiETfw0BlY6kWZDUfc7oY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lE3K96EJBUFxeAdOslcvNiLh3sQ+GL8EeMpT8sDN0dhRDKenRp3S53wTQMxOq+Obmh6xYdcM5XsMUw/m3/J2DW8M01ZK7nhb7wp9kZ2oeQAg0WADdspJ/kgXoEo8R8bpqdGvUC3f9YsGTLeQa684SfdCLelXf3XkCwu23AY9KU8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=YsjEMuYU; arc=none smtp.client-ip=67.231.153.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="YsjEMuYU" Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.18.1.2/8.18.1.2) with ESMTP id 48BHjWcD004157 for ; Wed, 11 Sep 2024 13:12:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=DXtaPgb+qvZzCCmfCvKuh+yhmFMjVQhQpX9blciC+FY=; b= YsjEMuYUTsSBN755HDJm+B6lwaH5xXA2582L+1+0UsJCx4UWxaoYuWZnluLltqJa Om1r9BUWJZfvZz39mDJTfIuLCDQGwx3Ebtx3TSp/JPiPAGZM8JS2O+q6YBV/Yc7o epKpGzkQjw7pLpDeSSBW8Dv8SaWUV6OZFrSyNDEjLekCSaArF10b9wA+dCsqZGlp L4H9p8mwECQcW/mG5mIY3hJxpzSO9XU8rxiV/wH/wRZeeHbddx5BcGVkI5/FDpX9 WrTyJoLuL9DFGaeMEM18dGgZrGjV3PZBRFKk6UShyjAsZaFa/vF+3BK8N8DGFrNy Wj4udevGi7tXNnJfhtXhjA== Received: from maileast.thefacebook.com ([163.114.130.16]) by m0001303.ppops.net (PPS) with ESMTPS id 41k44nnb2x-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 11 Sep 2024 13:12:55 -0700 (PDT) Received: from twshared22972.15.frc2.facebook.com (2620:10d:c0a8:1c::11) by mail.thefacebook.com (2620:10d:c0a9:6f::8fd4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 11 Sep 2024 20:12:49 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id 2BC5712E5EDB4; Wed, 11 Sep 2024 13:12:42 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv4 08/10] nvme-rdma: use request helper to get integrity segments Date: Wed, 11 Sep 2024 13:12:38 -0700 Message-ID: <20240911201240.3982856-9-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240911201240.3982856-1-kbusch@meta.com> References: <20240911201240.3982856-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: smxNDHg0DOjXepXuWJPDE5gtVW9mK4H2 X-Proofpoint-GUID: smxNDHg0DOjXepXuWJPDE5gtVW9mK4H2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-11_01,2024-09-09_02,2024-09-02_01 From: Keith Busch The request tracks the integrity segments already, so no need to recount the segements again. Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Reviewed-by: Martin K. Petersen Reviewed-by: Kanchan Joshi --- drivers/nvme/host/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 15b5e06039a5f..537844ee906b3 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1496,7 +1496,7 @@ static int nvme_rdma_dma_map_req(struct ib_device *ibdev, struct request *rq, req->metadata_sgl->sg_table.sgl = (struct scatterlist *)(req->metadata_sgl + 1); ret = sg_alloc_table_chained(&req->metadata_sgl->sg_table, - blk_rq_count_integrity_sg(rq->q, rq->bio), + blk_rq_nr_integrity_segments(rq), req->metadata_sgl->sg_table.sgl, NVME_INLINE_METADATA_SG_CNT); if (unlikely(ret)) { From patchwork Wed Sep 11 20:12:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13801038 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (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 9EF451BBBC3 for ; Wed, 11 Sep 2024 20:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085575; cv=none; b=mUKGSOF/7Dand91Gu9OU8F300iwcg88jZIc1SFRN17TSwbzJtrKzOddeDD6iw6E+nOtAxS9Fcao4kQlzto7YB/vbyMB4SKV4JTHedN4u9KiSKAa5TcAO8g/uLninNKVuM6SJDhez+2njpd3/gP3udR2u0KKFnRwFY6Fy0gf0irI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085575; c=relaxed/simple; bh=C5YqJXSDNUUKcFAisOJitck7spdt9t1MEjADNt3GwMs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T6zvD+a9QWRRVuDuLjJFTeVT68r9vWJvSx2fPwiXOgCq76Mk46MB4nmZJk5k3LLsVvO13Q3pvP9IpkQ12T2sSJRziHlNrHChSJYQzT+yKw7Ms7vaGRAllSE0qykJKoN/YT8laMusnoG0eWlCbdj+rSWr8wQDSMiNVlmngblrbD0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=mdOBuuJe; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="mdOBuuJe" Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48BHjapI013456 for ; Wed, 11 Sep 2024 13:12:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=glK27eRNV5Tvvrk4Gur6XaK1EaNcTcPLRinvoVpWM0k=; b= mdOBuuJe1joge39y41WQn6lwPVOxDkoMjveWtiAL2Ku0H11+uJcOKa+k7ThsX19Y FVqp2rLf3kuE601Sa+lOqKBt+MizPvH83OiexSONF2QDlwIjfqCnhJ/Qg5uASiy8 DBQGdCRzpeh985yrsXSNZWjp07nFLtZbYvISv9OvHRJZgca5BdBcJl3ShWA6EsIW jwlN9wZyjMvb4KFINGXr78Xmze8qo1wDr38xlekJhgfFRyAhZh0zZMzBwZVc+fmW vhLnRv6YsYrnvGtuxdHVibVEMBj9FnQRnlB8CFLwUIQNGj/NJ0j3jXOv9mIruHug mjSv4Do4BELu7LM1/viLxw== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41k623mvsa-20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 11 Sep 2024 13:12:52 -0700 (PDT) Received: from twshared25838.31.frc3.facebook.com (2620:10d:c0a8:fe::f072) by mail.thefacebook.com (2620:10d:c0a9:6f::8fd4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 11 Sep 2024 20:12:47 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id 3C1DF12E5EDB5; Wed, 11 Sep 2024 13:12:42 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv4 09/10] block: unexport blk_rq_count_integrity_sg Date: Wed, 11 Sep 2024 13:12:39 -0700 Message-ID: <20240911201240.3982856-10-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240911201240.3982856-1-kbusch@meta.com> References: <20240911201240.3982856-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: 0WkbMAj3rljlEVC61HAkZZA6DkHzfcim X-Proofpoint-ORIG-GUID: 0WkbMAj3rljlEVC61HAkZZA6DkHzfcim X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-11_01,2024-09-09_02,2024-09-02_01 From: Keith Busch There are no external users of this. Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Reviewed-by: Martin K. Petersen --- block/blk-integrity.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index ddc742d58330b..1d82b18e06f8e 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -53,7 +53,6 @@ int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio) return segments; } -EXPORT_SYMBOL(blk_rq_count_integrity_sg); /** * blk_rq_map_integrity_sg - Map integrity metadata into a scatterlist From patchwork Wed Sep 11 20:12:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13801037 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) (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 5FE631BB6B8 for ; Wed, 11 Sep 2024 20:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.153.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085574; cv=none; b=N2I3dhzGFxgksFTPSe8XCXoCEmURy263QkqdW/LWJHdcGboRigVs3p4s5S+2TwGb67JS/cAEiFy2PsR4ODGOT8WtYzd2V8LMlM1LS29tm+OSTa22bgWTZogpaExJ8y1KJKyPCUHsOLt4ql/ZfMeap1hLhFuyJ8jHAPlun0CZrQI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726085574; c=relaxed/simple; bh=Oo0dPTDf9ItnMgvteF4FJbsDScEClak3uSx24CdFjaA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YSRJoqTG2O4LYI5vgLTU64X6mc07La9McdRFmEldDY9XVYrywY1Rv+CSAamc7lozFZTub9mel2WekQeuu6b31DS5DJUR5oLj17G25w+12C+T05uCUcQXiOfsGLeZIEpi/qpkggxdkRtxy7lff2yJ9ztdD7vYr9EYxKhfUws0nq0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=hNHws+QL; arc=none smtp.client-ip=67.231.153.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="hNHws+QL" Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48BJM4LO001527 for ; Wed, 11 Sep 2024 13:12:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=8EfbBDn2sY/rKJtZTNRmZQB1k2PQSCWXx9V8eeGKzYM=; b= hNHws+QLMxOq02r6GrX7MSQZhT077eXyXvO0ozOkLKjLvSyKOYFESuZ4IUqn61Dw t8ayfvFSWSXTk/f3CRhF3bOS7o5SZLYcZ6Z4ITv1rvVDJW3mFzXODvdMvai5o73A U/zdSDzDd1JVpq9TrvBDNDkgePtyVKRSfVlebN+ebrfe4sHzlFkbvDV8mEEsoZKT Sd/16/pFGRMKCM/jC0H4XE6GLd4yigJ4xSmOHk5QC1hsOfKWkpofJam++uNBMkBZ HJjrUMnzxnJqN3XxKkTmD28Yf9qBdgpKRUWteaXe9rknW+WB3agt6fsj/0sU3U/a foZ2toq67ftfFON4gi3iMg== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41kha48ajv-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 11 Sep 2024 13:12:52 -0700 (PDT) Received: from twshared25838.31.frc3.facebook.com (2620:10d:c0a8:1c::1b) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 11 Sep 2024 20:12:47 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id 4853D12E5EDB6; Wed, 11 Sep 2024 13:12:42 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv4 10/10] blk-integrity: improved sg segment mapping Date: Wed, 11 Sep 2024 13:12:40 -0700 Message-ID: <20240911201240.3982856-11-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240911201240.3982856-1-kbusch@meta.com> References: <20240911201240.3982856-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: EF_7Sh7TAm5nb_At67ZBx12j4e54elJY X-Proofpoint-ORIG-GUID: EF_7Sh7TAm5nb_At67ZBx12j4e54elJY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-11_01,2024-09-09_02,2024-09-02_01 From: Keith Busch Make the integrity mapping more like data mapping, blk_rq_map_sg. Use the request to validate the segment count, and update the callers so they don't have to. Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- block/blk-integrity.c | 15 +++++++++++---- drivers/nvme/host/rdma.c | 4 ++-- drivers/scsi/scsi_lib.c | 11 +++-------- include/linux/blk-integrity.h | 6 ++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 1d82b18e06f8e..549480aa2a069 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -62,19 +62,20 @@ int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio) * * Description: Map the integrity vectors in request into a * scatterlist. The scatterlist must be big enough to hold all - * elements. I.e. sized using blk_rq_count_integrity_sg(). + * elements. I.e. sized using blk_rq_count_integrity_sg() or + * rq->nr_integrity_segments. */ -int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio, - struct scatterlist *sglist) +int blk_rq_map_integrity_sg(struct request *rq, struct scatterlist *sglist) { struct bio_vec iv, ivprv = { NULL }; + struct request_queue *q = rq->q; struct scatterlist *sg = NULL; + struct bio *bio = rq->bio; unsigned int segments = 0; struct bvec_iter iter; int prev = 0; bio_for_each_integrity_vec(iv, bio, iter) { - if (prev) { if (!biovec_phys_mergeable(q, &ivprv, &iv)) goto new_segment; @@ -102,6 +103,12 @@ int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio, if (sg) sg_mark_end(sg); + /* + * Something must have been wrong if the figured number of segment + * is bigger than number of req's physical integrity segments + */ + BUG_ON(segments > blk_rq_nr_phys_segments(rq)); + BUG_ON(segments > queue_max_integrity_segments(q)); return segments; } EXPORT_SYMBOL(blk_rq_map_integrity_sg); diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 537844ee906b3..0d6d8431208a5 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1504,8 +1504,8 @@ static int nvme_rdma_dma_map_req(struct ib_device *ibdev, struct request *rq, goto out_unmap_sg; } - req->metadata_sgl->nents = blk_rq_map_integrity_sg(rq->q, - rq->bio, req->metadata_sgl->sg_table.sgl); + req->metadata_sgl->nents = blk_rq_map_integrity_sg(rq, + req->metadata_sgl->sg_table.sgl); *pi_count = ib_dma_map_sg(ibdev, req->metadata_sgl->sg_table.sgl, req->metadata_sgl->nents, diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index fa59b54a8f4c6..16e97925606b6 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1163,7 +1163,6 @@ blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd) if (blk_integrity_rq(rq)) { struct scsi_data_buffer *prot_sdb = cmd->prot_sdb; - int ivecs; if (WARN_ON_ONCE(!prot_sdb)) { /* @@ -1175,19 +1174,15 @@ blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd) goto out_free_sgtables; } - ivecs = blk_rq_nr_integrity_segments(rq); - if (sg_alloc_table_chained(&prot_sdb->table, ivecs, + if (sg_alloc_table_chained(&prot_sdb->table, + blk_rq_nr_integrity_segments(rq), prot_sdb->table.sgl, SCSI_INLINE_PROT_SG_CNT)) { ret = BLK_STS_RESOURCE; goto out_free_sgtables; } - count = blk_rq_map_integrity_sg(rq->q, rq->bio, - prot_sdb->table.sgl); - BUG_ON(count > ivecs); - BUG_ON(count > queue_max_integrity_segments(rq->q)); - + count = blk_rq_map_integrity_sg(rq, prot_sdb->table.sgl); cmd->prot_sdb = prot_sdb; cmd->prot_sdb->table.nents = count; } diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h index 9c7029aa9c22a..6a62885a6beab 100644 --- a/include/linux/blk-integrity.h +++ b/include/linux/blk-integrity.h @@ -25,8 +25,7 @@ static inline bool queue_limits_stack_integrity_bdev(struct queue_limits *t, } #ifdef CONFIG_BLK_DEV_INTEGRITY -int blk_rq_map_integrity_sg(struct request_queue *, struct bio *, - struct scatterlist *); +int blk_rq_map_integrity_sg(struct request *, struct scatterlist *); int blk_rq_count_integrity_sg(struct request_queue *, struct bio *); int blk_rq_integrity_map_user(struct request *rq, void __user *ubuf, ssize_t bytes, u32 seed); @@ -98,8 +97,7 @@ static inline int blk_rq_count_integrity_sg(struct request_queue *q, { return 0; } -static inline int blk_rq_map_integrity_sg(struct request_queue *q, - struct bio *b, +static inline int blk_rq_map_integrity_sg(struct request *q, struct scatterlist *s) { return 0;