From: Brian Foster <bfoster@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/3] xfs: replace do_mod with native operations
Date: Thu, 7 Jun 2018 07:42:05 -0400 [thread overview]
Message-ID: <20180607114204.GD7798@bfoster> (raw)
In-Reply-To: <20180607052751.6541-3-david@fromorbit.com>
On Thu, Jun 07, 2018 at 03:27:50PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> 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>
> ---
> fs/xfs/libxfs/xfs_bmap.c | 37 +++++++++++++++++++++++--------------
> fs/xfs/xfs_bmap_util.c | 14 +++++++++-----
> fs/xfs/xfs_inode.c | 2 +-
> fs/xfs/xfs_iomap.h | 4 ++--
> fs/xfs/xfs_linux.h | 19 -------------------
> fs/xfs/xfs_log_recover.c | 32 +++++++++++++++++++++++++-------
> fs/xfs/xfs_rtalloc.c | 15 +++++++++++----
> 7 files changed, 71 insertions(+), 52 deletions(-)
>
...
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index 7d897c58b0c8..4405ff21f9a9 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -1235,6 +1235,25 @@ xlog_verify_head(
> be32_to_cpu((*rhead)->h_size));
> }
>
> +/*
> + * We need to make sure we handle log wrapping properly, so we can't use teh
> + * calculated logbno directly. Make sure it wraps to teh correct bno inside teh
> + * log.
> + *
s/teh/the/
> + * 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
...
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index 80bbfe604ce0..776502a5dcb7 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
...
> @@ -1262,8 +1266,11 @@ xfs_rtpick_extent(
> resid = seq - (1ULL << log2);
> b = (mp->m_sb.sb_rextents * ((resid << 1) + 1ULL)) >>
> (log2 + 1);
> - if (b >= mp->m_sb.sb_rextents)
> - b = do_mod(b, mp->m_sb.sb_rextents);
> + if (b >= mp->m_sb.sb_rextents) {
> + xfs_rtblock_t mod;
> + div64_u64_rem(b, mp->m_sb.sb_rextents, &mod);
> + b = mod;
> + }
Shouldn't we be able to do 'div64_u64_rem(b, mp->m_sb.sb_rextents, &b)'
here? Otherwise looks fine:
Reviewed-by: Brian Foster <bfoster@redhat.com>
> if (b + len > mp->m_sb.sb_rextents)
> b = mp->m_sb.sb_rextents - len;
> }
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-06-07 11:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-07 5:27 [PATCH 0/3] xfs: minor cleanups Dave Chinner
2018-06-07 5:27 ` [PATCH 1/3] xfs: move various type verifiers to common file Dave Chinner
2018-06-07 11:41 ` Brian Foster
2018-06-07 15:23 ` Darrick J. Wong
2018-06-08 6:24 ` Christoph Hellwig
2018-06-07 5:27 ` [PATCH 2/3] xfs: replace do_mod with native operations Dave Chinner
2018-06-07 11:42 ` Brian Foster [this message]
2018-06-07 16:01 ` Darrick J. Wong
2018-06-07 22:23 ` Dave Chinner
2018-06-07 15:54 ` Darrick J. Wong
2018-06-07 22:28 ` Dave Chinner
2018-06-08 0:43 ` [PATCH 2/3 V2] " Dave Chinner
2018-06-08 6:19 ` Christoph Hellwig
2018-06-08 7:31 ` Dave Chinner
2018-06-07 5:27 ` [PATCH 3/3] xfs: clean up MIN/MAX Dave Chinner
2018-06-07 11:42 ` Brian Foster
2018-06-08 6:23 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180607114204.GD7798@bfoster \
--to=bfoster@redhat.com \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox