Whamcloud - gitweb
libe2p: remove nested #ifdefs in fgetflags.c and fsetflags.c
[tools/e2fsprogs.git] / lib / e2p / ljs.c
index 0b1bead..5972819 100644 (file)
@@ -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) {
@@ -54,7 +65,12 @@ void e2p_list_journal_super(FILE *f, char *journal_sb_buf,
        unsigned int size;
        int j, printed = 0;
        unsigned int i, nr_users;
+       int num_fc_blks = 0;
+       int journal_blks = 0;
 
+       if (flags & E2P_LIST_JOURNAL_FLAG_FC)
+               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++) {
                mask = e2p_be32(*mask_ptr);
@@ -68,7 +84,7 @@ void e2p_list_journal_super(FILE *f, char *journal_sb_buf,
        if (printed == 0)
                fprintf(f, " (none)");
        fputc('\n', f);
-       fputs("Journal size:             ", f);
+       fputs("Total journal size:       ", f);
        size = (ntohl(jsb->s_blocksize) / 1024) * ntohl(jsb->s_maxlen);
        if (size < 8192)
                fprintf(f, "%uk\n", size);
@@ -78,8 +94,13 @@ void e2p_list_journal_super(FILE *f, char *journal_sb_buf,
        if (exp_block_size != (int) ntohl(jsb->s_blocksize))
                fprintf(f, "Journal block size:       %u\n",
                        (unsigned int)ntohl(jsb->s_blocksize));
-       fprintf(f, "Journal length:           %u\n",
-               (unsigned int)ntohl(jsb->s_maxlen));
+       fprintf(f, "Total journal blocks:     %u\n",
+               (unsigned int)(journal_blks + num_fc_blks));
+       fprintf(f, "Max transaction length:   %u\n",
+               (unsigned int)journal_blks);
+       fprintf(f, "Fast commit length:       %u\n",
+               (unsigned int)num_fc_blks);
+
        if (ntohl(jsb->s_first) != 1)
                fprintf(f, "Journal first block:      %u\n",
                        (unsigned int)ntohl(jsb->s_first));
@@ -89,22 +110,22 @@ void e2p_list_journal_super(FILE *f, char *journal_sb_buf,
                (unsigned int)ntohl(jsb->s_start));
        if (nr_users != 1)
                fprintf(f, "Journal number of users:  %u\n", nr_users);
-       if (jsb->s_feature_compat & e2p_be32(JFS_FEATURE_COMPAT_CHECKSUM))
+       if (jsb->s_feature_compat & e2p_be32(JBD2_FEATURE_COMPAT_CHECKSUM))
                fprintf(f, "%s", "Journal checksum type:    crc32\n");
        if ((jsb->s_feature_incompat &
-            e2p_be32(JFS_FEATURE_INCOMPAT_CSUM_V3)) ||
+            e2p_be32(JBD2_FEATURE_INCOMPAT_CSUM_V3)) ||
            (jsb->s_feature_incompat &
-            e2p_be32(JFS_FEATURE_INCOMPAT_CSUM_V2)))
+            e2p_be32(JBD2_FEATURE_INCOMPAT_CSUM_V2)))
                fprintf(f, "Journal checksum type:    %s\n"
                        "Journal checksum:         0x%08x\n",
                        journal_checksum_type_str(jsb->s_checksum_type),
                        e2p_be32(jsb->s_checksum));
        if ((nr_users > 1) ||
            !e2p_is_null_uuid(&jsb->s_users[0])) {
-               for (i=0; i < nr_users; i++) {
+               for (i=0; i < nr_users && i < JBD2_USERS_MAX; i++) {
                        printf(i ? "                          %s\n"
                               : "Journal users:            %s\n",
-                              e2p_uuid2str(&jsb->s_users[i*16]));
+                              e2p_uuid2str(&jsb->s_users[i * UUID_SIZE]));
                }
        }
        if (jsb->s_errno != 0)