From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/4] xfs: introduce xfs_aligned_fsb_count
Date: Thu, 2 Feb 2017 14:56:29 -0800 [thread overview]
Message-ID: <20170202225629.GO9134@birch.djwong.org> (raw)
In-Reply-To: <1485985359-971-3-git-send-email-hch@lst.de>
On Wed, Feb 01, 2017 at 10:42:37PM +0100, Christoph Hellwig wrote:
> Factor a helper to calculate the extent-size aligned block out of the
> iomap code, so that it can be reused by the upcoming reflink dio code.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks like a reasonable enough code replacement, so:
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/xfs_iomap.c | 11 ++---------
> fs/xfs/xfs_iomap.h | 20 ++++++++++++++++++++
> 2 files changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index d17aa3b..9d811eb 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -162,7 +162,7 @@ xfs_iomap_write_direct(
> xfs_fileoff_t last_fsb;
> xfs_filblks_t count_fsb, resaligned;
> xfs_fsblock_t firstfsb;
> - xfs_extlen_t extsz, temp;
> + xfs_extlen_t extsz;
> int nimaps;
> int quota_flag;
> int rt;
> @@ -203,14 +203,7 @@ xfs_iomap_write_direct(
> }
> count_fsb = last_fsb - offset_fsb;
> ASSERT(count_fsb > 0);
> -
> - resaligned = count_fsb;
> - if (unlikely(extsz)) {
> - if ((temp = do_mod(offset_fsb, extsz)))
> - resaligned += temp;
> - if ((temp = do_mod(resaligned, extsz)))
> - resaligned += extsz - temp;
> - }
> + resaligned = xfs_aligned_fsb_count(offset_fsb, count_fsb, extsz);
>
> if (unlikely(rt)) {
> resrtextents = qblocks = resaligned;
> diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h
> index 6d45cf0..1fef4a5 100644
> --- a/fs/xfs/xfs_iomap.h
> +++ b/fs/xfs/xfs_iomap.h
> @@ -33,6 +33,26 @@ void xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *,
> struct xfs_bmbt_irec *);
> xfs_extlen_t xfs_eof_alignment(struct xfs_inode *ip, xfs_extlen_t extsize);
>
> +static inline xfs_filblks_t
> +xfs_aligned_fsb_count(
> + xfs_fileoff_t offset_fsb,
> + xfs_filblks_t count_fsb,
> + xfs_extlen_t extsz)
> +{
> + if (extsz) {
> + xfs_extlen_t align;
> +
> + align = do_mod(offset_fsb, extsz);
> + if (align)
> + count_fsb += align;
> + align = do_mod(count_fsb, extsz);
> + if (align)
> + count_fsb += extsz - align;
> + }
> +
> + return count_fsb;
> +}
> +
> extern struct iomap_ops xfs_iomap_ops;
> extern struct iomap_ops xfs_xattr_iomap_ops;
>
> --
> 2.1.4
>
> --
> 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:[~2017-02-02 22:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-01 21:42 reflink direct I/O improvements V2 Christoph Hellwig
2017-02-01 21:42 ` [PATCH 1/4] xfs: reject all unaligned direct writes to reflinked files Christoph Hellwig
2017-02-02 23:01 ` Darrick J. Wong
2017-02-01 21:42 ` [PATCH 2/4] xfs: introduce xfs_aligned_fsb_count Christoph Hellwig
2017-02-02 22:56 ` Darrick J. Wong [this message]
2017-02-01 21:42 ` [PATCH 3/4] xfs: go straight to real allocations for direct I/O COW writes Christoph Hellwig
2017-02-01 21:42 ` [PATCH 4/4] xfs: allocate direct I/O COW blocks in iomap_begin Christoph Hellwig
2017-02-03 0:55 ` Darrick J. Wong
2017-02-03 10:53 ` Christoph Hellwig
2017-02-05 20:13 ` 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=20170202225629.GO9134@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=hch@lst.de \
--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;
as well as URLs for NNTP newsgroup(s).