Re: [PATCH v2] fs: don't flush in-flight wb switches for superblocks without cgroup writeback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri 26-07-24 11:05:25, 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@xxxxxxxxxx>
> Suggested-by: Jan Kara <jack@xxxxxxx>

Looks good! Thanks! Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

								Honza

> ---
> Changes since v1:
> - do the check in cgroup_writeback_umount().
> - check the capabilities of bdi.
> ---
>  fs/fs-writeback.c         | 6 +++++-
>  fs/super.c                | 2 +-
>  include/linux/writeback.h | 4 ++--
>  3 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 92a5b8283528..09facd4356d9 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -1140,8 +1140,12 @@ int cgroup_writeback_by_id(u64 bdi_id, int memcg_id,
>   * rare occurrences and synchronize_rcu() can take a while, perform
>   * flushing iff wb switches are in flight.
>   */
> -void cgroup_writeback_umount(void)
> +void cgroup_writeback_umount(struct super_block *sb)
>  {
> +
> +	if (!(sb->s_bdi->capabilities & BDI_CAP_WRITEBACK))
> +		return;
> +
>  	/*
>  	 * SB_ACTIVE should be reliably cleared before checking
>  	 * isw_nr_in_flight, see generic_shutdown_super().
> diff --git a/fs/super.c b/fs/super.c
> index 095ba793e10c..acc16450da0e 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -621,7 +621,7 @@ void generic_shutdown_super(struct super_block *sb)
>  		sync_filesystem(sb);
>  		sb->s_flags &= ~SB_ACTIVE;
>  
> -		cgroup_writeback_umount();
> +		cgroup_writeback_umount(sb);
>  
>  		/* Evict all inodes with zero refcount. */
>  		evict_inodes(sb);
> diff --git a/include/linux/writeback.h b/include/linux/writeback.h
> index 112d806ddbe4..d78d3dce4ede 100644
> --- a/include/linux/writeback.h
> +++ b/include/linux/writeback.h
> @@ -217,7 +217,7 @@ void wbc_account_cgroup_owner(struct writeback_control *wbc, struct page *page,
>  			      size_t bytes);
>  int cgroup_writeback_by_id(u64 bdi_id, int memcg_id,
>  			   enum wb_reason reason, struct wb_completion *done);
> -void cgroup_writeback_umount(void);
> +void cgroup_writeback_umount(struct super_block *sb);
>  bool cleanup_offline_cgwb(struct bdi_writeback *wb);
>  
>  /**
> @@ -324,7 +324,7 @@ static inline void wbc_account_cgroup_owner(struct writeback_control *wbc,
>  {
>  }
>  
> -static inline void cgroup_writeback_umount(void)
> +static inline void cgroup_writeback_umount(struct super_block *sb)
>  {
>  }
>  
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux