On Wed, Jan 20, 2021 at 01:26:26PM -0800, Harshad Shirwadkar wrote: > > - Fix compilation error by defining jbd2_journal_get_fc_num_blks (also > rename it to jbd_get_fc_num_blks) as a preprocessor macro instead of > inline function which gets compiled out when "-g" is passed Unfortunately, this still doesn't quite fix things. The problem with this approach is the preprocessor macro uses be32_to_cpu(), which gets turned into ext2fs_swab32(). And the libe2p shared library is not allowed to depend on libext2fs. Otherwise when we build with configure --enable-elf-shlibs, the link of misc/chattr fails with: <tytso@cwcc> {/build/e2fsprogs/misc} 1078% make V=1 ../util/subst -f ../util/subst.conf /usr/projects/e2fsprogs/e2fsprogs/lib/dirpaths.h.in ../lib/dirpaths.h gcc -Wl,-rpath-link,../lib -o chattr chattr.o ../lib/libe2p.so ../lib/libcom_err.so \ /bin/ld: ../lib/libe2p.so: undefined reference to `ext2fs_swab32' collect2: error: ld returned 1 exit status make: *** [Makefile:636: chattr] Error 1 We had already defined e2p_be32() and use it in other places in lib/e2p/ljs.c. So I fixed this by taking your Dec 10th version of the patch series, and making the following change to patch 4/15: diff --git a/lib/e2p/ljs.c b/lib/e2p/ljs.c index 9f866c7e..59728198 100644 --- a/lib/e2p/ljs.c +++ b/lib/e2p/ljs.c @@ -36,6 +36,17 @@ static __u32 e2p_swab32(__u32 val) #define e2p_be32(x) e2p_swab32(x) #endif +/* + * This function is copied from kernel-jbd.h's function + * jbd2_journal_get_num_fc_blks() to avoid inter-library dependencies. + */ +static inline int get_num_fc_blks(journal_superblock_t *jsb) +{ + int num_fc_blocks = e2p_be32(jsb->s_num_fc_blks); + + return num_fc_blocks ? num_fc_blocks : JBD2_DEFAULT_FAST_COMMIT_BLOCKS; +} + static const char *journal_checksum_type_str(__u8 type) { switch (type) { @@ -58,7 +69,7 @@ void e2p_list_journal_super(FILE *f, char *journal_sb_buf, int journal_blks = 0; if (flags & E2P_LIST_JOURNAL_FLAG_FC) - num_fc_blks = jbd2_journal_get_num_fc_blks((journal_superblock_t *)journal_sb_buf); + num_fc_blks = get_num_fc_blks((journal_superblock_t *)journal_sb_buf); journal_blks = ntohl(jsb->s_maxlen) - num_fc_blks; fprintf(f, "%s", "Journal features: "); for (i=0, mask_ptr=&jsb->s_feature_compat; i <3; i++,mask_ptr++) {