All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH V3 4/5] ext4: get discard out of jbd2 commit kthread contex
@ 2021-07-26 20:30 kernel test robot
  0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2021-07-26 20:30 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 9859 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210724074124.25731-5-jianchao.wan9@gmail.com>
References: <20210724074124.25731-5-jianchao.wan9@gmail.com>
TO: Wang Jianchao <jianchao.wan9@gmail.com>
TO: linux-ext4(a)vger.kernel.org
TO: linux-kernel(a)vger.kernel.org
CC: tytso(a)mit.edu
CC: adilger.kernel(a)dilger.ca

Hi Wang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ext4/dev]
[also build test WARNING on linux/master linus/master v5.14-rc3 next-20210723]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Wang-Jianchao/ext4-get-discard-out-of-jbd2-commit-context/20210724-154426
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: mips-randconfig-s031-20210726 (attached as .config)
compiler: mips-linux-gcc (GCC) 10.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/0day-ci/linux/commit/c1714c046fe748ad2324623d650c2dfe5b3b7a55
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Wang-Jianchao/ext4-get-discard-out-of-jbd2-commit-context/20210724-154426
        git checkout c1714c046fe748ad2324623d650c2dfe5b3b7a55
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=mips SHELL=/bin/bash fs/ext4/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
   command-line: note: in included file:
   builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_ACQUIRE redefined
   builtin:0:0: sparse: this was the original definition
   builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_SEQ_CST redefined
   builtin:0:0: sparse: this was the original definition
   builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_ACQ_REL redefined
   builtin:0:0: sparse: this was the original definition
   builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_RELEASE redefined
   builtin:0:0: sparse: this was the original definition
   fs/ext4/mballoc.c:994:9: sparse: sparse: context imbalance in 'ext4_mb_choose_next_group_cr1' - wrong count at exit
   fs/ext4/mballoc.c:1264:9: sparse: sparse: context imbalance in 'ext4_mb_init_cache' - different lock contexts for basic block
   fs/ext4/mballoc.c:2168:5: sparse: sparse: context imbalance in 'ext4_mb_try_best_found' - different lock contexts for basic block
   fs/ext4/mballoc.c:2196:5: sparse: sparse: context imbalance in 'ext4_mb_find_by_goal' - different lock contexts for basic block
   fs/ext4/mballoc.c:2483:12: sparse: sparse: context imbalance in 'ext4_mb_good_group_nolock' - wrong count at exit
   fs/ext4/mballoc.c:2698:87: sparse: sparse: context imbalance in 'ext4_mb_regular_allocator' - different lock contexts for basic block
   fs/ext4/mballoc.c:2972:13: sparse: sparse: context imbalance in 'ext4_mb_seq_structs_summary_start' - wrong count at exit
   fs/ext4/mballoc.c:3044:13: sparse: sparse: context imbalance in 'ext4_mb_seq_structs_summary_stop' - unexpected unlock
>> fs/ext4/mballoc.c:3333:9: sparse: sparse: context imbalance in 'ext4_discard_work' - different lock contexts for basic block
   fs/ext4/mballoc.c:3542:17: sparse: sparse: context imbalance in 'ext4_mb_release' - different lock contexts for basic block
   fs/ext4/mballoc.c:3662:26: sparse: sparse: context imbalance in 'ext4_free_data_in_buddy' - wrong count at exit
   fs/ext4/mballoc.c:3873:15: sparse: sparse: context imbalance in 'ext4_mb_mark_diskspace_used' - different lock contexts for basic block
   fs/ext4/mballoc.c:3881:6: sparse: sparse: context imbalance in 'ext4_mb_mark_bb' - different lock contexts for basic block
   fs/ext4/mballoc.c:4203:13: sparse: sparse: context imbalance in 'ext4_discard_allocated_blocks' - different lock contexts for basic block
   fs/ext4/mballoc.c:4505:13: sparse: sparse: context imbalance in 'ext4_mb_put_pa' - different lock contexts for basic block
   fs/ext4/mballoc.c:4842:9: sparse: sparse: context imbalance in 'ext4_mb_discard_group_preallocations' - different lock contexts for basic block
   fs/ext4/mballoc.c:4995:9: sparse: sparse: context imbalance in 'ext4_discard_preallocations' - different lock contexts for basic block
   fs/ext4/mballoc.c:5062:9: sparse: sparse: context imbalance in 'ext4_mb_show_ac' - different lock contexts for basic block
   fs/ext4/mballoc.c:5290:9: sparse: sparse: context imbalance in 'ext4_mb_discard_lg_preallocations' - different lock contexts for basic block
   fs/ext4/mballoc.c:5062:9: sparse: sparse: context imbalance in 'ext4_mb_new_blocks' - different lock contexts for basic block
   fs/ext4/mballoc.c:5935:9: sparse: sparse: context imbalance in 'ext4_free_blocks' - different lock contexts for basic block
   fs/ext4/mballoc.c:6235:15: sparse: sparse: context imbalance in 'ext4_group_add_blocks' - different lock contexts for basic block
   fs/ext4/mballoc.c:6275:24: sparse: sparse: context imbalance in 'ext4_trim_extent' - wrong count at exit
   fs/ext4/mballoc.c:6325:9: sparse: sparse: context imbalance in 'ext4_try_to_trim_range' - different lock contexts for basic block
   fs/ext4/mballoc.c:6342:1: sparse: sparse: context imbalance in 'ext4_trim_all_free' - different lock contexts for basic block
   fs/ext4/mballoc.c:6471:1: sparse: sparse: context imbalance in 'ext4_mballoc_query_range' - different lock contexts for basic block

vim +/ext4_discard_work +3333 fs/ext4/mballoc.c

2892c15ddda6a7 Eric Sandeen  2011-02-12  3315  
c1714c046fe748 Wang Jianchao 2021-07-24  3316  static void ext4_discard_work(struct work_struct *work)
c1714c046fe748 Wang Jianchao 2021-07-24  3317  {
c1714c046fe748 Wang Jianchao 2021-07-24  3318  	struct ext4_sb_info *sbi = container_of(work,
c1714c046fe748 Wang Jianchao 2021-07-24  3319  			struct ext4_sb_info, s_discard_work);
c1714c046fe748 Wang Jianchao 2021-07-24  3320  	struct super_block *sb = sbi->s_sb;
c1714c046fe748 Wang Jianchao 2021-07-24  3321  	struct ext4_free_data *fd, *nfd;
c1714c046fe748 Wang Jianchao 2021-07-24  3322  	struct ext4_buddy e4b;
c1714c046fe748 Wang Jianchao 2021-07-24  3323  	struct list_head discard_list;
c1714c046fe748 Wang Jianchao 2021-07-24  3324  	ext4_group_t grp, load_grp;
c1714c046fe748 Wang Jianchao 2021-07-24  3325  	int err = 0;
c1714c046fe748 Wang Jianchao 2021-07-24  3326  
c1714c046fe748 Wang Jianchao 2021-07-24  3327  	INIT_LIST_HEAD(&discard_list);
c1714c046fe748 Wang Jianchao 2021-07-24  3328  	spin_lock(&sbi->s_md_lock);
c1714c046fe748 Wang Jianchao 2021-07-24  3329  	list_splice_init(&sbi->s_discard_list, &discard_list);
c1714c046fe748 Wang Jianchao 2021-07-24  3330  	spin_unlock(&sbi->s_md_lock);
c1714c046fe748 Wang Jianchao 2021-07-24  3331  
c1714c046fe748 Wang Jianchao 2021-07-24  3332  	load_grp = UINT_MAX;
c1714c046fe748 Wang Jianchao 2021-07-24 @3333  	list_for_each_entry_safe(fd, nfd, &discard_list, efd_list) {
c1714c046fe748 Wang Jianchao 2021-07-24  3334  		/*
c1714c046fe748 Wang Jianchao 2021-07-24  3335  		 * If filesystem is umounting or no memory, give up the discard
c1714c046fe748 Wang Jianchao 2021-07-24  3336  		 */
c1714c046fe748 Wang Jianchao 2021-07-24  3337  		if ((sb->s_flags & SB_ACTIVE) && !err) {
c1714c046fe748 Wang Jianchao 2021-07-24  3338  			grp = fd->efd_group;
c1714c046fe748 Wang Jianchao 2021-07-24  3339  			if (grp != load_grp) {
c1714c046fe748 Wang Jianchao 2021-07-24  3340  				if (load_grp != UINT_MAX)
c1714c046fe748 Wang Jianchao 2021-07-24  3341  					ext4_mb_unload_buddy(&e4b);
c1714c046fe748 Wang Jianchao 2021-07-24  3342  
c1714c046fe748 Wang Jianchao 2021-07-24  3343  				err = ext4_mb_load_buddy(sb, grp, &e4b);
c1714c046fe748 Wang Jianchao 2021-07-24  3344  				if (err) {
c1714c046fe748 Wang Jianchao 2021-07-24  3345  					kmem_cache_free(ext4_free_data_cachep, fd);
c1714c046fe748 Wang Jianchao 2021-07-24  3346  					load_grp = UINT_MAX;
c1714c046fe748 Wang Jianchao 2021-07-24  3347  					continue;
c1714c046fe748 Wang Jianchao 2021-07-24  3348  				} else {
c1714c046fe748 Wang Jianchao 2021-07-24  3349  					load_grp = grp;
c1714c046fe748 Wang Jianchao 2021-07-24  3350  				}
c1714c046fe748 Wang Jianchao 2021-07-24  3351  			}
c1714c046fe748 Wang Jianchao 2021-07-24  3352  
c1714c046fe748 Wang Jianchao 2021-07-24  3353  			ext4_lock_group(sb, grp);
c1714c046fe748 Wang Jianchao 2021-07-24  3354  			ext4_try_to_trim_range(sb, &e4b, fd->efd_start_cluster,
c1714c046fe748 Wang Jianchao 2021-07-24  3355  						fd->efd_start_cluster + fd->efd_count - 1, 1);
c1714c046fe748 Wang Jianchao 2021-07-24  3356  			ext4_unlock_group(sb, grp);
c1714c046fe748 Wang Jianchao 2021-07-24  3357  		}
c1714c046fe748 Wang Jianchao 2021-07-24  3358  		kmem_cache_free(ext4_free_data_cachep, fd);
c1714c046fe748 Wang Jianchao 2021-07-24  3359  	}
c1714c046fe748 Wang Jianchao 2021-07-24  3360  
c1714c046fe748 Wang Jianchao 2021-07-24  3361  	if (load_grp != UINT_MAX)
c1714c046fe748 Wang Jianchao 2021-07-24  3362  		ext4_mb_unload_buddy(&e4b);
c1714c046fe748 Wang Jianchao 2021-07-24  3363  }
c1714c046fe748 Wang Jianchao 2021-07-24  3364  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 36123 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH V3 0/5] ext4: get discard out of jbd2 commit context
@ 2021-07-24  7:41 Wang Jianchao
  2021-07-24  7:41 ` [PATCH V3 4/5] ext4: get discard out of jbd2 commit kthread contex Wang Jianchao
  0 siblings, 1 reply; 7+ messages in thread
From: Wang Jianchao @ 2021-07-24  7:41 UTC (permalink / raw)
  To: linux-ext4, linux-kernel; +Cc: tytso, adilger.kernel

Hi all

This is the version 3 patch set that attempts to get discard out of the jbd2
commit kthread. When the user delete a lot data and cause discard flooding,
the jbd2 commit kthread can be blocked for very long time and then all of
the metadata operations are blocked due to no journal space.

The xfstest with following parameters,
MODULAR=0
TEST_DIR=/mnt/test
TEST_DEV=/dev/nbd37p1
SCRATCH_MNT=/mnt/scratch
SCRATCH_DEV=/dev/nbd37p2
MOUNT_OPTIONS="-o discard"
has passed. The result is consistent w/ or w/o this patch set.

There are 5 patches,

Patch 1 ~ 3, there are no functional changes in them, but just some preparation
for following patches

Patch 4 introduces a async kworker to do discard in fstrim fation which implements
the core idea of this patch set.

Patch 5 let the fallocate retry when err is ENOSPC. This fix the generic/371

Any comments are welcome ;)

V2 -> V3
 - Get rid of the per block group rb tree which carries freed entry. It is not neccesary
   because we have done aggregation when wait for journal commit. Just use a list
   to carry the free entries.

V1 -> V2
 - free the blocks back to mb buddy after commit and then do ftrim fashion discard

 fs/ext4/ext4.h    |   2 +
 fs/ext4/extents.c |   6 ++-
 fs/ext4/mballoc.c | 223 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
 3 files changed, 151 insertions(+), 80 deletions(-)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-08-26  8:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-26 20:30 [PATCH V3 4/5] ext4: get discard out of jbd2 commit kthread contex kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2021-07-24  7:41 [PATCH V3 0/5] ext4: get discard out of jbd2 commit context Wang Jianchao
2021-07-24  7:41 ` [PATCH V3 4/5] ext4: get discard out of jbd2 commit kthread contex Wang Jianchao
2021-08-04 15:45   ` Jan Kara
2021-08-26  7:15     ` Wang Jianchao
2021-08-12 19:46   ` Theodore Ts'o
2021-08-26  7:51     ` Wang Jianchao
2021-08-26  8:58       ` Wang Jianchao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.