From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 14/15] xfs: don't rely on extent indices in xfs_bmap_insert_extents
Date: Fri, 20 Oct 2017 17:27:14 -0700 [thread overview]
Message-ID: <20171021002714.GH4755@magnolia> (raw)
In-Reply-To: <20171019065942.18813-15-hch@lst.de>
On Thu, Oct 19, 2017 at 08:59:41AM +0200, Christoph Hellwig wrote:
> Rewrite xfs_bmap_insert_extents so that we don't rely on extent indices
> except for iterating over them. Not being able to iterate to the previous
> extent or finding the extent that stop_fsb is in are sufficient exit
> conditions, and we don't need to do any extent count games given that:
>
> a) we already flushed all delalloc extents past our start offset
> before doing the operation
> b) xfs_iext_count() includes delalloc extents anyway
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> fs/xfs/libxfs/xfs_bmap.c | 47 +++++++++--------------------------------------
> 1 file changed, 9 insertions(+), 38 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 4c89fdacda90..9b638cc49f5c 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -5726,10 +5726,8 @@ xfs_bmap_insert_extents(
> struct xfs_mount *mp = ip->i_mount;
> struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
> struct xfs_btree_cur *cur = NULL;
> - struct xfs_bmbt_irec got, next, s;
> + struct xfs_bmbt_irec got, next;
> xfs_extnum_t current_ext;
> - xfs_extnum_t total_extents;
> - xfs_extnum_t stop_extent;
> xfs_fileoff_t new_startoff;
> int error = 0;
> int logflags = 0;
> @@ -5760,37 +5758,14 @@ xfs_bmap_insert_extents(
> cur->bc_private.b.flags = 0;
> }
>
> - /*
> - * There may be delalloc extents in the data fork before the range we
> - * are collapsing out, so we cannot use the count of real extents here.
> - * Instead we have to calculate it from the incore fork.
> - */
> - total_extents = xfs_iext_count(ifp);
> - if (total_extents == 0) {
> - *done = true;
> - goto del_cursor;
> - }
> -
> - /*
> - * In case of first right shift, we need to initialize next_fsb
> - */
> if (*next_fsb == NULLFSBLOCK) {
> - current_ext = total_extents - 1;
> - xfs_iext_get_extent(ifp, current_ext, &got);
> - if (stop_fsb > got.br_startoff) {
> + current_ext = xfs_iext_count(ifp) - 1;
> + if (!xfs_iext_get_extent(ifp, current_ext, &got) ||
> + stop_fsb > got.br_startoff) {
> *done = true;
> goto del_cursor;
> }
> - *next_fsb = got.br_startoff;
> } else {
> - /*
> - * Look up the extent index for the fsb where we start shifting. We can
> - * henceforth iterate with current_ext as extent list changes are locked
> - * out via ilock.
> - *
> - * If next_fsb lies in a hole beyond which there are no extents we are
> - * done.
> - */
> if (!xfs_iext_lookup_extent(ip, ifp, *next_fsb, ¤t_ext,
> &got)) {
> *done = true;
> @@ -5799,18 +5774,13 @@ xfs_bmap_insert_extents(
> }
> XFS_WANT_CORRUPTED_RETURN(mp, !isnullstartblock(got.br_startblock));
>
> - /* Lookup the extent index at which we have to stop */
> - xfs_iext_lookup_extent(ip, ifp, stop_fsb, &stop_extent, &s);
> - /* Make stop_extent exclusive of shift range */
> - stop_extent--;
> - if (current_ext <= stop_extent) {
> + if (stop_fsb >= got.br_startoff + got.br_blockcount) {
> error = -EIO;
> goto del_cursor;
> }
>
> new_startoff = got.br_startoff + offset_shift_fsb;
> - if (current_ext < total_extents - 1) {
> - xfs_iext_get_extent(ifp, current_ext + 1, &next);
> + if (xfs_iext_get_extent(ifp, current_ext + 1, &next)) {
> if (new_startoff + got.br_blockcount > next.br_startoff) {
> error = -EINVAL;
> goto del_cursor;
> @@ -5830,11 +5800,12 @@ xfs_bmap_insert_extents(
> cur, &logflags, dfops, new_startoff);
> if (error)
> goto del_cursor;
> - if (--current_ext == stop_extent) {
> +
> + if (!xfs_iext_get_extent(ifp, --current_ext, &got) ||
> + stop_fsb >= got.br_startoff + got.br_blockcount) {
> *done = true;
> goto del_cursor;
> }
> - xfs_iext_get_extent(ifp, current_ext, &got);
>
> *next_fsb = got.br_startoff;
> del_cursor:
> --
> 2.14.1
>
> --
> 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-10-21 0:27 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-19 6:59 more extent mapping cleanups Christoph Hellwig
2017-10-19 6:59 ` [PATCH 01/15] xfs: add a xfs_bmap_fork_to_state helper Christoph Hellwig
2017-10-19 22:48 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 02/15] xfs: make better use of the 'state' variable in xfs_bmap_del_extent_real Christoph Hellwig
2017-10-19 22:49 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 03/15] xfs: remove post-bmap tracing in xfs_bmap_local_to_extents Christoph Hellwig
2017-10-19 22:49 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 04/15] xfs: move pre/post-bmap tracing into xfs_iext_update_extent Christoph Hellwig
2017-10-19 22:50 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 05/15] xfs: remove XFS_BMAP_TRACE_EXLIST Christoph Hellwig
2017-10-19 22:50 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 06/15] xfs: remove the never fully implemented UUID fork format Christoph Hellwig
2017-10-19 22:48 ` Darrick J. Wong
2017-10-20 7:02 ` Christoph Hellwig
2017-10-20 16:52 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 07/15] xfs: remove if_rdev Christoph Hellwig
2017-10-19 22:52 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 08/15] xfs: inline xfs_shift_file_space into callers Christoph Hellwig
2017-10-21 0:07 ` Darrick J. Wong
2017-10-21 8:13 ` Christoph Hellwig
2017-10-21 18:06 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 09/15] xfs: remove XFS_BMAP_MAX_SHIFT_EXTENTS Christoph Hellwig
2017-10-21 0:10 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 10/15] xfs: split xfs_bmap_shift_extents Christoph Hellwig
2017-10-21 0:22 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 11/15] xfs: remove xfs_bmse_shift_one Christoph Hellwig
2017-10-21 0:25 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 12/15] xfs: update got in xfs_bmap_shift_update_extent Christoph Hellwig
2017-10-21 0:25 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 13/15] xfs: don't rely on extent indices in xfs_bmap_collapse_extents Christoph Hellwig
2017-10-21 0:26 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 14/15] xfs: don't rely on extent indices in xfs_bmap_insert_extents Christoph Hellwig
2017-10-21 0:27 ` Darrick J. Wong [this message]
2017-10-19 6:59 ` [PATCH 15/15] xfs: rewrite xfs_bmap_first_unused to make better use of xfs_iext_get_extent Christoph Hellwig
2017-10-21 0:27 ` Darrick J. Wong
2017-10-19 20:04 ` more extent mapping cleanups Darrick J. Wong
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=20171021002714.GH4755@magnolia \
--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