tree:
https://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux-stable.git queue-5.4
head: b19ca15421f87ab0b820032a1891f1e0a13bce70
commit: 07feb40c162ebecbea7d1ea560e553e32e0e8b48 [2/3] btrfs: take overcommit into account
in inc_block_group_ro
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0
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
#
https://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux-stable.git/c...
git remote add sashal-linux-stable
https://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux-stable.git
git fetch --no-tags sashal-linux-stable queue-5.4
git checkout 07feb40c162ebecbea7d1ea560e553e32e0e8b48
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=xtensa
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 >>):
In file included from arch/xtensa/include/asm/processor.h:15,
from arch/xtensa/include/asm/thread_info.h:20,
from arch/xtensa/include/asm/current.h:14,
from include/linux/sched.h:12,
from fs/btrfs/misc.h:6,
from fs/btrfs/block-group.c:3:
include/linux/scatterlist.h: In function 'sg_set_buf':
arch/xtensa/include/asm/page.h:182:9: warning: comparison of unsigned expression >=
0 is always true [-Wtype-limits]
182 | ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) <
max_mapnr)
| ^~
include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
include/linux/scatterlist.h:143:2: note: in expansion of macro 'BUG_ON'
143 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~
arch/xtensa/include/asm/page.h:190:32: note: in expansion of macro 'pfn_valid'
190 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
| ^~~~~~~~~
include/linux/scatterlist.h:143:10: note: in expansion of macro
'virt_addr_valid'
143 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~~~~~~~~~~
In file included from fs/btrfs/block-group.c:14:
fs/btrfs/sysfs.h: At top level:
fs/btrfs/sysfs.h:16:1: warning: type qualifiers ignored on function return type
[-Wignored-qualifiers]
16 | const char * const btrfs_feature_set_name(enum btrfs_feature_set set);
| ^~~~~
fs/btrfs/block-group.c: In function 'inc_block_group_ro':
> fs/btrfs/block-group.c:1189:6: warning: variable
'min_allocable_bytes' set but not used [-Wunused-but-set-variable]
1189
| u64 min_allocable_bytes;
| ^~~~~~~~~~~~~~~~~~~
vim +/min_allocable_bytes +1189 fs/btrfs/block-group.c
e3e0520b32bc3db Josef Bacik 2019-06-20 1171
26ce2095e03c248 Josef Bacik 2019-06-20 1172 /*
26ce2095e03c248 Josef Bacik 2019-06-20 1173 * Mark block group @cache read-only, so
later write won't happen to block
26ce2095e03c248 Josef Bacik 2019-06-20 1174 * group @cache.
26ce2095e03c248 Josef Bacik 2019-06-20 1175 *
26ce2095e03c248 Josef Bacik 2019-06-20 1176 * If @force is not set, this function will
only mark the block group readonly
26ce2095e03c248 Josef Bacik 2019-06-20 1177 * if we have enough free space (1M) in
other metadata/system block groups.
26ce2095e03c248 Josef Bacik 2019-06-20 1178 * If @force is not set, this function will
mark the block group readonly
26ce2095e03c248 Josef Bacik 2019-06-20 1179 * without checking free space.
26ce2095e03c248 Josef Bacik 2019-06-20 1180 *
26ce2095e03c248 Josef Bacik 2019-06-20 1181 * NOTE: This function doesn't care if
other block groups can contain all the
26ce2095e03c248 Josef Bacik 2019-06-20 1182 * data in this block group. That check
should be done by relocation routine,
26ce2095e03c248 Josef Bacik 2019-06-20 1183 * not this function.
26ce2095e03c248 Josef Bacik 2019-06-20 1184 */
e11c0406ad1bb60 Josef Bacik 2019-06-20 1185 static int inc_block_group_ro(struct
btrfs_block_group_cache *cache, int force)
26ce2095e03c248 Josef Bacik 2019-06-20 1186 {
26ce2095e03c248 Josef Bacik 2019-06-20 1187 struct btrfs_space_info *sinfo =
cache->space_info;
26ce2095e03c248 Josef Bacik 2019-06-20 1188 u64 num_bytes;
26ce2095e03c248 Josef Bacik 2019-06-20 @1189 u64 min_allocable_bytes;
26ce2095e03c248 Josef Bacik 2019-06-20 1190 int ret = -ENOSPC;
26ce2095e03c248 Josef Bacik 2019-06-20 1191
26ce2095e03c248 Josef Bacik 2019-06-20 1192 /*
26ce2095e03c248 Josef Bacik 2019-06-20 1193 * We need some metadata space and system
metadata space for
26ce2095e03c248 Josef Bacik 2019-06-20 1194 * allocating chunks in some corner cases
until we force to set
26ce2095e03c248 Josef Bacik 2019-06-20 1195 * it to be readonly.
26ce2095e03c248 Josef Bacik 2019-06-20 1196 */
26ce2095e03c248 Josef Bacik 2019-06-20 1197 if ((sinfo->flags &
26ce2095e03c248 Josef Bacik 2019-06-20 1198 (BTRFS_BLOCK_GROUP_SYSTEM |
BTRFS_BLOCK_GROUP_METADATA)) &&
26ce2095e03c248 Josef Bacik 2019-06-20 1199 !force)
26ce2095e03c248 Josef Bacik 2019-06-20 1200 min_allocable_bytes = SZ_1M;
26ce2095e03c248 Josef Bacik 2019-06-20 1201 else
26ce2095e03c248 Josef Bacik 2019-06-20 1202 min_allocable_bytes = 0;
26ce2095e03c248 Josef Bacik 2019-06-20 1203
26ce2095e03c248 Josef Bacik 2019-06-20 1204 spin_lock(&sinfo->lock);
26ce2095e03c248 Josef Bacik 2019-06-20 1205 spin_lock(&cache->lock);
26ce2095e03c248 Josef Bacik 2019-06-20 1206
26ce2095e03c248 Josef Bacik 2019-06-20 1207 if (cache->ro) {
26ce2095e03c248 Josef Bacik 2019-06-20 1208 cache->ro++;
26ce2095e03c248 Josef Bacik 2019-06-20 1209 ret = 0;
26ce2095e03c248 Josef Bacik 2019-06-20 1210 goto out;
26ce2095e03c248 Josef Bacik 2019-06-20 1211 }
26ce2095e03c248 Josef Bacik 2019-06-20 1212
26ce2095e03c248 Josef Bacik 2019-06-20 1213 num_bytes = cache->key.offset -
cache->reserved - cache->pinned -
26ce2095e03c248 Josef Bacik 2019-06-20 1214 cache->bytes_super -
btrfs_block_group_used(&cache->item);
26ce2095e03c248 Josef Bacik 2019-06-20 1215
26ce2095e03c248 Josef Bacik 2019-06-20 1216 /*
07feb40c162ebec Josef Bacik 2020-10-14 1217 * Data never overcommits, even in mixed
mode, so do just the straight
07feb40c162ebec Josef Bacik 2020-10-14 1218 * check of left over space in how much we
have allocated.
07feb40c162ebec Josef Bacik 2020-10-14 1219 */
07feb40c162ebec Josef Bacik 2020-10-14 1220 if (force) {
07feb40c162ebec Josef Bacik 2020-10-14 1221 ret = 0;
07feb40c162ebec Josef Bacik 2020-10-14 1222 } else if (sinfo->flags &
BTRFS_BLOCK_GROUP_DATA) {
07feb40c162ebec Josef Bacik 2020-10-14 1223 u64 sinfo_used =
btrfs_space_info_used(sinfo, true);
07feb40c162ebec Josef Bacik 2020-10-14 1224
07feb40c162ebec Josef Bacik 2020-10-14 1225 /*
26ce2095e03c248 Josef Bacik 2019-06-20 1226 * Here we make sure if we mark this bg
RO, we still have enough
07feb40c162ebec Josef Bacik 2020-10-14 1227 * free space as buffer.
07feb40c162ebec Josef Bacik 2020-10-14 1228 */
07feb40c162ebec Josef Bacik 2020-10-14 1229 if (sinfo_used + num_bytes <=
sinfo->total_bytes)
07feb40c162ebec Josef Bacik 2020-10-14 1230 ret = 0;
07feb40c162ebec Josef Bacik 2020-10-14 1231 } else {
07feb40c162ebec Josef Bacik 2020-10-14 1232 /*
07feb40c162ebec Josef Bacik 2020-10-14 1233 * We overcommit metadata, so we need to
do the
07feb40c162ebec Josef Bacik 2020-10-14 1234 * btrfs_can_overcommit check here, and we
need to pass in
07feb40c162ebec Josef Bacik 2020-10-14 1235 * BTRFS_RESERVE_NO_FLUSH to give
ourselves the most amount of
07feb40c162ebec Josef Bacik 2020-10-14 1236 * leeway to allow us to mark this block
group as read only.
26ce2095e03c248 Josef Bacik 2019-06-20 1237 */
07feb40c162ebec Josef Bacik 2020-10-14 1238 if
(btrfs_can_overcommit(cache->fs_info, sinfo, num_bytes,
07feb40c162ebec Josef Bacik 2020-10-14 1239 BTRFS_RESERVE_NO_FLUSH))
07feb40c162ebec Josef Bacik 2020-10-14 1240 ret = 0;
07feb40c162ebec Josef Bacik 2020-10-14 1241 }
07feb40c162ebec Josef Bacik 2020-10-14 1242
07feb40c162ebec Josef Bacik 2020-10-14 1243 if (!ret) {
26ce2095e03c248 Josef Bacik 2019-06-20 1244 sinfo->bytes_readonly += num_bytes;
26ce2095e03c248 Josef Bacik 2019-06-20 1245 cache->ro++;
26ce2095e03c248 Josef Bacik 2019-06-20 1246 list_add_tail(&cache->ro_list,
&sinfo->ro_bgs);
26ce2095e03c248 Josef Bacik 2019-06-20 1247 }
26ce2095e03c248 Josef Bacik 2019-06-20 1248 out:
26ce2095e03c248 Josef Bacik 2019-06-20 1249 spin_unlock(&cache->lock);
26ce2095e03c248 Josef Bacik 2019-06-20 1250 spin_unlock(&sinfo->lock);
26ce2095e03c248 Josef Bacik 2019-06-20 1251 if (ret == -ENOSPC &&
btrfs_test_opt(cache->fs_info, ENOSPC_DEBUG)) {
26ce2095e03c248 Josef Bacik 2019-06-20 1252 btrfs_info(cache->fs_info,
26ce2095e03c248 Josef Bacik 2019-06-20 1253 "unable to make block group %llu
ro",
26ce2095e03c248 Josef Bacik 2019-06-20 1254 cache->key.objectid);
26ce2095e03c248 Josef Bacik 2019-06-20 1255 btrfs_dump_space_info(cache->fs_info,
cache->space_info, 0, 0);
26ce2095e03c248 Josef Bacik 2019-06-20 1256 }
26ce2095e03c248 Josef Bacik 2019-06-20 1257 return ret;
26ce2095e03c248 Josef Bacik 2019-06-20 1258 }
26ce2095e03c248 Josef Bacik 2019-06-20 1259
:::::: The code at line 1189 was first introduced by commit
:::::: 26ce2095e03c248759951d81fdff37e2bf32601c btrfs: migrate inc/dec_block_group_ro
code
:::::: TO: Josef Bacik <josef(a)toxicpanda.com>
:::::: CC: David Sterba <dsterba(a)suse.com>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org