[Ocfs2-commits] mfasheh commits r945 - in branches/new-dir-format/src: . inc

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed May 26 20:55:28 CDT 2004


Author: mfasheh
Date: 2004-05-26 19:55:26 -0500 (Wed, 26 May 2004)
New Revision: 945

Modified:
   branches/new-dir-format/src/alloc.c
   branches/new-dir-format/src/file.c
   branches/new-dir-format/src/inc/journal.h
   branches/new-dir-format/src/inc/ocfs.h
   branches/new-dir-format/src/super.c
Log:
* merge everything in new-dir-format to trunk revision r940



Modified: branches/new-dir-format/src/alloc.c
===================================================================
--- branches/new-dir-format/src/alloc.c	2004-05-27 00:23:09 UTC (rev 944)
+++ branches/new-dir-format/src/alloc.c	2004-05-27 00:55:26 UTC (rev 945)
@@ -3619,7 +3619,6 @@
 {
 	int status = 0;
 	__u32 bitswanted;
-	__u32 csize = osb->vol_layout.cluster_size;
 	int use_global = 1;
 
 	LOG_ENTRY_ARGS("(file_size = (%llu), handle = 0x%p, sysfile = %s)\n", 
@@ -3632,7 +3631,7 @@
 	}
 
 	/* need to calculate a couple of things for below... */
-	bitswanted = (file_size + (csize-1)) >> osb->cluster_size_bits;
+	bitswanted = ocfs_clusters_for_bytes(osb->sb, file_size);
 
 	/* Ok, now decide if we can use local alloc bitmap.
 	 * We *always* use global bitmap for clustersize > 128k,

Modified: branches/new-dir-format/src/file.c
===================================================================
--- branches/new-dir-format/src/file.c	2004-05-27 00:23:09 UTC (rev 944)
+++ branches/new-dir-format/src/file.c	2004-05-27 00:55:26 UTC (rev 945)
@@ -957,8 +957,8 @@
 	LOG_ENTRY_ARGS ("(file_off = %llu, file_size = %llu\n", 
 		   file_off, file_size);
 
-	new_alloc_size = ((file_size + (osb->vol_layout.cluster_size - 1)) >> 
-			  osb->cluster_size_bits) << osb->cluster_size_bits;
+	new_alloc_size = ocfs_align_bytes_to_clusters(osb->sb,
+						      file_size);
 
 	LOG_TRACE_ARGS("new_alloc_size = %llu\n", new_alloc_size);
 

Modified: branches/new-dir-format/src/inc/journal.h
===================================================================
--- branches/new-dir-format/src/inc/journal.h	2004-05-27 00:23:09 UTC (rev 944)
+++ branches/new-dir-format/src/inc/journal.h	2004-05-27 00:55:26 UTC (rev 945)
@@ -352,8 +352,8 @@
 {
 	int bitmap_blocks;
 	unsigned int bits_wanted;
-
-	bits_wanted = OCFS_ALIGN(bytes_wanted, cluster_size) / cluster_size;
+	bits_wanted = (__u32)OCFS_ALIGN(bytes_wanted, cluster_size) /
+		      cluster_size;
 	/* take advantage of the fact that we always allocate in one 
 	 * large chunk. */
 	bitmap_blocks = 1 + OCFS_ALIGN(bits_wanted, OCFS_BITS_IN_CHUNK) /

Modified: branches/new-dir-format/src/inc/ocfs.h
===================================================================
--- branches/new-dir-format/src/inc/ocfs.h	2004-05-27 00:23:09 UTC (rev 944)
+++ branches/new-dir-format/src/inc/ocfs.h	2004-05-27 00:55:26 UTC (rev 945)
@@ -2283,6 +2283,29 @@
 	return;
 }
 
+static inline unsigned int ocfs_clusters_for_bytes(struct super_block *sb,
+						   __u64 bytes)
+{
+	int cl_bits = OCFS_SB(sb)->cluster_size_bits;
+	unsigned int clusters;
+
+	bytes += OCFS_SB(sb)->vol_layout.cluster_size - 1;
+	/* OCFS2 just cannot have enough clusters to overflow this */
+	clusters = (unsigned int)(bytes >> cl_bits);
+
+	return clusters;
+}
+
+static inline __u64 ocfs_align_bytes_to_clusters(struct super_block *sb,
+						 __u64 bytes)
+{
+	int cl_bits = OCFS_SB(sb)->cluster_size_bits;
+	unsigned int clusters;
+
+	clusters = ocfs_clusters_for_bytes(sb, bytes);
+	return (__u64)clusters << cl_bits;
+}
+
 static inline int ocfs_inc_icount(struct inode *inode)
 {
 	struct dentry *dentry = NULL;

Modified: branches/new-dir-format/src/super.c
===================================================================
--- branches/new-dir-format/src/super.c	2004-05-27 00:23:09 UTC (rev 944)
+++ branches/new-dir-format/src/super.c	2004-05-27 00:55:26 UTC (rev 945)
@@ -752,6 +752,7 @@
 {
 	ocfs_super *osb = NULL;
 	__u32 numbits, freebits = 0;
+	unsigned int reserved_bits;
 	int status = 0;
 	ocfs_file_entry *bm_lock = NULL;
 	struct buffer_head *bh = NULL;
@@ -771,7 +772,8 @@
 	    freebits = numbits - bm_lock->u.bitinfo.used_bits;
 
 	/* take out the space reserved for system files */
-	freebits -= (8 * ONE_MEGA_BYTE / osb->vol_layout.cluster_size);	
+	reserved_bits = ocfs_clusters_for_bytes(sb, 8 * ONE_MEGA_BYTE);
+	freebits -= reserved_bits;
 
 	buf->f_type = OCFS_MAGIC;
 	buf->f_bsize = sb->s_blocksize;
@@ -781,7 +783,7 @@
 	buf->f_blocks =
 		(unsigned long) ((unsigned long) (numbits) *
 				 (unsigned long) (osb->vol_layout.cluster_size >> osb->sect_size_bits) -
-				 (8 * ONE_MEGA_BYTE / osb->vol_layout.cluster_size)); 
+				 reserved_bits);
 	buf->f_bfree =
 	    (unsigned long) (freebits * (osb->vol_layout.cluster_size >> osb->sect_size_bits));
 	buf->f_bavail = buf->f_bfree;
@@ -791,7 +793,7 @@
 	buf->f_blocks =
 		(sector_t) ((unsigned long) (numbits) *
 			    (unsigned long) (osb->vol_layout.cluster_size >> osb->sect_size_bits) -
-			    (8 * ONE_MEGA_BYTE / osb->vol_layout.cluster_size)); 
+			    reserved_bits);
 	buf->f_bfree =
 	    (sector_t) (freebits * (osb->vol_layout.cluster_size >> osb->sect_size_bits));
 	buf->f_files = (sector_t) (numbits);
@@ -1114,8 +1116,8 @@
 #endif
 
 	/* Shutdown the journal and sync up and clear the local alloc. */
+	ocfs_shutdown_local_alloc(osb, NULL, 1, 0);
 	ocfs_journal_shutdown(osb);
-	ocfs_shutdown_local_alloc(osb, NULL, 1, 0);
 
 	/* unset the mounted flag -- we're done with the journal and
 	 * the local alloc bitmap */



More information about the Ocfs2-commits mailing list