From patchwork Wed Sep 4 15:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13791097 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 DB6C41DC754 for ; Wed, 4 Sep 2024 15:26:21 +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=1725463583; cv=none; b=V+E2YRWQonVwC/5nUJCd95a4vqaxThfIHVlR4GIYh6tulpIP4En5KEriIVk0MfowYPnS9tLTQt9d8TytEd1on2vORo0LEJ2SWCa8b2UKC/IHWQ+ONc17pZD6h+FaG5bvf6C/rzUyVVBakICIKk13df3VcVgOabOBkEtevu+CEKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463583; c=relaxed/simple; bh=9vS7WtpRyiE+BLkhEWwb5KsvA1A51Cz9iROIwAJDUsY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lBBWU/hKrmae0p+khIbYbj8WthDFb7mhM07NOZTArJLctjEwDnY2yG1ptnb8Iv37weq+wYtrl0nG7Zlsth2iafheJoKdkfsihrxNRHaT2Bc8F+fo/41eKIpGxbWUYNyfILbcN2qvvLdGzaY7eumhVVvSaMomAvojvBYtIvmRj5w= 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=Hi8kP2nY; 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="Hi8kP2nY" 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 4845F7Wd022818 for ; Wed, 4 Sep 2024 08:26:21 -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=rd7a/k5fb4q3A2ywz24VKgaB3Pwg9YzXlvjTsg1C6HY=; b= Hi8kP2nYf0wRpYjozES0Sosfu/EGIo6kVR9uDPeUa5Xt+sWTKXii+m1+4myIO4TM OZQDic7hNdeGNzd3dFBEsaCMq2hOmN4RG9bQtWju7JTHWhe1REUMMbtgP859sCam WxjlCernoQTGslwKD2RwQqHkjlqS6zdT3oNhwQSf4VzYIEHafhmR7GoAzU2GRNQ5 T5NAUygpwUs82YEhJVOZfeQjRJI2Ap8cO+CBe55ZX04Gcd0KBAZiQnf5Or8ATkJp eMYvriATFnxqP41EWtvYbyv2VlxdY6ymsOArUVSoqBbCxOe1A5OWiR6yCfNUiyJN cOHoyyDnxm3Sdk4XqryLsA== Received: from mail.thefacebook.com ([163.114.134.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41eh7v2vxw-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:21 -0700 (PDT) Received: from twshared34253.17.frc2.facebook.com (2620:10d:c085:108::4) by mail.thefacebook.com (2620:10d:c08b:78::2ac9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 4 Sep 2024 15:26:12 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id A784612A036E3; Wed, 4 Sep 2024 08:26:07 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv3 01/10] blk-mq: set the nr_integrity_segments from bio Date: Wed, 4 Sep 2024 08:25:56 -0700 Message-ID: <20240904152605.4055570-2-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240904152605.4055570-1-kbusch@meta.com> References: <20240904152605.4055570-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: wALK_SlgrX-UWvmDnxSW9DaHh2QzGGgm X-Proofpoint-GUID: wALK_SlgrX-UWvmDnxSW9DaHh2QzGGgm 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-04_13,2024-09-04_01,2024-09-02_01 From: Keith Busch This value is used for potential merging later. Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig --- block/blk-mq.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index 36abbaefe3874..3ed5181c75610 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2546,6 +2546,10 @@ 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 defined(CONFIG_BLK_DEV_INTEGRITY) + if (bio->bi_opf & REQ_INTEGRITY) + rq->nr_integrity_segments = blk_rq_count_integrity_sg(rq->q, bio); +#endif /* 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 4 15:25:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13791104 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 174CE1DEFEF for ; Wed, 4 Sep 2024 15:26:50 +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=1725463612; cv=none; b=PZEtNK9zzpC8vBmOPXxMsIBpXcBhODcx29uXYmQGwBnwLvORrhxWl5XpXMDcZS50GLwdim6lsBNkyG7SYSsOAm+m/eZead41z2iWGIkK4cYQMM5LYwjIXD08Rf9js2Q7yqur55CvZjv85RtHJAHPQ4jWNWZOPX3jjuL7enSNNFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463612; c=relaxed/simple; bh=tX/zarXxO7puhxjx/jrVhqBehAaFTn8xlf2Qid+DYjo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lYEgXD3GaLUoslaggh0jWhv/tXpOW1htfxRB8DOef//WClDievhRYXA70iUGIAwXlN9xywlnbXuRYUzwwhCWdLMo6krrO/c30mzOK0cm6jsoIghWbPpzHkHOhmOyHXzJlkZlPdgb9xUwEHTUyioIhUcmWhLTYWVy9EdOz/GSzcs= 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=CzsZeyu+; 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="CzsZeyu+" Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 484DoYWV030424 for ; Wed, 4 Sep 2024 08:26: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=vtkxDOQrx1Rg5NzxikIzXHuhR2yFcTtLhhIWMA6/swA=; b= CzsZeyu+NICK0kL6N+7EH6c+Q2ef0hYEvS4+uyv6H+z2M4z1PRNqUcRTy/jtjmzx DvUOPc5SyoGrDuTFop/iebQfl3cJv85LExffkOiM1iuGSrsGvVTOd9Xk6ic2wdlW 9tk5OpXDX16eRDgwauwVyHcXo7VTUG4b4t1GbZ5oaHoNxa7JIaNa6Vie1lH8Hdo4 9qyDdJkzBWQhSJwyFyJEnBco/I3PmMffLxrlEbX7/6a9mjeHzeEG7M1bMNrrbfRN pMBt5UI+ls9t3QF3e2pNt8VJPRLm9OtCF2uWzPc51qGAaA+sPa60qiJBr/VU1hfR 46GKo83b1Hsxv/qT961xew== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41e5y5xxc7-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:49 -0700 (PDT) Received: from twshared4923.09.ash9.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, 4 Sep 2024 15:26:11 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id ADC0912A036E5; Wed, 4 Sep 2024 08:26:07 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv3 02/10] block: provide helper for nr_integrity_segments Date: Wed, 4 Sep 2024 08:25:57 -0700 Message-ID: <20240904152605.4055570-3-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240904152605.4055570-1-kbusch@meta.com> References: <20240904152605.4055570-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: A7bsxPLav5VXEt7gpqXwrhPHz5m1guNM X-Proofpoint-GUID: A7bsxPLav5VXEt7gpqXwrhPHz5m1guNM 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-04_13,2024-09-04_01,2024-09-02_01 From: Keith Busch This way drivers that want this value don't need to concern themselves with the CONFIG_BLK_DEV_INTEGRITY setting. Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig --- include/linux/blk-mq.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 8d304b1d16b15..3984aad9bf64a 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -228,6 +228,18 @@ static inline unsigned short req_get_ioprio(struct request *req) return req->ioprio; } +#ifdef CONFIG_BLK_DEV_INTEGRITY +static inline unsigned short blk_rq_integrity_segments(struct request *rq) +{ + return rq->nr_integrity_segments; +} +#else +static inline unsigned short blk_rq_integrity_segments(struct request *rq) +{ + return 0; +} +#endif + #define rq_data_dir(rq) (op_is_write(req_op(rq)) ? WRITE : READ) #define rq_dma_dir(rq) \ From patchwork Wed Sep 4 15:25:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13791098 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 E9E421EC017 for ; Wed, 4 Sep 2024 15:26:43 +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=1725463605; cv=none; b=H8qk6rSD3bBYWZcSJDuRMPSsDri1WnAn7oAXuOV6HZHgAEfWBwVXulVQglIOPFtmmiiCzGl6BkqXuAg0fmkeUbfGIDHBYAsisYU0nRDjGzGXr17yVU5VN383hzEWmXIt6TQTkdabYtHRK8rcCeS3BZzg9N6eFQ4IkAMLLy5TZ3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463605; c=relaxed/simple; bh=tbelIYErMOsag2MIJL4MBYUSOAYcOXInrX7qRvcyW5w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cyfQfTiRSQLuh291FpGWYNxrnO9LAYUgaav+oLtJjcCFV5T4CLl7YRdp7pTDLl8n+nuLaHQCKtEgBmxA4hrz/t+0lyF3uBdqAWZHoUR4ApEngX8t9AevQvo+FVnuduaaRlfjSeVdSfvIe1ngSJ8Txd+ydOavYSkWDzudCnlEwOo= 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=WcZ8iVmH; 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="WcZ8iVmH" Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 484F7NrO018169 for ; Wed, 4 Sep 2024 08:26:43 -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=/PAGpf/UPAc9rFDLEQebGE5/D0j//o/WEEpf7l0XZ+M=; b= WcZ8iVmHX9iXjyHoQrIn7V6wfWSmW8wfICQcMbWYb8nv2nMiEr/9JiGopqAio7r0 NRhQYm5SUQarsIiM8qcC11WrSAhxQ2WedjIs9uZGJcPYGyjdydQpRv4s3tEImtIX Jky/3qOqyLss7LTdgh8mVM7Gg8m6r3T6uCirDD0pXJYb/Gb3gxdgbVgp2nAMpH6n TH6Nw4TzIKJTScciuvC/Vm8nLDtrd+ci4DC6Jc1Hiiaw0S5BkxHa8Ep0Bd1ALgJC rRpAEtojrzfOZ2ltWP6Y4qFbpbFNTcDvhL8231fRzKiI/eUtUDifE1zrplDQ8hEZ 8jvvnJBmZbBPW+rn5L4x+g== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41eejbkfeg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:42 -0700 (PDT) Received: from twshared4923.09.ash9.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, 4 Sep 2024 15:26:11 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id B7C9312A036E7; Wed, 4 Sep 2024 08:26:07 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv3 03/10] scsi: use request helper to get integrity segments Date: Wed, 4 Sep 2024 08:25:58 -0700 Message-ID: <20240904152605.4055570-4-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240904152605.4055570-1-kbusch@meta.com> References: <20240904152605.4055570-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: snj6xqTk2P1XCvomcD50yfyvjxMKd0pv X-Proofpoint-GUID: snj6xqTk2P1XCvomcD50yfyvjxMKd0pv 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-04_13,2024-09-04_01,2024-09-02_01 From: Keith Busch The request tracks the integrity segments already, so no need to recount the segements again. Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig --- 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..dc1a1644cbc0c 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_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 4 15:25:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13791099 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 BD67B1DC754 for ; Wed, 4 Sep 2024 15:26:44 +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=1725463606; cv=none; b=soYN1lJ1GRHtU0LXrPO/LYALfxX0vj43uMbPERPCKvBZlCiJ8E2PhiQdwfV/wDivNCxUabrjZInh2kH4y5/KVJLsPE9C3eN0/u4tco29i6FcA2aRHK7gAr49a0pKOZdLIX4lotaWnx7Ffvj3BuLxIOV0XoqQ2+da14EJgfoL83A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463606; c=relaxed/simple; bh=wgCiCeySyO0FcFxrr+YSd3x8cxBMpFU7my8lcR2bZro=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HBCJ/N2bVfpHc53enAmVDxcdzcmwkURivV0VT4MXPTzbBkfpV88DMcA6FB3tpsFZyfZH+O8yIRw5QFQR43lVtaucjRS8B8mzypq7VIsOrfZrB0M89O4wk8PsQcfLV1B0VE5pzRgBlKAXrPunKTmxpyujSDiAUa32NWZ7rD31eK8= 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=NZ46nCG8; 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="NZ46nCG8" 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 4849U2Nm022336 for ; Wed, 4 Sep 2024 08:26:44 -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=egTi6ZnQ87q4SMqOIPKOssZGP60h07A6RuSO4eqy0Ec=; b= NZ46nCG8ND7KWwYTthaKR3mFkW2WvO4AGdAU8J4YDryDRHRbmqJq+xsAAdCtIsrO 1hNhT/RqHv7eY9a+Fm61GZu3hxF5wE00/FJT6uK5LTaAnXUIs8nIrB7y6uUMQZ4s ZuTBC9To3V+F2qrGbaRwgnT+L26aKcQHZoFWCwIR2Uk7oiWBeGimsAK1ErlpQG3e ssaC2YGlGKyKm28nh9WDyBYj0HjNoCuvEhhKxna5+E4SraaOosoQ+JQJzz0x/jKz sZoyTD2Cm0VDUcs3V9xINzRKXXOhCn0O1rBA9/8Tt0Ehchaaoy8txzHqKVebXl2V ThhXLRqGt8LF/jT8w5XaEQ== Received: from mail.thefacebook.com ([163.114.134.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41emyp1w8k-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:43 -0700 (PDT) Received: from twshared34253.17.frc2.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c08b:78::c78f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 4 Sep 2024 15:26:12 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id BFEAA12A036E9; Wed, 4 Sep 2024 08:26:07 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv3 04/10] nvme-rdma: use request helper to get integrity segments Date: Wed, 4 Sep 2024 08:25:59 -0700 Message-ID: <20240904152605.4055570-5-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240904152605.4055570-1-kbusch@meta.com> References: <20240904152605.4055570-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: sLUVUJzuqaBcMg944PJ1k171ZHLjhUM- X-Proofpoint-ORIG-GUID: sLUVUJzuqaBcMg944PJ1k171ZHLjhUM- 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-04_13,2024-09-04_01,2024-09-02_01 From: Keith Busch The request tracks the integrity segments already, so no need to recount the segements again. Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig --- 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 2eb33842f9711..dc0987d42c6b2 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_integrity_segments(rq), req->metadata_sgl->sg_table.sgl, NVME_INLINE_METADATA_SG_CNT); if (unlikely(ret)) { From patchwork Wed Sep 4 15:26:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13791105 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 B6E1A1DC754 for ; Wed, 4 Sep 2024 15:26:57 +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=1725463619; cv=none; b=SBeaFB1AAE60Y0tOy1NthjLmMDwQ35Ro4D/AVjhUbcW835VwcMYqIRVLwQ5SE99vldm/m1pGINk6ShOGKcILZdaOLJj0rguqXHRmGzuIACCJdAAsCSSqU/HiT9MqQTxcAlP4Il8ZU9cmI+kPEDjZsA3dKBrQPW2XYlJ1ibKwOOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463619; c=relaxed/simple; bh=mIMzDYPipEZCzvoJEZhl1TTa2Z2biQRbEVba7c6Ips0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XiZ5hU42SRo1G3UXwmxoFh/GsTh6+VxFI/A0V9d6iwtOqhggKxgEJC9j+KDvvbvPTbnmYuRC0ZySxWCJFAPVaFwqf5AJAvZKaJAgga3ZeNlYycEL/FgwULpDxqqn2zsWqzBTGYfSSi/I5yPjZgCFcC/roytaDkeupWOCV453Urs= 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=F8RfilbV; 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="F8RfilbV" 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 4849UfQB022985 for ; Wed, 4 Sep 2024 08:26:57 -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=nYakPJ9rnveCc/VvRR9I1ztb2OG9ggJMLK0vhtAOxDs=; b= F8RfilbVxSMoFlVK8z/wsOmEiHTmIjzfYzFKHUGW8uOTfYDkPhl/6EjFBqTC2hgB 5Es2V3DiEGOIDjVa8DjWzUofi+I0OFyTqQCt0FGOwD7wiy0HJaCUDPwLln1iTlXy O5Q6s97aWzHjfVYr/B6+9VXxlgHmHQ+avoT9LfP77j5CMVWl68o2kVzOrsanallK OCLkp1/fbEtOvjXzrVEh8myYeT8kXn2ZbtumDNr9TM5eIQY6lIaV8DAa83MgZZRQ 8u73FAjmRYF3DTiq3VcG7LF4JnIC+grFabeaL9r8orp6KFaMGq/pUxueXkPqucRM 8TyZ9DWVMI62HhU5m2vVIA== Received: from mail.thefacebook.com ([163.114.134.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41emyp1wcm-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:56 -0700 (PDT) Received: from twshared34253.17.frc2.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c08b:78::2ac9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 4 Sep 2024 15:26:13 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id C80ED12A036EB; Wed, 4 Sep 2024 08:26:07 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv3 05/10] block: unexport blk_rq_count_integrity_sg Date: Wed, 4 Sep 2024 08:26:00 -0700 Message-ID: <20240904152605.4055570-6-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240904152605.4055570-1-kbusch@meta.com> References: <20240904152605.4055570-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: -HiehyxzMLq6vhHc_pHGPrUEi7ajhCyu X-Proofpoint-ORIG-GUID: -HiehyxzMLq6vhHc_pHGPrUEi7ajhCyu 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-04_13,2024-09-04_01,2024-09-02_01 From: Keith Busch There are no external users of this. Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig --- block/blk-integrity.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 010decc892eaa..4365960153b91 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 4 15:26:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13791101 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 E8D901DEFD8 for ; Wed, 4 Sep 2024 15:26:47 +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=1725463609; cv=none; b=Gh5Ausgk1cqKBgc/3GmWMrPb18OnJQeqw4tx7b69e0EDAkYmDxmu8q1JWCOZBqBldpNosC7SIPkMbfoR4V5wlKjKcvvvxGzuXSP6HrgXyutArMWAE1UX0am6l4vvNBuR1REvlQUuyNndE9GlpZJJRXoFJzNHq7bO/1HuRxR1qEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463609; c=relaxed/simple; bh=RI5yfFpeZBwqVIsb9LoEydItydrNT9LimgiKrP3jGzg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fYY4DbOUr9X3n3X1+2VlOphMV6We5i+iWfOGm7sRIQ8zvZWYtX2xd1KicqiKw43sfKJLy8hrNwxrEmxnn7ZMZP2pYSZSS3K1omAENW/iDl1QJ3G1ohr7tsauDnsarj2eIOY6/s6Sxkgc6m3ZUQIIEUc6Jm2E7MQ3+b2zPZiaPyI= 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=MKZxzqTw; 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="MKZxzqTw" 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 4849U2Nv022336 for ; Wed, 4 Sep 2024 08:26:47 -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=HJP9fbquyO89MaTiOtDLqqeht8rmftU7NWjYzfHDelI=; b= MKZxzqTw9ZehoIqgfEiCZ7e55mbnZP46oroZbom7rS5p6j47x9bf4cYzarRVEc8b iUzWv9pXWp0siB9/bLu4iA+0yvZu8vuteL18Gi4P2WxBRqx8mfEqK3nfUd467Bdz fMLazFlbnYBEgawdjLGeKP+h/dAI6yExAZQtkMljo1gfzs0qiMn1ggIAk1/O5obq aB8P6YB8ZPuTVUByAvC0nWSJ0Ae+ATF4ePGNkkFS6YIdpbqaqX/n3odS9TsRWPks eVPDfB/3vvSekFmnP0eEqhQPi3T29m1PSILB60IOXJEOs9ZOmzBb6lO9H8aaEHQL nuNUmSlD9wuhS4BvtdPKCA== Received: from mail.thefacebook.com ([163.114.134.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41emyp1w8k-13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:47 -0700 (PDT) Received: from twshared34253.17.frc2.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c08b:78::c78f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 4 Sep 2024 15:26:12 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id D030A12A036ED; Wed, 4 Sep 2024 08:26:07 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv3 06/10] blk-integrity: simplify counting segments Date: Wed, 4 Sep 2024 08:26:01 -0700 Message-ID: <20240904152605.4055570-7-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240904152605.4055570-1-kbusch@meta.com> References: <20240904152605.4055570-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: _Z_PQzaD9T7pu64BQTXadQqpCyLVe8He X-Proofpoint-ORIG-GUID: _Z_PQzaD9T7pu64BQTXadQqpCyLVe8He 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-04_13,2024-09-04_01,2024-09-02_01 From: Keith Busch The segments are already packed to the queue limits when adding them to the bio, so each vector is already its own segment. No need to attempt compacting them even more. And give the function a more appropriate name, since we're counting segments, not scatter-gather elements. Signed-off-by: Keith Busch --- block/blk-integrity.c | 33 ++++++--------------------------- block/blk-mq.c | 2 +- include/linux/blk-integrity.h | 5 ++--- 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 4365960153b91..c180141b7871c 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -17,39 +17,18 @@ #include "blk.h" /** - * blk_rq_count_integrity_sg - Count number of integrity scatterlist elements - * @q: request queue + * blk_rq_count_integrity_segs - Count number of integrity segments * @bio: bio with integrity metadata attached * * Description: Returns the number of elements required in a * scatterlist corresponding to the integrity metadata in a bio. */ -int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio) +int blk_rq_count_integrity_segs(struct bio *bio) { - struct bio_vec iv, ivprv = { NULL }; unsigned int segments = 0; - unsigned int seg_size = 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; - if (seg_size + iv.bv_len > queue_max_segment_size(q)) - goto new_segment; - - seg_size += iv.bv_len; - } else { -new_segment: - segments++; - seg_size = iv.bv_len; - } - - prev = 1; - ivprv = iv; - } + for_each_bio(bio) + segments += bio->bi_integrity->bip_vcnt; return segments; } @@ -62,7 +41,7 @@ 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_segs(). */ int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio, struct scatterlist *sglist) @@ -145,7 +124,7 @@ bool blk_integrity_merge_bio(struct request_queue *q, struct request *req, return false; bio->bi_next = NULL; - nr_integrity_segs = blk_rq_count_integrity_sg(q, bio); + nr_integrity_segs = blk_rq_count_integrity_segs(bio); bio->bi_next = next; if (req->nr_integrity_segments + nr_integrity_segs > diff --git a/block/blk-mq.c b/block/blk-mq.c index 3ed5181c75610..79cc66275f1cd 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2548,7 +2548,7 @@ static void blk_mq_bio_to_request(struct request *rq, struct bio *bio, blk_rq_bio_prep(rq, bio, nr_segs); #if defined(CONFIG_BLK_DEV_INTEGRITY) if (bio->bi_opf & REQ_INTEGRITY) - rq->nr_integrity_segments = blk_rq_count_integrity_sg(rq->q, bio); + rq->nr_integrity_segments = blk_rq_count_integrity_segs(bio); #endif /* This can't fail, since GFP_NOIO includes __GFP_DIRECT_RECLAIM. */ diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h index de98049b7ded9..0de05278ac824 100644 --- a/include/linux/blk-integrity.h +++ b/include/linux/blk-integrity.h @@ -27,7 +27,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_count_integrity_sg(struct request_queue *, struct bio *); +int blk_rq_count_integrity_segs(struct bio *); static inline bool blk_integrity_queue_supports_integrity(struct request_queue *q) @@ -91,8 +91,7 @@ static inline struct bio_vec rq_integrity_vec(struct request *rq) rq->bio->bi_integrity->bip_iter); } #else /* CONFIG_BLK_DEV_INTEGRITY */ -static inline int blk_rq_count_integrity_sg(struct request_queue *q, - struct bio *b) +static inline int blk_rq_count_integrity_segs(struct bio *b) { return 0; } From patchwork Wed Sep 4 15:26:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13791103 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 10BA31DEFEE for ; Wed, 4 Sep 2024 15:26:49 +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=1725463611; cv=none; b=dapEZ2Du3r+ce30a9glykMc/EQejMxeS2c8Waoo2hN2qbrDJtv8cP+h2Ixh3cgzzp96/spgHcC4JOeNbM16jahi4et2pdJkbBkrOw0hIcoraKkNVqq05g2QloGYTiHJddCplcW6Dulo5FFZ0ou4lwIBOY7oq9tU4h4agc0M11hY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463611; c=relaxed/simple; bh=3IVzbpR/rJR6wU1RUBfwFsTfYvzBRNjtgQJN0hgzS+s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lz/xyZDkuSL+Gge1R/qHKQcfiUtzQrVV4waBgMFo5Q69UZu9XBbuRmK5wswu0T5R072ifdUJz/6pANz0cVyO05d5zQZslFxtdVPEZ+LWX3lp62nDME4ebvbVIa2BmShracPDAMOgZ1wA0LnHKvBbfZ/O6p7wnrju2r9evJGu7lA= 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=e9HKErPF; 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="e9HKErPF" Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.18.1.2/8.18.1.2) with ESMTP id 484DJKxU023016 for ; Wed, 4 Sep 2024 08:26: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=mx/X2bX0pns4vleyJjY1s7PAjZcF77tvDOIJw1tvmqU=; b= e9HKErPFSEqRS6SYxYEtI9ugoHRs6t3oU4pALUyW1xJlmj2BHRKFcBP4qm5fXSY3 /737uAIkHJe+jJ5o6SCUfX/EPUP8ijUUSWv81aP0f1NS+XaioTE7nzqDgkY7jLIl Pee8NK65RncXXy2zrxyREMIniI9jnoLrIWOc3jfpOFeiAcm6V/xg5gX1qJan1QiX G0Ekw7fA3yJgvGciJWta+RMmBzvwEmRDwHwfDV6igqFxTK8m0V/3HzeimXxKuWZM Vmsbe2GL1TymKRc0JSnfSuNRyGNZ9irYYLAmLSqMHJi3kJocZkWbqhPULHMZc3Bq NHbwF5ttjON97JYNPjfS6A== Received: from mail.thefacebook.com ([163.114.134.16]) by m0089730.ppops.net (PPS) with ESMTPS id 41e5r4q3vq-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:48 -0700 (PDT) Received: from twshared17102.15.frc2.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c08b:78::c78f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 4 Sep 2024 15:26:17 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id E07A612A036EF; Wed, 4 Sep 2024 08:26:07 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv3 07/10] blk-integrity: simplify mapping sg Date: Wed, 4 Sep 2024 08:26:02 -0700 Message-ID: <20240904152605.4055570-8-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240904152605.4055570-1-kbusch@meta.com> References: <20240904152605.4055570-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: 77kyH_SJrinDh0P4QvCpoHoIPJunKu1h X-Proofpoint-GUID: 77kyH_SJrinDh0P4QvCpoHoIPJunKu1h 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-04_13,2024-09-04_01,2024-09-02_01 From: Keith Busch The segments are already packed to the queue limits when adding them to the bio, so each vector is already its own segment. No need to attempt compacting them even more. Signed-off-by: Keith Busch --- block/blk-integrity.c | 35 +++++++++-------------------------- drivers/nvme/host/rdma.c | 4 ++-- drivers/scsi/scsi_lib.c | 3 +-- include/linux/blk-integrity.h | 6 ++---- 4 files changed, 14 insertions(+), 34 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index c180141b7871c..cfb394eff35c8 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -35,7 +35,6 @@ int blk_rq_count_integrity_segs(struct bio *bio) /** * blk_rq_map_integrity_sg - Map integrity metadata into a scatterlist - * @q: request queue * @bio: bio with integrity metadata attached * @sglist: target scatterlist * @@ -43,39 +42,23 @@ int blk_rq_count_integrity_segs(struct bio *bio) * scatterlist. The scatterlist must be big enough to hold all * elements. I.e. sized using blk_rq_count_integrity_segs(). */ -int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio, - struct scatterlist *sglist) +int blk_rq_map_integrity_sg(struct bio *bio, struct scatterlist *sglist) { - struct bio_vec iv, ivprv = { NULL }; struct scatterlist *sg = NULL; unsigned int segments = 0; struct bvec_iter iter; - int prev = 0; + struct bio_vec iv; bio_for_each_integrity_vec(iv, bio, iter) { - - if (prev) { - if (!biovec_phys_mergeable(q, &ivprv, &iv)) - goto new_segment; - if (sg->length + iv.bv_len > queue_max_segment_size(q)) - goto new_segment; - - sg->length += iv.bv_len; - } else { -new_segment: - if (!sg) - sg = sglist; - else { - sg_unmark_end(sg); - sg = sg_next(sg); - } - - sg_set_page(sg, iv.bv_page, iv.bv_len, iv.bv_offset); - segments++; + if (!sg) + sg = sglist; + else { + sg_unmark_end(sg); + sg = sg_next(sg); } - prev = 1; - ivprv = iv; + sg_set_page(sg, iv.bv_page, iv.bv_len, iv.bv_offset); + segments++; } if (sg) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index dc0987d42c6b2..fab205bb4f3ed 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->bio, + 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 dc1a1644cbc0c..33a7d07dcbe26 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1183,8 +1183,7 @@ blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd) goto out_free_sgtables; } - count = blk_rq_map_integrity_sg(rq->q, rq->bio, - prot_sdb->table.sgl); + count = blk_rq_map_integrity_sg(rq->bio, prot_sdb->table.sgl); BUG_ON(count > ivecs); BUG_ON(count > queue_max_integrity_segments(rq->q)); diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h index 0de05278ac824..38b43d6c797df 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 bio *, struct scatterlist *); int blk_rq_count_integrity_segs(struct bio *); static inline bool @@ -95,8 +94,7 @@ static inline int blk_rq_count_integrity_segs(struct bio *b) { 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 bio *b, struct scatterlist *s) { return 0; From patchwork Wed Sep 4 15:26:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13791102 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 6E4E51DEFE2 for ; Wed, 4 Sep 2024 15:26: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=1725463611; cv=none; b=WhIW0ahYzi5mNTiMtQTGSVwIuqRy6Dan/epoDD1PTqlm3SXE+15NyCDBe3SN26CumUSJNbS4BQvFES/MQscg+6rdb41/XP31CIJpm8WKM3d8/8j3Qha6e5YauDIkH3UIrGQ92eoQgiza4x0+5A7LB7cMSy4U+STLLCGKwOqop4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463611; c=relaxed/simple; bh=ofC0ovGscBqX1aIm7wKKCbfSgkopWKpd6aY9RZvnHlY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IMyoyq7Enigan3ZnyAR6YybEszs9wJvZ4IQaJpy1zdZfW1dzy6JwgM6FW0zt8Yapp9miYJAWOSUrbnvLl7k+8snUG5ZAy3wap0jzvKTIZC0vLtrwcQ3aQVx36TxB4bJCOMj8GhBXEno2lqx1ziaw9WBC1SV/ZuXn7FSuEsQ9T9M= 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=Vvcjkg5A; 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="Vvcjkg5A" 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 4849U2O0022336 for ; Wed, 4 Sep 2024 08:26:48 -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=+//qAOpLt4ftix8+c0vKQWrZh5psXGJmgTeFdUI7xuY=; b= Vvcjkg5AWfp6o2vD/rovTbpYGk1no5V3qyj7A5L6tRi3oOL8Fmto4yigitIhAlXy yH0fjMbIOfMBvELMf5v+m8GbFk4n2OBnN+bOgWYnYffmUexkzpdJ/AYx+Qjh3YSN +vjpkfx3XeMF5f0ELRkCBXuwBpUv02Lp6sNe8foxDtKzsjm2btVbPPl36GWNYeSi K1hv+HOvnlXCvnQ/ggVpZGk9StsjLIAZDwaj+YVDg8nq1osKQjfa0TbW95OA27Xq /O6ptYw3MVo26j5fxhvtpXpcqUHMmsj2yIVkbKMjF70C8opk+dVIwKvGFDeVabY+ r7n810lu/dsy/6HkU1onTg== Received: from mail.thefacebook.com ([163.114.134.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41emyp1w8k-16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:48 -0700 (PDT) Received: from twshared34253.17.frc2.facebook.com (2620:10d:c085:208::7cb7) by mail.thefacebook.com (2620:10d:c08b:78::c78f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 4 Sep 2024 15:26:13 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id E8A6012A036F1; Wed, 4 Sep 2024 08:26:07 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv3 08/10] blk-integrity: remove inappropriate limit checks Date: Wed, 4 Sep 2024 08:26:03 -0700 Message-ID: <20240904152605.4055570-9-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240904152605.4055570-1-kbusch@meta.com> References: <20240904152605.4055570-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: wp2i9s12_Z6ax5tm3WipU9w8Ib6_SeYT X-Proofpoint-ORIG-GUID: wp2i9s12_Z6ax5tm3WipU9w8Ib6_SeYT 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-04_13,2024-09-04_01,2024-09-02_01 From: Keith Busch The queue limits for block access are not the same as metadata access. Delete these. Signed-off-by: Keith Busch --- block/bio-integrity.c | 7 ------- block/blk-integrity.c | 3 --- block/blk-merge.c | 6 ------ block/blk.h | 34 ---------------------------------- 4 files changed, 50 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 8d1fb38f745f9..ddd85eb46fbfb 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -184,13 +184,6 @@ int bio_integrity_add_page(struct bio *bio, struct page *page, if (bip->bip_vcnt >= min(bip->bip_max_vcnt, queue_max_integrity_segments(q))) return 0; - - /* - * If the queue doesn't support SG gaps and adding this segment - * would create a gap, disallow it. - */ - if (bvec_gap_to_prev(&q->limits, bv, offset)) - return 0; } bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset); diff --git a/block/blk-integrity.c b/block/blk-integrity.c index cfb394eff35c8..f9367f3a04208 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -85,9 +85,6 @@ bool blk_integrity_merge_rq(struct request_queue *q, struct request *req, q->limits.max_integrity_segments) return false; - if (integrity_req_gap_back_merge(req, next->bio)) - return false; - return true; } diff --git a/block/blk-merge.c b/block/blk-merge.c index 56769c4bcd799..43ab1ce09de65 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -650,9 +650,6 @@ int ll_back_merge_fn(struct request *req, struct bio *bio, unsigned int nr_segs) { if (req_gap_back_merge(req, bio)) return 0; - if (blk_integrity_rq(req) && - integrity_req_gap_back_merge(req, bio)) - return 0; if (!bio_crypt_ctx_back_mergeable(req, bio)) return 0; if (blk_rq_sectors(req) + bio_sectors(bio) > @@ -669,9 +666,6 @@ static int ll_front_merge_fn(struct request *req, struct bio *bio, { if (req_gap_front_merge(req, bio)) return 0; - if (blk_integrity_rq(req) && - integrity_req_gap_front_merge(req, bio)) - return 0; if (!bio_crypt_ctx_front_mergeable(req, bio)) return 0; if (blk_rq_sectors(req) + bio_sectors(bio) > diff --git a/block/blk.h b/block/blk.h index 32f4e9f630a3a..3f6198824b258 100644 --- a/block/blk.h +++ b/block/blk.h @@ -224,29 +224,6 @@ bool blk_integrity_merge_rq(struct request_queue *, struct request *, struct request *); bool blk_integrity_merge_bio(struct request_queue *, struct request *, struct bio *); - -static inline bool integrity_req_gap_back_merge(struct request *req, - struct bio *next) -{ - struct bio_integrity_payload *bip = bio_integrity(req->bio); - struct bio_integrity_payload *bip_next = bio_integrity(next); - - return bvec_gap_to_prev(&req->q->limits, - &bip->bip_vec[bip->bip_vcnt - 1], - bip_next->bip_vec[0].bv_offset); -} - -static inline bool integrity_req_gap_front_merge(struct request *req, - struct bio *bio) -{ - struct bio_integrity_payload *bip = bio_integrity(bio); - struct bio_integrity_payload *bip_next = bio_integrity(req->bio); - - return bvec_gap_to_prev(&req->q->limits, - &bip->bip_vec[bip->bip_vcnt - 1], - bip_next->bip_vec[0].bv_offset); -} - extern const struct attribute_group blk_integrity_attr_group; #else /* CONFIG_BLK_DEV_INTEGRITY */ static inline bool blk_integrity_merge_rq(struct request_queue *rq, @@ -259,17 +236,6 @@ static inline bool blk_integrity_merge_bio(struct request_queue *rq, { return true; } -static inline bool integrity_req_gap_back_merge(struct request *req, - struct bio *next) -{ - return false; -} -static inline bool integrity_req_gap_front_merge(struct request *req, - struct bio *bio) -{ - return false; -} - static inline void blk_flush_integrity(void) { } From patchwork Wed Sep 4 15:26:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13791106 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 40D9E1DEFC3 for ; Wed, 4 Sep 2024 15:26: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=1725463619; cv=none; b=sBJtwFQ2UtP4vcWK+4taDSIN5+4vHdhS/hs+BH/HcQn/oWbrozxUNRlfTRuUMZ+xVS4qKcIUt9KbDS2YpAk26G9+yKdfykr0gaswNWot8oeQLnsK9OWXZ9brKOSneYJCP0RnacGdTmzLAnB5G67+RC7gaDfRISsU98lan7mJX1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463619; c=relaxed/simple; bh=zjPO7a36oyeTYw4vRZcmsRpR1owOO/bCCBvRpagrY/c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OXgZ2WtPdnPvPc7Y0kcQT7IDvCpJhKQhdWyJi3vg5j88qNR6EGpKxs4H9Z9hGOAkSHe0kFjTVdmXjug/3bhb0KcmRrxJ+M+KytXMDIAyYlOKKs9/AVVTZvU1ePORAIRyUBQD353eOldtCmTrRYoiwrdKQbANBmdSIoeRbU7ilYI= 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=LDHAoo1X; 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="LDHAoo1X" 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 4849UfQD022985 for ; Wed, 4 Sep 2024 08:26:57 -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=1UwveGw9W/6ottXJOf2+aM2Smjb0TJhMxeWYP59wn24=; b= LDHAoo1XSGB2sWIJSk9qzaebmYZIgrIiR1Vs+iYRRE62yw6zWWXvFonOJZ5zpy8j nqw2awN3EWkK8+25A4dhgDDvyiQAjhLM28CbcmIp4wl0Ulk83YvsU05H6E5nGgsR ze/PQuonu+jIalBJCSoq7W8bKUa6creFJ7NCbAN3ZUqgyxdODBj7WA/4FxJtr6A+ krWG3spX8FhVtf2dgwGqqn9wkM9GEc5flZgHcWqQf3hf6e0bIZ4G0ziKvpSvArkp nSGJrAKBE3sYuAZOuB+5pS0ff3bcA+QxtQgegHcU6UG3wpSYUYWmKFgTHZ0KSBJu cfnbDgfxtkXVAJsSkwflOw== Received: from mail.thefacebook.com ([163.114.134.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41emyp1wcm-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:57 -0700 (PDT) Received: from twshared34253.17.frc2.facebook.com (2620:10d:c085:108::4) by mail.thefacebook.com (2620:10d:c08b:78::2ac9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 4 Sep 2024 15:26:13 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id 02BA112A036F5; Wed, 4 Sep 2024 08:26:07 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv3 09/10] blk-integrity: consider entire bio list for merging Date: Wed, 4 Sep 2024 08:26:04 -0700 Message-ID: <20240904152605.4055570-10-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240904152605.4055570-1-kbusch@meta.com> References: <20240904152605.4055570-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: MJSOomLRAfD6PLPjb8A4Ncw_hqHw9xfd X-Proofpoint-ORIG-GUID: MJSOomLRAfD6PLPjb8A4Ncw_hqHw9xfd 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-04_13,2024-09-04_01,2024-09-02_01 From: Keith Busch If a bio is merged to a req, the entire bio list is merged, so don't temporarily unchain it when counting segments for consideration. 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 f9367f3a04208..985de64409cf5 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -92,7 +92,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; @@ -103,10 +102,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_segs(bio); - bio->bi_next = next; - if (req->nr_integrity_segments + nr_integrity_segs > q->limits.max_integrity_segments) return false; From patchwork Wed Sep 4 15:26:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13791107 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 7B71A1DCB1A for ; Wed, 4 Sep 2024 15:27:01 +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=1725463622; cv=none; b=nqtAN7eV4OTQTY5GQ49gBZija7sQRNIZ3LC+wJafCm4HPayHuE+YTciT+b7bSEC8K0BWjDi/J6hzva65cgefBVCoZ1unyimc0YeU/YbOM7hTuKi9H0Et+23GouRoTiC9paSj1ZiuvHb3aJfzJl7MKGl3wQtf39b8D5HG7lM5iqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463622; c=relaxed/simple; bh=5KQLAlCMR+XTitxHoZQD1lWU0ZzLC2eldZx59yE78U8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PHUpjJiwPz94QUEZQJ3VVQ3MNr3q97h/S1juGvoogemaFb32IqNL2062nvAqez3rj0a3sxg/S3dWs+4QcWyNQSQcPPwYF/mXgHH53ql3Q2Emu0pXVp13/IXFtgWbLp5HSNjyDI0ndgLHgeU2E7WZmHebGAribZVKkbrFb0EKhUA= 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=nyL5oyEa; 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="nyL5oyEa" 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 4849UfQL022985 for ; Wed, 4 Sep 2024 08:27:01 -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=NJGuAIm2f/+xDgo4fPX/O74jcJilrmqmvJTBA0uhJGc=; b= nyL5oyEaGJWXzULQsfYGJ6uKN6VABTQnRYeh9CmKT0pqmLAP4tmD8ftHZj1FzyPv lLStP3qmimHauADdGo8UaU5K0EgMftNJ/tzK8KtGnngdNgoTCDb1jangu38tRBTU LpOdGHIVVXpQNZIfDQ9/N513Uxsbj3sH2H3VUN8d1UF40rXyXRg1LcW7Fx4X1/qN cAz2b1b+9zlOkfF3vMJebHWrex0uEb5kVHybCJUt1dQktESVlZUa7cFLAir8CpjA RMY7h8Ecvq4FSYr/iHXXbAjgAJx5ELK3rcsQ0jM1u3i6csMs31wN3NtZl36tehKB yNGh3JJEuzlbwYlr8seE2A== Received: from mail.thefacebook.com ([163.114.134.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41emyp1wcm-16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:27:00 -0700 (PDT) Received: from twshared17102.15.frc2.facebook.com (2620:10d:c085:108::8) by mail.thefacebook.com (2620:10d:c08b:78::2ac9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Wed, 4 Sep 2024 15:26:17 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id 0AD7412A036F7; Wed, 4 Sep 2024 08:26:08 -0700 (PDT) From: Keith Busch To: , , , , , , CC: Keith Busch Subject: [PATCHv3 10/10] blk-merge: properly account for integrity segments Date: Wed, 4 Sep 2024 08:26:05 -0700 Message-ID: <20240904152605.4055570-11-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240904152605.4055570-1-kbusch@meta.com> References: <20240904152605.4055570-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: tsCulZyzwADxfKvgb3yLai_gZ2rtotDq X-Proofpoint-ORIG-GUID: tsCulZyzwADxfKvgb3yLai_gZ2rtotDq 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-04_13,2024-09-04_01,2024-09-02_01 From: Keith Busch Merging two requests wasn't accounting for the new segment count, so add the "next" segement count to the first on a successful merge. 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. Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig --- block/blk-integrity.c | 2 -- block/blk-merge.c | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 985de64409cf5..4222c78eab18f 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -107,8 +107,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 43ab1ce09de65..734e6e22a6d22 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -639,6 +639,10 @@ static inline int ll_new_hw_segment(struct request *req, struct bio *bio, * counters. */ req->nr_phys_segments += nr_phys_segs; +#if defined(CONFIG_BLK_DEV_INTEGRITY) + if (bio->bi_opf & REQ_INTEGRITY) + req->nr_integrity_segments += blk_rq_count_integrity_segs(bio); +#endif return 1; no_merge: @@ -725,6 +729,9 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req, /* Merge is OK... */ req->nr_phys_segments = total_phys_segments; +#if defined(CONFIG_BLK_DEV_INTEGRITY) + req->nr_integrity_segments += next->nr_integrity_segments; +#endif return 1; }