From patchwork Wed Jun 26 10:06:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13712783 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 AB95A17F4E8 for ; Wed, 26 Jun 2024 11:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402148; cv=none; b=s61gtf6eKgpe/Ncc8gFssALtTWbze1pndfLnXjeWGJTKUxRWnyesEScvKi+bEz+HaSlVjP2xjh6peQtgBgOwYX4lSRdRMOKCOSuUtQMSl1zaLe0QtgLwAsh5e/tN1HyN0kx5v8qWtgq9cfbi+yujSNdwY/ge0nNsazXqBYrJLd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719402148; c=relaxed/simple; bh=8hu2gELgAaPO9ThdtDrVOBEQrck8AWf/89L08gXHjvo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=ltyuaBbeXGesZxu1gXiDTXu5kfanPvYdMNtO/0Qjacdv3Ech039CScqKA9/iwQl/zLMc6QLD4FZWBeP0/m4i/iNXYyCpHuo70/ihfqHbQlynvd6URj6IzVP3F8/mUKp8pSFkepMQ6VZOxjAX5CSl/c/4Y8eG3EqeY7Rwxoq2E+I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=hRXcryWv; arc=none smtp.client-ip=203.254.224.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="hRXcryWv" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240626114225epoutp010fbf0f844a90b2da688b056f65c15f5e~ciyQlEJyc1762517625epoutp01f for ; Wed, 26 Jun 2024 11:42:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240626114225epoutp010fbf0f844a90b2da688b056f65c15f5e~ciyQlEJyc1762517625epoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1719402145; bh=nXGPzER1JF01Eq/Va1G8I1f4os1fOKXD7EF9v6r4iM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hRXcryWvbC7asq2VcYxnTBbOYtFDaTYfkNgjxiJlp2tLW/cX4zDKGCyauZFQU2R5G 5ruNTFaba0MTGGQamO/0P5TJG87NOReVLPFMUonV1fU4Pvy1DJsihVaeWYjIc+PyzS sGXSo0/GHkpizyFleaeRvRsQD2vaTgET+K2aQd64= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240626114224epcas5p47a3e3da5c0bc0c406bfb9ed989ec64e6~ciyP1O5oC0207802078epcas5p4I; Wed, 26 Jun 2024 11:42:24 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.178]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4W8KYp3v2nz4x9Pp; Wed, 26 Jun 2024 11:42:22 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id EC.75.19174.E9EFB766; Wed, 26 Jun 2024 20:42:22 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240626101519epcas5p163b0735c1604a228196f0e8c14773005~chmOOAph61565315653epcas5p1H; Wed, 26 Jun 2024 10:15:19 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240626101519epsmtrp1fd3887d9cd4992b3258841181ca9ce27~chmONJVY91023810238epsmtrp1k; Wed, 26 Jun 2024 10:15:19 +0000 (GMT) X-AuditID: b6c32a50-87fff70000004ae6-ed-667bfe9ebdf3 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id D9.6A.19057.73AEB766; Wed, 26 Jun 2024 19:15:19 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240626101518epsmtip1c3b688bf7716f6795f14ab17527fc687~chmMm6_kR0370603706epsmtip1C; Wed, 26 Jun 2024 10:15:18 +0000 (GMT) From: Anuj Gupta To: asml.silence@gmail.com, mpatocka@redhat.com, axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Kanchan Joshi Subject: [PATCH v2 05/10] block: introduce BIP_CLONED flag Date: Wed, 26 Jun 2024 15:36:55 +0530 Message-Id: <20240626100700.3629-6-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626100700.3629-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAJsWRmVeSWpSXmKPExsWy7bCmpu68f9VpBvO2yFrMWbWN0WL13X42 i5WrjzJZvGs9x2Jx9P9bNotJh64xWuy9pW0xf9lTdovlx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SzXn 1+nNy2+tK8iNWZJrteBlkRJLcUaioRZzUXEiAHW0shj7AgAA X-CMS-MailID: 20240626101519epcas5p163b0735c1604a228196f0e8c14773005 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240626101519epcas5p163b0735c1604a228196f0e8c14773005 References: <20240626100700.3629-1-anuj20.g@samsung.com> From: Kanchan Joshi Set the BIP_CLONED flag when bip is cloned. Use that flag to ensure that integrity is freed for cloned user bip. Note that a bio may have BIO_CLONED flag set but it may still not be sharing the integrity vecs. Signed-off-by: Kanchan Joshi Signed-off-by: Christoph Hellwig --- block/bio-integrity.c | 5 ++++- include/linux/bio.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 845d4038afb1..8f07c4d0fada 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -147,7 +147,8 @@ void bio_integrity_free(struct bio *bio) struct bio_integrity_payload *bip = bio_integrity(bio); struct bio_set *bs = bio->bi_pool; - if (bip->bip_flags & BIP_INTEGRITY_USER) + if (bip->bip_flags & BIP_INTEGRITY_USER && + !(bip->bip_flags & BIP_CLONED)) return; if (bip->bip_flags & BIP_BLOCK_INTEGRITY) kfree(bvec_virt(bip->bip_vec)); @@ -662,6 +663,8 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, bip->bip_iter = bip_src->bip_iter; bip->bip_flags = bip_src->bip_flags & ~(BIP_BLOCK_INTEGRITY | BIP_COPY_USER); + bip->bip_flags |= BIP_CLONED; + return 0; } diff --git a/include/linux/bio.h b/include/linux/bio.h index 818e93612947..44226fcb4d00 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -329,6 +329,7 @@ enum bip_flags { BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */ BIP_INTEGRITY_USER = 1 << 5, /* Integrity payload is user address */ BIP_COPY_USER = 1 << 6, /* Kernel bounce buffer in use */ + BIP_CLONED = 1 << 7, /* Indicates that bip is cloned */ }; /*