Whamcloud - gitweb
LU-14729 osd-ldiskfs: declare dirty block groups correctly 06/45506/2
authorWang Shilong <wshilong@ddn.com>
Wed, 2 Jun 2021 01:52:39 +0000 (09:52 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Sun, 14 Nov 2021 03:10:33 +0000 (03:10 +0000)
Calculate dirty block groups only include estimated extents,
indirect blocks and extent node/leaf blocks are missed, this
could make us short of credits.

Lustre-change: https://review.whamcloud.com/43890
Lustre-commit: 42cda8781f94ad1138afac2d23180ea48f3c3450

Fixes: 0271b17b80a82 ("LU-14134 osd-ldiskfs: reduce credits for new writing")
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: Iec8525823b04e909c030f94bf75b8eca60d31c50
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/45506
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Tested-by: Andreas Dilger <adilger@whamcloud.com>
lustre/osd-ldiskfs/osd_io.c

index 6b1f43d..66e13c4 100644 (file)
@@ -1372,7 +1372,7 @@ static int osd_declare_write_commit(const struct lu_env *env,
        int                     extents = 0;
        int                     depth;
        int                     i;
-       int                     newblocks = 0;
+       int                     dirty_groups = 0;
        int                     rc = 0;
        int                     credits = 0;
        long long               quota_space = 0;
@@ -1422,7 +1422,6 @@ static int osd_declare_write_commit(const struct lu_env *env,
                }
 
                /* count only unmapped changes */
-               newblocks++;
                if (lnb[i].lnb_file_offset != extent.end || extent.end == 0) {
                        if (extent.end != 0)
                                extents += (extent.end - extent.start +
@@ -1441,7 +1440,7 @@ static int osd_declare_write_commit(const struct lu_env *env,
         * overwrite case, no need to modify tree and
         * allocate blocks.
         */
-       if (!newblocks)
+       if (!extent.end)
                goto out_declare;
 
        extents += (extent.end - extent.start +
@@ -1458,6 +1457,7 @@ static int osd_declare_write_commit(const struct lu_env *env,
        if (extents > MAX_EXTENTS_PER_WRITE)
                extents = MAX_EXTENTS_PER_WRITE;
 
+       dirty_groups = extents;
        /*
         * each extent can go into new leaf causing a split
         * 5 is max tree depth: inode + 4 index blocks
@@ -1470,11 +1470,11 @@ static int osd_declare_write_commit(const struct lu_env *env,
                 */
                depth = ext_depth(inode);
                depth = max(depth, 1) + 1;
-               newblocks += depth;
+               dirty_groups += depth;
                credits += depth * 2 * extents;
        } else {
                depth = 3;
-               newblocks += depth;
+               dirty_groups += depth;
                credits += depth * extents;
        }
 
@@ -1489,16 +1489,16 @@ static int osd_declare_write_commit(const struct lu_env *env,
        /* each new block can go in different group (bitmap + gd) */
 
        /* we can't dirty more bitmap blocks than exist */
-       if (extents > LDISKFS_SB(osd_sb(osd))->s_groups_count)
+       if (dirty_groups > LDISKFS_SB(osd_sb(osd))->s_groups_count)
                credits += LDISKFS_SB(osd_sb(osd))->s_groups_count;
        else
-               credits += extents;
+               credits += dirty_groups;
 
        /* we can't dirty more gd blocks than exist */
        if (extents > LDISKFS_SB(osd_sb(osd))->s_gdb_count)
                credits += LDISKFS_SB(osd_sb(osd))->s_gdb_count;
        else
-               credits += extents;
+               credits += dirty_groups;
 
        CDEBUG(D_INODE,
               "%s: inode #%lu extent_bytes %u extents %d credits %d\n",