From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Gao Xiang <hsiangkao@aol.com>
Cc: linux-xfs@vger.kernel.org, Gao Xiang <hsiangkao@redhat.com>
Subject: Re: [PATCH] xfs: drop the obsolete comment on filestream locking
Date: Wed, 23 Sep 2020 09:27:01 -0700 [thread overview]
Message-ID: <20200923162701.GQ7955@magnolia> (raw)
In-Reply-To: <20200922034249.20549-1-hsiangkao@aol.com>
On Tue, Sep 22, 2020 at 11:42:49AM +0800, Gao Xiang wrote:
> From: Gao Xiang <hsiangkao@redhat.com>
>
> Since commit 1c1c6ebcf52 ("xfs: Replace per-ag array with a radix
> tree"), there is no m_peraglock anymore, so it's hard to understand
> the described situation since per-ag is no longer an array and no
> need to reallocate, call xfs_filestream_flush() in growfs.
>
> In addition, the race condition for shrink feature is quite confusing
> to me currently as well. Get rid of it instead.
>
> Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
I'm convinced by the discussion, so:
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/xfs_filestream.c | 34 +---------------------------------
> 1 file changed, 1 insertion(+), 33 deletions(-)
>
> diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
> index 1a88025e68a3..db23e455eb91 100644
> --- a/fs/xfs/xfs_filestream.c
> +++ b/fs/xfs/xfs_filestream.c
> @@ -33,39 +33,7 @@ enum xfs_fstrm_alloc {
> /*
> * Allocation group filestream associations are tracked with per-ag atomic
> * counters. These counters allow xfs_filestream_pick_ag() to tell whether a
> - * particular AG already has active filestreams associated with it. The mount
> - * point's m_peraglock is used to protect these counters from per-ag array
> - * re-allocation during a growfs operation. When xfs_growfs_data_private() is
> - * about to reallocate the array, it calls xfs_filestream_flush() with the
> - * m_peraglock held in write mode.
> - *
> - * Since xfs_mru_cache_flush() guarantees that all the free functions for all
> - * the cache elements have finished executing before it returns, it's safe for
> - * the free functions to use the atomic counters without m_peraglock protection.
> - * This allows the implementation of xfs_fstrm_free_func() to be agnostic about
> - * whether it was called with the m_peraglock held in read mode, write mode or
> - * not held at all. The race condition this addresses is the following:
> - *
> - * - The work queue scheduler fires and pulls a filestream directory cache
> - * element off the LRU end of the cache for deletion, then gets pre-empted.
> - * - A growfs operation grabs the m_peraglock in write mode, flushes all the
> - * remaining items from the cache and reallocates the mount point's per-ag
> - * array, resetting all the counters to zero.
> - * - The work queue thread resumes and calls the free function for the element
> - * it started cleaning up earlier. In the process it decrements the
> - * filestreams counter for an AG that now has no references.
> - *
> - * With a shrinkfs feature, the above scenario could panic the system.
> - *
> - * All other uses of the following macros should be protected by either the
> - * m_peraglock held in read mode, or the cache's internal locking exposed by the
> - * interval between a call to xfs_mru_cache_lookup() and a call to
> - * xfs_mru_cache_done(). In addition, the m_peraglock must be held in read mode
> - * when new elements are added to the cache.
> - *
> - * Combined, these locking rules ensure that no associations will ever exist in
> - * the cache that reference per-ag array elements that have since been
> - * reallocated.
> + * particular AG already has active filestreams associated with it.
> */
> int
> xfs_filestream_peek_ag(
> --
> 2.24.0
>
prev parent reply other threads:[~2020-09-23 16:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200922034249.20549-1-hsiangkao.ref@aol.com>
2020-09-22 3:42 ` [PATCH] xfs: drop the obsolete comment on filestream locking Gao Xiang
2020-09-22 4:44 ` Gao Xiang
2020-09-22 16:03 ` Darrick J. Wong
2020-09-22 16:23 ` Gao Xiang
2020-09-22 16:40 ` Darrick J. Wong
2020-09-22 21:26 ` Dave Chinner
2020-09-23 0:21 ` Gao Xiang
2020-09-23 7:05 ` Christoph Hellwig
2020-09-23 16:27 ` Darrick J. Wong [this message]
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=20200923162701.GQ7955@magnolia \
--to=darrick.wong@oracle.com \
--cc=hsiangkao@aol.com \
--cc=hsiangkao@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