[Ocfs2-tools-commits] zab commits r1021 - branches/endian-safe/libocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Aug 4 18:01:48 CDT 2005


Author: zab
Date: 2005-08-04 18:01:47 -0500 (Thu, 04 Aug 2005)
New Revision: 1021

Modified:
   branches/endian-safe/libocfs2/extents.c
   branches/endian-safe/libocfs2/inode.c
Log:
o swap fields *after* referencing them to swap dependent fields
  (indistinguishable from competence at 20 paces!)


Modified: branches/endian-safe/libocfs2/extents.c
===================================================================
--- branches/endian-safe/libocfs2/extents.c	2005-08-04 21:31:17 UTC (rev 1020)
+++ branches/endian-safe/libocfs2/extents.c	2005-08-04 23:01:47 UTC (rev 1021)
@@ -41,10 +41,6 @@
 	if (cpu_is_little_endian)
 		return;
 
-	el->l_tree_depth = bswap_16(el->l_tree_depth);
-	el->l_count = bswap_16(el->l_count);
-	el->l_next_free_rec = bswap_16(el->l_next_free_rec);
-
 	for(i = 0; i < el->l_next_free_rec; i++) {
 		ocfs2_extent_rec *rec = &el->l_recs[i];
 
@@ -52,6 +48,10 @@
 		rec->e_clusters = bswap_32(rec->e_clusters);
 		rec->e_blkno = bswap_64(rec->e_blkno);
 	}
+
+	el->l_tree_depth = bswap_16(el->l_tree_depth);
+	el->l_count = bswap_16(el->l_count);
+	el->l_next_free_rec = bswap_16(el->l_next_free_rec);
 }
 
 static void ocfs2_swap_extent_block(ocfs2_extent_block *eb)

Modified: branches/endian-safe/libocfs2/inode.c
===================================================================
--- branches/endian-safe/libocfs2/inode.c	2005-08-04 21:31:17 UTC (rev 1020)
+++ branches/endian-safe/libocfs2/inode.c	2005-08-04 23:01:47 UTC (rev 1021)
@@ -67,27 +67,6 @@
 	if (cpu_is_little_endian)
 		return;
 
-	di->i_generation    = bswap_32(di->i_generation);
-	di->i_suballoc_slot = bswap_16(di->i_suballoc_slot);
-	di->i_suballoc_bit  = bswap_16(di->i_suballoc_bit);
-	di->i_clusters      = bswap_32(di->i_clusters);
-	di->i_uid           = bswap_32(di->i_uid);
-	di->i_gid           = bswap_32(di->i_gid);
-	di->i_size          = bswap_64(di->i_size);
-	di->i_mode          = bswap_16(di->i_mode);
-	di->i_links_count   = bswap_16(di->i_links_count);
-	di->i_flags         = bswap_32(di->i_flags);
-	di->i_atime         = bswap_64(di->i_atime);
-	di->i_ctime         = bswap_64(di->i_ctime);
-	di->i_mtime         = bswap_64(di->i_mtime);
-	di->i_dtime         = bswap_64(di->i_dtime);
-	di->i_blkno         = bswap_64(di->i_blkno);
-	di->i_last_eb_blk   = bswap_64(di->i_last_eb_blk);
-	di->i_fs_generation = bswap_32(di->i_fs_generation);
-	di->i_atime_nsec    = bswap_32(di->i_atime_nsec);
-	di->i_ctime_nsec    = bswap_32(di->i_ctime_nsec);
-	di->i_mtime_nsec    = bswap_32(di->i_mtime_nsec);
-
 	if (S_ISCHR(di->i_mode) || S_ISBLK(di->i_mode))
 		di->id1.dev1.i_rdev = bswap_64(di->id1.dev1.i_rdev);
 	else if (di->i_flags & OCFS2_BITMAP_FL) {
@@ -130,11 +109,6 @@
 		ocfs2_chain_list *cl = &di->id2.i_chain;
 		uint16_t i;
 
-		cl->cl_cpg           = bswap_16(cl->cl_cpg);
-		cl->cl_bpc           = bswap_16(cl->cl_bpc);
-		cl->cl_count         = bswap_16(cl->cl_count);
-		cl->cl_next_free_rec = bswap_16(cl->cl_next_free_rec);
-
 		for (i = 0; i < cl->cl_next_free_rec; i++) {
 			ocfs2_chain_rec *rec = &cl->cl_recs[i];
 
@@ -143,19 +117,25 @@
 			rec->c_blkno = bswap_64(rec->c_blkno);
 		}
 
+		cl->cl_cpg           = bswap_16(cl->cl_cpg);
+		cl->cl_bpc           = bswap_16(cl->cl_bpc);
+		cl->cl_count         = bswap_16(cl->cl_count);
+		cl->cl_next_free_rec = bswap_16(cl->cl_next_free_rec);
+
 	} else if (di->i_flags & OCFS2_DEALLOC_FL) {
 		ocfs2_truncate_log *tl = &di->id2.i_dealloc;
 		uint16_t i;
 
-		tl->tl_count = bswap_16(tl->tl_count);
-		tl->tl_used  = bswap_16(tl->tl_used);
-
 		for(i = 0; i < tl->tl_count; i++) {
 			ocfs2_truncate_rec *rec = &tl->tl_recs[i];
 
 			rec->t_start    = bswap_32(rec->t_start);
 			rec->t_clusters = bswap_32(rec->t_clusters);
 		}
+
+		tl->tl_count = bswap_16(tl->tl_count);
+		tl->tl_used  = bswap_16(tl->tl_used);
+
 	} else {
 		/* ok, now that we don't have any of the explicit _FL 
 		 * bits set, we're a "regular" file that has an 
@@ -165,6 +145,27 @@
 		      di->i_clusters == 0))
 			ocfs2_swap_extent_list(&di->id2.i_list);
 	}
+
+	di->i_generation    = bswap_32(di->i_generation);
+	di->i_suballoc_slot = bswap_16(di->i_suballoc_slot);
+	di->i_suballoc_bit  = bswap_16(di->i_suballoc_bit);
+	di->i_clusters      = bswap_32(di->i_clusters);
+	di->i_uid           = bswap_32(di->i_uid);
+	di->i_gid           = bswap_32(di->i_gid);
+	di->i_size          = bswap_64(di->i_size);
+	di->i_mode          = bswap_16(di->i_mode);
+	di->i_links_count   = bswap_16(di->i_links_count);
+	di->i_flags         = bswap_32(di->i_flags);
+	di->i_atime         = bswap_64(di->i_atime);
+	di->i_ctime         = bswap_64(di->i_ctime);
+	di->i_mtime         = bswap_64(di->i_mtime);
+	di->i_dtime         = bswap_64(di->i_dtime);
+	di->i_blkno         = bswap_64(di->i_blkno);
+	di->i_last_eb_blk   = bswap_64(di->i_last_eb_blk);
+	di->i_fs_generation = bswap_32(di->i_fs_generation);
+	di->i_atime_nsec    = bswap_32(di->i_atime_nsec);
+	di->i_ctime_nsec    = bswap_32(di->i_ctime_nsec);
+	di->i_mtime_nsec    = bswap_32(di->i_mtime_nsec);
 }
 
 errcode_t ocfs2_read_inode(ocfs2_filesys *fs, uint64_t blkno,



More information about the Ocfs2-tools-commits mailing list