Skip to content

Commit 6bbb4d9

Browse files
Christoph Hellwigbrauner
authored andcommitted
xfs: support T10 protection information
Add support for generating / verifying protection information in the file system. This is largely done by simply setting the IOMAP_F_INTEGRITY flag and letting iomap do all of the work. XFS just has to ensure that the data read completions for integrity data are run from user context. For zoned writeback, XFS also has to generate the integrity data itself as the zoned writeback path is not using the generic writeback_submit implementation. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260223132021.292832-17-hch@lst.de Tested-by: Anuj Gupta <anuj20.g@samsung.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 0b10a37 commit 6bbb4d9

2 files changed

Lines changed: 49 additions & 7 deletions

File tree

fs/xfs/xfs_aops.c

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "xfs_icache.h"
2323
#include "xfs_zone_alloc.h"
2424
#include "xfs_rtgroup.h"
25+
#include <linux/bio-integrity.h>
2526

2627
struct xfs_writepage_ctx {
2728
struct iomap_writepage_ctx ctx;
@@ -661,6 +662,8 @@ xfs_zoned_writeback_submit(
661662
bio_endio(&ioend->io_bio);
662663
return error;
663664
}
665+
if (wpc->iomap.flags & IOMAP_F_INTEGRITY)
666+
fs_bio_integrity_generate(&ioend->io_bio);
664667
xfs_zone_alloc_and_submit(ioend, &XFS_ZWPC(wpc)->open_zone);
665668
return 0;
666669
}
@@ -741,20 +744,56 @@ xfs_vm_bmap(
741744
return iomap_bmap(mapping, block, &xfs_read_iomap_ops);
742745
}
743746

747+
static void
748+
xfs_bio_submit_read(
749+
const struct iomap_iter *iter,
750+
struct iomap_read_folio_ctx *ctx)
751+
{
752+
struct bio *bio = ctx->read_ctx;
753+
754+
/* defer read completions to the ioend workqueue */
755+
iomap_init_ioend(iter->inode, bio, ctx->read_ctx_file_offset, 0);
756+
bio->bi_end_io = xfs_end_bio;
757+
submit_bio(bio);
758+
}
759+
760+
static const struct iomap_read_ops xfs_iomap_read_ops = {
761+
.read_folio_range = iomap_bio_read_folio_range,
762+
.submit_read = xfs_bio_submit_read,
763+
.bio_set = &iomap_ioend_bioset,
764+
};
765+
766+
static inline const struct iomap_read_ops *
767+
xfs_get_iomap_read_ops(
768+
const struct address_space *mapping)
769+
{
770+
struct xfs_inode *ip = XFS_I(mapping->host);
771+
772+
if (bdev_has_integrity_csum(xfs_inode_buftarg(ip)->bt_bdev))
773+
return &xfs_iomap_read_ops;
774+
return &iomap_bio_read_ops;
775+
}
776+
744777
STATIC int
745778
xfs_vm_read_folio(
746-
struct file *unused,
747-
struct folio *folio)
779+
struct file *file,
780+
struct folio *folio)
748781
{
749-
iomap_bio_read_folio(folio, &xfs_read_iomap_ops);
782+
struct iomap_read_folio_ctx ctx = { .cur_folio = folio };
783+
784+
ctx.ops = xfs_get_iomap_read_ops(folio->mapping);
785+
iomap_read_folio(&xfs_read_iomap_ops, &ctx, NULL);
750786
return 0;
751787
}
752788

753789
STATIC void
754790
xfs_vm_readahead(
755791
struct readahead_control *rac)
756792
{
757-
iomap_bio_readahead(rac, &xfs_read_iomap_ops);
793+
struct iomap_read_folio_ctx ctx = { .rac = rac };
794+
795+
ctx.ops = xfs_get_iomap_read_ops(rac->mapping),
796+
iomap_readahead(&xfs_read_iomap_ops, &ctx, NULL);
758797
}
759798

760799
static int

fs/xfs/xfs_iomap.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,14 @@ xfs_bmbt_to_iomap(
143143
}
144144
iomap->offset = XFS_FSB_TO_B(mp, imap->br_startoff);
145145
iomap->length = XFS_FSB_TO_B(mp, imap->br_blockcount);
146-
if (mapping_flags & IOMAP_DAX)
146+
iomap->flags = iomap_flags;
147+
if (mapping_flags & IOMAP_DAX) {
147148
iomap->dax_dev = target->bt_daxdev;
148-
else
149+
} else {
149150
iomap->bdev = target->bt_bdev;
150-
iomap->flags = iomap_flags;
151+
if (bdev_has_integrity_csum(iomap->bdev))
152+
iomap->flags |= IOMAP_F_INTEGRITY;
153+
}
151154

152155
/*
153156
* If the inode is dirty for datasync purposes, let iomap know so it

0 commit comments

Comments
 (0)