···22132213bool22142214xfs_verify_magic(22152215 struct xfs_buf *bp,22162216- uint32_t dmagic)22162216+ __be32 dmagic)22172217{22182218 struct xfs_mount *mp = bp->b_target->bt_mount;22192219 int idx;···22222222 if (unlikely(WARN_ON(!bp->b_ops || !bp->b_ops->magic[idx])))22232223 return false;22242224 return dmagic == bp->b_ops->magic[idx];22252225+}22262226+/*22272227+ * Verify an on-disk magic value against the magic value specified in the22282228+ * verifier structure. The verifier magic is in disk byte order so the caller is22292229+ * expected to pass the value directly from disk.22302230+ */22312231+bool22322232+xfs_verify_magic16(22332233+ struct xfs_buf *bp,22342234+ __be16 dmagic)22352235+{22362236+ struct xfs_mount *mp = bp->b_target->bt_mount;22372237+ int idx;22382238+22392239+ idx = xfs_sb_version_hascrc(&mp->m_sb);22402240+ if (unlikely(WARN_ON(!bp->b_ops || !bp->b_ops->magic16[idx])))22412241+ return false;22422242+ return dmagic == bp->b_ops->magic16[idx];22252243}
+6-2
fs/xfs/xfs_buf.h
···125125126126struct xfs_buf_ops {127127 char *name;128128- uint32_t magic[2]; /* v4 and v5 on disk magic values */128128+ union {129129+ __be32 magic[2]; /* v4 and v5 on disk magic values */130130+ __be16 magic16[2]; /* v4 and v5 on disk magic values */131131+ };129132 void (*verify_read)(struct xfs_buf *);130133 void (*verify_write)(struct xfs_buf *);131134 xfs_failaddr_t (*verify_struct)(struct xfs_buf *bp);···390387#define xfs_readonly_buftarg(buftarg) bdev_read_only((buftarg)->bt_bdev)391388392389int xfs_buf_reverify(struct xfs_buf *bp, const struct xfs_buf_ops *ops);393393-bool xfs_verify_magic(struct xfs_buf *bp, uint32_t dmagic);390390+bool xfs_verify_magic(struct xfs_buf *bp, __be32 dmagic);391391+bool xfs_verify_magic16(struct xfs_buf *bp, __be16 dmagic);394392395393#endif /* __XFS_BUF_H__ */
+1-1
fs/xfs/xfs_log_recover.c
···30493049 * Make sure the place we're flushing out to really looks30503050 * like an inode!30513051 */30523052- if (unlikely(!xfs_verify_magic(bp, dip->di_magic))) {30523052+ if (unlikely(!xfs_verify_magic16(bp, dip->di_magic))) {30533053 xfs_alert(mp,30543054 "%s: Bad inode magic number, dip = "PTR_FMT", dino bp = "PTR_FMT", ino = %Ld",30553055 __func__, dip, bp, in_f->ilf_ino);