[PATCH v3 6/8] ext4: make ext4_es_insert_delayed_block return void

Baokun Li posted 8 patches 2 years, 10 months ago
There is a newer version of this series
[PATCH v3 6/8] ext4: make ext4_es_insert_delayed_block return void
Posted by Baokun Li 2 years, 10 months ago
Now it never fails when inserting a delay extent, so the return value in
ext4_es_insert_delayed_block is no longer necessary, let it return void.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
V2->V3:
	New added.

 fs/ext4/extents_status.c | 23 ++++++-----------------
 fs/ext4/extents_status.h |  4 ++--
 fs/ext4/inode.c          |  7 ++-----
 3 files changed, 10 insertions(+), 24 deletions(-)

diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 1ba2dd14367c..047ec2fc4899 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -1980,17 +1980,14 @@ bool ext4_is_pending(struct inode *inode, ext4_lblk_t lblk)
  * @lblk - logical block to be added
  * @allocated - indicates whether a physical cluster has been allocated for
  *              the logical cluster that contains the block
- *
- * Returns 0 on success, negative error code on failure.
  */
-int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
-				 bool allocated)
+void ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
+				  bool allocated)
 {
 	struct extent_status newes;
-	int err = 0;
 
 	if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
-		return 0;
+		return;
 
 	es_debug("add [%u/1) delayed to extent status tree of inode %lu\n",
 		 lblk, inode->i_ino);
@@ -2005,24 +2002,16 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
 	write_lock(&EXT4_I(inode)->i_es_lock);
 
 	__es_remove_extent(inode, lblk, lblk, NULL);
-retry:
-	err = __es_insert_extent(inode, &newes);
-	if (err == -ENOMEM && __es_shrink(EXT4_SB(inode->i_sb),
-					  128, EXT4_I(inode)))
-		goto retry;
-	if (err != 0)
-		goto error;
+
+	/* We never return an error when inserting a delayed extent. */
+	(void) __es_insert_extent(inode, &newes);
 
 	if (allocated)
 		__insert_pending(inode, lblk);
-
-error:
 	write_unlock(&EXT4_I(inode)->i_es_lock);
 
 	ext4_es_print_tree(inode);
 	ext4_print_pending_tree(inode);
-
-	return err;
 }
 
 /*
diff --git a/fs/ext4/extents_status.h b/fs/ext4/extents_status.h
index 526a68890aa6..c22edb931f1b 100644
--- a/fs/ext4/extents_status.h
+++ b/fs/ext4/extents_status.h
@@ -249,8 +249,8 @@ extern void ext4_exit_pending(void);
 extern void ext4_init_pending_tree(struct ext4_pending_tree *tree);
 extern void ext4_remove_pending(struct inode *inode, ext4_lblk_t lblk);
 extern bool ext4_is_pending(struct inode *inode, ext4_lblk_t lblk);
-extern int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
-					bool allocated);
+extern void ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
+					 bool allocated);
 extern unsigned int ext4_es_delayed_clu(struct inode *inode, ext4_lblk_t lblk,
 					ext4_lblk_t len);
 extern void ext4_clear_inode_es(struct inode *inode);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 3bd4d5bbf0aa..9fd3d526f591 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1635,7 +1635,7 @@ static void ext4_print_free_blocks(struct inode *inode)
 static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
-	int ret;
+	int ret = 0;
 	bool allocated = false;
 	bool reserved = false;
 
@@ -1677,10 +1677,7 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
 		}
 	}
 
-	ret = ext4_es_insert_delayed_block(inode, lblk, allocated);
-	if (ret && reserved)
-		ext4_da_release_space(inode, 1);
-
+	ext4_es_insert_delayed_block(inode, lblk, allocated);
 errout:
 	return ret;
 }
-- 
2.31.1
Re: [PATCH v3 6/8] ext4: make ext4_es_insert_delayed_block return void
Posted by kernel test robot 2 years, 10 months ago
Hi Baokun,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tytso-ext4/dev]
[also build test WARNING on linus/master v6.3-rc6 next-20230412]
[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/Baokun-Li/ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation/20230412-204407
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
patch link:    https://lore.kernel.org/r/20230412124126.2286716-7-libaokun1%40huawei.com
patch subject: [PATCH v3 6/8] ext4: make ext4_es_insert_delayed_block return void
config: x86_64-randconfig-a002-20230410 (https://download.01.org/0day-ci/archive/20230413/202304130044.d3iOG59z-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
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://github.com/intel-lab-lkp/linux/commit/87f992eeab9cd894894e27c3c6ff322cbd473ebf
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Baokun-Li/ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation/20230412-204407
        git checkout 87f992eeab9cd894894e27c3c6ff322cbd473ebf
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash fs/ext4/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304130044.d3iOG59z-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> fs/ext4/inode.c:1640:7: warning: variable 'reserved' set but not used [-Wunused-but-set-variable]
           bool reserved = false;
                ^
   1 warning generated.


vim +/reserved +1640 fs/ext4/inode.c

df22291ff0fde0 Aneesh Kumar K.V 2008-09-08  1623  
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1624  /*
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1625   * ext4_insert_delayed_block - adds a delayed block to the extents status
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1626   *                             tree, incrementing the reserved cluster/block
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1627   *                             count or making a pending reservation
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1628   *                             where needed
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1629   *
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1630   * @inode - file containing the newly added block
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1631   * @lblk - logical block to be added
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1632   *
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1633   * Returns 0 on success, negative error code on failure.
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1634   */
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1635  static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1636  {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1637  	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
87f992eeab9cd8 Baokun Li        2023-04-12  1638  	int ret = 0;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1639  	bool allocated = false;
6fed83957f21ef Jeffle Xu        2021-08-23 @1640  	bool reserved = false;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1641  
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1642  	/*
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1643  	 * If the cluster containing lblk is shared with a delayed,
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1644  	 * written, or unwritten extent in a bigalloc file system, it's
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1645  	 * already been accounted for and does not need to be reserved.
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1646  	 * A pending reservation must be made for the cluster if it's
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1647  	 * shared with a written or unwritten extent and doesn't already
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1648  	 * have one.  Written and unwritten extents can be purged from the
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1649  	 * extents status tree if the system is under memory pressure, so
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1650  	 * it's necessary to examine the extent tree if a search of the
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1651  	 * extents status tree doesn't get a match.
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1652  	 */
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1653  	if (sbi->s_cluster_ratio == 1) {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1654  		ret = ext4_da_reserve_space(inode);
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1655  		if (ret != 0)   /* ENOSPC */
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1656  			goto errout;
6fed83957f21ef Jeffle Xu        2021-08-23  1657  		reserved = true;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1658  	} else {   /* bigalloc */
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1659  		if (!ext4_es_scan_clu(inode, &ext4_es_is_delonly, lblk)) {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1660  			if (!ext4_es_scan_clu(inode,
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1661  					      &ext4_es_is_mapped, lblk)) {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1662  				ret = ext4_clu_mapped(inode,
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1663  						      EXT4_B2C(sbi, lblk));
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1664  				if (ret < 0)
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1665  					goto errout;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1666  				if (ret == 0) {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1667  					ret = ext4_da_reserve_space(inode);
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1668  					if (ret != 0)   /* ENOSPC */
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1669  						goto errout;
6fed83957f21ef Jeffle Xu        2021-08-23  1670  					reserved = true;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1671  				} else {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1672  					allocated = true;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1673  				}
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1674  			} else {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1675  				allocated = true;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1676  			}
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1677  		}
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1678  	}
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1679  
87f992eeab9cd8 Baokun Li        2023-04-12  1680  	ext4_es_insert_delayed_block(inode, lblk, allocated);
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1681  errout:
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1682  	return ret;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1683  }
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1684  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Re: [PATCH v3 6/8] ext4: make ext4_es_insert_delayed_block return void
Posted by kernel test robot 2 years, 10 months ago
Hi Baokun,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tytso-ext4/dev]
[also build test WARNING on linus/master v6.3-rc6 next-20230412]
[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/Baokun-Li/ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation/20230412-204407
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
patch link:    https://lore.kernel.org/r/20230412124126.2286716-7-libaokun1%40huawei.com
patch subject: [PATCH v3 6/8] ext4: make ext4_es_insert_delayed_block return void
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230412/202304122234.3Meeshf9-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.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://github.com/intel-lab-lkp/linux/commit/87f992eeab9cd894894e27c3c6ff322cbd473ebf
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Baokun-Li/ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation/20230412-204407
        git checkout 87f992eeab9cd894894e27c3c6ff322cbd473ebf
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash fs/ext4/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304122234.3Meeshf9-lkp@intel.com/

All warnings (new ones prefixed by >>):

   fs/ext4/inode.c: In function 'ext4_insert_delayed_block':
>> fs/ext4/inode.c:1640:14: warning: variable 'reserved' set but not used [-Wunused-but-set-variable]
    1640 |         bool reserved = false;
         |              ^~~~~~~~


vim +/reserved +1640 fs/ext4/inode.c

df22291ff0fde0 Aneesh Kumar K.V 2008-09-08  1623  
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1624  /*
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1625   * ext4_insert_delayed_block - adds a delayed block to the extents status
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1626   *                             tree, incrementing the reserved cluster/block
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1627   *                             count or making a pending reservation
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1628   *                             where needed
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1629   *
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1630   * @inode - file containing the newly added block
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1631   * @lblk - logical block to be added
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1632   *
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1633   * Returns 0 on success, negative error code on failure.
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1634   */
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1635  static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1636  {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1637  	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
87f992eeab9cd8 Baokun Li        2023-04-12  1638  	int ret = 0;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1639  	bool allocated = false;
6fed83957f21ef Jeffle Xu        2021-08-23 @1640  	bool reserved = false;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1641  
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1642  	/*
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1643  	 * If the cluster containing lblk is shared with a delayed,
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1644  	 * written, or unwritten extent in a bigalloc file system, it's
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1645  	 * already been accounted for and does not need to be reserved.
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1646  	 * A pending reservation must be made for the cluster if it's
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1647  	 * shared with a written or unwritten extent and doesn't already
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1648  	 * have one.  Written and unwritten extents can be purged from the
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1649  	 * extents status tree if the system is under memory pressure, so
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1650  	 * it's necessary to examine the extent tree if a search of the
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1651  	 * extents status tree doesn't get a match.
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1652  	 */
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1653  	if (sbi->s_cluster_ratio == 1) {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1654  		ret = ext4_da_reserve_space(inode);
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1655  		if (ret != 0)   /* ENOSPC */
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1656  			goto errout;
6fed83957f21ef Jeffle Xu        2021-08-23  1657  		reserved = true;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1658  	} else {   /* bigalloc */
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1659  		if (!ext4_es_scan_clu(inode, &ext4_es_is_delonly, lblk)) {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1660  			if (!ext4_es_scan_clu(inode,
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1661  					      &ext4_es_is_mapped, lblk)) {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1662  				ret = ext4_clu_mapped(inode,
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1663  						      EXT4_B2C(sbi, lblk));
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1664  				if (ret < 0)
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1665  					goto errout;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1666  				if (ret == 0) {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1667  					ret = ext4_da_reserve_space(inode);
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1668  					if (ret != 0)   /* ENOSPC */
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1669  						goto errout;
6fed83957f21ef Jeffle Xu        2021-08-23  1670  					reserved = true;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1671  				} else {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1672  					allocated = true;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1673  				}
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1674  			} else {
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1675  				allocated = true;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1676  			}
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1677  		}
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1678  	}
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1679  
87f992eeab9cd8 Baokun Li        2023-04-12  1680  	ext4_es_insert_delayed_block(inode, lblk, allocated);
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1681  errout:
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1682  	return ret;
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1683  }
0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1684  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Re: [PATCH v3 6/8] ext4: make ext4_es_insert_delayed_block return void
Posted by Baokun Li 2 years, 10 months ago
On 2023/4/12 22:19, kernel test robot wrote:
> Hi Baokun,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on tytso-ext4/dev]
> [also build test WARNING on linus/master v6.3-rc6 next-20230412]
> [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/Baokun-Li/ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation/20230412-204407
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
> patch link:    https://lore.kernel.org/r/20230412124126.2286716-7-libaokun1%40huawei.com
> patch subject: [PATCH v3 6/8] ext4: make ext4_es_insert_delayed_block return void
> config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230412/202304122234.3Meeshf9-lkp@intel.com/config)
> compiler: m68k-linux-gcc (GCC) 12.1.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://github.com/intel-lab-lkp/linux/commit/87f992eeab9cd894894e27c3c6ff322cbd473ebf
>          git remote add linux-review https://github.com/intel-lab-lkp/linux
>          git fetch --no-tags linux-review Baokun-Li/ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation/20230412-204407
>          git checkout 87f992eeab9cd894894e27c3c6ff322cbd473ebf
>          # save the config file
>          mkdir build_dir && cp config build_dir/.config
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash fs/ext4/
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> | Link: https://lore.kernel.org/oe-kbuild-all/202304122234.3Meeshf9-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
>     fs/ext4/inode.c: In function 'ext4_insert_delayed_block':
>>> fs/ext4/inode.c:1640:14: warning: variable 'reserved' set but not used [-Wunused-but-set-variable]
>      1640 |         bool reserved = false;
>           |              ^~~~~~~~

Thank you very much for testing, I will fix this issue in the next 
version of the patch.

I checked with make W=2 to see if it would introduce a compile warning 
before sending,
but it did not check for the problem. When I saw this email I checked 
again with W=1,
and this checked the problem instead. This is strange, doesn't it seem 
to me that a high
rank warning check should include a low rank warning check?
Am I misunderstanding or is this a bug?

>
> vim +/reserved +1640 fs/ext4/inode.c
>
> df22291ff0fde0 Aneesh Kumar K.V 2008-09-08  1623
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1624  /*
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1625   * ext4_insert_delayed_block - adds a delayed block to the extents status
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1626   *                             tree, incrementing the reserved cluster/block
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1627   *                             count or making a pending reservation
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1628   *                             where needed
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1629   *
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1630   * @inode - file containing the newly added block
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1631   * @lblk - logical block to be added
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1632   *
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1633   * Returns 0 on success, negative error code on failure.
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1634   */
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1635  static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1636  {
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1637  	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
> 87f992eeab9cd8 Baokun Li        2023-04-12  1638  	int ret = 0;
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1639  	bool allocated = false;
> 6fed83957f21ef Jeffle Xu        2021-08-23 @1640  	bool reserved = false;
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1641
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1642  	/*
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1643  	 * If the cluster containing lblk is shared with a delayed,
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1644  	 * written, or unwritten extent in a bigalloc file system, it's
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1645  	 * already been accounted for and does not need to be reserved.
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1646  	 * A pending reservation must be made for the cluster if it's
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1647  	 * shared with a written or unwritten extent and doesn't already
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1648  	 * have one.  Written and unwritten extents can be purged from the
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1649  	 * extents status tree if the system is under memory pressure, so
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1650  	 * it's necessary to examine the extent tree if a search of the
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1651  	 * extents status tree doesn't get a match.
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1652  	 */
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1653  	if (sbi->s_cluster_ratio == 1) {
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1654  		ret = ext4_da_reserve_space(inode);
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1655  		if (ret != 0)   /* ENOSPC */
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1656  			goto errout;
> 6fed83957f21ef Jeffle Xu        2021-08-23  1657  		reserved = true;
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1658  	} else {   /* bigalloc */
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1659  		if (!ext4_es_scan_clu(inode, &ext4_es_is_delonly, lblk)) {
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1660  			if (!ext4_es_scan_clu(inode,
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1661  					      &ext4_es_is_mapped, lblk)) {
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1662  				ret = ext4_clu_mapped(inode,
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1663  						      EXT4_B2C(sbi, lblk));
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1664  				if (ret < 0)
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1665  					goto errout;
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1666  				if (ret == 0) {
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1667  					ret = ext4_da_reserve_space(inode);
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1668  					if (ret != 0)   /* ENOSPC */
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1669  						goto errout;
> 6fed83957f21ef Jeffle Xu        2021-08-23  1670  					reserved = true;
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1671  				} else {
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1672  					allocated = true;
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1673  				}
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1674  			} else {
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1675  				allocated = true;
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1676  			}
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1677  		}
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1678  	}
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1679
> 87f992eeab9cd8 Baokun Li        2023-04-12  1680  	ext4_es_insert_delayed_block(inode, lblk, allocated);
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1681  errout:
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1682  	return ret;
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1683  }
> 0b02f4c0d6d9e2 Eric Whitney     2018-10-01  1684
>