[Ocfs2-commits] jlbec commits r939 - in trunk/src: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue May 25 15:03:05 CDT 2004
Author: jlbec
Date: 2004-05-25 14:03:04 -0500 (Tue, 25 May 2004)
New Revision: 939
Modified:
trunk/src/alloc.c
trunk/src/file.c
trunk/src/inc/ocfs.h
trunk/src/super.c
Log:
o Remove various OCFS_ALIGN() calls, replacing with functions
ocfs_clusters_for_bytes() and ocfs_align_blocks_to_clusters().
Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c 2004-05-25 18:53:58 UTC (rev 938)
+++ trunk/src/alloc.c 2004-05-25 19:03:04 UTC (rev 939)
@@ -3794,7 +3794,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",
@@ -3807,7 +3806,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: trunk/src/file.c
===================================================================
--- trunk/src/file.c 2004-05-25 18:53:58 UTC (rev 938)
+++ trunk/src/file.c 2004-05-25 19:03:04 UTC (rev 939)
@@ -986,8 +986,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: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h 2004-05-25 18:53:58 UTC (rev 938)
+++ trunk/src/inc/ocfs.h 2004-05-25 19:03:04 UTC (rev 939)
@@ -2355,6 +2355,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: trunk/src/super.c
===================================================================
--- trunk/src/super.c 2004-05-25 18:53:58 UTC (rev 938)
+++ trunk/src/super.c 2004-05-25 19:03:04 UTC (rev 939)
@@ -724,6 +724,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;
@@ -743,7 +744,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;
@@ -753,7 +755,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;
@@ -763,7 +765,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);
More information about the Ocfs2-commits
mailing list