vfs_journal.c code questions

Rongsheng Fang rfang at coke.umuc.edu
Tue Mar 8 09:49:57 PST 2005


I was reading through the vfs_journal.c code and was confused by some
of the code:

/usr/src/sys/kern/vfs_journal.c

In function journal_install_vfs_journal()

. ..
jrecord_init(jo, &jrec, JREC_STREAMID_DISCONT);
jrecord_write(&jrec, JTYPE_ASSOCIATE, 0);
. ..


1) the `streamid' parameter for jrecord_init() is set to
   JREC_STREAMID_DISCONT which is defined as 0x0002.

   While in function jrecord_init():

    ...
    if (streamid < 0) {
        streamid = sid++;       /* XXX need to track stream ids! */
        if (sid == JREC_STREAMID_JMAX)
            sid = JREC_STREAMID_JMIN;
    }
    jrec->streamid = streamid;
    ...

    So now jrec->streamid is JREC_STREAMID_DISCONT (0x0002).

    Shouldn't streamid be some number between JREC_STREAMID_JMIN and
    JREC_STREAMID_JMAX?

#define JREC_STREAMID_JMIN      0x0100  /* lowest allowed general id */
#define JREC_STREAMID_JMAX      0x2000  /* (one past the highest allowed id) */

2) then jrecord_write() comes right after jrecord_init() (also in
   function journal_install_vfs_journal()): 
   
   jrecord_write(&jrec, JTYPE_ASSOCIATE, 0);

   In function jrecord_write():
    
    /*
     * Try to catch some obvious errors.  Nesting records must specify a
     * size of 0, and there should be no left-overs from previous operations
     * (such as incomplete data writeouts).
     */
    KKASSERT(bytes == 0 || (rectype & JMASK_NESTED) == 0);
    KKASSERT(jrec->residual == 0);

    Then the kernel is going to panic? Actually it's not in practice, so
    I am a bit confused :(

Thanks,

Rongsheng





More information about the Kernel mailing list