[Bug 261850] Ext2 FileSystem: There is a bug in disk data block allocation

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 10 Feb 2022 02:10:07 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261850

            Bug ID: 261850
           Summary: Ext2 FileSystem: There is a bug in disk data block
                    allocation
           Product: Base System
           Version: 13.0-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: chenguang.wang@terapines.com

git diff fs/ext2fs/ext2_alloc.c
diff --git a/fs/ext2fs/ext2_alloc.c b/fs/ext2fs/ext2_alloc.c
index 4c265a1a8..9e05d02de 100644
--- a/fs/ext2fs/ext2_alloc.c
+++ b/fs/ext2fs/ext2_alloc.c
@@ -1067,7 +1067,7 @@ ext2_alloccg(struct inode *ip, int cg, daddr_t bpref, int
size)
                start = dtogd(fs, bpref) / NBBY;
        else
                start = 0;
-       end = howmany(fs->e2fs_fpg, NBBY) - start;
+       end = howmany(fs->e2fs_fpg, NBBY);
 retry:
        runlen = 0;
        runstart = 0;

    In this function, the variable "start" is the starting position where we
traverse the block bitmap of a cylinder group , and the variable "end" is the
ending position. Therefore, I don't think we should subtract "start" in the
process of calculating "end".
    In fact, I'm not sure if there's something wrong with my understanding. I
would be very grateful if someone could help me!

-- 
You are receiving this mail because:
You are the assignee for the bug.