tree: https://github.com/ammarfaizi2/linux-block kdave/linux/for-next head: 98e89a12003c17d07349af29b2591f5c13a4b548 commit: 1556cd3d099ad18a04f2b198adf7ae6bf4d6458c btrfs: locking: use atomic for DREW lock writers date: 2 days ago config: x86_64-rhel-8.3-syz compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/ammarfaizi2/linux-block/commit/1556cd3d099ad18a04f2b198adf7ae6bf4d6458c git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block git fetch --no-tags ammarfaizi2-block kdave/linux/for-next git checkout 1556cd3d099ad18a04f2b198adf7ae6bf4d6458c # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 olddefconfig make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash fs/btrfs/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot All warnings (new ones prefixed by >>): fs/btrfs/disk-io.c: In function 'btrfs_init_fs_root': >> fs/btrfs/disk-io.c:1524:22: warning: unused variable 'nofs_flag' [-Wunused-variable] 1524 | unsigned int nofs_flag; | ^~~~~~~~~ vim +/nofs_flag +1524 fs/btrfs/disk-io.c 416bc6580bb01d Josef Bacik 2013-04-23 1515 2dfb1e43f57dd3 Qu Wenruo 2020-06-16 1516 /* 2dfb1e43f57dd3 Qu Wenruo 2020-06-16 1517 * Initialize subvolume root in-memory structure 2dfb1e43f57dd3 Qu Wenruo 2020-06-16 1518 * 2dfb1e43f57dd3 Qu Wenruo 2020-06-16 1519 * @anon_dev: anonymous device to attach to the root, if zero, allocate new 2dfb1e43f57dd3 Qu Wenruo 2020-06-16 1520 */ 2dfb1e43f57dd3 Qu Wenruo 2020-06-16 1521 static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev) cb517eabba4f10 Miao Xie 2013-05-15 1522 { cb517eabba4f10 Miao Xie 2013-05-15 1523 int ret; dcc3eb9638c3c9 Nikolay Borisov 2020-01-30 @1524 unsigned int nofs_flag; cb517eabba4f10 Miao Xie 2013-05-15 1525 1556cd3d099ad1 David Sterba 2023-01-10 1526 btrfs_drew_lock_init(&root->snapshot_lock); 8257b2dc3c1a10 Miao Xie 2014-03-06 1527 aeb935a455812e Qu Wenruo 2020-05-15 1528 if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID && 37f00a6d2e9c97 Johannes Thumshirn 2021-09-09 1529 !btrfs_is_data_reloc_root(root)) { 92a7cc4252231d Qu Wenruo 2020-05-15 1530 set_bit(BTRFS_ROOT_SHAREABLE, &root->state); f39e457156f919 Josef Bacik 2020-01-24 1531 btrfs_check_and_init_root_item(&root->root_item); f39e457156f919 Josef Bacik 2020-01-24 1532 } f39e457156f919 Josef Bacik 2020-01-24 1533 851fd730a743e0 Qu Wenruo 2020-06-16 1534 /* 851fd730a743e0 Qu Wenruo 2020-06-16 1535 * Don't assign anonymous block device to roots that are not exposed to 851fd730a743e0 Qu Wenruo 2020-06-16 1536 * userspace, the id pool is limited to 1M 851fd730a743e0 Qu Wenruo 2020-06-16 1537 */ 851fd730a743e0 Qu Wenruo 2020-06-16 1538 if (is_fstree(root->root_key.objectid) && 851fd730a743e0 Qu Wenruo 2020-06-16 1539 btrfs_root_refs(&root->root_item) > 0) { 2dfb1e43f57dd3 Qu Wenruo 2020-06-16 1540 if (!anon_dev) { cb517eabba4f10 Miao Xie 2013-05-15 1541 ret = get_anon_bdev(&root->anon_dev); cb517eabba4f10 Miao Xie 2013-05-15 1542 if (ret) 876d2cf141b42f Liu Bo 2016-06-28 1543 goto fail; 2dfb1e43f57dd3 Qu Wenruo 2020-06-16 1544 } else { 2dfb1e43f57dd3 Qu Wenruo 2020-06-16 1545 root->anon_dev = anon_dev; 2dfb1e43f57dd3 Qu Wenruo 2020-06-16 1546 } 851fd730a743e0 Qu Wenruo 2020-06-16 1547 } f32e48e925964c Chandan Rajendra 2016-01-07 1548 f32e48e925964c Chandan Rajendra 2016-01-07 1549 mutex_lock(&root->objectid_mutex); 453e4873869f5e Nikolay Borisov 2020-12-07 1550 ret = btrfs_init_root_free_objectid(root); f32e48e925964c Chandan Rajendra 2016-01-07 1551 if (ret) { f32e48e925964c Chandan Rajendra 2016-01-07 1552 mutex_unlock(&root->objectid_mutex); 876d2cf141b42f Liu Bo 2016-06-28 1553 goto fail; f32e48e925964c Chandan Rajendra 2016-01-07 1554 } f32e48e925964c Chandan Rajendra 2016-01-07 1555 6b8fad576a3c8f Nikolay Borisov 2020-12-07 1556 ASSERT(root->free_objectid <= BTRFS_LAST_FREE_OBJECTID); f32e48e925964c Chandan Rajendra 2016-01-07 1557 f32e48e925964c Chandan Rajendra 2016-01-07 1558 mutex_unlock(&root->objectid_mutex); f32e48e925964c Chandan Rajendra 2016-01-07 1559 cb517eabba4f10 Miao Xie 2013-05-15 1560 return 0; cb517eabba4f10 Miao Xie 2013-05-15 1561 fail: 84db5ccf426289 David Sterba 2018-07-20 1562 /* The caller is responsible to call btrfs_free_fs_root */ cb517eabba4f10 Miao Xie 2013-05-15 1563 return ret; cb517eabba4f10 Miao Xie 2013-05-15 1564 } cb517eabba4f10 Miao Xie 2013-05-15 1565 :::::: The code at line 1524 was first introduced by commit :::::: dcc3eb9638c3c927f1597075e851d0a16300a876 btrfs: convert snapshot/nocow exlcusion to drew lock :::::: TO: Nikolay Borisov :::::: CC: David Sterba -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests