From: Qi Zheng <qi.zheng@linux.dev>
To: Dave Chinner <david@fromorbit.com>
Cc: akpm@linux-foundation.org, tkhai@ya.ru, roman.gushchin@linux.dev,
vbabka@suse.cz, viro@zeniv.linux.org.uk, brauner@kernel.org,
djwong@kernel.org, hughd@google.com, paulmck@kernel.org,
muchun.song@linux.dev, linux-mm@kvack.org,
linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
linux-kernel@vger.kernel.org,
Qi Zheng <zhengqi.arch@bytedance.com>
Subject: Re: [PATCH 6/8] xfs: introduce xfs_fs_destroy_super()
Date: Thu, 1 Jun 2023 16:43:32 +0800 [thread overview]
Message-ID: <b85c0d63-f6a5-73c4-e574-163b0b07d80a@linux.dev> (raw)
In-Reply-To: <ZHfc3V4KKmW8QTR2@dread.disaster.area>
Hi Dave,
On 2023/6/1 07:48, Dave Chinner wrote:
> On Wed, May 31, 2023 at 09:57:40AM +0000, Qi Zheng wrote:
>> From: Kirill Tkhai <tkhai@ya.ru>
>>
>> xfs_fs_nr_cached_objects() touches sb->s_fs_info,
>> and this patch makes it to be destructed later.
>>
>> After this patch xfs_fs_nr_cached_objects() is safe
>> for splitting unregister_shrinker(): mp->m_perag_tree
>> is stable till destroy_super_work(), while iteration
>> over it is already RCU-protected by internal XFS
>> business.
>>
>> Signed-off-by: Kirill Tkhai <tkhai@ya.ru>
>> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
>> ---
>> fs/xfs/xfs_super.c | 25 ++++++++++++++++++++++---
>> 1 file changed, 22 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
>> index 7e706255f165..694616524c76 100644
>> --- a/fs/xfs/xfs_super.c
>> +++ b/fs/xfs/xfs_super.c
>> @@ -743,11 +743,18 @@ xfs_fs_drop_inode(
>> }
>>
>> static void
>> -xfs_mount_free(
>> +xfs_free_names(
>> struct xfs_mount *mp)
>> {
>> kfree(mp->m_rtname);
>> kfree(mp->m_logname);
>> +}
>> +
>> +static void
>> +xfs_mount_free(
>> + struct xfs_mount *mp)
>> +{
>> + xfs_free_names(mp);
>> kmem_free(mp);
>> }
>>
>> @@ -1136,8 +1143,19 @@ xfs_fs_put_super(
>> xfs_destroy_mount_workqueues(mp);
>> xfs_close_devices(mp);
>>
>> - sb->s_fs_info = NULL;
>> - xfs_mount_free(mp);
>> + xfs_free_names(mp);
>> +}
>> +
>> +static void
>> +xfs_fs_destroy_super(
>> + struct super_block *sb)
>> +{
>> + if (sb->s_fs_info) {
>> + struct xfs_mount *mp = XFS_M(sb);
>> +
>> + kmem_free(mp);
>> + sb->s_fs_info = NULL;
>> + }
>> }
>>
>> static long
>> @@ -1165,6 +1183,7 @@ static const struct super_operations xfs_super_operations = {
>> .dirty_inode = xfs_fs_dirty_inode,
>> .drop_inode = xfs_fs_drop_inode,
>> .put_super = xfs_fs_put_super,
>> + .destroy_super = xfs_fs_destroy_super,
>> .sync_fs = xfs_fs_sync_fs,
>> .freeze_fs = xfs_fs_freeze,
>> .unfreeze_fs = xfs_fs_unfreeze,
>
> I don't really like this ->destroy_super() callback, especially as
> it's completely undocumented as to why it exists. This is purely a
> work-around for handling extended filesystem superblock shrinker
> functionality, yet there's nothing that tells the reader this.
>
> It also seems to imply that the superblock shrinker can continue to
> run after the existing unregister_shrinker() call before ->kill_sb()
> is called. This violates the assumption made in filesystems that the
> superblock shrinkers have been stopped and will never run again
> before ->kill_sb() is called. Hence ->kill_sb() implementations
> assume there is nothing else accessing filesystem owned structures
> and it can tear down internal structures safely.
>
> Realistically, the days of XFS using this superblock shrinker
> extension are numbered. We've got a lot of the infrastructure we
> need in place to get rid of the background inode reclaim
> infrastructure that requires this shrinker extension, and it's on my
> list of things that need to be addressed in the near future.
>
> In fact, now that I look at it, I think the shmem usage of this
> superblock shrinker interface is broken - it returns SHRINK_STOP to
> ->free_cached_objects(), but the only valid return value is the
> number of objects freed (i.e. 0 is nothing freed). These special
> superblock extension interfaces do not work like a normal
> shrinker....
>
> Hence I think the shmem usage should be replaced with an separate
> internal shmem shrinker that is managed by the filesystem itself
> (similar to how XFS has multiple internal shrinkers).
>
> At this point, then the only user of this interface is (again) XFS.
> Given this, adding new VFS methods for a single filesystem
> for functionality that is planned to be removed is probably not the
> best approach to solving the problem.
Thanks for such a detailed analysis. Kirill Tkhai just proposeed a
new method[1], I cc'd you on the email.
[1].
https://lore.kernel.org/lkml/bab60fe4-964c-43a6-ecce-4cbd4981d875@ya.ru/
Thanks,
Qi
>
> Cheers,
>
> Dave.
next prev parent reply other threads:[~2023-06-01 8:43 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 9:57 [PATCH 0/8] make unregistration of super_block shrinker more faster Qi Zheng
2023-05-31 9:57 ` [PATCH 1/8] mm: vmscan: move shrinker_debugfs_remove() before synchronize_srcu() Qi Zheng
2023-05-31 10:49 ` Christian Brauner
2023-05-31 12:52 ` Qi Zheng
2023-05-31 9:57 ` [PATCH 2/8] mm: vmscan: split unregister_shrinker() Qi Zheng
2023-05-31 22:57 ` Dave Chinner
2023-05-31 9:57 ` [PATCH 3/8] fs: move list_lru_destroy() to destroy_super_work() Qi Zheng
2023-05-31 23:00 ` Dave Chinner
2023-05-31 9:57 ` [PATCH 4/8] fs: shrink only (SB_ACTIVE|SB_BORN) superblocks in super_cache_scan() Qi Zheng
2023-05-31 23:12 ` Dave Chinner
2023-05-31 9:57 ` [PATCH 5/8] fs: introduce struct super_operations::destroy_super() callback Qi Zheng
2023-05-31 11:19 ` Christian Brauner
2023-05-31 12:54 ` Qi Zheng
2023-05-31 9:57 ` [PATCH 6/8] xfs: introduce xfs_fs_destroy_super() Qi Zheng
2023-05-31 23:48 ` Dave Chinner
2023-06-01 8:43 ` Qi Zheng [this message]
2023-06-01 9:58 ` Christian Brauner
2023-06-01 23:06 ` Dave Chinner
2023-06-02 3:13 ` Qi Zheng
2023-06-02 15:15 ` Darrick J. Wong
2023-06-05 11:50 ` Christian Brauner
2023-06-05 12:16 ` Qi Zheng
2023-05-31 9:57 ` [PATCH 7/8] shmem: implement shmem_destroy_super() Qi Zheng
2023-05-31 9:57 ` [PATCH 8/8] fs: use unregister_shrinker_delayed_{initiate, finalize} for super_block shrinker Qi Zheng
[not found] ` <20230531114054.bf077db642aa9c58c0831687@linux-foundation.org>
2023-06-01 8:46 ` [PATCH 0/8] make unregistration of super_block shrinker more faster Qi Zheng
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=b85c0d63-f6a5-73c4-e574-163b0b07d80a@linux.dev \
--to=qi.zheng@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=hughd@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=muchun.song@linux.dev \
--cc=paulmck@kernel.org \
--cc=roman.gushchin@linux.dev \
--cc=tkhai@ya.ru \
--cc=vbabka@suse.cz \
--cc=viro@zeniv.linux.org.uk \
--cc=zhengqi.arch@bytedance.com \
/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