diff options
author | Dave Chinner <dchinner@redhat.com> | 2018-06-08 09:54:22 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2018-06-08 10:07:52 -0700 |
commit | 0703a8e1c17e2cba742eafe640be3b60f77352c4 (patch) | |
tree | f52e7880cb8e77ef601a5937b1586271e2389b9b /fs/xfs/xfs_log_recover.c | |
parent | bb3d48dcf86a97dc25fe9fc2c11938e19cb4399a (diff) | |
download | lwn-0703a8e1c17e2cba742eafe640be3b60f77352c4.tar.gz lwn-0703a8e1c17e2cba742eafe640be3b60f77352c4.zip |
xfs: replace do_mod with native operations
do_mod() is a hold-over from when we have different sizes for file
offsets and and other internal values for 40 bit XFS filesystems.
Hence depending on build flags variables passed to do_mod() could
change size. We no longer support those small format filesystems and
hence everything is of fixed size theses days, even on 32 bit
platforms.
As such, we can convert all the do_mod() callers to platform
optimised modulus operations as defined by linux/math64.h.
Individual conversions depend on the types of variables being used.
Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/xfs_log_recover.c')
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index b1aedf73d09d..b181b5f57a19 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -1236,6 +1236,25 @@ xlog_verify_head( } /* + * We need to make sure we handle log wrapping properly, so we can't use the + * calculated logbno directly. Make sure it wraps to the correct bno inside the + * log. + * + * The log is limited to 32 bit sizes, so we use the appropriate modulus + * operation here and cast it back to a 64 bit daddr on return. + */ +static inline xfs_daddr_t +xlog_wrap_logbno( + struct xlog *log, + xfs_daddr_t bno) +{ + int mod; + + div_s64_rem(bno, log->l_logBBsize, &mod); + return mod; +} + +/* * Check whether the head of the log points to an unmount record. In other * words, determine whether the log is clean. If so, update the in-core state * appropriately. @@ -1283,12 +1302,13 @@ xlog_check_unmount_rec( } else { hblks = 1; } - after_umount_blk = rhead_blk + hblks + BTOBB(be32_to_cpu(rhead->h_len)); - after_umount_blk = do_mod(after_umount_blk, log->l_logBBsize); + + after_umount_blk = xlog_wrap_logbno(log, + rhead_blk + hblks + BTOBB(be32_to_cpu(rhead->h_len))); + if (*head_blk == after_umount_blk && be32_to_cpu(rhead->h_num_logops) == 1) { - umount_data_blk = rhead_blk + hblks; - umount_data_blk = do_mod(umount_data_blk, log->l_logBBsize); + umount_data_blk = xlog_wrap_logbno(log, rhead_blk + hblks); error = xlog_bread(log, umount_data_blk, 1, bp, &offset); if (error) return error; @@ -5459,9 +5479,7 @@ xlog_do_recovery_pass( */ if (blk_no + bblks <= log->l_logBBsize || blk_no >= log->l_logBBsize) { - /* mod blk_no in case the header wrapped and - * pushed it beyond the end of the log */ - rblk_no = do_mod(blk_no, log->l_logBBsize); + rblk_no = xlog_wrap_logbno(log, blk_no); error = xlog_bread(log, rblk_no, bblks, dbp, &offset); if (error) |