tree:
https://github.com/0day-ci/linux/commits/UPDATE-20200915-201414/Ye-Bin/ex...
head: be9ed3afd2b7b27b328283e3994e99b4f9694eb4
commit: be9ed3afd2b7b27b328283e3994e99b4f9694eb4 [1/1] ext4: Fix dead loop in
ext4_mb_new_blocks
config: x86_64-randconfig-a016-20200916 (attached as .config)
compiler: clang version 12.0.0 (
https://github.com/llvm/llvm-project
9e3842d60351f986d77dfe0a94f76e4fd895f188)
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
git checkout be9ed3afd2b7b27b328283e3994e99b4f9694eb4
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
> fs/ext4/mballoc.c:4245:1: warning: unused label 'out'
[-Wunused-label]
out:
^~~~
1 warning generated.
#
https://github.com/0day-ci/linux/commit/be9ed3afd2b7b27b328283e3994e99b4f...
git remote add linux-review
https://github.com/0day-ci/linux
git fetch --no-tags linux-review
UPDATE-20200915-201414/Ye-Bin/ext4-Fix-dead-loop-in-ext4_mb_new_blocks/20200914-184737
git checkout be9ed3afd2b7b27b328283e3994e99b4f9694eb4
vim +/out +4245 fs/ext4/mballoc.c
c9de560ded61fa Alex Tomas 2008-01-29 4142
c9de560ded61fa Alex Tomas 2008-01-29 4143 /*
c9de560ded61fa Alex Tomas 2008-01-29 4144 * releases all preallocations in
given group
c9de560ded61fa Alex Tomas 2008-01-29 4145 *
c9de560ded61fa Alex Tomas 2008-01-29 4146 * first, we need to decide discard
policy:
c9de560ded61fa Alex Tomas 2008-01-29 4147 * - when do we discard
c9de560ded61fa Alex Tomas 2008-01-29 4148 * 1) ENOSPC
c9de560ded61fa Alex Tomas 2008-01-29 4149 * - how many do we discard
c9de560ded61fa Alex Tomas 2008-01-29 4150 * 1) how many requested
c9de560ded61fa Alex Tomas 2008-01-29 4151 */
4ddfef7b41aebb Eric Sandeen 2008-04-29 4152 static noinline_for_stack int
4ddfef7b41aebb Eric Sandeen 2008-04-29 4153
ext4_mb_discard_group_preallocations(struct super_block *sb,
c9de560ded61fa Alex Tomas 2008-01-29 4154 ext4_group_t group, int
needed)
c9de560ded61fa Alex Tomas 2008-01-29 4155 {
c9de560ded61fa Alex Tomas 2008-01-29 4156 struct ext4_group_info *grp =
ext4_get_group_info(sb, group);
c9de560ded61fa Alex Tomas 2008-01-29 4157 struct buffer_head *bitmap_bh =
NULL;
c9de560ded61fa Alex Tomas 2008-01-29 4158 struct ext4_prealloc_space *pa,
*tmp;
c9de560ded61fa Alex Tomas 2008-01-29 4159 struct list_head list;
c9de560ded61fa Alex Tomas 2008-01-29 4160 struct ext4_buddy e4b;
c9de560ded61fa Alex Tomas 2008-01-29 4161 int err;
c9de560ded61fa Alex Tomas 2008-01-29 4162 int busy = 0;
c9de560ded61fa Alex Tomas 2008-01-29 4163 int free = 0;
c9de560ded61fa Alex Tomas 2008-01-29 4164
d3df14535f4a5b Ritesh Harjani 2020-05-10 4165 mb_debug(sb, "discard
preallocation for group %u\n", group);
c9de560ded61fa Alex Tomas 2008-01-29 4166 if
(list_empty(&grp->bb_prealloc_list))
bbc4ec77e9f9c7 Ritesh Harjani 2020-05-10 4167 goto out_dbg;
c9de560ded61fa Alex Tomas 2008-01-29 4168
574ca174c97f79 Theodore Ts'o 2008-07-11 4169 bitmap_bh =
ext4_read_block_bitmap(sb, group);
9008a58e5dcee0 Darrick J. Wong 2015-10-17 4170 if (IS_ERR(bitmap_bh)) {
9008a58e5dcee0 Darrick J. Wong 2015-10-17 4171 err = PTR_ERR(bitmap_bh);
54d3adbc29f0c7 Theodore Ts'o 2020-03-28 4172 ext4_error_err(sb, -err,
54d3adbc29f0c7 Theodore Ts'o 2020-03-28 4173 "Error %d
reading block bitmap for %u",
9008a58e5dcee0 Darrick J. Wong 2015-10-17 4174 err, group);
bbc4ec77e9f9c7 Ritesh Harjani 2020-05-10 4175 goto out_dbg;
c9de560ded61fa Alex Tomas 2008-01-29 4176 }
c9de560ded61fa Alex Tomas 2008-01-29 4177
c9de560ded61fa Alex Tomas 2008-01-29 4178 err = ext4_mb_load_buddy(sb,
group, &e4b);
ce89f46cb833f8 Aneesh Kumar K.V 2008-07-23 4179 if (err) {
9651e6b2e20648 Konstantin Khlebnikov 2017-05-21 4180 ext4_warning(sb, "Error %d
loading buddy information for %u",
9651e6b2e20648 Konstantin Khlebnikov 2017-05-21 4181 err, group);
ce89f46cb833f8 Aneesh Kumar K.V 2008-07-23 4182 put_bh(bitmap_bh);
bbc4ec77e9f9c7 Ritesh Harjani 2020-05-10 4183 goto out_dbg;
ce89f46cb833f8 Aneesh Kumar K.V 2008-07-23 4184 }
c9de560ded61fa Alex Tomas 2008-01-29 4185
c9de560ded61fa Alex Tomas 2008-01-29 4186 if (needed == 0)
7137d7a48e2213 Theodore Ts'o 2011-09-09 4187 needed =
EXT4_CLUSTERS_PER_GROUP(sb) + 1;
c9de560ded61fa Alex Tomas 2008-01-29 4188
c9de560ded61fa Alex Tomas 2008-01-29 4189 INIT_LIST_HEAD(&list);
c9de560ded61fa Alex Tomas 2008-01-29 4190 repeat:
c9de560ded61fa Alex Tomas 2008-01-29 4191 ext4_lock_group(sb, group);
07b5b8e1ac4004 Ritesh Harjani 2020-05-20 4192 this_cpu_inc(discard_pa_seq);
c9de560ded61fa Alex Tomas 2008-01-29 4193 list_for_each_entry_safe(pa, tmp,
c9de560ded61fa Alex Tomas 2008-01-29 4194 &grp->bb_prealloc_list,
pa_group_list) {
c9de560ded61fa Alex Tomas 2008-01-29 4195 spin_lock(&pa->pa_lock);
c9de560ded61fa Alex Tomas 2008-01-29 4196 if
(atomic_read(&pa->pa_count)) {
c9de560ded61fa Alex Tomas 2008-01-29 4197
spin_unlock(&pa->pa_lock);
c9de560ded61fa Alex Tomas 2008-01-29 4198 busy = 1;
c9de560ded61fa Alex Tomas 2008-01-29 4199 continue;
c9de560ded61fa Alex Tomas 2008-01-29 4200 }
c9de560ded61fa Alex Tomas 2008-01-29 4201 if (pa->pa_deleted) {
c9de560ded61fa Alex Tomas 2008-01-29 4202
spin_unlock(&pa->pa_lock);
c9de560ded61fa Alex Tomas 2008-01-29 4203 continue;
c9de560ded61fa Alex Tomas 2008-01-29 4204 }
c9de560ded61fa Alex Tomas 2008-01-29 4205
c9de560ded61fa Alex Tomas 2008-01-29 4206 /* seems this one can be freed
... */
27bc446e2def38 brookxu 2020-08-17 4207 ext4_mb_mark_pa_deleted(sb, pa);
c9de560ded61fa Alex Tomas 2008-01-29 4208
c9de560ded61fa Alex Tomas 2008-01-29 4209 /* we can trust pa_free ... */
c9de560ded61fa Alex Tomas 2008-01-29 4210 free += pa->pa_free;
c9de560ded61fa Alex Tomas 2008-01-29 4211
c9de560ded61fa Alex Tomas 2008-01-29 4212
spin_unlock(&pa->pa_lock);
c9de560ded61fa Alex Tomas 2008-01-29 4213
c9de560ded61fa Alex Tomas 2008-01-29 4214
list_del(&pa->pa_group_list);
c9de560ded61fa Alex Tomas 2008-01-29 4215
list_add(&pa->u.pa_tmp_list, &list);
c9de560ded61fa Alex Tomas 2008-01-29 4216 }
c9de560ded61fa Alex Tomas 2008-01-29 4217
c9de560ded61fa Alex Tomas 2008-01-29 4218 /* now free all selected PAs */
c9de560ded61fa Alex Tomas 2008-01-29 4219 list_for_each_entry_safe(pa, tmp,
&list, u.pa_tmp_list) {
c9de560ded61fa Alex Tomas 2008-01-29 4220
c9de560ded61fa Alex Tomas 2008-01-29 4221 /* remove from object (inode or
locality group) */
c9de560ded61fa Alex Tomas 2008-01-29 4222 spin_lock(pa->pa_obj_lock);
c9de560ded61fa Alex Tomas 2008-01-29 4223
list_del_rcu(&pa->pa_inode_list);
c9de560ded61fa Alex Tomas 2008-01-29 4224 spin_unlock(pa->pa_obj_lock);
c9de560ded61fa Alex Tomas 2008-01-29 4225
cc0fb9ad7dbc5a Aneesh Kumar K.V 2009-03-27 4226 if (pa->pa_type ==
MB_GROUP_PA)
3e1e5f50163246 Eric Sandeen 2010-10-27 4227
ext4_mb_release_group_pa(&e4b, pa);
c9de560ded61fa Alex Tomas 2008-01-29 4228 else
3e1e5f50163246 Eric Sandeen 2010-10-27 4229
ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa);
c9de560ded61fa Alex Tomas 2008-01-29 4230
c9de560ded61fa Alex Tomas 2008-01-29 4231
list_del(&pa->u.pa_tmp_list);
c9de560ded61fa Alex Tomas 2008-01-29 4232 call_rcu(&(pa)->u.pa_rcu,
ext4_mb_pa_callback);
c9de560ded61fa Alex Tomas 2008-01-29 4233 }
c9de560ded61fa Alex Tomas 2008-01-29 4234
be9ed3afd2b7b2 Jan Kara 2020-09-15 4235 /* if we still need more blocks
and some PAs were used, try again */
be9ed3afd2b7b2 Jan Kara 2020-09-15 4236 if (free < needed &&
busy) {
be9ed3afd2b7b2 Jan Kara 2020-09-15 4237 ext4_unlock_group(sb, group);
be9ed3afd2b7b2 Jan Kara 2020-09-15 4238 cond_resched();
be9ed3afd2b7b2 Jan Kara 2020-09-15 4239 busy = 0;
be9ed3afd2b7b2 Jan Kara 2020-09-15 4240 /* Make sure we increment
discard_pa_seq again */
be9ed3afd2b7b2 Jan Kara 2020-09-15 4241 needed -= free;
be9ed3afd2b7b2 Jan Kara 2020-09-15 4242 free = 0;
be9ed3afd2b7b2 Jan Kara 2020-09-15 4243 goto repeat;
be9ed3afd2b7b2 Jan Kara 2020-09-15 4244 }
c9de560ded61fa Alex Tomas 2008-01-29 @4245 out:
c9de560ded61fa Alex Tomas 2008-01-29 4246 ext4_unlock_group(sb, group);
e39e07fdfd98be Jing Zhang 2010-05-14 4247 ext4_mb_unload_buddy(&e4b);
c9de560ded61fa Alex Tomas 2008-01-29 4248 put_bh(bitmap_bh);
bbc4ec77e9f9c7 Ritesh Harjani 2020-05-10 4249 out_dbg:
d3df14535f4a5b Ritesh Harjani 2020-05-10 4250 mb_debug(sb, "discarded (%d)
blocks preallocated for group %u bb_free (%d)\n",
bbc4ec77e9f9c7 Ritesh Harjani 2020-05-10 4251 free, group, grp->bb_free);
c9de560ded61fa Alex Tomas 2008-01-29 4252 return free;
c9de560ded61fa Alex Tomas 2008-01-29 4253 }
c9de560ded61fa Alex Tomas 2008-01-29 4254
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org