This helpers converts offset which XFS uses to store fsverity metadata on disk to the offset in the pagecache. Signed-off-by: Andrey Albershteyn --- fs/xfs/xfs_fsverity.c | 14 ++++++++++++++ fs/xfs/xfs_fsverity.h | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/fs/xfs/xfs_fsverity.c b/fs/xfs/xfs_fsverity.c index 47add19a241e..4b918eb746d7 100644 --- a/fs/xfs/xfs_fsverity.c +++ b/fs/xfs/xfs_fsverity.c @@ -8,6 +8,20 @@ #include "xfs_fsverity.h" #include +loff_t +xfs_fsverity_offset_to_disk(struct xfs_inode *ip, loff_t offset) +{ + return (offset - fsverity_metadata_offset(VFS_I(ip))) | + XFS_FSVERITY_REGION_START; +} + +loff_t +xfs_fsverity_offset_from_disk(struct xfs_inode *ip, loff_t offset) +{ + return (offset ^ XFS_FSVERITY_REGION_START) + + fsverity_metadata_offset(VFS_I(ip)); +} + bool xfs_fsverity_sealed_data( const struct xfs_inode *ip, diff --git a/fs/xfs/xfs_fsverity.h b/fs/xfs/xfs_fsverity.h index 5fc55f42b317..6f3d60f010d8 100644 --- a/fs/xfs/xfs_fsverity.h +++ b/fs/xfs/xfs_fsverity.h @@ -10,6 +10,8 @@ #ifdef CONFIG_FS_VERITY bool xfs_fsverity_sealed_data(const struct xfs_inode *ip, loff_t offset); +loff_t xfs_fsverity_offset_to_disk(struct xfs_inode *ip, loff_t pos); +loff_t xfs_fsverity_offset_from_disk(struct xfs_inode *ip, loff_t offset); #else static inline loff_t xfs_fsverity_offset_to_disk(struct xfs_inode *ip, loff_t pos) @@ -17,6 +19,17 @@ static inline loff_t xfs_fsverity_offset_to_disk(struct xfs_inode *ip, WARN_ON_ONCE(1); return ULLONG_MAX; } +static inline loff_t xfs_fsverity_offset_from_disk(struct xfs_inode *ip, + loff_t offset) +{ + WARN_ON_ONCE(1); + return ULLONG_MAX; +} +static inline bool xfs_fsverity_sealed_data(const struct xfs_inode *ip, + loff_t offset) +{ + return false; +} #endif /* CONFIG_FS_VERITY */ #endif /* __XFS_FSVERITY_H__ */ -- 2.51.2