From 6f3a74986a37babc93acda56fd3d9891745c224e Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Wed, 15 Jun 2011 13:41:46 -0600 Subject: [PATCH] LU-264 Use ext2fs_get_memalign() to align memory Use the ext2fs_get_memalign() function that is available in newer versions of e2fsprogs instead of open-coding it for the MMP block buffer reads that use O_DIRECT. Change-Id: I18702097fe2967614f9c1d2462a2436786bad70e Signed-off-by: Andreas Dilger --- patches/e2fsprogs-mmp.patch | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/patches/e2fsprogs-mmp.patch b/patches/e2fsprogs-mmp.patch index aae67d1..79c49aa 100644 --- a/patches/e2fsprogs-mmp.patch +++ b/patches/e2fsprogs-mmp.patch @@ -609,14 +609,13 @@ Index: e2fsprogs/lib/ext2fs/ext2fs.h struct struct_ext2_filsys { errcode_t magic; io_channel io; -@@ -249,6 +259,19 @@ struct struct_ext2_filsys { +@@ -249,6 +259,18 @@ struct struct_ext2_filsys { io_channel image_io; /* + * Buffers for Multiple mount protection(MMP) block. + */ + void *mmp_buf; -+ void *mmp_unaligned_buf; + void *mmp_cmp; + int mmp_fd; + @@ -680,8 +679,8 @@ Index: e2fsprogs/lib/ext2fs/freefs.c + if (fs->mmp_buf) + ext2fs_free_mem(&fs->mmp_buf); -+ if (fs->mmp_unaligned_buf) -+ ext2fs_free_mem(&fs->mmp_unaligned_buf); ++ if (fs->mmp_cmp) ++ ext2fs_free_mem(&fs->mmp_cmp); + fs->magic = 0; @@ -690,7 +689,7 @@ Index: e2fsprogs/lib/ext2fs/mmp.c =================================================================== --- /dev/null +++ e2fsprogs/lib/ext2fs/mmp.c -@@ -0,0 +1,417 @@ +@@ -0,0 +1,413 @@ +/* + * Helper functions for multiple mount protection (MMP). + * @@ -732,8 +731,6 @@ Index: e2fsprogs/lib/ext2fs/mmp.c +#endif +} + -+#define ptr_align(ptr, size) (void *)(((unsigned long)(ptr) + (size) - 1) & \ -+ ~((unsigned long)(size) - 1)) +#ifndef O_DIRECT +#define O_DIRECT 0 +#endif @@ -756,10 +753,9 @@ Index: e2fsprogs/lib/ext2fs/mmp.c + + if (bufsize < mmp_pagesize()) + bufsize = mmp_pagesize(); -+ retval = ext2fs_get_mem(bufsize * 2, &fs->mmp_unaligned_buf); ++ retval = ext2fs_get_memalign(bufsize, bufsize, &fs->mmp_cmp); + if (retval) + return retval; -+ fs->mmp_cmp = ptr_align(fs->mmp_unaligned_buf, bufsize); + } + + /* ext2fs_open reserves fd0,1,2 to avoid stdio collision */ @@ -1063,9 +1059,8 @@ Index: e2fsprogs/lib/ext2fs/mmp.c + ext2fs_free_mem(&fs->mmp_buf); + fs->mmp_buf = NULL; + } -+ if (fs->mmp_unaligned_buf) { -+ ext2fs_free_mem(&fs->mmp_unaligned_buf); -+ fs->mmp_unaligned_buf = NULL; ++ if (fs->mmp_cmp) { ++ ext2fs_free_mem(&fs->mmp_cmp); + fs->mmp_cmp = NULL; + } + -- 1.8.3.1