http://jfs.bkbits.net/linux-2.5
jfs.adm@bkbits.net|ChangeSet|20041108204834|60879 jfs.adm

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/11/01 08:00:01-06:00 shaggy@austin.ibm.com 
#   JFS: make some symbols static
#   
#   The patch below makes some JFS symbols that are only used inside the
#   file they are defined in static.
#   
#   Signed-off-by: Adrian Bunk <bunk@stusta.de>
#   Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
# 
# fs/jfs/jfs_txnmgr.c
#   2004/11/01 07:59:47-06:00 shaggy@austin.ibm.com +2 -2
#   Add static keywords
# 
# fs/jfs/jfs_metapage.c
#   2004/11/01 07:59:47-06:00 shaggy@austin.ibm.com +1 -1
#   Add static keywords
# 
# fs/jfs/jfs_logmgr.c
#   2004/11/01 07:59:47-06:00 shaggy@austin.ibm.com +4 -4
#   Add static keywords
# 
# ChangeSet
#   2004/11/01 07:55:47-06:00 shaggy@austin.ibm.com 
#   JFS: use alloc_metapage for consistency
#   
#   We defind alloc_metapage, but instead of using it, the potential callers
#   are calling mempool_alloc directly.  Since we have and use the function,
#   free_metapage, we should be consistent and use alloc_metapage.
#   
#   This patch also changes the argument to alloc_metapage so that the
#   caller passes gfp_mask directly, rather than a less descriptive flag.
#   
#   Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
# 
# fs/jfs/jfs_metapage.c
#   2004/11/01 07:55:33-06:00 shaggy@austin.ibm.com +4 -4
#   use alloc_metapage instead of calling mempool_alloc directly
# 
# ChangeSet
#   2004/10/26 12:12:49-05:00 shaggy@austin.ibm.com 
#   JFS: endian annotations
#   
#   Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
# 
# fs/jfs/jfs_xtree.h
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +7 -7
#   endian annotations
# 
# fs/jfs/jfs_xtree.c
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +1 -1
#   endian annotations
# 
# fs/jfs/jfs_xattr.h
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +2 -2
#   endian annotations
# 
# fs/jfs/jfs_unicode.h
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +24 -8
#   endian annotations
# 
# fs/jfs/jfs_unicode.c
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +1 -1
#   endian annotations
# 
# fs/jfs/jfs_types.h
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +8 -8
#   endian annotations
# 
# fs/jfs/jfs_superblock.h
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +16 -16
#   endian annotations
# 
# fs/jfs/jfs_mount.c
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +1 -1
#   endian annotations
# 
# fs/jfs/jfs_logmgr.h
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +48 -48
#   endian annotations
# 
# fs/jfs/jfs_imap.h
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +46 -28
#   endian annotations
# 
# fs/jfs/jfs_imap.c
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +33 -32
#   endian annotations
# 
# fs/jfs/jfs_dtree.h
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +9 -9
#   endian annotations
# 
# fs/jfs/jfs_dtree.c
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +15 -11
#   endian annotations
# 
# fs/jfs/jfs_dmap.h
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +46 -29
#   endian annotations
# 
# fs/jfs/jfs_dmap.c
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +5 -5
#   endian annotations
# 
# fs/jfs/jfs_dinode.h
#   2004/10/26 12:12:30-05:00 shaggy@austin.ibm.com +14 -14
#   endian annotations
# 
# ChangeSet
#   2004/10/26 08:43:22-05:00 shaggy@austin.ibm.com 
#   JFS: avoid assert in lbmfree
#   
#   In the error path, lmLogInit must clear log->lbuf_free before
#   calling lbmFree.
#   
#   Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
# 
# fs/jfs/jfs_logmgr.c
#   2004/10/26 08:43:01-05:00 shaggy@austin.ibm.com +2 -0
#   error path in lmLogInit must zero wqueue & l_wqnext when calling lbmFree
# 
# ChangeSet
#   2004/09/02 10:19:56-05:00 shaggy@austin.ibm.com 
#   JFS: Fix extent overflow bugs
#   
#   The code which handled adding a new extent when it is unable to grow an extent
#   past the maximum size made an invalid assumption about when the root page
#   would split.
#   
#   Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
# 
# fs/jfs/jfs_xtree.c
#   2004/09/02 10:19:36-05:00 shaggy@austin.ibm.com +26 -34
#   Code splitting extents when maximum extent size reached was buggy
# 
diff -Nru a/fs/jfs/jfs_dinode.h b/fs/jfs/jfs_dinode.h
--- a/fs/jfs/jfs_dinode.h	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_dinode.h	2004-11-09 00:31:18 -08:00
@@ -39,22 +39,22 @@
 	 *
 	 * define generic/POSIX attributes
 	 */
-	u32 di_inostamp;	/* 4: stamp to show inode belongs to fileset */
-	s32 di_fileset;		/* 4: fileset number */
-	u32 di_number;		/* 4: inode number, aka file serial number */
-	u32 di_gen;		/* 4: inode generation number */
+	__le32 di_inostamp;	/* 4: stamp to show inode belongs to fileset */
+	__le32 di_fileset;	/* 4: fileset number */
+	__le32 di_number;	/* 4: inode number, aka file serial number */
+	__le32 di_gen;		/* 4: inode generation number */
 
 	pxd_t di_ixpxd;		/* 8: inode extent descriptor */
 
-	s64 di_size;		/* 8: size */
-	s64 di_nblocks;		/* 8: number of blocks allocated */
+	__le64 di_size;		/* 8: size */
+	__le64 di_nblocks;	/* 8: number of blocks allocated */
 
-	u32 di_nlink;		/* 4: number of links to the object */
+	__le32 di_nlink;	/* 4: number of links to the object */
 
-	u32 di_uid;		/* 4: user id of owner */
-	u32 di_gid;		/* 4: group id of owner */
+	__le32 di_uid;		/* 4: user id of owner */
+	__le32 di_gid;		/* 4: group id of owner */
 
-	u32 di_mode;		/* 4: attribute, format and permission */
+	__le32 di_mode;		/* 4: attribute, format and permission */
 
 	struct timestruc_t di_atime;	/* 8: time last data accessed */
 	struct timestruc_t di_ctime;	/* 8: time last status changed */
@@ -65,9 +65,9 @@
 
 	dxd_t di_ea;		/* 16: ea descriptor */
 
-	u32 di_next_index;	/* 4: Next available dir_table index */
+	__le32 di_next_index;	/* 4: Next available dir_table index */
 
-	s32 di_acltype;		/* 4: Type of ACL */
+	__le32 di_acltype;	/* 4: Type of ACL */
 
 	/*
 	 *      Extension Areas.
@@ -103,7 +103,7 @@
 				u8 _data[96];		/* 96: unused */
 				struct {
 					void *_imap;	/* 4: unused */
-					u32 _gengen;	/* 4: generator */
+					__le32 _gengen;	/* 4: generator */
 				} _imap;
 			} _u1;				/* 96: */
 #define di_gengen	u._file._u1._imap._gengen
@@ -114,7 +114,7 @@
 					u8 unused[16];	/* 16: */
 					dxd_t _dxd;	/* 16: */
 					union {
-						u32 _rdev;	/* 4: */
+						__le32 _rdev;	/* 4: */
 						u8 _fastsymlink[128];
 					} _u;
 					u8 _inlineea[128];
diff -Nru a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
--- a/fs/jfs/jfs_dmap.c	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_dmap.c	2004-11-09 00:31:18 -08:00
@@ -194,7 +194,7 @@
 int dbMount(struct inode *ipbmap)
 {
 	struct bmap *bmp;
-	struct dbmap *dbmp_le;
+	struct dbmap_disk *dbmp_le;
 	struct metapage *mp;
 	int i;
 
@@ -216,7 +216,7 @@
 	}
 
 	/* copy the on-disk bmap descriptor to its in-memory version. */
-	dbmp_le = (struct dbmap *) mp->data;
+	dbmp_le = (struct dbmap_disk *) mp->data;
 	bmp->db_mapsize = le64_to_cpu(dbmp_le->dn_mapsize);
 	bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree);
 	bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
@@ -301,7 +301,7 @@
  */
 int dbSync(struct inode *ipbmap)
 {
-	struct dbmap *dbmp_le;
+	struct dbmap_disk *dbmp_le;
 	struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap;
 	struct metapage *mp;
 	int i;
@@ -318,7 +318,7 @@
 		return -EIO;
 	}
 	/* copy the in-memory version of the bmap to the on-disk version */
-	dbmp_le = (struct dbmap *) mp->data;
+	dbmp_le = (struct dbmap_disk *) mp->data;
 	dbmp_le->dn_mapsize = cpu_to_le64(bmp->db_mapsize);
 	dbmp_le->dn_nfree = cpu_to_le64(bmp->db_nfree);
 	dbmp_le->dn_l2nbperpage = cpu_to_le32(bmp->db_l2nbperpage);
@@ -3782,7 +3782,7 @@
 
 	/* set the rest of the words in the page to allocated (ONES) */
 	for (i = w; i < LPERDMAP; i++)
-		dp->pmap[i] = dp->wmap[i] = ONES;
+		dp->pmap[i] = dp->wmap[i] = cpu_to_le32(ONES);
 
 	/*
 	 * init tree
diff -Nru a/fs/jfs/jfs_dmap.h b/fs/jfs/jfs_dmap.h
--- a/fs/jfs/jfs_dmap.h	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_dmap.h	2004-11-09 00:31:18 -08:00
@@ -145,10 +145,10 @@
  * dmaptree must be consistent with dmapctl.
  */
 struct dmaptree {
-	s32 nleafs;		/* 4: number of tree leafs      */
-	s32 l2nleafs;		/* 4: l2 number of tree leafs   */
-	s32 leafidx;		/* 4: index of first tree leaf  */
-	s32 height;		/* 4: height of the tree        */
+	__le32 nleafs;		/* 4: number of tree leafs      */
+	__le32 l2nleafs;	/* 4: l2 number of tree leafs   */
+	__le32 leafidx;		/* 4: index of first tree leaf  */
+	__le32 height;		/* 4: height of the tree        */
 	s8 budmin;		/* 1: min l2 tree leaf value to combine */
 	s8 stree[TREESIZE];	/* TREESIZE: tree               */
 	u8 pad[2];		/* 2: pad to word boundary      */
@@ -158,13 +158,13 @@
  *	dmap page per 8K blocks bitmap
  */
 struct dmap {
-	s32 nblocks;		/* 4: num blks covered by this dmap     */
-	s32 nfree;		/* 4: num of free blks in this dmap     */
-	s64 start;		/* 8: starting blkno for this dmap      */
+	__le32 nblocks;		/* 4: num blks covered by this dmap     */
+	__le32 nfree;		/* 4: num of free blks in this dmap     */
+	__le64 start;		/* 8: starting blkno for this dmap      */
 	struct dmaptree tree;	/* 360: dmap tree                       */
 	u8 pad[1672];		/* 1672: pad to 2048 bytes              */
-	u32 wmap[LPERDMAP];	/* 1024: bits of the working map        */
-	u32 pmap[LPERDMAP];	/* 1024: bits of the persistent map     */
+	__le32 wmap[LPERDMAP];	/* 1024: bits of the working map        */
+	__le32 pmap[LPERDMAP];	/* 1024: bits of the persistent map     */
 };				/* - 4096 -                             */
 
 /*
@@ -173,10 +173,10 @@
  * dmapctl must be consistent with dmaptree.
  */
 struct dmapctl {
-	s32 nleafs;		/* 4: number of tree leafs      */
-	s32 l2nleafs;		/* 4: l2 number of tree leafs   */
-	s32 leafidx;		/* 4: index of the first tree leaf      */
-	s32 height;		/* 4: height of tree            */
+	__le32 nleafs;		/* 4: number of tree leafs      */
+	__le32 l2nleafs;	/* 4: l2 number of tree leafs   */
+	__le32 leafidx;		/* 4: index of the first tree leaf      */
+	__le32 height;		/* 4: height of tree            */
 	s8 budmin;		/* 1: minimum l2 tree leaf value        */
 	s8 stree[CTLTREESIZE];	/* CTLTREESIZE: dmapctl tree    */
 	u8 pad[2714];		/* 2714: pad to 4096            */
@@ -201,30 +201,47 @@
 /* 
  *	on-disk aggregate disk allocation map descriptor.
  */
-struct dbmap {
-	s64 dn_mapsize;		/* 8: number of blocks in aggregate     */
-	s64 dn_nfree;		/* 8: num free blks in aggregate map    */
-	s32 dn_l2nbperpage;	/* 4: number of blks per page           */
-	s32 dn_numag;		/* 4: total number of ags               */
-	s32 dn_maxlevel;	/* 4: number of active ags              */
-	s32 dn_maxag;		/* 4: max active alloc group number     */
-	s32 dn_agpref;		/* 4: preferred alloc group (hint)      */
-	s32 dn_aglevel;		/* 4: dmapctl level holding the AG      */
-	s32 dn_agheigth;	/* 4: height in dmapctl of the AG       */
-	s32 dn_agwidth;		/* 4: width in dmapctl of the AG        */
-	s32 dn_agstart;		/* 4: start tree index at AG height     */
-	s32 dn_agl2size;	/* 4: l2 num of blks per alloc group    */
-	s64 dn_agfree[MAXAG];	/* 8*MAXAG: per AG free count           */
-	s64 dn_agsize;		/* 8: num of blks per alloc group       */
+struct dbmap_disk {
+	__le64 dn_mapsize;	/* 8: number of blocks in aggregate     */
+	__le64 dn_nfree;	/* 8: num free blks in aggregate map    */
+	__le32 dn_l2nbperpage;	/* 4: number of blks per page           */
+	__le32 dn_numag;	/* 4: total number of ags               */
+	__le32 dn_maxlevel;	/* 4: number of active ags              */
+	__le32 dn_maxag;	/* 4: max active alloc group number     */
+	__le32 dn_agpref;	/* 4: preferred alloc group (hint)      */
+	__le32 dn_aglevel;	/* 4: dmapctl level holding the AG      */
+	__le32 dn_agheigth;	/* 4: height in dmapctl of the AG       */
+	__le32 dn_agwidth;	/* 4: width in dmapctl of the AG        */
+	__le32 dn_agstart;	/* 4: start tree index at AG height     */
+	__le32 dn_agl2size;	/* 4: l2 num of blks per alloc group    */
+	__le64 dn_agfree[MAXAG];/* 8*MAXAG: per AG free count           */
+	__le64 dn_agsize;	/* 8: num of blks per alloc group       */
 	s8 dn_maxfreebud;	/* 1: max free buddy system             */
 	u8 pad[3007];		/* 3007: pad to 4096                    */
 };				/* - 4096 -                             */
 
+struct dbmap {
+	s64 dn_mapsize;		/* number of blocks in aggregate     */
+	s64 dn_nfree;		/* num free blks in aggregate map    */
+	int dn_l2nbperpage;	/* number of blks per page           */
+	int dn_numag;		/* total number of ags               */
+	int dn_maxlevel;	/* number of active ags              */
+	int dn_maxag;		/* max active alloc group number     */
+	int dn_agpref;		/* preferred alloc group (hint)      */
+	int dn_aglevel;		/* dmapctl level holding the AG      */
+	int dn_agheigth;	/* height in dmapctl of the AG       */
+	int dn_agwidth;		/* width in dmapctl of the AG        */
+	int dn_agstart;		/* start tree index at AG height     */
+	int dn_agl2size;	/* l2 num of blks per alloc group    */
+	s64 dn_agfree[MAXAG];	/* per AG free count           */
+	s64 dn_agsize;		/* num of blks per alloc group       */
+	signed char dn_maxfreebud;	/* max free buddy system             */
+};				/* - 4096 -                             */
 /* 
  *	in-memory aggregate disk allocation map descriptor.
  */
 struct bmap {
-	struct dbmap db_bmap;	/* on-disk aggregate map descriptor */
+	struct dbmap db_bmap;		/* on-disk aggregate map descriptor */
 	struct inode *db_ipbmap;	/* ptr to aggregate map incore inode */
 	struct semaphore db_bmaplock;	/* aggregate map lock */
 	atomic_t db_active[MAXAG];	/* count of active, open files in AG */
diff -Nru a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
--- a/fs/jfs/jfs_dtree.c	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_dtree.c	2004-11-09 00:31:18 -08:00
@@ -852,7 +852,7 @@
 		n = NDTLEAF_LEGACY(name->namlen);
 		data.leaf.ip = NULL;	/* signifies legacy directory format */
 	}
-	data.leaf.ino = cpu_to_le32(*fsn);
+	data.leaf.ino = *fsn;
 
 	/*
 	 *      leaf page does not have enough room for new entry:
@@ -3570,7 +3570,8 @@
 		     dtpage_t * p,	/* directory page */
 		     int si)
 {				/* entry slot index */
-	wchar_t *kname, *name;
+	wchar_t *kname;
+	__le16 *name;
 	int klen, namlen, len, rc;
 	struct idtentry *ih;
 	struct dtslot *t;
@@ -3646,7 +3647,8 @@
 		     int si,	/* entry slot index */
 		     int flag)
 {
-	wchar_t *kname, *name, x;
+	wchar_t *kname, x;
+	__le16 *name;
 	int klen, namlen, len, rc;
 	struct ldtentry *lh;
 	struct idtentry *ih;
@@ -3824,7 +3826,8 @@
 	struct idtentry *ih;
 	struct dtslot *t;
 	int namlen, len;
-	wchar_t *name, *kname;
+	wchar_t *kname;
+	__le16 *name;
 
 	/* get entry */
 	stbl = DT_GETSTBL(p);
@@ -3852,7 +3855,7 @@
 	/*
 	 * move head/only segment
 	 */
-	UniStrncpy_le(kname, name, len);
+	UniStrncpy_from_le(kname, name, len);
 
 	/*
 	 * move additional segment(s)
@@ -3863,7 +3866,7 @@
 		kname += len;
 		namlen -= len;
 		len = min(namlen, DTSLOTDATALEN);
-		UniStrncpy_le(kname, t->name, len);
+		UniStrncpy_from_le(kname, t->name, len);
 
 		si = t->next;
 	}
@@ -3885,7 +3888,8 @@
 	struct ldtentry *lh = NULL;
 	struct idtentry *ih = NULL;
 	int hsi, fsi, klen, len, nextindex;
-	wchar_t *kname, *name;
+	wchar_t *kname;
+	__le16 *name;
 	s8 *stbl;
 	pxd_t *xd;
 	struct dt_lock *dtlck = *dtlock;
@@ -3914,7 +3918,7 @@
 	if (p->header.flag & BT_LEAF) {
 		lh = (struct ldtentry *) h;
 		lh->next = h->next;
-		lh->inumber = data->leaf.ino;	/* little-endian */
+		lh->inumber = cpu_to_le32(data->leaf.ino);
 		lh->namlen = klen;
 		name = lh->name;
 		if (data->leaf.ip) {
@@ -3936,7 +3940,7 @@
 		len = min(klen, DTIHDRDATALEN);
 	}
 
-	UniStrncpy_le(name, kname, len);
+	UniStrncpy_to_le(name, kname, len);
 
 	n = 1;
 	xsi = hsi;
@@ -3971,7 +3975,7 @@
 
 		kname += len;
 		len = min(klen, DTSLOTDATALEN);
-		UniStrncpy_le(t->name, kname, len);
+		UniStrncpy_to_le(t->name, kname, len);
 
 		n++;
 		xsi = fsi;
@@ -4174,7 +4178,7 @@
 			d++;
 
 			len = min(snamlen, DTSLOTDATALEN);
-			UniStrncpy(d->name, s->name, len);
+			UniStrncpy_le(d->name, s->name, len);
 
 			ns++;
 			nd++;
diff -Nru a/fs/jfs/jfs_dtree.h b/fs/jfs/jfs_dtree.h
--- a/fs/jfs/jfs_dtree.h	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_dtree.h	2004-11-09 00:31:18 -08:00
@@ -47,7 +47,7 @@
 struct dtslot {
 	s8 next;		/* 1: */
 	s8 cnt;			/* 1: */
-	wchar_t name[15];	/* 30: */
+	__le16 name[15];	/* 30: */
 };				/* (32) */
 
 
@@ -67,7 +67,7 @@
 
 	s8 next;		/* 1: */
 	u8 namlen;		/* 1: */
-	wchar_t name[11];	/* 22: 2-byte aligned */
+	__le16 name[11];	/* 22: 2-byte aligned */
 };				/* (32) */
 
 #define DTIHDRSIZE	10
@@ -83,11 +83,11 @@
  * 	For legacy filesystems, name contains 13 wchars -- no index field
  */
 struct ldtentry {
-	u32 inumber;		/* 4: 4-byte aligned */
+	__le32 inumber;		/* 4: 4-byte aligned */
 	s8 next;		/* 1: */
 	u8 namlen;		/* 1: */
-	wchar_t name[11];	/* 22: 2-byte aligned */
-	u32 index;		/* 4: index into dir_table */
+	__le16 name[11];	/* 22: 2-byte aligned */
+	__le32 index;		/* 4: index into dir_table */
 };				/* (32) */
 
 #define DTLHDRSIZE	6
@@ -113,7 +113,7 @@
 	u8 flag;		/* 1: 0 if free */
 	u8 slot;		/* 1: slot within leaf page of entry */
 	u8 addr1;		/* 1: upper 8 bits of leaf page address */
-	u32 addr2;		/* 4: lower 32 bits of leaf page address -OR-
+	__le32 addr2;		/* 4: lower 32 bits of leaf page address -OR-
 				   index of next entry when this entry was deleted */
 };				/* (8) */
 
@@ -151,7 +151,7 @@
 		s8 freecnt;	/* 1: free count */
 		s8 freelist;	/* 1: freelist header */
 
-		u32 idotdot;	/* 4: parent inode number */
+		__le32 idotdot;	/* 4: parent inode number */
 
 		s8 stbl[8];	/* 8: sorted entry index table */
 	} header;		/* (32) */
@@ -192,8 +192,8 @@
  */
 typedef union {
 	struct {
-		s64 next;	/* 8: next sibling */
-		s64 prev;	/* 8: previous sibling */
+		__le64 next;	/* 8: next sibling */
+		__le64 prev;	/* 8: previous sibling */
 
 		u8 flag;	/* 1: */
 		u8 nextindex;	/* 1: next entry index in stbl */
diff -Nru a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
--- a/fs/jfs/jfs_imap.c	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_imap.c	2004-11-09 00:31:18 -08:00
@@ -131,7 +131,7 @@
 	struct inomap *imap;
 	struct metapage *mp;
 	int index;
-	struct dinomap *dinom_le;
+	struct dinomap_disk *dinom_le;
 
 	/*
 	 * allocate/initialize the in-memory inode map control structure
@@ -154,7 +154,7 @@
 	}
 
 	/* copy the on-disk version to the in-memory version. */
-	dinom_le = (struct dinomap *) mp->data;
+	dinom_le = (struct dinomap_disk *) mp->data;
 	imap->im_freeiag = le32_to_cpu(dinom_le->in_freeiag);
 	imap->im_nextiag = le32_to_cpu(dinom_le->in_nextiag);
 	atomic_set(&imap->im_numinos, le32_to_cpu(dinom_le->in_numinos));
@@ -242,7 +242,7 @@
  */
 int diSync(struct inode *ipimap)
 {
-	struct dinomap *dinom_le;
+	struct dinomap_disk *dinom_le;
 	struct inomap *imp = JFS_IP(ipimap)->i_imap;
 	struct metapage *mp;
 	int index;
@@ -260,7 +260,7 @@
 	}
 
 	/* copy the in-memory version to the on-disk version */
-	dinom_le = (struct dinomap *) mp->data;
+	dinom_le = (struct dinomap_disk *) mp->data;
 	dinom_le->in_freeiag = cpu_to_le32(imp->im_freeiag);
 	dinom_le->in_nextiag = cpu_to_le32(imp->im_nextiag);
 	dinom_le->in_numinos = cpu_to_le32(atomic_read(&imp->im_numinos));
@@ -1027,7 +1027,7 @@
 			 */
 			iagp->inofreefwd =
 			    cpu_to_le32(imap->im_agctl[agno].inofree);
-			iagp->inofreeback = -1;
+			iagp->inofreeback = cpu_to_le32(-1);
 			imap->im_agctl[agno].inofree = iagno;
 		}
 		IREAD_UNLOCK(ipimap);
@@ -1037,7 +1037,7 @@
 		 * inodes (i.e., the inode being freed is the first free 
 		 * inode of extent),
 		 */
-		if (iagp->wmap[extno] == ONES) {
+		if (iagp->wmap[extno] == cpu_to_le32(ONES)) {
 			sword = extno >> L2EXTSPERSUM;
 			bitno = extno & (EXTSPERSUM - 1);
 			iagp->inosmap[sword] &=
@@ -1185,7 +1185,7 @@
 
 		iagp->extfreefwd =
 		    cpu_to_le32(imap->im_agctl[agno].extfree);
-		iagp->extfreeback = -1;
+		iagp->extfreeback = cpu_to_le32(-1);
 		imap->im_agctl[agno].extfree = iagno;
 	} else {
 		/* remove the iag from the ag extent list if all extents
@@ -1201,7 +1201,7 @@
 				imap->im_agctl[agno].extfree =
 				    le32_to_cpu(iagp->extfreefwd);
 
-			iagp->extfreefwd = iagp->extfreeback = -1;
+			iagp->extfreefwd = iagp->extfreeback = cpu_to_le32(-1);
 
 			IAGFREE_LOCK(imap);
 			iagp->iagfree = cpu_to_le32(imap->im_freeiag);
@@ -1223,7 +1223,7 @@
 			imap->im_agctl[agno].inofree =
 			    le32_to_cpu(iagp->inofreefwd);
 
-		iagp->inofreefwd = iagp->inofreeback = -1;
+		iagp->inofreefwd = iagp->inofreeback = cpu_to_le32(-1);
 	}
 
 	/* update the inode extent address and working map 
@@ -2131,7 +2131,7 @@
 	 * allocated.  if so, update the free inode summary
 	 * map to reflect this.
 	 */
-	if (iagp->wmap[extno] == ONES) {
+	if (iagp->wmap[extno] == cpu_to_le32(ONES)) {
 		sword = extno >> L2EXTSPERSUM;
 		bitno = extno & (EXTSPERSUM - 1);
 		iagp->inosmap[sword] |= cpu_to_le32(HIGHORDER >> bitno);
@@ -2153,7 +2153,7 @@
 			imap->im_agctl[agno].inofree =
 			    le32_to_cpu(iagp->inofreefwd);
 		}
-		iagp->inofreefwd = iagp->inofreeback = -1;
+		iagp->inofreefwd = iagp->inofreeback = cpu_to_le32(-1);
 	}
 
 	/* update the free inode count at the iag, ag, inode
@@ -2362,7 +2362,7 @@
 			imap->im_agctl[agno].extfree =
 			    le32_to_cpu(iagp->extfreefwd);
 
-		iagp->extfreefwd = iagp->extfreeback = -1;
+		iagp->extfreefwd = iagp->extfreeback = cpu_to_le32(-1);
 	} else {
 		/* if the iag has all free extents (newly allocated iag),
 		 * add the iag to the ag free extent list.
@@ -2372,7 +2372,7 @@
 				aiagp->extfreeback = cpu_to_le32(iagno);
 
 			iagp->extfreefwd = cpu_to_le32(fwd);
-			iagp->extfreeback = -1;
+			iagp->extfreeback = cpu_to_le32(-1);
 			imap->im_agctl[agno].extfree = iagno;
 		}
 	}
@@ -2386,7 +2386,7 @@
 
 		iagp->inofreefwd =
 		    cpu_to_le32(imap->im_agctl[agno].inofree);
-		iagp->inofreeback = -1;
+		iagp->inofreeback = cpu_to_le32(-1);
 		imap->im_agctl[agno].inofree = iagno;
 	}
 
@@ -2592,9 +2592,9 @@
 		/* init the iag */
 		memset(iagp, 0, sizeof(struct iag));
 		iagp->iagnum = cpu_to_le32(iagno);
-		iagp->inofreefwd = iagp->inofreeback = -1;
-		iagp->extfreefwd = iagp->extfreeback = -1;
-		iagp->iagfree = -1;
+		iagp->inofreefwd = iagp->inofreeback = cpu_to_le32(-1);
+		iagp->extfreefwd = iagp->extfreeback = cpu_to_le32(-1);
+		iagp->iagfree = cpu_to_le32(-1);
 		iagp->nfreeinos = 0;
 		iagp->nfreeexts = cpu_to_le32(EXTSPERIAG);
 
@@ -2602,7 +2602,7 @@
 		 * summary map initialization handled by bzero).
 		 */
 		for (i = 0; i < SMAPSZ; i++)
-			iagp->inosmap[i] = ONES;
+			iagp->inosmap[i] = cpu_to_le32(ONES);
 
 		flush_metapage(mp);
 
@@ -2676,7 +2676,7 @@
 
 	/* remove the iag from the iag free list */
 	imap->im_freeiag = le32_to_cpu(iagp->iagfree);
-	iagp->iagfree = -1;
+	iagp->iagfree = cpu_to_le32(-1);
 
 	/* set the return iag number and buffer pointer */
 	*iagnop = iagno;
@@ -2924,8 +2924,8 @@
 
 	/* init per AG control information im_agctl[] */
 	for (i = 0; i < MAXAG; i++) {
-		imap->im_agctl[i].inofree = -1;	/* free inode list */
-		imap->im_agctl[i].extfree = -1;	/* free extent list */
+		imap->im_agctl[i].inofree = -1;
+		imap->im_agctl[i].extfree = -1;
 		imap->im_agctl[i].numinos = 0;	/* number of backed inodes */
 		imap->im_agctl[i].numfree = 0;	/* number of free backed inodes */
 	}
@@ -2970,18 +2970,18 @@
 
 		/* if any backed free inodes, insert at AG free inode list */
 		if ((int) le32_to_cpu(iagp->nfreeinos) > 0) {
-			if ((head = imap->im_agctl[n].inofree) == -1)
-				iagp->inofreefwd = iagp->inofreeback = -1;
-			else {
+			if ((head = imap->im_agctl[n].inofree) == -1) {
+				iagp->inofreefwd = cpu_to_le32(-1);
+				iagp->inofreeback = cpu_to_le32(-1);
+			} else {
 				if ((rc = diIAGRead(imap, head, &hbp))) {
 					rcx = rc;
 					goto nextiag;
 				}
 				hiagp = (struct iag *) hbp->data;
-				hiagp->inofreeback =
-				    le32_to_cpu(iagp->iagnum);
+				hiagp->inofreeback = iagp->iagnum;
 				iagp->inofreefwd = cpu_to_le32(head);
-				iagp->inofreeback = -1;
+				iagp->inofreeback = cpu_to_le32(-1);
 				write_metapage(hbp);
 			}
 
@@ -2996,9 +2996,10 @@
 
 		/* if any free extents, insert at AG free extent list */
 		if (le32_to_cpu(iagp->nfreeexts) > 0) {
-			if ((head = imap->im_agctl[n].extfree) == -1)
-				iagp->extfreefwd = iagp->extfreeback = -1;
-			else {
+			if ((head = imap->im_agctl[n].extfree) == -1) {
+				iagp->extfreefwd = cpu_to_le32(-1);
+				iagp->extfreeback = cpu_to_le32(-1);
+			} else {
 				if ((rc = diIAGRead(imap, head, &hbp))) {
 					rcx = rc;
 					goto nextiag;
@@ -3006,7 +3007,7 @@
 				hiagp = (struct iag *) hbp->data;
 				hiagp->extfreeback = iagp->iagnum;
 				iagp->extfreefwd = cpu_to_le32(head);
-				iagp->extfreeback = -1;
+				iagp->extfreeback = cpu_to_le32(-1);
 				write_metapage(hbp);
 			}
 
@@ -3053,7 +3054,7 @@
 		if (readSuper(sb, &bh))
 			return;
 		j_sb = (struct jfs_superblock *)bh->b_data;
-		j_sb->s_flag |= JFS_BAD_SAIT;
+		j_sb->s_flag |= cpu_to_le32(JFS_BAD_SAIT);
 
 		mark_buffer_dirty(bh);
 		sync_dirty_buffer(bh);
diff -Nru a/fs/jfs/jfs_imap.h b/fs/jfs/jfs_imap.h
--- a/fs/jfs/jfs_imap.h	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_imap.h	2004-11-09 00:31:18 -08:00
@@ -60,16 +60,16 @@
  *	inode allocation group page (per 4096 inodes of an AG)
  */
 struct iag {
-	s64 agstart;		/* 8: starting block of ag              */
-	s32 iagnum;		/* 4: inode allocation group number     */
-	s32 inofreefwd;		/* 4: ag inode free list forward        */
-	s32 inofreeback;	/* 4: ag inode free list back           */
-	s32 extfreefwd;		/* 4: ag inode extent free list forward */
-	s32 extfreeback;	/* 4: ag inode extent free list back    */
-	s32 iagfree;		/* 4: iag free list                     */
+	__le64 agstart;		/* 8: starting block of ag              */
+	__le32 iagnum;		/* 4: inode allocation group number     */
+	__le32 inofreefwd;	/* 4: ag inode free list forward        */
+	__le32 inofreeback;	/* 4: ag inode free list back           */
+	__le32 extfreefwd;	/* 4: ag inode extent free list forward */
+	__le32 extfreeback;	/* 4: ag inode extent free list back    */
+	__le32 iagfree;		/* 4: iag free list                     */
 
 	/* summary map: 1 bit per inode extent */
-	s32 inosmap[SMAPSZ];	/* 16: sum map of mapwords w/ free inodes;
+	__le32 inosmap[SMAPSZ];	/* 16: sum map of mapwords w/ free inodes;
 				 *      note: this indicates free and backed
 				 *      inodes, if the extent is not backed the
 				 *      value will be 1.  if the extent is
@@ -78,43 +78,61 @@
 				 *      backed but at least one of the inodes is
 				 *      free the value will be 0.
 				 */
-	s32 extsmap[SMAPSZ];	/* 16: sum map of mapwords w/ free extents */
-	s32 nfreeinos;		/* 4: number of free inodes             */
-	s32 nfreeexts;		/* 4: number of free extents            */
+	__le32 extsmap[SMAPSZ];	/* 16: sum map of mapwords w/ free extents */
+	__le32 nfreeinos;		/* 4: number of free inodes             */
+	__le32 nfreeexts;		/* 4: number of free extents            */
 	/* (72) */
 	u8 pad[1976];		/* 1976: pad to 2048 bytes */
 	/* allocation bit map: 1 bit per inode (0 - free, 1 - allocated) */
-	u32 wmap[EXTSPERIAG];	/* 512: working allocation map  */
-	u32 pmap[EXTSPERIAG];	/* 512: persistent allocation map */
+	__le32 wmap[EXTSPERIAG];	/* 512: working allocation map  */
+	__le32 pmap[EXTSPERIAG];	/* 512: persistent allocation map */
 	pxd_t inoext[EXTSPERIAG];	/* 1024: inode extent addresses */
 };				/* (4096) */
 
 /*
  *	per AG control information (in inode map control page)
  */
-struct iagctl {
-	s32 inofree;		/* 4: free inode list anchor            */
-	s32 extfree;		/* 4: free extent list anchor           */
-	s32 numinos;		/* 4: number of backed inodes           */
-	s32 numfree;		/* 4: number of free inodes             */
+struct iagctl_disk {
+	__le32 inofree;		/* 4: free inode list anchor            */
+	__le32 extfree;		/* 4: free extent list anchor           */
+	__le32 numinos;		/* 4: number of backed inodes           */
+	__le32 numfree;		/* 4: number of free inodes             */
 };				/* (16) */
 
+struct iagctl {
+	int inofree;		/* free inode list anchor            */
+	int extfree;		/* free extent list anchor           */
+	int numinos;		/* number of backed inodes           */
+	int numfree;		/* number of free inodes             */
+};
+
 /*
  *	per fileset/aggregate inode map control page
  */
-struct dinomap {
-	s32 in_freeiag;		/* 4: free iag list anchor     */
-	s32 in_nextiag;		/* 4: next free iag number     */
-	s32 in_numinos;		/* 4: num of backed inodes */
-	s32 in_numfree;		/* 4: num of free backed inodes */
-	s32 in_nbperiext;	/* 4: num of blocks per inode extent */
-	s32 in_l2nbperiext;	/* 4: l2 of in_nbperiext */
-	s32 in_diskblock;	/* 4: for standalone test driver  */
-	s32 in_maxag;		/* 4: for standalone test driver  */
+struct dinomap_disk {
+	__le32 in_freeiag;	/* 4: free iag list anchor     */
+	__le32 in_nextiag;	/* 4: next free iag number     */
+	__le32 in_numinos;	/* 4: num of backed inodes */
+	__le32 in_numfree;	/* 4: num of free backed inodes */
+	__le32 in_nbperiext;	/* 4: num of blocks per inode extent */
+	__le32 in_l2nbperiext;	/* 4: l2 of in_nbperiext */
+	__le32 in_diskblock;	/* 4: for standalone test driver  */
+	__le32 in_maxag;	/* 4: for standalone test driver  */
 	u8 pad[2016];		/* 2016: pad to 2048 */
-	struct iagctl in_agctl[MAXAG];	/* 2048: AG control information */
+	struct iagctl_disk in_agctl[MAXAG]; /* 2048: AG control information */
 };				/* (4096) */
 
+struct dinomap {
+	int in_freeiag;		/* free iag list anchor     */
+	int in_nextiag;		/* next free iag number     */
+	int in_numinos;		/* num of backed inodes */
+	int in_numfree;		/* num of free backed inodes */
+	int in_nbperiext;	/* num of blocks per inode extent */
+	int in_l2nbperiext;	/* l2 of in_nbperiext */
+	int in_diskblock;	/* for standalone test driver  */
+	int in_maxag;		/* for standalone test driver  */
+	struct iagctl in_agctl[MAXAG];	/* AG control information */
+};
 
 /*
  *	In-core inode map control page
diff -Nru a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
--- a/fs/jfs/jfs_logmgr.c	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_logmgr.c	2004-11-09 00:31:18 -08:00
@@ -161,9 +161,9 @@
 /*
  * Global list of active external journals
  */
-LIST_HEAD(jfs_external_logs);
-struct jfs_log *dummy_log = NULL;
-DECLARE_MUTEX(jfs_log_sem);
+static LIST_HEAD(jfs_external_logs);
+static struct jfs_log *dummy_log = NULL;
+static DECLARE_MUTEX(jfs_log_sem);
 
 /*
  * external references
@@ -205,7 +205,7 @@
  *	statistics
  */
 #ifdef CONFIG_JFS_STATISTICS
-struct lmStat {
+static struct lmStat {
 	uint commit;		/* # of commit */
 	uint pagedone;		/* # of page written */
 	uint submitted;		/* # of pages submitted */
@@ -1435,6 +1435,8 @@
 	 *      unwind on error
 	 */
       errout30:		/* release log page */
+	log->wqueue = NULL;
+	bp->l_wqnext = NULL;
 	lbmFree(bp);
 
       errout20:		/* release log superblock */
diff -Nru a/fs/jfs/jfs_logmgr.h b/fs/jfs/jfs_logmgr.h
--- a/fs/jfs/jfs_logmgr.h	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_logmgr.h	2004-11-09 00:31:18 -08:00
@@ -62,17 +62,17 @@
 #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 {
@@ -121,17 +121,17 @@
  */
 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;
 };
 
@@ -202,11 +202,11 @@
 	/*
 	 * 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 @@
 		 * 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 @@
 		 * 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,10 +260,10 @@
 		 * 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) */
 
@@ -279,9 +279,9 @@
 		 *
 		 */
 		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 @@
 		 * 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 @@
 		 * 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;
@@ -327,8 +327,8 @@
 		 * replay of the 
 		 */
 		struct {
-			s32 fileset;	/* 4: fileset number */
-			u32 inode;	/* 4: inode number */
+			__le32 fileset;	/* 4: fileset number */
+			__le32 inode;	/* 4: inode number */
 		} noredofile;
 
 		/*
@@ -337,9 +337,9 @@
 		 * 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 +357,8 @@
  *	line vector descriptor
  */
 struct lvd {
-	s16 offset;
-	s16 length;
+	__le16 offset;
+	__le16 length;
 };
 
 
@@ -372,7 +372,7 @@
 				 */
 	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) */
@@ -398,7 +398,7 @@
 
 	/* 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 */
diff -Nru a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
--- a/fs/jfs/jfs_metapage.c	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_metapage.c	2004-11-09 00:31:18 -08:00
@@ -31,7 +31,7 @@
 static spinlock_t meta_lock = SPIN_LOCK_UNLOCKED;
 
 #ifdef CONFIG_JFS_STATISTICS
-struct {
+static struct {
 	uint	pagealloc;	/* # of page allocations */
 	uint	pagefree;	/* # of page frees */
 	uint	lockwait;	/* # of sleeping lock_metapage() calls */
@@ -108,9 +108,9 @@
 	}
 }
 
-static inline struct metapage *alloc_metapage(int no_wait)
+static inline struct metapage *alloc_metapage(int gfp_mask)
 {
-	return mempool_alloc(metapage_mempool, no_wait ? GFP_ATOMIC : GFP_NOFS);
+	return mempool_alloc(metapage_mempool, gfp_mask);
 }
 
 static inline void free_metapage(struct metapage *mp)
@@ -289,7 +289,7 @@
 		 */
 		mp = NULL;
 		if (JFS_IP(inode)->fileset == AGGREGATE_I) {
-			mp =  mempool_alloc(metapage_mempool, GFP_ATOMIC);
+			mp = alloc_metapage(GFP_ATOMIC);
 			if (!mp) {
 				/*
 				 * mempool is supposed to protect us from
@@ -306,7 +306,7 @@
 			struct metapage *mp2;
 
 			spin_unlock(&meta_lock);
-			mp =  mempool_alloc(metapage_mempool, GFP_NOFS);
+			mp = alloc_metapage(GFP_NOFS);
 			spin_lock(&meta_lock);
 
 			/* we dropped the meta_lock, we need to search the
diff -Nru a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
--- a/fs/jfs/jfs_mount.c	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_mount.c	2004-11-09 00:31:18 -08:00
@@ -324,7 +324,7 @@
 	 */
 	/* validate fs signature */
 	if (strncmp(j_sb->s_magic, JFS_MAGIC, 4) ||
-	    j_sb->s_version > cpu_to_le32(JFS_VERSION)) {
+	    le32_to_cpu(j_sb->s_version) > JFS_VERSION) {
 		rc = -EINVAL;
 		goto out;
 	}
diff -Nru a/fs/jfs/jfs_superblock.h b/fs/jfs/jfs_superblock.h
--- a/fs/jfs/jfs_superblock.h	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_superblock.h	2004-11-09 00:31:18 -08:00
@@ -35,29 +35,29 @@
  */
 struct jfs_superblock {
 	char s_magic[4];	/* 4: magic number */
-	u32 s_version;		/* 4: version number */
+	__le32 s_version;	/* 4: version number */
 
-	s64 s_size;		/* 8: aggregate size in hardware/LVM blocks;
+	__le64 s_size;		/* 8: aggregate size in hardware/LVM blocks;
 				 * VFS: number of blocks
 				 */
-	s32 s_bsize;		/* 4: aggregate block size in bytes; 
+	__le32 s_bsize;		/* 4: aggregate block size in bytes; 
 				 * VFS: fragment size
 				 */
-	s16 s_l2bsize;		/* 2: log2 of s_bsize */
-	s16 s_l2bfactor;	/* 2: log2(s_bsize/hardware block size) */
-	s32 s_pbsize;		/* 4: hardware/LVM block size in bytes */
-	s16 s_l2pbsize;		/* 2: log2 of s_pbsize */
-	s16 pad;		/* 2: padding necessary for alignment */
+	__le16 s_l2bsize;	/* 2: log2 of s_bsize */
+	__le16 s_l2bfactor;	/* 2: log2(s_bsize/hardware block size) */
+	__le32 s_pbsize;	/* 4: hardware/LVM block size in bytes */
+	__le16 s_l2pbsize;	/* 2: log2 of s_pbsize */
+	__le16 pad;		/* 2: padding necessary for alignment */
 
-	u32 s_agsize;		/* 4: allocation group size in aggr. blocks */
+	__le32 s_agsize;	/* 4: allocation group size in aggr. blocks */
 
-	u32 s_flag;		/* 4: aggregate attributes:
+	__le32 s_flag;		/* 4: aggregate attributes:
 				 *    see jfs_filsys.h
 				 */
-	u32 s_state;		/* 4: mount/unmount/recovery state: 
+	__le32 s_state;		/* 4: mount/unmount/recovery state: 
 				 *    see jfs_filsys.h
 				 */
-	s32 s_compress;		/* 4: > 0 if data compression */
+	__le32 s_compress;		/* 4: > 0 if data compression */
 
 	pxd_t s_ait2;		/* 8: first extent of secondary
 				 *    aggregate inode table
@@ -66,15 +66,15 @@
 	pxd_t s_aim2;		/* 8: first extent of secondary
 				 *    aggregate inode map
 				 */
-	u32 s_logdev;		/* 4: device address of log */
-	s32 s_logserial;	/* 4: log serial number at aggregate mount */
+	__le32 s_logdev;		/* 4: device address of log */
+	__le32 s_logserial;	/* 4: log serial number at aggregate mount */
 	pxd_t s_logpxd;		/* 8: inline log extent */
 
 	pxd_t s_fsckpxd;	/* 8: inline fsck work space extent */
 
 	struct timestruc_t s_time;	/* 8: time last updated */
 
-	s32 s_fsckloglen;	/* 4: Number of filesystem blocks reserved for
+	__le32 s_fsckloglen;	/* 4: Number of filesystem blocks reserved for
 				 *    the fsck service log.  
 				 *    N.B. These blocks are divided among the
 				 *         versions kept.  This is not a per
@@ -95,7 +95,7 @@
 				 */
 
 	/* extendfs() parameter under s_state & FM_EXTENDFS */
-	s64 s_xsize;		/* 8: extendfs s_size */
+	__le64 s_xsize;		/* 8: extendfs s_size */
 	pxd_t s_xfsckpxd;	/* 8: extendfs fsckpxd */
 	pxd_t s_xlogpxd;	/* 8: extendfs logpxd */
 	/* - 128 byte boundary - */
diff -Nru a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
--- a/fs/jfs/jfs_txnmgr.c	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_txnmgr.c	2004-11-09 00:31:18 -08:00
@@ -80,7 +80,7 @@
 int jfs_tlocks_low;		/* Indicates low number of available tlocks */
 
 #ifdef CONFIG_JFS_STATISTICS
-struct {
+static struct {
 	uint txBegin;
 	uint txBegin_barrier;
 	uint txBegin_lockslow;
@@ -152,7 +152,7 @@
 /*
  *      statistics
  */
-struct {
+static struct {
 	tid_t maxtid;		/* 4: biggest tid ever used */
 	lid_t maxlid;		/* 4: biggest lid ever used */
 	int ntid;		/* 4: # of transactions performed */
diff -Nru a/fs/jfs/jfs_types.h b/fs/jfs/jfs_types.h
--- a/fs/jfs/jfs_types.h	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_types.h	2004-11-09 00:31:18 -08:00
@@ -45,8 +45,8 @@
  * Almost identical to Linux's timespec, but not quite
  */
 struct timestruc_t {
-	u32 tv_sec;
-	u32 tv_nsec;
+	__le32 tv_sec;
+	__le32 tv_nsec;
 };
 
 /*
@@ -96,7 +96,7 @@
 typedef struct {
 	unsigned len:24;
 	unsigned addr1:8;
-	u32 addr2;
+	__le32 addr2;
 } pxd_t;
 
 /* xd_t field construction */
@@ -127,11 +127,11 @@
  */
 typedef struct {
 	unsigned flag:8;	/* 1: flags */
-	unsigned rsrvd:24;	/* 3: */
-	u32 size;		/* 4: size in byte */
+	unsigned rsrvd:24;
+	__le32 size;		/* 4: size in byte */
 	unsigned len:24;	/* 3: length in unit of fsblksize */
 	unsigned addr1:8;	/* 1: address in unit of fsblksize */
-	u32 addr2;		/* 4: address in unit of fsblksize */
+	__le32 addr2;		/* 4: address in unit of fsblksize */
 } dxd_t;			/* - 16 - */
 
 /* dxd_t flags */
@@ -168,10 +168,10 @@
 	u8 delta;		/* Alert Threshold delta (in percent)   */
 	u8 rsrvd1;
 	u8 limit_hi;		/* DASD limit (in logical blocks)       */
-	u32 limit_lo;		/* DASD limit (in logical blocks)       */
+	__le32 limit_lo;	/* DASD limit (in logical blocks)       */
 	u8 rsrvd2[3];
 	u8 used_hi;		/* DASD usage (in logical blocks)       */
-	u32 used_lo;		/* DASD usage (in logical blocks)       */
+	__le32 used_lo;		/* DASD usage (in logical blocks)       */
 };
 
 #define DASDLIMIT(dasdp) \
diff -Nru a/fs/jfs/jfs_unicode.c b/fs/jfs/jfs_unicode.c
--- a/fs/jfs/jfs_unicode.c	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_unicode.c	2004-11-09 00:31:18 -08:00
@@ -29,7 +29,7 @@
  * FUNCTION:	Convert little-endian unicode string to character string
  *
  */
-int jfs_strfromUCS_le(char *to, const wchar_t * from,	/* LITTLE ENDIAN */
+int jfs_strfromUCS_le(char *to, const __le16 * from,
 		      int len, struct nls_table *codepage)
 {
 	int i;
diff -Nru a/fs/jfs/jfs_unicode.h b/fs/jfs/jfs_unicode.h
--- a/fs/jfs/jfs_unicode.h	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_unicode.h	2004-11-09 00:31:18 -08:00
@@ -31,7 +31,7 @@
 extern signed char UniUpperTable[512];
 extern UNICASERANGE UniUpperRange[];
 extern int get_UCSname(struct component_name *, struct dentry *);
-extern int jfs_strfromUCS_le(char *, const wchar_t *, int, struct nls_table *);
+extern int jfs_strfromUCS_le(char *, const __le16 *, int, struct nls_table *);
 
 #define free_UCSname(COMP) kfree((COMP)->name)
 
@@ -51,10 +51,10 @@
 /*
  * UniStrncpy:  Copy length limited string with pad
  */
-static inline wchar_t *UniStrncpy(wchar_t * ucs1, const wchar_t * ucs2,
+static inline __le16 *UniStrncpy_le(__le16 * ucs1, const __le16 * ucs2,
 				  size_t n)
 {
-	wchar_t *anchor = ucs1;
+	__le16 *anchor = ucs1;
 
 	while (n-- && *ucs2)	/* Copy the strings */
 		*ucs1++ = *ucs2++;
@@ -68,7 +68,7 @@
 /*
  * UniStrncmp_le:  Compare length limited string - native to little-endian
  */
-static inline int UniStrncmp_le(const wchar_t * ucs1, const wchar_t * ucs2,
+static inline int UniStrncmp_le(const wchar_t * ucs1, const __le16 * ucs2,
 				size_t n)
 {
 	if (!n)
@@ -81,10 +81,27 @@
 }
 
 /*
- * UniStrncpy_le:  Copy length limited string with pad to little-endian
+ * UniStrncpy_to_le:  Copy length limited string with pad to little-endian
+ */
+static inline __le16 *UniStrncpy_to_le(__le16 * ucs1, const wchar_t * ucs2,
+				       size_t n)
+{
+	__le16 *anchor = ucs1;
+
+	while (n-- && *ucs2)	/* Copy the strings */
+		*ucs1++ = cpu_to_le16(*ucs2++);
+
+	n++;
+	while (n--)		/* Pad with nulls */
+		*ucs1++ = 0;
+	return anchor;
+}
+
+/*
+ * UniStrncpy_from_le:  Copy length limited string with pad from little-endian
  */
-static inline wchar_t *UniStrncpy_le(wchar_t * ucs1, const wchar_t * ucs2,
-				     size_t n)
+static inline wchar_t *UniStrncpy_from_le(wchar_t * ucs1, const __le16 * ucs2,
+					  size_t n)
 {
 	wchar_t *anchor = ucs1;
 
@@ -96,7 +113,6 @@
 		*ucs1++ = 0;
 	return anchor;
 }
-
 
 /*
  * UniToupper:  Convert a unicode character to upper case
diff -Nru a/fs/jfs/jfs_xattr.h b/fs/jfs/jfs_xattr.h
--- a/fs/jfs/jfs_xattr.h	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_xattr.h	2004-11-09 00:31:18 -08:00
@@ -27,12 +27,12 @@
 struct jfs_ea {
 	u8 flag;	/* Unused? */
 	u8 namelen;	/* Length of name */
-	u16 valuelen;	/* Length of value */
+	__le16 valuelen;	/* Length of value */
 	char name[0];	/* Attribute name (includes null-terminator) */
 };			/* Value immediately follows name */
 
 struct jfs_ea_list {
-	u32 size;		/* overall size */
+	__le32 size;		/* overall size */
 	struct jfs_ea ea[0];	/* Variable length list */
 };
 
diff -Nru a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
--- a/fs/jfs/jfs_xtree.c	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_xtree.c	2004-11-09 00:31:18 -08:00
@@ -958,7 +958,7 @@
 
 	/* is inode xtree root extension/inline EA area free ? */
 	if ((sp->header.flag & BT_ROOT) && (!S_ISDIR(ip->i_mode)) &&
-	    (sp->header.maxentry < cpu_to_le16(XTROOTMAXSLOT)) &&
+	    (le16_to_cpu(sp->header.maxentry) < XTROOTMAXSLOT) &&
 	    (JFS_IP(ip)->mode2 & INLINEEA)) {
 		sp->header.maxentry = cpu_to_le16(XTROOTMAXSLOT);
 		JFS_IP(ip)->mode2 &= ~INLINEEA;
@@ -1622,7 +1622,6 @@
 	s64 xaddr;
 	struct tlock *tlck;
 	struct xtlock *xtlck = NULL;
-	int rootsplit = 0;
 
 	jfs_info("xtExtend: nxoff:0x%lx nxlen:0x%x", (ulong) xoff, xlen);
 
@@ -1678,8 +1677,6 @@
 	 * The xtSplitUp() will insert the entry and unpin the leaf page.
 	 */
 	if (nextindex == le16_to_cpu(p->header.maxentry)) {
-		rootsplit = p->header.flag & BT_ROOT;
-
 		/* xtSpliUp() unpins leaf pages */
 		split.mp = mp;
 		split.index = index + 1;
@@ -1691,16 +1688,21 @@
 		if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
 			return rc;
 
+		/* get back old page */
+		XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+		if (rc)
+			return rc;
 		/*
 		 * if leaf root has been split, original root has been
 		 * copied to new child page, i.e., original entry now
 		 * resides on the new child page;
 		 */
-		if (rootsplit) {
+		if (p->header.flag & BT_INTERNAL) {
 			ASSERT(p->header.nextindex ==
 			       cpu_to_le16(XTENTRYSTART + 1));
 			xad = &p->xad[XTENTRYSTART];
 			bn = addressXAD(xad);
+			XT_PUTPAGE(mp);
 
 			/* get new child page */
 			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
@@ -1712,11 +1714,6 @@
 				tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
 				xtlck = (struct xtlock *) & tlck->lock;
 			}
-		} else {
-			/* get back old page */
-			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
-			if (rc)
-				return rc;
 		}
 	}
 	/*
@@ -1790,7 +1787,6 @@
 	struct xtlock *xtlck = 0;
 	struct tlock *mtlck;
 	struct maplock *pxdlock;
-	int rootsplit = 0;
 
 /*
 printf("xtTailgate: nxoff:0x%lx nxlen:0x%x nxaddr:0x%lx\n",
@@ -1848,8 +1844,6 @@
 	 * The xtSplitUp() will insert the entry and unpin the leaf page.
 	 */
 	if (nextindex == le16_to_cpu(p->header.maxentry)) {
-		rootsplit = p->header.flag & BT_ROOT;
-
 		/* xtSpliUp() unpins leaf pages */
 		split.mp = mp;
 		split.index = index + 1;
@@ -1861,16 +1855,21 @@
 		if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
 			return rc;
 
+		/* get back old page */
+		XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+		if (rc)
+			return rc;
 		/*
 		 * if leaf root has been split, original root has been
 		 * copied to new child page, i.e., original entry now
 		 * resides on the new child page;
 		 */
-		if (rootsplit) {
+		if (p->header.flag & BT_INTERNAL) {
 			ASSERT(p->header.nextindex ==
 			       cpu_to_le16(XTENTRYSTART + 1));
 			xad = &p->xad[XTENTRYSTART];
 			bn = addressXAD(xad);
+			XT_PUTPAGE(mp);
 
 			/* get new child page */
 			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
@@ -1882,11 +1881,6 @@
 				tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
 				xtlck = (struct xtlock *) & tlck->lock;
 			}
-		} else {
-			/* get back old page */
-			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
-			if (rc)
-				return rc;
 		}
 	}
 	/*
@@ -1976,7 +1970,7 @@
 	s64 nxaddr, xaddr;
 	struct tlock *tlck;
 	struct xtlock *xtlck = NULL;
-	int rootsplit = 0, newpage = 0;
+	int newpage = 0;
 
 	/* there must exist extent to be tailgated */
 	nxoff = offsetXAD(nxad);
@@ -2183,7 +2177,6 @@
 
 	/* insert nXAD:recorded */
 	if (nextindex == le16_to_cpu(p->header.maxentry)) {
-		rootsplit = p->header.flag & BT_ROOT;
 
 		/* xtSpliUp() unpins leaf pages */
 		split.mp = mp;
@@ -2196,16 +2189,21 @@
 		if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
 			return rc;
 
+		/* get back old page */
+		XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+		if (rc)
+			return rc;
 		/*
 		 * if leaf root has been split, original root has been
 		 * copied to new child page, i.e., original entry now
 		 * resides on the new child page;
 		 */
-		if (rootsplit) {
+		if (p->header.flag & BT_INTERNAL) {
 			ASSERT(p->header.nextindex ==
 			       cpu_to_le16(XTENTRYSTART + 1));
 			xad = &p->xad[XTENTRYSTART];
 			bn = addressXAD(xad);
+			XT_PUTPAGE(mp);
 
 			/* get new child page */
 			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
@@ -2218,11 +2216,6 @@
 				xtlck = (struct xtlock *) & tlck->lock;
 			}
 		} else {
-			/* get back old page */
-			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
-			if (rc)
-				return rc;
-
 			/* is nXAD on new page ? */
 			if (newindex >
 			    (le16_to_cpu(p->header.maxentry) >> 1)) {
@@ -2336,8 +2329,6 @@
 	xlen = xlen - nxlen;
 	xaddr = xaddr + nxlen;
 	if (nextindex == le16_to_cpu(p->header.maxentry)) {
-		rootsplit = p->header.flag & BT_ROOT;
-
 /*
 printf("xtUpdate.updateLeft.split p:0x%p\n", p);
 */
@@ -2352,16 +2343,22 @@
 		if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
 			return rc;
 
+		/* get back old page */
+		XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
+		if (rc)
+			return rc;
+
 		/*
 		 * if leaf root has been split, original root has been
 		 * copied to new child page, i.e., original entry now
 		 * resides on the new child page;
 		 */
-		if (rootsplit) {
+		if (p->header.flag & BT_INTERNAL) {
 			ASSERT(p->header.nextindex ==
 			       cpu_to_le16(XTENTRYSTART + 1));
 			xad = &p->xad[XTENTRYSTART];
 			bn = addressXAD(xad);
+			XT_PUTPAGE(mp);
 
 			/* get new child page */
 			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
@@ -2373,11 +2370,6 @@
 				tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
 				xtlck = (struct xtlock *) & tlck->lock;
 			}
-		} else {
-			/* get back old page */
-			XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
-			if (rc)
-				return rc;
 		}
 	} else {
 		/* if insert into middle, shift right remaining entries */
diff -Nru a/fs/jfs/jfs_xtree.h b/fs/jfs/jfs_xtree.h
--- a/fs/jfs/jfs_xtree.h	2004-11-09 00:31:18 -08:00
+++ b/fs/jfs/jfs_xtree.h	2004-11-09 00:31:18 -08:00
@@ -32,10 +32,10 @@
 	unsigned flag:8;	/* 1: flag */
 	unsigned rsvrd:16;	/* 2: reserved */
 	unsigned off1:8;	/* 1: offset in unit of fsblksize */
-	u32 off2;		/* 4: offset in unit of fsblksize */
+	__le32 off2;		/* 4: offset in unit of fsblksize */
 	unsigned len:24;	/* 3: length in unit of fsblksize */
 	unsigned addr1:8;	/* 1: address in unit of fsblksize */
-	u32 addr2;		/* 4: address in unit of fsblksize */
+	__le32 addr2;		/* 4: address in unit of fsblksize */
 } xad_t;			/* (16) */
 
 #define MAXXLEN         ((1 << 24) - 1)
@@ -90,14 +90,14 @@
  */
 typedef union {
 	struct xtheader {
-		s64 next;	/* 8: */
-		s64 prev;	/* 8: */
+		__le64 next;	/* 8: */
+		__le64 prev;	/* 8: */
 
 		u8 flag;	/* 1: */
 		u8 rsrvd1;	/* 1: */
-		s16 nextindex;	/* 2: next index = number of entries */
-		s16 maxentry;	/* 2: max number of entries */
-		s16 rsrvd2;	/* 2: */
+		__le16 nextindex;	/* 2: next index = number of entries */
+		__le16 maxentry;	/* 2: max number of entries */
+		__le16 rsrvd2;	/* 2: */
 
 		pxd_t self;	/* 8: self */
 	} header;		/* (32) */
