fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / jfs / jfs_logmgr.h
index 995f124..a53fb17 100644 (file)
@@ -4,16 +4,16 @@
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or 
+ *   the Free Software Foundation; either version 2 of the License, or
  *   (at your option) any later version.
- * 
+ *
  *   This program is distributed in the hope that it will be useful,
  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
  *   the GNU General Public License for more details.
  *
  *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software 
+ *   along with this program;  if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 #ifndef        _H_JFS_LOGMGR
 /*
  *     log logical volume
  *
- * a log is used to make the commit operation on journalled 
+ * a log is used to make the commit operation on journalled
  * files within the same logical volume group atomic.
  * a log is implemented with a logical volume.
- * there is one log per logical volume group. 
+ * there is one log per logical volume group.
  *
  * block 0 of the log logical volume is not used (ipl etc).
  * block 1 contains a log "superblock" and is used by logFormat(),
- * lmLogInit(), lmLogShutdown(), and logRedo() to record status 
- * of the log but is not otherwise used during normal processing. 
+ * lmLogInit(), lmLogShutdown(), and logRedo() to record status
+ * of the log but is not otherwise used during normal processing.
  * blocks 2 - (N-1) are used to contain log records.
  *
- * when a volume group is varied-on-line, logRedo() must have 
- * been executed before the file systems (logical volumes) in 
+ * when a volume group is varied-on-line, logRedo() must have
+ * been executed before the file systems (logical volumes) in
  * the volume group can be mounted.
  */
 /*
 #define MAX_ACTIVE     128     /* Max active file systems sharing log */
 
 struct logsuper {
-       u32 magic;              /* 4: log lv identifier */
-       s32 version;            /* 4: version number */
-       s32 serial;             /* 4: log open/mount counter */
-       s32 size;               /* 4: size in number of LOGPSIZE blocks */
-       s32 bsize;              /* 4: logical block size in byte */
-       s32 l2bsize;            /* 4: log2 of bsize */
+       __le32 magic;           /* 4: log lv identifier */
+       __le32 version;         /* 4: version number */
+       __le32 serial;          /* 4: log open/mount counter */
+       __le32 size;            /* 4: size in number of LOGPSIZE blocks */
+       __le32 bsize;           /* 4: logical block size in byte */
+       __le32 l2bsize;         /* 4: log2 of bsize */
 
-       u32 flag;               /* 4: option */
-       u32 state;              /* 4: state - see below */
+       __le32 flag;            /* 4: option */
+       __le32 state;           /* 4: state - see below */
 
-       s32 end;                /* 4: addr of last log record set by logredo */
+       __le32 end;             /* 4: addr of last log record set by logredo */
        char uuid[16];          /* 16: 128-bit journal uuid */
        char label[16];         /* 16: journal label */
        struct {
@@ -97,41 +97,41 @@ struct logsuper {
  *     log logical page
  *
  * (this comment should be rewritten !)
- * the header and trailer structures (h,t) will normally have 
+ * the header and trailer structures (h,t) will normally have
  * the same page and eor value.
- * An exception to this occurs when a complete page write is not 
+ * An exception to this occurs when a complete page write is not
  * accomplished on a power failure. Since the hardware may "split write"
- * sectors in the page, any out of order sequence may occur during powerfail 
+ * sectors in the page, any out of order sequence may occur during powerfail
  * and needs to be recognized during log replay.  The xor value is
  * an "exclusive or" of all log words in the page up to eor.  This
  * 32 bit eor is stored with the top 16 bits in the header and the
  * bottom 16 bits in the trailer.  logredo can easily recognize pages
- * that were not completed by reconstructing this eor and checking 
+ * that were not completed by reconstructing this eor and checking
  * the log page.
  *
- * Previous versions of the operating system did not allow split 
- * writes and detected partially written records in logredo by 
- * ordering the updates to the header, trailer, and the move of data 
- * into the logdata area.  The order: (1) data is moved (2) header 
- * is updated (3) trailer is updated.  In logredo, when the header 
- * differed from the trailer, the header and trailer were reconciled 
- * as follows: if h.page != t.page they were set to the smaller of 
- * the two and h.eor and t.eor set to 8 (i.e. empty page). if (only) 
+ * Previous versions of the operating system did not allow split
+ * writes and detected partially written records in logredo by
+ * ordering the updates to the header, trailer, and the move of data
+ * into the logdata area.  The order: (1) data is moved (2) header
+ * is updated (3) trailer is updated.  In logredo, when the header
+ * differed from the trailer, the header and trailer were reconciled
+ * as follows: if h.page != t.page they were set to the smaller of
+ * the two and h.eor and t.eor set to 8 (i.e. empty page). if (only)
  * h.eor != t.eor they were set to the smaller of their two values.
  */
 struct logpage {
        struct {                /* header */
-               s32 page;       /* 4: log sequence page number */
-               s16 rsrvd;      /* 2: */
-               s16 eor;        /* 2: end-of-log offset of lasrt record write */
+               __le32 page;    /* 4: log sequence page number */
+               __le16 rsrvd;   /* 2: */
+               __le16 eor;     /* 2: end-of-log offset of lasrt record write */
        } h;
 
-       s32 data[LOGPSIZE / 4 - 4];     /* log record area */
+       __le32 data[LOGPSIZE / 4 - 4];  /* log record area */
 
        struct {                /* trailer */
-               s32 page;       /* 4: normally the same as h.page */
-               s16 rsrvd;      /* 2: */
-               s16 eor;        /* 2: normally the same as h.eor */
+               __le32 page;    /* 4: normally the same as h.page */
+               __le16 rsrvd;   /* 2: */
+               __le16 eor;     /* 2: normally the same as h.eor */
        } t;
 };
 
@@ -147,20 +147,20 @@ struct logpage {
  * in a  page, pages are written to temporary paging space if
  * if they must be written to disk before commit, and i/o is
  * scheduled for modified pages to their home location after
- * the log records containing the after values and the commit 
+ * the log records containing the after values and the commit
  * record is written to the log on disk, undo discards the copy
  * in main-memory.)
  *
- * a log record consists of a data area of variable length followed by 
+ * a log record consists of a data area of variable length followed by
  * a descriptor of fixed size LOGRDSIZE bytes.
- * the  data area is rounded up to an integral number of 4-bytes and 
+ * the  data area is rounded up to an integral number of 4-bytes and
  * must be no longer than LOGPSIZE.
- * the descriptor is of size of multiple of 4-bytes and aligned on a 
- * 4-byte boundary. 
+ * the descriptor is of size of multiple of 4-bytes and aligned on a
+ * 4-byte boundary.
  * records are packed one after the other in the data area of log pages.
- * (sometimes a DUMMY record is inserted so that at least one record ends 
+ * (sometimes a DUMMY record is inserted so that at least one record ends
  * on every page or the longest record is placed on at most two pages).
- * the field eor in page header/trailer points to the byte following 
+ * the field eor in page header/trailer points to the byte following
  * the last record on a page.
  */
 
@@ -202,11 +202,11 @@ struct lrd {
        /*
         * type independent area
         */
-       s32 logtid;             /* 4: log transaction identifier */
-       s32 backchain;          /* 4: ptr to prev record of same transaction */
-       u16 type;               /* 2: record type */
-       s16 length;             /* 2: length of data in record (in byte) */
-       u32 aggregate;          /* 4: file system lv/aggregate */
+       __le32 logtid;          /* 4: log transaction identifier */
+       __le32 backchain;       /* 4: ptr to prev record of same transaction */
+       __le16 type;            /* 2: record type */
+       __le16 length;          /* 2: length of data in record (in byte) */
+       __le32 aggregate;       /* 4: file system lv/aggregate */
        /* (16) */
 
        /*
@@ -228,10 +228,10 @@ struct lrd {
                 * N.B. REDOPAGE, NOREDOPAGE, and UPDATEMAP must be same format;
                 */
                struct {
-                       u32 fileset;    /* 4: fileset number */
-                       u32 inode;      /* 4: inode number */
-                       u16 type;       /* 2: REDOPAGE record type */
-                       s16 l2linesize; /* 2: log2 of line size */
+                       __le32 fileset; /* 4: fileset number */
+                       __le32 inode;   /* 4: inode number */
+                       __le16 type;    /* 2: REDOPAGE record type */
+                       __le16 l2linesize;      /* 2: log2 of line size */
                        pxd_t pxd;      /* 8: on-disk page pxd */
                } redopage;     /* (20) */
 
@@ -244,10 +244,10 @@ struct lrd {
                 * N.B. REDOPAGE, NOREDOPAGE, and UPDATEMAP must be same format;
                 */
                struct {
-                       s32 fileset;    /* 4: fileset number */
-                       u32 inode;      /* 4: inode number */
-                       u16 type;       /* 2: NOREDOPAGE record type */
-                       s16 rsrvd;      /* 2: reserved */
+                       __le32 fileset; /* 4: fileset number */
+                       __le32 inode;   /* 4: inode number */
+                       __le16 type;    /* 2: NOREDOPAGE record type */
+                       __le16 rsrvd;   /* 2: reserved */
                        pxd_t pxd;      /* 8: on-disk page pxd */
                } noredopage;   /* (20) */
 
@@ -260,28 +260,28 @@ struct lrd {
                 * N.B. REDOPAGE, NOREDOPAGE, and UPDATEMAP must be same format;
                 */
                struct {
-                       u32 fileset;    /* 4: fileset number */
-                       u32 inode;      /* 4: inode number */
-                       u16 type;       /* 2: UPDATEMAP record type */
-                       s16 nxd;        /* 2: number of extents */
+                       __le32 fileset; /* 4: fileset number */
+                       __le32 inode;   /* 4: inode number */
+                       __le16 type;    /* 2: UPDATEMAP record type */
+                       __le16 nxd;     /* 2: number of extents */
                        pxd_t pxd;      /* 8: pxd */
                } updatemap;    /* (20) */
 
                /*
                 *      NOREDOINOEXT: the inode extent is freed
                 *
-                * do not apply after-image records which precede this 
-                * record in the log with the any of the 4 page block 
-                * numbers in this inode extent. 
-                * 
-                * NOTE: The fileset and pxd fields MUST remain in 
+                * do not apply after-image records which precede this
+                * record in the log with the any of the 4 page block
+                * numbers in this inode extent.
+                *
+                * NOTE: The fileset and pxd fields MUST remain in
                 *       the same fields in the REDOPAGE record format.
                 *
                 */
                struct {
-                       s32 fileset;    /* 4: fileset number */
-                       s32 iagnum;     /* 4: IAG number     */
-                       s32 inoext_idx; /* 4: inode extent index */
+                       __le32 fileset; /* 4: fileset number */
+                       __le32 iagnum;  /* 4: IAG number     */
+                       __le32 inoext_idx;      /* 4: inode extent index */
                        pxd_t pxd;      /* 8: on-disk page pxd */
                } noredoinoext; /* (20) */
 
@@ -291,7 +291,7 @@ struct lrd {
                 * replay log upto syncpt address specified;
                 */
                struct {
-                       s32 sync;       /* 4: syncpt address (0 = here) */
+                       __le32 sync;    /* 4: syncpt address (0 = here) */
                } syncpt;
 
                /*
@@ -307,8 +307,8 @@ struct lrd {
                 * N.B.: nextents should be length of data/sizeof(xad_t)
                 */
                struct {
-                       s32 type;       /* 4: FREEXTENT record type */
-                       s32 nextent;    /* 4: number of extents */
+                       __le32 type;    /* 4: FREEXTENT record type */
+                       __le32 nextent; /* 4: number of extents */
 
                        /* data: PXD or XAD list */
                } freextent;
@@ -319,27 +319,25 @@ struct lrd {
                 * do not apply records which precede this record in the log
                 * with the same inode number.
                 *
-                * NOREDILE must be the first to be written at commit
+                * NOREDOFILE must be the first to be written at commit
                 * (last to be read in logredo()) - it prevents
                 * replay of preceding updates of all preceding generations
-                * of the inumber esp. the on-disk inode itself, 
-                * but does NOT prevent
-                * replay of the 
+                * of the inumber esp. the on-disk inode itself.
                 */
                struct {
-                       s32 fileset;    /* 4: fileset number */
-                       u32 inode;      /* 4: inode number */
+                       __le32 fileset; /* 4: fileset number */
+                       __le32 inode;   /* 4: inode number */
                } noredofile;
 
                /*
-                *      ? NEWPAGE: 
+                *      ? NEWPAGE:
                 *
                 * metadata type dependent
                 */
                struct {
-                       s32 fileset;    /* 4: fileset number */
-                       u32 inode;      /* 4: inode number */
-                       s32 type;       /* 4: NEWPAGE record type */
+                       __le32 fileset; /* 4: fileset number */
+                       __le32 inode;   /* 4: inode number */
+                       __le32 type;    /* 4: NEWPAGE record type */
                        pxd_t pxd;      /* 8: on-disk page pxd */
                } newpage;
 
@@ -357,8 +355,8 @@ struct lrd {
  *     line vector descriptor
  */
 struct lvd {
-       s16 offset;
-       s16 length;
+       __le16 offset;
+       __le16 length;
 };
 
 
@@ -372,7 +370,7 @@ struct jfs_log {
                                 */
        struct list_head journal_list; /* Global list */
        struct block_device *bdev; /* 4: log lv pointer */
-       s32 serial;             /* 4: log mount serial number */
+       int serial;             /* 4: log mount serial number */
 
        s64 base;               /* @8: log extent address (inline log ) */
        int size;               /* 4: log size in log page (in page) */
@@ -389,7 +387,7 @@ struct jfs_log {
        int eor;                /* 4: eor of last record in eol page */
        struct lbuf *bp;        /* 4: current log page buffer */
 
-       struct semaphore loglock;       /* 4: log write serialization lock */
+       struct mutex loglock;   /* 4: log write serialization lock */
 
        /* syncpt */
        int nextsync;           /* 4: bytes to write before next syncpt */
@@ -398,7 +396,7 @@ struct jfs_log {
 
        /* commit */
        uint cflag;             /* 4: */
-       struct list_head        cqueue; /* FIFO commit queue */
+       struct list_head cqueue; /* FIFO commit queue */
        struct tblock *flush_tblk; /* tblk we're waiting on for flush */
        int gcrtc;              /* 4: GC_READY transaction count */
        struct tblock *gclrt;   /* 4: latest GC_READY transaction */
@@ -463,9 +461,10 @@ struct lbuf {
 
        s64 l_blkno;            /* 8: log page block number */
        caddr_t l_ldata;        /* 4: data page */
+       struct page *l_page;    /* The page itself */
+       uint l_offset;          /* Offset of l_ldata within the page */
 
        wait_queue_head_t l_ioevent;    /* 4: i/o done event */
-       struct page *l_page;    /* The page itself */
 };
 
 /* Reuse l_freelist for redrive list */
@@ -489,8 +488,9 @@ struct logsyncblk {
  */
 
 #define LOGSYNC_LOCK_INIT(log) spin_lock_init(&(log)->synclock)
-#define LOGSYNC_LOCK(log) spin_lock(&(log)->synclock)
-#define LOGSYNC_UNLOCK(log) spin_unlock(&(log)->synclock)
+#define LOGSYNC_LOCK(log, flags) spin_lock_irqsave(&(log)->synclock, flags)
+#define LOGSYNC_UNLOCK(log, flags) \
+       spin_unlock_irqrestore(&(log)->synclock, flags)
 
 /* compute the difference in bytes of lsn from sync point */
 #define logdiff(diff, lsn, log)\
@@ -505,6 +505,9 @@ extern int lmLogClose(struct super_block *sb);
 extern int lmLogShutdown(struct jfs_log * log);
 extern int lmLogInit(struct jfs_log * log);
 extern int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize);
+extern int lmGroupCommit(struct jfs_log *, struct tblock *);
+extern int jfsIOWait(void *);
 extern void jfs_flush_journal(struct jfs_log * log, int wait);
+extern void jfs_syncpt(struct jfs_log *log, int hard_sync);
 
 #endif                         /* _H_JFS_LOGMGR */