Whamcloud - gitweb
LU-10026 ldiskfs: mballoc to preserve preallocation's start 67/55467/2
authorAlex Zhuravlev <bzzz@whamcloud.com>
Tue, 4 Jun 2024 12:25:35 +0000 (15:25 +0300)
committerOleg Drokin <green@whamcloud.com>
Sun, 24 Nov 2024 06:04:19 +0000 (06:04 +0000)
.. used in dense preallocation. otherwise it's possible to lose
preallocated space when the corresponding cache bitmap is dropped
from the cache, then ldiskfs will be printing error messages
about block counter mismatch.

Fixes: 686dee707f ("LU-10026 osd-ldiskfs: use preallocation for dense writes")
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I93177510af959e849dba7a9c35d81bc27809a31b
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55467
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
ldiskfs/kernel_patches/patches/rhel8/ext4-mballoc-dense.patch

index a3d17ff..e920283 100644 (file)
        if (flags & EXT4_GET_BLOCKS_METADATA_NOFAIL)
 --- linux-4.18.0-80.1.2.el8_0.orig/fs/ext4/mballoc.c
 +++ linux-4.18.0-80.1.2.el8_0/fs/ext4/mballoc.c
-@@ -4267,6 +4291,25 @@ ext4_mb_use_inode_pa(struct ext4
+@@ -4267,6 +4291,23 @@ ext4_mb_use_inode_pa(struct ext4
        ext4_fsblk_t end;
        int len;
 
-+      if (ac->ac_flags & EXT4_MB_VERY_DENSE && !pa->pa_regular) {
++      if (!pa->pa_regular && (ac->ac_flags & EXT4_MB_VERY_DENSE ||
++          pa->pa_free != pa->pa_len)) {
 +              unsigned int len = ac->ac_o_ex.fe_len;
 +              if (len > pa->pa_free)
 +                      len = pa->pa_free;
 +              ext4_get_group_no_and_offset(ac->ac_sb,
-+                                      pa->pa_pstart,
++                                      pa->pa_pstart + (pa->pa_len - pa->pa_free),
 +                                      &ac->ac_b_ex.fe_group,
 +                                      &ac->ac_b_ex.fe_start);
 +              ac->ac_b_ex.fe_len = len;
-+              pa->pa_lstart += len;
-+              pa->pa_pstart += len;
 +              pa->pa_free -= len;
-+              pa->pa_len -= len;
 +              ac->ac_status = AC_STATUS_FOUND;
 +              ac->ac_pa = pa;
 +              return;