From: "Darrick J. Wong" <djwong@kernel.org>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/4] xfs: drop submit side trans alloc for append ioends
Date: Wed, 7 Apr 2021 08:31:52 -0700 [thread overview]
Message-ID: <20210407153152.GI3957620@magnolia> (raw)
In-Reply-To: <20210405145903.629152-2-bfoster@redhat.com>
On Mon, Apr 05, 2021 at 10:59:00AM -0400, Brian Foster wrote:
> Per-inode ioend completion batching has a log reservation deadlock
> vector between preallocated append transactions and transactions
> that are acquired at completion time for other purposes (i.e.,
> unwritten extent conversion or COW fork remaps). For example, if the
> ioend completion workqueue task executes on a batch of ioends that
> are sorted such that an append ioend sits at the tail, it's possible
> for the outstanding append transaction reservation to block
> allocation of transactions required to process preceding ioends in
> the list.
>
> Append ioend completion is historically the common path for on-disk
> inode size updates. While file extending writes may have completed
> sometime earlier, the on-disk inode size is only updated after
> successful writeback completion. These transactions are preallocated
> serially from writeback context to mitigate concurrency and
> associated log reservation pressure across completions processed by
> multi-threaded workqueue tasks.
>
> However, now that delalloc blocks unconditionally map to unwritten
> extents at physical block allocation time, size updates via append
> ioends are relatively rare. This means that inode size updates most
> commonly occur as part of the preexisting completion time
> transaction to convert unwritten extents. As a result, there is no
> longer a strong need to preallocate size update transactions.
>
> Remove the preallocation of inode size update transactions to avoid
> the ioend completion processing log reservation deadlock. Instead,
> continue to send all potential size extending ioends to workqueue
> context for completion and allocate the transaction from that
> context. This ensures that no outstanding log reservation is owned
> by the ioend completion worker task when it begins to process
> ioends.
>
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
> fs/xfs/xfs_aops.c | 45 +++------------------------------------------
> 1 file changed, 3 insertions(+), 42 deletions(-)
>
> diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
> index 1cc7c36d98e9..c1951975bd6a 100644
> --- a/fs/xfs/xfs_aops.c
> +++ b/fs/xfs/xfs_aops.c
> @@ -39,33 +39,6 @@ static inline bool xfs_ioend_is_append(struct iomap_ioend *ioend)
> XFS_I(ioend->io_inode)->i_d.di_size;
> }
>
> -STATIC int
> -xfs_setfilesize_trans_alloc(
> - struct iomap_ioend *ioend)
> -{
> - struct xfs_mount *mp = XFS_I(ioend->io_inode)->i_mount;
> - struct xfs_trans *tp;
> - int error;
> -
> - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp);
> - if (error)
> - return error;
> -
> - ioend->io_private = tp;
> -
> - /*
> - * We may pass freeze protection with a transaction. So tell lockdep
> - * we released it.
> - */
> - __sb_writers_release(ioend->io_inode->i_sb, SB_FREEZE_FS);
> - /*
> - * We hand off the transaction to the completion thread now, so
> - * clear the flag here.
> - */
> - xfs_trans_clear_context(tp);
> - return 0;
> -}
> -
> /*
> * Update on-disk file size now that data has been written to disk.
> */
> @@ -182,12 +155,10 @@ xfs_end_ioend(
> error = xfs_reflink_end_cow(ip, offset, size);
Seems reasonable to me. xfs_reflink_end_cow_extent should probably
learn how to extend the ondisk EOF as patch 6/4.
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> else if (ioend->io_type == IOMAP_UNWRITTEN)
> error = xfs_iomap_write_unwritten(ip, offset, size, false);
> - else
> - ASSERT(!xfs_ioend_is_append(ioend) || ioend->io_private);
>
> done:
> - if (ioend->io_private)
> - error = xfs_setfilesize_ioend(ioend, error);
> + if (!error && xfs_ioend_is_append(ioend))
> + error = xfs_setfilesize(ip, ioend->io_offset, ioend->io_size);
> iomap_finish_ioends(ioend, error);
> memalloc_nofs_restore(nofs_flag);
> }
> @@ -237,7 +208,7 @@ xfs_end_io(
>
> static inline bool xfs_ioend_needs_workqueue(struct iomap_ioend *ioend)
> {
> - return ioend->io_private ||
> + return xfs_ioend_is_append(ioend) ||
> ioend->io_type == IOMAP_UNWRITTEN ||
> (ioend->io_flags & IOMAP_F_SHARED);
> }
> @@ -250,8 +221,6 @@ xfs_end_bio(
> struct xfs_inode *ip = XFS_I(ioend->io_inode);
> unsigned long flags;
>
> - ASSERT(xfs_ioend_needs_workqueue(ioend));
> -
> spin_lock_irqsave(&ip->i_ioend_lock, flags);
> if (list_empty(&ip->i_ioend_list))
> WARN_ON_ONCE(!queue_work(ip->i_mount->m_unwritten_workqueue,
> @@ -501,14 +470,6 @@ xfs_prepare_ioend(
> ioend->io_offset, ioend->io_size);
> }
>
> - /* Reserve log space if we might write beyond the on-disk inode size. */
> - if (!status &&
> - ((ioend->io_flags & IOMAP_F_SHARED) ||
> - ioend->io_type != IOMAP_UNWRITTEN) &&
> - xfs_ioend_is_append(ioend) &&
> - !ioend->io_private)
> - status = xfs_setfilesize_trans_alloc(ioend);
> -
> memalloc_nofs_restore(nofs_flag);
>
> if (xfs_ioend_needs_workqueue(ioend))
> --
> 2.26.3
>
next prev parent reply other threads:[~2021-04-07 15:31 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-05 14:58 [PATCH 0/4] xfs: ioend batching log reservation deadlock Brian Foster
2021-04-05 14:59 ` [PATCH 1/4] xfs: drop submit side trans alloc for append ioends Brian Foster
2021-04-07 6:33 ` Christoph Hellwig
2021-04-07 11:23 ` Brian Foster
2021-04-07 15:31 ` Darrick J. Wong [this message]
2021-04-09 13:47 ` Brian Foster
2021-04-09 16:07 ` Darrick J. Wong
2021-04-05 14:59 ` [PATCH 2/4] xfs: open code ioend needs workqueue helper Brian Foster
2021-04-07 6:34 ` Christoph Hellwig
2021-04-07 11:24 ` Brian Foster
2021-04-07 15:23 ` Darrick J. Wong
2021-04-07 15:42 ` Darrick J. Wong
2021-04-05 14:59 ` [PATCH 3/4] xfs: drop unused ioend private merge and setfilesize code Brian Foster
2021-04-05 17:55 ` Christoph Hellwig
2021-04-05 18:08 ` Brian Foster
2021-04-07 6:36 ` Christoph Hellwig
2021-04-07 15:40 ` Darrick J. Wong
2021-04-05 14:59 ` [PATCH 4/4] xfs: drop unnecessary setfilesize helper Brian Foster
2021-04-07 6:37 ` Christoph Hellwig
2021-04-07 15:40 ` Darrick J. Wong
2021-04-06 10:27 ` [PATCH 5/4] iomap: remove unused private field from ioend Brian Foster
2021-04-07 6:40 ` Christoph Hellwig
2021-04-07 15:36 ` 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=20210407153152.GI3957620@magnolia \
--to=djwong@kernel.org \
--cc=bfoster@redhat.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).