From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/2] xfs: fix double ijoin in xfs_reflink_cancel_cow_range
Date: Fri, 9 Mar 2018 10:43:35 -0800 [thread overview]
Message-ID: <20180309184335.GG18989@magnolia> (raw)
In-Reply-To: <20180307091020.6186-3-david@fromorbit.com>
On Wed, Mar 07, 2018 at 08:10:20PM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> AN inode is joined to teh same transaction twice in
> xfs_reflink_cancel_cow_range() resulting in the following assert
> failure:
>
> [ 30.180485] XFS: Assertion failed: !(lip->li_flags & XFS_LI_TRANS), file: fs/xfs/xfs_trans.c, line: 740
> [ 30.183435] ------------[ cut here ]------------
> ......
> [ 30.209264] Call Trace:
> [ 30.209935] xfs_trans_add_item+0xcc/0xe0
> [ 30.210968] xfs_reflink_cancel_cow_blocks+0xab/0x290
> [ 30.212249] ? xfs_trans_reserve+0x1b4/0x2b0
> [ 30.213320] ? kmem_zone_alloc+0x61/0xe0
> [ 30.214321] xfs_reflink_cancel_cow_range+0xb2/0x1f0
> [ 30.215616] xfs_fs_destroy_inode+0x1bd/0x280
> [ 30.216757] dispose_list+0x35/0x40
> [ 30.217656] evict_inodes+0x132/0x160
> [ 30.218620] generic_shutdown_super+0x3a/0x110
> [ 30.219771] kill_block_super+0x21/0x50
> [ 30.220762] deactivate_locked_super+0x39/0x70
> [ 30.221909] cleanup_mnt+0x3b/0x70
> [ 30.222819] task_work_run+0x7f/0xa0
> [ 30.223762] exit_to_usermode_loop+0x9b/0xa0
> [ 30.224884] do_syscall_64+0x18f/0x1a0
>
> Fix it and document that the callers of
> xfs_reflink_cancel_cow_blocks() must have already joined the inode
> to the permanent transaction passed in.
>
> Signed-Off-By: Dave Chinner <dchinner@redhat.com>
> ---
> fs/xfs/xfs_reflink.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 8c16177b33d4..6225d1ea3fdb 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -552,6 +552,9 @@ xfs_reflink_trim_irec_to_next_cow(
> *
> * If cancel_real is true this function cancels all COW fork extents for the
> * inode; if cancel_real is false, real extents are not cleared.
> + *
> + * Caller must have already joined the inode to the current transaction. The
> + * inode will be joined to the transaction returned to the caller.
> */
> int
> xfs_reflink_cancel_cow_blocks(
> @@ -592,7 +595,6 @@ xfs_reflink_cancel_cow_blocks(
> if (error)
> break;
> } else if (del.br_state == XFS_EXT_UNWRITTEN || cancel_real) {
> - xfs_trans_ijoin(*tpp, ip, 0);
Looks ok, but...
> xfs_defer_init(&dfops, &firstfsb);
>
> /* Free the CoW orphan record. */
> @@ -1571,6 +1573,7 @@ xfs_reflink_clear_inode_flag(
Wait, what? Why are we messing with xfs_reflink_clear_inode_flag here?
(Shame on me for looking at patch 3 before patch 2.)
The comment update in patch 3 is fine (caller must ijoin, function will
ijoin if returning new transaction) but ... didn't this function already
do all this before this churn below?
--D
> * We didn't find any shared blocks so turn off the reflink flag.
> * First, get rid of any leftover CoW mappings.
> */
> + xfs_trans_ijoin(*tpp, ip, 0);
> error = xfs_reflink_cancel_cow_blocks(ip, tpp, 0, NULLFILEOFF, true);
> if (error)
> return error;
> @@ -1579,7 +1582,6 @@ xfs_reflink_clear_inode_flag(
> trace_xfs_reflink_unset_inode_flag(ip);
> ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> xfs_inode_clear_cowblocks_tag(ip);
> - xfs_trans_ijoin(*tpp, ip, 0);
> xfs_trans_log_inode(*tpp, ip, XFS_ILOG_CORE);
>
> return error;
> --
> 2.16.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:[~2018-03-09 18:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-07 9:10 [PATCH 0/2] xfs: fix transaction joining problems Dave Chinner
2018-03-07 9:10 ` [PATCH 1/2] xfs: fix double ijoin in xfs_inactive_symlink_rmt() Dave Chinner
2018-03-09 18:34 ` Darrick J. Wong
2018-03-07 9:10 ` [PATCH 2/2] xfs: fix double ijoin in xfs_reflink_cancel_cow_range Dave Chinner
2018-03-07 13:17 ` Christoph Hellwig
2018-03-07 21:07 ` Dave Chinner
2018-03-08 8:17 ` Christoph Hellwig
2018-03-09 18:43 ` Darrick J. Wong [this message]
2018-03-10 0:48 ` Dave Chinner
2018-03-07 9:19 ` [PATCH 3/2] xfs: fix double ijoin in xfs_reflink_clear_inode_flag() Dave Chinner
2018-03-09 18:39 ` 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=20180309184335.GG18989@magnolia \
--to=darrick.wong@oracle.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;
as well as URLs for NNTP newsgroup(s).