]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: refactor aligned MMP buffer allocation
authorDarrick J. Wong <djwong@kernel.org>
Tue, 7 Oct 2025 17:36:12 +0000 (10:36 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 9 Mar 2026 02:14:03 +0000 (19:14 -0700)
Hoist the code that allocates an MMP buffer into a separate helper.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
debian/libext2fs2t64.symbols
lib/ext2fs/dupfs.c
lib/ext2fs/ext2fs.h
lib/ext2fs/mmp.c

index 01f4f269a2660e980076048d0dbb65e3b346277a..affe4c27d4e7916b98656f44941c482df52c972e 100644 (file)
@@ -448,6 +448,7 @@ libext2fs.so.2 libext2fs2t64 #MINVER#
  ext2fs_mmp_clear@Base 1.42
  ext2fs_mmp_csum_set@Base 1.43
  ext2fs_mmp_csum_verify@Base 1.43
+ ext2fs_mmp_get_mem@Base 1.47.4
  ext2fs_mmp_init@Base 1.42
  ext2fs_mmp_new_seq@Base 1.42
  ext2fs_mmp_read@Base 1.42
index 02721e1a574a1fef6b0c2a59cbe651303b42af39..0fd4e6c67afb5d3bc7b5c32e3472f1a28481dda9 100644 (file)
@@ -104,10 +104,7 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest)
                }
        }
        if (src->mmp_cmp) {
-               int align = ext2fs_get_dio_alignment(src->mmp_fd);
-
-               retval = ext2fs_get_memalign(src->blocksize, align,
-                                            &fs->mmp_cmp);
+               retval = ext2fs_mmp_get_mem(src, &fs->mmp_cmp);
                if (retval)
                        goto errout;
                memcpy(fs->mmp_cmp, src->mmp_cmp, src->blocksize);
index 02212e8ffa597475e8ce0f8108a30c11b2e0777c..0b93bbd356fc152234bb4977eb3095a26071624f 100644 (file)
@@ -1863,6 +1863,7 @@ errcode_t ext2fs_mmp_update(ext2_filsys fs);
 errcode_t ext2fs_mmp_update2(ext2_filsys fs, int immediately);
 errcode_t ext2fs_mmp_stop(ext2_filsys fs);
 unsigned ext2fs_mmp_new_seq(void);
+errcode_t ext2fs_mmp_get_mem(ext2_filsys fs, void **ptr);
 
 /* read_bb.c */
 extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs,
index 6337852c3f6700a5e6219e3274b2dceeb61d1586..41ef4e3e2aa6c5764a000c370a03ac288e36287b 100644 (file)
 #endif
 #endif
 
+errcode_t ext2fs_mmp_get_mem(ext2_filsys fs, void **ptr)
+{
+       int align = ext2fs_get_dio_alignment(fs->mmp_fd);
+
+       return ext2fs_get_memalign(fs->blocksize, align, ptr);
+}
+
 errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf)
 {
 #ifdef CONFIG_MMP
@@ -78,10 +85,7 @@ errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf)
        }
 
        if (fs->mmp_cmp == NULL) {
-               int align = ext2fs_get_dio_alignment(fs->mmp_fd);
-
-               retval = ext2fs_get_memalign(fs->blocksize, align,
-                                            &fs->mmp_cmp);
+               retval = ext2fs_mmp_get_mem(fs, &fs->mmp_cmp);
                if (retval)
                        return retval;
        }