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: 825836 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 A552D1DA615 for ; Wed, 4 Sep 2024 15:26:25 +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=1725463587; cv=none; b=k2gboSlgj10Y0fv+5x4ERx7XJBWRy2G2DKhjWcHmPk7PtDmk/RS1oTOmmR762qKJ2MkMciCKbcURPbNEwy0KdlaAs62XN2/6UPQ3CM+7N2uGKn5YIWVAABSXcfa4adsgJq+bGJi1bY5xJosktHW15Emdy2zBOq9DlcnTsxddnn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463587; c=relaxed/simple; bh=9vS7WtpRyiE+BLkhEWwb5KsvA1A51Cz9iROIwAJDUsY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=o67zub4AlBsxvKKbu8apTc1k3pc3pFovyVVamarhF3oS64kyaRldxrE77FJ+IeRAXPE//iyGekL/5yg/+tl+99tK2TID1w6+K7RSFNjYk6rGGuGLa6zvgP73BYrfXn8T31jbAkEQHSgFemZrOTmRa1/IDPr2QHWgJYVEoQGtEIM= 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 4845F7Wj022818 for ; Wed, 4 Sep 2024 08:26:25 -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-15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:24 -0700 (PDT) Received: from twshared34253.17.frc2.facebook.com (2620:10d:c085:108::150d) 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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: Eclz2GJnv_iy37q45D9j3nrvf_BjnN24 X-Proofpoint-GUID: Eclz2GJnv_iy37q45D9j3nrvf_BjnN24 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: 825546 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 B29711DEFE7 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=d0G8GO1NYJbyZuDf1oL1FVdJkDQsggv7UXMnHw9blW7VXAuRT5xkJiEhyUxvAEwjQlZEBYP74T6omMZ2ZqXlC5x1hIYwtSfG1jRUFgxz6phPxEPZhy/v9nNrgT1gBpwX4aLJ0p28g7adgd5FTpMpSZlL57/kIFkxqvXA0s63b6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463611; 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=aJt6nsCkFuGXGTb9E8Ljdwj6mauic3FlPo21uEy1rbiV85s6s3F6+00kK7c9NMV1bOcbdcGRcAveBNhMpBxFDUK34InoecwW4Hm/XPAc1cWZcdFOw3shOQ94FqjiUDvYRQ3B9RHZYDcQDPaexeT+/3BXd9Zb5+Ai9DLA0x1rjMY= 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.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="CzsZeyu+" 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 484F4ToN017373 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=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 41eejbkfh6-4 (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:1b::2d) 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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: Ycd9q3iBZIqGvWz7L647-eoGFxA6_cC5 X-Proofpoint-GUID: Ycd9q3iBZIqGvWz7L647-eoGFxA6_cC5 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: 825837 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 E878DDDCD for ; Wed, 4 Sep 2024 15:26:13 +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=1725463575; cv=none; b=iPd9mkHqu6U8kT16U2eefS74/iS4bb1d2isarFZj5WMnfn9xtpv+6cZJSWkGO5VJchM8awECD0tkoTpWBCJ9WvR8387fbISC6ut2yQBEDeojtphT8Dy5dCAqHuTYSe/HZlFTn7eXSrpDsD2V7ZZvPbvdBUIuQFL0AJFlrKbCs68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463575; c=relaxed/simple; bh=tbelIYErMOsag2MIJL4MBYUSOAYcOXInrX7qRvcyW5w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TPcgFav3+uRi3elL2LjrkvBhgcaFTPNu5Z+kuwhowngyp5ANvSqj95w3F5aXxO3m0o/QlGEPNvO2UIcygkdK7KvWj0bLpB5ruLtFFSHQPuKquVlQm7MPvCLdiXnxgFii7gQ/eKOFFSzY7qKV+yQhnLU9Jq8CubKqRpIG9WHeCus= 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.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="WcZ8iVmH" 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 484DoYWR030424 for ; Wed, 4 Sep 2024 08:26:12 -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 41e5y5xxc7-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:12 -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 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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: RUeJ9Ns8bwETT3p9TTyAg8uEYrSbwKC6 X-Proofpoint-GUID: RUeJ9Ns8bwETT3p9TTyAg8uEYrSbwKC6 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: 825835 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 01A7A1EC017 for ; Wed, 4 Sep 2024 15:26:45 +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=1725463607; cv=none; b=lieOtjs6mDCJXxtTgsOwpT9EqcHozlQL7YL64OPGUEdDdtXC2w8NcjEbkiiRWjdmhbjQPvN5Ptkv8I4VGOwQGglh9OXv+UuPoKxnr4hlq3mGbbbLYb1qkNn+dDId82Z5NAQ6h4GsHUlvnccr0AJPxCKeLOY2YBG4Z6GZ0e4WF/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463607; c=relaxed/simple; bh=wgCiCeySyO0FcFxrr+YSd3x8cxBMpFU7my8lcR2bZro=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lgcs0zfHq9YoYFjKfkaaf0xxm+OoNOviCphdoYyPkHUV0bocY51tJAV06+/oUEE4lG4tgdzGj5FoVGEBUdZjKTJek6T3x26nGyDT27iQ4nbWwp77EXj/OEsPwZ/CRJgQ2/uhoN/UTgknRtU4PIONsW7n/XOi30Vo3x2xp6whYcE= 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 4849U2Np022336 for ; Wed, 4 Sep 2024 08:26:45 -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-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:45 -0700 (PDT) Received: from twshared34253.17.frc2.facebook.com (2620:10d:c085:108::4) 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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: TNZQOTI84PsmZySwthhqNq3Wd9bRzBiE X-Proofpoint-ORIG-GUID: TNZQOTI84PsmZySwthhqNq3Wd9bRzBiE 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: 825833 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 5481F1DEFE5 for ; Wed, 4 Sep 2024 15:26: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=1725463612; cv=none; b=Vz0sSpe2pCAYmM0m7eBl7cGelsLM7Dd37cAGApQNstXnV93Ijx2X9cNueoOMEBCc9DKwlEpTj1KXvpJveCjXakCn/Op/N0BREcP1qe/Zv2OSCdYGt89B0voWCEKpqLKmmx9BAWe19mgEfcHnYJxyZeFTosgtIrkZi40i2+Fi/IA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463612; c=relaxed/simple; bh=mIMzDYPipEZCzvoJEZhl1TTa2Z2biQRbEVba7c6Ips0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Vt12wEu5S2AK7AJzlRn+KyM1+2NShZjUk2zruu9Me10wCDXDn+6wofaRbaqjPiOw8FDxIBkPMDFqn5+dK7uzjwFyWTbKvGXRd8VVonO0C2K4akW0LZ4nE4OYBzIiMKMsqBD3xdB29FspKDZl14xXfIbsQ79v8PkObrXJWHfdxdA= 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 (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 484EJAkH010145 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=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 41e8fvdk4c-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:50 -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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: mSEmFvmWJgsG7XFNgrn6Nm_ODi4jUy27 X-Proofpoint-GUID: mSEmFvmWJgsG7XFNgrn6Nm_ODi4jUy27 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: 825548 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 DC7991EC017 for ; Wed, 4 Sep 2024 15:26:20 +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=1725463582; cv=none; b=cVe1Olh1xeEZd+GkO4xr/4mukGULk+YP45VERHrxiKBslEdcR1Lubrrg4RUl7upmDS37I0mo+mH5RxCQDzPhtnI0qyWrFsWYujbXxunVYiB+L/vlh4aC683zw+g3n6Pb3rzqQUzubIiSfBQhaingIB2LLFDQwfBDDo/kxsi8KjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463582; c=relaxed/simple; bh=RI5yfFpeZBwqVIsb9LoEydItydrNT9LimgiKrP3jGzg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M3dvSvSYtUbkTM2C3B4DVUzNxwgv2v/xzrS9+dok8iKkchzYibWJZyTUmzCEw7BtjUsURwHneq2Mshm3ldgUkuWvx/qBmzMqUQXuXszC9ASdZmaR6XuRgMXK9PxS9k/Ub7KWfmJw0Ln/7Ec/ZoJSBGgCmOV4UpT4WjLe4Znou1M= 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 (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4845F7Wa022818 for ; Wed, 4 Sep 2024 08:26:20 -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 41eh7v2vxw-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:20 -0700 (PDT) Received: from twshared34253.17.frc2.facebook.com (2620:10d:c085:208::f) 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 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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: mON0KXiPcwz_pSUh9VxR8AbNxfB9GZ5k X-Proofpoint-GUID: mON0KXiPcwz_pSUh9VxR8AbNxfB9GZ5k 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: 825834 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 B29C61DEFEA 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=mSkQGwaQU84tQgS/201pinOuoIkWiqIGX7s0jRB6ibqbDiaWR9hEzcRxhcHsyFtbhMebs66hPzHarZDlmN293g5iFx+bcwvFmqcWaVypQh26YaXWp1lsgfyA3mt4Aw+etgSWad5joyAUthRMne6bpg47+RI5EX/RT/OUZXtnJnM= 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.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="e9HKErPF" 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 4849U2O1022336 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 mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41emyp1w8k-17 (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::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: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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: ZI4CParDnUGKiQ_5gSRU1pmMCjhLq4Ha X-Proofpoint-ORIG-GUID: ZI4CParDnUGKiQ_5gSRU1pmMCjhLq4Ha 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: 825545 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 B60AF1DEFEC 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=oHLwJQo/ohPtZtML6wtpcwy78/iregq9dIds4cMv5Fd1ZpmNFvQZVdKcPnNZ/MTfOEEab0vAAes2GfzqV49/4xpj0n4BX6om713O+gLkPSvq7ilXDrxkxufXCgyLr+8WrHOAGZqmvL0KW1Z3XbqyZgdGQy2T279BFLHfBzr8Wtg= 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.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="Vvcjkg5A" 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 484DJKxT023016 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 m0089730.ppops.net (PPS) with ESMTPS id 41e5r4q3vq-5 (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:108::8) 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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: MrIZGbQcZG1gwYpbmpvaxuPb9s2Af9F9 X-Proofpoint-GUID: MrIZGbQcZG1gwYpbmpvaxuPb9s2Af9F9 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: 825544 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 E07611DEFC1 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=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 4849UfQC022985 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-7 (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:208::f) 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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: eJGVoR_VcC3u1QaGr562izE7hURPhBCM X-Proofpoint-ORIG-GUID: eJGVoR_VcC3u1QaGr562izE7hURPhBCM 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: 825832 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 5BF1D1DEFC3 for ; Wed, 4 Sep 2024 15:27:00 +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=1725463621; cv=none; b=n0AaqDzRDi9oiErriHC32vULMNjYrYgRCuLad7u6qTTCqt8gVvUheHM+olowT5KK4yIi7HJJEwfiE1gymW/QD3YuqPrPh6v3ZJe/bppG+6Lyqe9xTV8zxt9aDYC7CSiNzYncxqpaoGS02YSuTSQ6EvDCrrqoIhGlSPxXFZWk77g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725463621; c=relaxed/simple; bh=5KQLAlCMR+XTitxHoZQD1lWU0ZzLC2eldZx59yE78U8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q19XcJHzNaRoWeUMfMc3TUYCtJOAgDiNz6BJ/FjZypAcxZm0WvcfuBzCEWVeuk/GA1ZufCzbvCxMxMJF7XSb+9KRlaDdvf5tmpy2ATHzo5jSwgzKF0pQW0ahK9fwXUpm22rT/1QX6gwt/tnsHhk+9N1L7yZ1onWhekp1SZdT7X0= 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 4849UfQI022985 for ; Wed, 4 Sep 2024 08:26:59 -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-13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 04 Sep 2024 08:26:59 -0700 (PDT) Received: from twshared17102.15.frc2.facebook.com (2620:10d:c085:108::150d) 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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: SPXHixYXINp9A95dJ2B5j42QZHQv2PLQ X-Proofpoint-ORIG-GUID: SPXHixYXINp9A95dJ2B5j42QZHQv2PLQ 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; }