Linux filesystem development
 help / color / mirror / Atom feed
From: Haifeng Xu <haifeng.xu@shopee.com>
To: Jan Kara <jack@suse.cz>
Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, tj@kernel.org,
	axboe@kernel.dk, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: don't flush in-flight wb switches for superblocks without cgroup writeback
Date: Fri, 26 Jul 2024 09:55:26 +0800	[thread overview]
Message-ID: <ed6f4fc6-bde5-4b04-badc-c4927334f766@shopee.com> (raw)
In-Reply-To: <20240725084232.bj7apjqqowae575c@quack3>

             

On 2024/7/25 16:42, Jan Kara wrote:
> On Thu 25-07-24 10:39:58, Haifeng Xu wrote:
>> When deactivating any type of superblock, it had to wait for the in-flight
>> wb switches to be completed. wb switches are executed in inode_switch_wbs_work_fn()
>> which needs to acquire the wb_switch_rwsem and races against sync_inodes_sb().
>> If there are too much dirty data in the superblock, the waiting time may increase
>> significantly.
>>
>> For superblocks without cgroup writeback such as tmpfs, they have nothing to
>> do with the wb swithes, so the flushing can be avoided.
>>
>> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
>> ---
>>  fs/super.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/super.c b/fs/super.c
>> index 095ba793e10c..f846f853e957 100644
>> --- a/fs/super.c
>> +++ b/fs/super.c
>> @@ -621,7 +621,8 @@ void generic_shutdown_super(struct super_block *sb)
>>  		sync_filesystem(sb);
>>  		sb->s_flags &= ~SB_ACTIVE;
>>  
>> -		cgroup_writeback_umount();
>> +		if (sb->s_bdi != &noop_backing_dev_info)
>> +			cgroup_writeback_umount();
> 
> So a more obvious check would be:
> 
> 		if (sb->s_bdi->capabilities & BDI_CAP_WRITEBACK)
> 
> even better would be if we'd pass 'sb' into cgroup_writeback_umount() and
> that function would do this check inside so that callers don't have to
> bother... I know there is only one caller so this is not a huge deal but
> still I'd find it cleaner that way.
> 
> 								Honza
> 

Yes, Thanks for you suggestions!

  reply	other threads:[~2024-07-26  1:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-25  2:39 [PATCH] fs: don't flush in-flight wb switches for superblocks without cgroup writeback Haifeng Xu
2024-07-25  8:42 ` Jan Kara
2024-07-26  1:55   ` Haifeng Xu [this message]
2024-07-26  3:05   ` [PATCH v2] " Haifeng Xu
2024-07-26  7:09     ` Christian Brauner
2024-07-29 11:10     ` Jan Kara

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=ed6f4fc6-bde5-4b04-badc-c4927334f766@shopee.com \
    --to=haifeng.xu@shopee.com \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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