From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 0F5262DC323; Wed, 18 Feb 2026 06:13:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771395222; cv=none; b=IIzQdBujIOB015MdGevf7apnLc2Ibyu0keFRAccZ1G0/viKiBLSxplIxLhs7TNW2ZuVGrOte9TQ88qjF6kdtUQnJVZys02dWF7IGmfL1ModvJZwjAKPG2wm2+A4lVQUdPu3ijboFZGKrcYTIRZ/6HYZc2G0PkPbcZ1AHxXYBKks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771395222; c=relaxed/simple; bh=Y9zQpBnOY3XsNhwdPyvpSO9SQI9w3QLDzOcy7Bn/HBg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=agQgIrBL2s4LuQFvsmjqE3eUp2Ixr+wvLsQVK7HKEPdkbcOATOam5uvhzAt4NGl3l3GLygh5P9xG2dCavcZmUZCrRJB9K08jrForSlgAbpzdmLJlXBEoL9qPIdJfZRQ3FgtgHAW21fxVNi19bF1ylL9BTeh5PQar5F5wIQcX/4s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Bp4MXyF7; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Bp4MXyF7" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=vqmLMmLSuW58/h9+4XMmo+oe3hP9517pKNkmn5AFtrA=; b=Bp4MXyF7w+07I1ReSWU2yGqv89 OrQZKcO2FZGi9b1jWr2Cmq5n4gTJIhd4CJe8uAnvLi8OC7/E2heAik0gYmbuLPgnHbral3R/bMT/o drxymHx7duv3Ea+evl8E1dV9tYQC4+CkBN+xBBxaMKajTDg5QBKlbH1Ad4EizJt5gtjpYDWyatpOu efJ3rs7Kcoa+wD4Ug8cftnPt1ujHS83Gpf2XMvnsNYTF0lF9aNp4tFV1RzwfpOJujCcp0/sUF20Xg P3FrSZGW4wrNrcuGVmJaXFoQyQZ3bmf4YjbHxe64wegfXYgOomjtTMi3Xw3K3bo/xyZcpjXQRtdlU Myr+X8vA==; Received: from [2001:4bb8:2dc:9863:1842:9381:9c0f:de32] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vsaod-00000009LUl-3MvY; Wed, 18 Feb 2026 06:13:40 +0000 From: Christoph Hellwig To: Jens Axboe , Christian Brauner Cc: "Darrick J. Wong" , Carlos Maiolino , "Martin K. Petersen" , Anuj Gupta , Kanchan Joshi , linux-block@vger.kernel.org, nvdimm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH 11/15] iomap: allow file systems to hook into buffered read bio submission Date: Wed, 18 Feb 2026 07:12:05 +0100 Message-ID: <20260218061238.3317841-12-hch@lst.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260218061238.3317841-1-hch@lst.de> References: <20260218061238.3317841-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html File systems such as btrfs have additional operations with bios such as verifying data checksums. Allow file systems to hook into submission of the bio to allow for this processing by replacing the direct submit_bio call in iomap_read_alloc_bio with a call into ->submit_read and exporting iomap_read_alloc_bio. Also add a new field to struct iomap_read_folio_ctx to track the file logic offset of the current read context. Based on a patch from Goldwyn Rodrigues . Signed-off-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" Tested-by: Anuj Gupta --- fs/iomap/bio.c | 15 +++++++++------ include/linux/iomap.h | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/fs/iomap/bio.c b/fs/iomap/bio.c index 80bbd328bd3c..903cb9fe759e 100644 --- a/fs/iomap/bio.c +++ b/fs/iomap/bio.c @@ -32,10 +32,11 @@ static void iomap_read_alloc_bio(const struct iomap_iter *iter, struct folio *folio = ctx->cur_folio; gfp_t gfp = mapping_gfp_constraint(folio->mapping, GFP_KERNEL); gfp_t orig_gfp = gfp; - struct bio *bio = ctx->read_ctx; + struct bio *bio; - if (bio) - submit_bio(bio); + /* Submit the existing range if there was one. */ + if (ctx->read_ctx) + ctx->ops->submit_read(iter, ctx); /* Same as readahead_gfp_mask: */ if (ctx->rac) @@ -56,9 +57,10 @@ static void iomap_read_alloc_bio(const struct iomap_iter *iter, bio_add_folio_nofail(bio, folio, plen, offset_in_folio(folio, iter->pos)); ctx->read_ctx = bio; + ctx->read_ctx_file_offset = iter->pos; } -static int iomap_bio_read_folio_range(const struct iomap_iter *iter, +int iomap_bio_read_folio_range(const struct iomap_iter *iter, struct iomap_read_folio_ctx *ctx, size_t plen) { struct folio *folio = ctx->cur_folio; @@ -70,10 +72,11 @@ static int iomap_bio_read_folio_range(const struct iomap_iter *iter, iomap_read_alloc_bio(iter, ctx, plen); return 0; } +EXPORT_SYMBOL_GPL(iomap_bio_read_folio_range); const struct iomap_read_ops iomap_bio_read_ops = { - .read_folio_range = iomap_bio_read_folio_range, - .submit_read = iomap_bio_submit_read, + .read_folio_range = iomap_bio_read_folio_range, + .submit_read = iomap_bio_submit_read, }; EXPORT_SYMBOL_GPL(iomap_bio_read_ops); diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 6fbe121e2adf..b2b9e649a3b8 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -493,6 +493,7 @@ struct iomap_read_folio_ctx { struct folio *cur_folio; struct readahead_control *rac; void *read_ctx; + loff_t read_ctx_file_offset; }; struct iomap_read_ops { @@ -599,6 +600,9 @@ int iomap_swapfile_activate(struct swap_info_struct *sis, extern struct bio_set iomap_ioend_bioset; #ifdef CONFIG_BLOCK +int iomap_bio_read_folio_range(const struct iomap_iter *iter, + struct iomap_read_folio_ctx *ctx, size_t plen); + extern const struct iomap_read_ops iomap_bio_read_ops; static inline void iomap_bio_read_folio(struct folio *folio, -- 2.47.3