Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* Re: [PATCH] btrfs: enhance ordered extent double freeing detection
       [not found] <53b793f2e7a7788f89cda97de565cfc1577cbf75.1733890357.git.wqu@suse.com>
@ 2024-12-11 18:11 ` kernel test robot
  2024-12-11 19:47   ` Qu Wenruo
  0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2024-12-11 18:11 UTC (permalink / raw)
  To: Qu Wenruo, linux-btrfs; +Cc: llvm, oe-kbuild-all

Hi Qu,

kernel test robot noticed the following build errors:

[auto build test ERROR on kdave/for-next]
[also build test ERROR on linus/master v6.13-rc2 next-20241211]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Qu-Wenruo/btrfs-enhance-ordered-extent-double-freeing-detection/20241211-121647
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
patch link:    https://lore.kernel.org/r/53b793f2e7a7788f89cda97de565cfc1577cbf75.1733890357.git.wqu%40suse.com
patch subject: [PATCH] btrfs: enhance ordered extent double freeing detection
config: i386-buildonly-randconfig-003-20241211 (https://download.01.org/0day-ci/archive/20241212/202412120136.6OwbbtZf-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241212/202412120136.6OwbbtZf-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412120136.6OwbbtZf-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from fs/btrfs/ordered-data.c:7:
   In file included from include/linux/blkdev.h:9:
   In file included from include/linux/blk_types.h:10:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:8:
   In file included from include/linux/cacheflush.h:5:
   In file included from arch/x86/include/asm/cacheflush.h:5:
   In file included from include/linux/mm.h:2223:
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
>> fs/btrfs/ordered-data.c:200:10: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
     200 |                 entry->finished_bitmap = bitmap_zalloc(
         |                 ~~~~~  ^
   fs/btrfs/ordered-data.c:202:15: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
     202 |                 if (!entry->finished_bitmap) {
         |                      ~~~~~  ^
   fs/btrfs/ordered-data.c:380:38: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
     380 |                 nr_set = bitmap_count_set(ordered->finished_bitmap, start_bit, nbits);
         |                                           ~~~~~~~  ^
   fs/btrfs/ordered-data.c:388:17: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
     388 |                                    ordered->finished_bitmap);
         |                                    ~~~~~~~  ^
   fs/btrfs/messages.h:44:41: note: expanded from macro 'btrfs_crit'
      44 |         btrfs_printk(fs_info, KERN_CRIT fmt, ##args)
         |                                                ^~~~
   fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
      27 |         _btrfs_printk(fs_info, fmt, ##args)
         |                                       ^~~~
   fs/btrfs/ordered-data.c:390:23: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
     390 |                 bitmap_set(ordered->finished_bitmap, start_bit, nbits);
         |                            ~~~~~~~  ^
   fs/btrfs/ordered-data.c:418:37: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
     418 |                 if (WARN_ON(!bitmap_full(ordered->finished_bitmap,
         |                                          ~~~~~~~  ^
   include/asm-generic/bug.h:123:25: note: expanded from macro 'WARN_ON'
     123 |         int __ret_warn_on = !!(condition);                              \
         |                                ^~~~~~~~~
   fs/btrfs/ordered-data.c:426:14: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
     426 |                                 ordered->finished_bitmap);
         |                                 ~~~~~~~  ^
   fs/btrfs/messages.h:44:41: note: expanded from macro 'btrfs_crit'
      44 |         btrfs_printk(fs_info, KERN_CRIT fmt, ##args)
         |                                                ^~~~
   fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
      27 |         _btrfs_printk(fs_info, fmt, ##args)
         |                                       ^~~~
   fs/btrfs/ordered-data.c:675:23: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
     675 |                         bitmap_free(entry->finished_bitmap);
         |                                     ~~~~~  ^
   1 warning and 8 errors generated.


vim +200 fs/btrfs/ordered-data.c

   147	
   148	static struct btrfs_ordered_extent *alloc_ordered_extent(
   149				struct btrfs_inode *inode, u64 file_offset, u64 num_bytes,
   150				u64 ram_bytes, u64 disk_bytenr, u64 disk_num_bytes,
   151				u64 offset, unsigned long flags, int compress_type)
   152	{
   153		struct btrfs_ordered_extent *entry;
   154		int ret;
   155		u64 qgroup_rsv = 0;
   156	
   157		if (flags &
   158		    ((1 << BTRFS_ORDERED_NOCOW) | (1 << BTRFS_ORDERED_PREALLOC))) {
   159			/* For nocow write, we can release the qgroup rsv right now */
   160			ret = btrfs_qgroup_free_data(inode, NULL, file_offset, num_bytes, &qgroup_rsv);
   161			if (ret < 0)
   162				return ERR_PTR(ret);
   163		} else {
   164			/*
   165			 * The ordered extent has reserved qgroup space, release now
   166			 * and pass the reserved number for qgroup_record to free.
   167			 */
   168			ret = btrfs_qgroup_release_data(inode, file_offset, num_bytes, &qgroup_rsv);
   169			if (ret < 0)
   170				return ERR_PTR(ret);
   171		}
   172		entry = kmem_cache_zalloc(btrfs_ordered_extent_cache, GFP_NOFS);
   173		if (!entry)
   174			return ERR_PTR(-ENOMEM);
   175	
   176		entry->file_offset = file_offset;
   177		entry->num_bytes = num_bytes;
   178		entry->ram_bytes = ram_bytes;
   179		entry->disk_bytenr = disk_bytenr;
   180		entry->disk_num_bytes = disk_num_bytes;
   181		entry->offset = offset;
   182		entry->bytes_left = num_bytes;
   183		entry->inode = BTRFS_I(igrab(&inode->vfs_inode));
   184		entry->compress_type = compress_type;
   185		entry->truncated_len = (u64)-1;
   186		entry->qgroup_rsv = qgroup_rsv;
   187		entry->flags = flags;
   188		refcount_set(&entry->refs, 1);
   189		init_waitqueue_head(&entry->wait);
   190		INIT_LIST_HEAD(&entry->list);
   191		INIT_LIST_HEAD(&entry->log_list);
   192		INIT_LIST_HEAD(&entry->root_extent_list);
   193		INIT_LIST_HEAD(&entry->work_list);
   194		INIT_LIST_HEAD(&entry->bioc_list);
   195		init_completion(&entry->completion);
   196	
   197		if (IS_ENABLED(CONFIG_BTRFS_DEBUG)) {
   198			struct btrfs_fs_info *fs_info = inode->root->fs_info;
   199	
 > 200			entry->finished_bitmap = bitmap_zalloc(
   201				num_bytes >> fs_info->sectorsize_bits, GFP_NOFS);
   202			if (!entry->finished_bitmap) {
   203				kmem_cache_free(btrfs_ordered_extent_cache, entry);
   204				return ERR_PTR(-ENOMEM);
   205			}
   206		}
   207		/*
   208		 * We don't need the count_max_extents here, we can assume that all of
   209		 * that work has been done at higher layers, so this is truly the
   210		 * smallest the extent is going to get.
   211		 */
   212		spin_lock(&inode->lock);
   213		btrfs_mod_outstanding_extents(inode, 1);
   214		spin_unlock(&inode->lock);
   215	
   216		return entry;
   217	}
   218	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] btrfs: enhance ordered extent double freeing detection
  2024-12-11 18:11 ` [PATCH] btrfs: enhance ordered extent double freeing detection kernel test robot
@ 2024-12-11 19:47   ` Qu Wenruo
  2024-12-11 21:26     ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2024-12-11 19:47 UTC (permalink / raw)
  To: kernel test robot, Qu Wenruo, linux-btrfs; +Cc: llvm, oe-kbuild-all



在 2024/12/12 04:41, kernel test robot 写道:
> Hi Qu,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on kdave/for-next]
> [also build test ERROR on linus/master v6.13-rc2 next-20241211]
> [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#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Qu-Wenruo/btrfs-enhance-ordered-extent-double-freeing-detection/20241211-121647
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
> patch link:    https://lore.kernel.org/r/53b793f2e7a7788f89cda97de565cfc1577cbf75.1733890357.git.wqu%40suse.com
> patch subject: [PATCH] btrfs: enhance ordered extent double freeing detection
> config: i386-buildonly-randconfig-003-20241211 (https://download.01.org/0day-ci/archive/20241212/202412120136.6OwbbtZf-lkp@intel.com/config)
> compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241212/202412120136.6OwbbtZf-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202412120136.6OwbbtZf-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>     In file included from fs/btrfs/ordered-data.c:7:
>     In file included from include/linux/blkdev.h:9:
>     In file included from include/linux/blk_types.h:10:
>     In file included from include/linux/bvec.h:10:
>     In file included from include/linux/highmem.h:8:
>     In file included from include/linux/cacheflush.h:5:
>     In file included from arch/x86/include/asm/cacheflush.h:5:
>     In file included from include/linux/mm.h:2223:
>     include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
>       518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
>           |                               ~~~~~~~~~~~ ^ ~~~
>>> fs/btrfs/ordered-data.c:200:10: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
>       200 |                 entry->finished_bitmap = bitmap_zalloc(
>           |                 ~~~~~  ^

I don't know why but it looks like IS_ENABLED() is not exactly doing the
#ifdef #endif, thus those checks are not fully skipped in this case.

Anyway I'll change it to the more traditional #ifdef #endif instead.

Thanks for the report.
Qu

>     fs/btrfs/ordered-data.c:202:15: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
>       202 |                 if (!entry->finished_bitmap) {
>           |                      ~~~~~  ^
>     fs/btrfs/ordered-data.c:380:38: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
>       380 |                 nr_set = bitmap_count_set(ordered->finished_bitmap, start_bit, nbits);
>           |                                           ~~~~~~~  ^
>     fs/btrfs/ordered-data.c:388:17: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
>       388 |                                    ordered->finished_bitmap);
>           |                                    ~~~~~~~  ^
>     fs/btrfs/messages.h:44:41: note: expanded from macro 'btrfs_crit'
>        44 |         btrfs_printk(fs_info, KERN_CRIT fmt, ##args)
>           |                                                ^~~~
>     fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
>        27 |         _btrfs_printk(fs_info, fmt, ##args)
>           |                                       ^~~~
>     fs/btrfs/ordered-data.c:390:23: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
>       390 |                 bitmap_set(ordered->finished_bitmap, start_bit, nbits);
>           |                            ~~~~~~~  ^
>     fs/btrfs/ordered-data.c:418:37: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
>       418 |                 if (WARN_ON(!bitmap_full(ordered->finished_bitmap,
>           |                                          ~~~~~~~  ^
>     include/asm-generic/bug.h:123:25: note: expanded from macro 'WARN_ON'
>       123 |         int __ret_warn_on = !!(condition);                              \
>           |                                ^~~~~~~~~
>     fs/btrfs/ordered-data.c:426:14: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
>       426 |                                 ordered->finished_bitmap);
>           |                                 ~~~~~~~  ^
>     fs/btrfs/messages.h:44:41: note: expanded from macro 'btrfs_crit'
>        44 |         btrfs_printk(fs_info, KERN_CRIT fmt, ##args)
>           |                                                ^~~~
>     fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
>        27 |         _btrfs_printk(fs_info, fmt, ##args)
>           |                                       ^~~~
>     fs/btrfs/ordered-data.c:675:23: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
>       675 |                         bitmap_free(entry->finished_bitmap);
>           |                                     ~~~~~  ^
>     1 warning and 8 errors generated.
>
>
> vim +200 fs/btrfs/ordered-data.c
>
>     147
>     148	static struct btrfs_ordered_extent *alloc_ordered_extent(
>     149				struct btrfs_inode *inode, u64 file_offset, u64 num_bytes,
>     150				u64 ram_bytes, u64 disk_bytenr, u64 disk_num_bytes,
>     151				u64 offset, unsigned long flags, int compress_type)
>     152	{
>     153		struct btrfs_ordered_extent *entry;
>     154		int ret;
>     155		u64 qgroup_rsv = 0;
>     156
>     157		if (flags &
>     158		    ((1 << BTRFS_ORDERED_NOCOW) | (1 << BTRFS_ORDERED_PREALLOC))) {
>     159			/* For nocow write, we can release the qgroup rsv right now */
>     160			ret = btrfs_qgroup_free_data(inode, NULL, file_offset, num_bytes, &qgroup_rsv);
>     161			if (ret < 0)
>     162				return ERR_PTR(ret);
>     163		} else {
>     164			/*
>     165			 * The ordered extent has reserved qgroup space, release now
>     166			 * and pass the reserved number for qgroup_record to free.
>     167			 */
>     168			ret = btrfs_qgroup_release_data(inode, file_offset, num_bytes, &qgroup_rsv);
>     169			if (ret < 0)
>     170				return ERR_PTR(ret);
>     171		}
>     172		entry = kmem_cache_zalloc(btrfs_ordered_extent_cache, GFP_NOFS);
>     173		if (!entry)
>     174			return ERR_PTR(-ENOMEM);
>     175
>     176		entry->file_offset = file_offset;
>     177		entry->num_bytes = num_bytes;
>     178		entry->ram_bytes = ram_bytes;
>     179		entry->disk_bytenr = disk_bytenr;
>     180		entry->disk_num_bytes = disk_num_bytes;
>     181		entry->offset = offset;
>     182		entry->bytes_left = num_bytes;
>     183		entry->inode = BTRFS_I(igrab(&inode->vfs_inode));
>     184		entry->compress_type = compress_type;
>     185		entry->truncated_len = (u64)-1;
>     186		entry->qgroup_rsv = qgroup_rsv;
>     187		entry->flags = flags;
>     188		refcount_set(&entry->refs, 1);
>     189		init_waitqueue_head(&entry->wait);
>     190		INIT_LIST_HEAD(&entry->list);
>     191		INIT_LIST_HEAD(&entry->log_list);
>     192		INIT_LIST_HEAD(&entry->root_extent_list);
>     193		INIT_LIST_HEAD(&entry->work_list);
>     194		INIT_LIST_HEAD(&entry->bioc_list);
>     195		init_completion(&entry->completion);
>     196
>     197		if (IS_ENABLED(CONFIG_BTRFS_DEBUG)) {
>     198			struct btrfs_fs_info *fs_info = inode->root->fs_info;
>     199
>   > 200			entry->finished_bitmap = bitmap_zalloc(
>     201				num_bytes >> fs_info->sectorsize_bits, GFP_NOFS);
>     202			if (!entry->finished_bitmap) {
>     203				kmem_cache_free(btrfs_ordered_extent_cache, entry);
>     204				return ERR_PTR(-ENOMEM);
>     205			}
>     206		}
>     207		/*
>     208		 * We don't need the count_max_extents here, we can assume that all of
>     209		 * that work has been done at higher layers, so this is truly the
>     210		 * smallest the extent is going to get.
>     211		 */
>     212		spin_lock(&inode->lock);
>     213		btrfs_mod_outstanding_extents(inode, 1);
>     214		spin_unlock(&inode->lock);
>     215
>     216		return entry;
>     217	}
>     218
>


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

* Re: [PATCH] btrfs: enhance ordered extent double freeing detection
  2024-12-11 19:47   ` Qu Wenruo
@ 2024-12-11 21:26     ` David Sterba
  0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2024-12-11 21:26 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: kernel test robot, Qu Wenruo, linux-btrfs, llvm, oe-kbuild-all

On Thu, Dec 12, 2024 at 06:17:37AM +1030, Qu Wenruo wrote:
> >>> fs/btrfs/ordered-data.c:200:10: error: no member named 'finished_bitmap' in 'struct btrfs_ordered_extent'
> >       200 |                 entry->finished_bitmap = bitmap_zalloc(
> >           |                 ~~~~~  ^
> 
> I don't know why but it looks like IS_ENABLED() is not exactly doing the
> #ifdef #endif, thus those checks are not fully skipped in this case.

It's never been equvalent to ifdef/endif, it evaluates to 0 or 1 if the
config option is enabled or not but otherwise the source code is still
compiled. The compiler then finds out it's dead code and eliminates it.

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

end of thread, other threads:[~2024-12-11 21:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <53b793f2e7a7788f89cda97de565cfc1577cbf75.1733890357.git.wqu@suse.com>
2024-12-11 18:11 ` [PATCH] btrfs: enhance ordered extent double freeing detection kernel test robot
2024-12-11 19:47   ` Qu Wenruo
2024-12-11 21:26     ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox