ext4: make ext4_es_insert_delayed_block() return void
authorBaokun Li <libaokun1@huawei.com>
Mon, 24 Apr 2023 03:38:44 +0000 (11:38 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 26 Jun 2023 23:35:12 +0000 (19:35 -0400)
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.

[ Fixed bug which caused system hangs during bigalloc test runs.  See
 https://lore.kernel.org/r/20230612030405.GH1436857@mit.edu for more
 details.  -- TYT ]

Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230424033846.4732-11-libaokun1@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/extents_status.c
fs/ext4/extents_status.h
fs/ext4/inode.c

index b01b3bd..6a020e6 100644 (file)
@@ -2016,11 +2016,9 @@ 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 err1 = 0;
@@ -2029,7 +2027,7 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
        struct extent_status *es2 = NULL;
 
        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);
@@ -2071,7 +2069,7 @@ error:
 
        ext4_es_print_tree(inode);
        ext4_print_pending_tree(inode);
-       return 0;
+       return;
 }
 
 /*
index 526a688..c22edb9 100644 (file)
@@ -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);
index 519f5a0..22c87aa 100644 (file)
@@ -1630,7 +1630,6 @@ 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;
        bool allocated = false;
-       bool reserved = false;
 
        /*
         * If the cluster containing lblk is shared with a delayed,
@@ -1646,8 +1645,7 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
        if (sbi->s_cluster_ratio == 1) {
                ret = ext4_da_reserve_space(inode);
                if (ret != 0)   /* ENOSPC */
-                       goto errout;
-               reserved = true;
+                       return ret;
        } else {   /* bigalloc */
                if (!ext4_es_scan_clu(inode, &ext4_es_is_delonly, lblk)) {
                        if (!ext4_es_scan_clu(inode,
@@ -1655,12 +1653,11 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
                                ret = ext4_clu_mapped(inode,
                                                      EXT4_B2C(sbi, lblk));
                                if (ret < 0)
-                                       goto errout;
+                                       return ret;
                                if (ret == 0) {
                                        ret = ext4_da_reserve_space(inode);
                                        if (ret != 0)   /* ENOSPC */
-                                               goto errout;
-                                       reserved = true;
+                                               return ret;
                                } else {
                                        allocated = true;
                                }
@@ -1670,12 +1667,8 @@ 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);
-
-errout:
-       return ret;
+       ext4_es_insert_delayed_block(inode, lblk, allocated);
+       return 0;
 }
 
 /*