[Ocfs2-tools-commits] jlbec commits r408 - in trunk: debugfs.ocfs2
libocfs2 libocfs2/include mkfs.ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Nov 17 17:49:32 CST 2004
Author: jlbec
Date: 2004-11-17 17:49:30 -0600 (Wed, 17 Nov 2004)
New Revision: 408
Modified:
trunk/debugfs.ocfs2/readfs.c
trunk/libocfs2/include/ocfs2.h
trunk/libocfs2/openfs.c
trunk/mkfs.ocfs2/mkfs.c
Log:
proper mkfs creation of the cluster bitmap chain allocator
Modified: trunk/debugfs.ocfs2/readfs.c
===================================================================
--- trunk/debugfs.ocfs2/readfs.c 2004-11-17 23:48:01 UTC (rev 407)
+++ trunk/debugfs.ocfs2/readfs.c 2004-11-17 23:49:30 UTC (rev 408)
@@ -274,7 +274,7 @@
inode = (ocfs2_dinode *)sysdir;
if (!S_ISDIR(inode->i_mode)) {
- printf("No system directory on thei volume\n");
+ printf("No system directory on the volume\n");
goto bail;
}
Modified: trunk/libocfs2/include/ocfs2.h
===================================================================
--- trunk/libocfs2/include/ocfs2.h 2004-11-17 23:48:01 UTC (rev 407)
+++ trunk/libocfs2/include/ocfs2.h 2004-11-17 23:49:30 UTC (rev 408)
@@ -495,7 +495,7 @@
return ret >> OCFS2_RAW_SB(fs->fs_super)->s_blocksize_bits;
}
-static inline uint64_t ocfs2_clusters_in_blocks(ocfs2_filesys *fs,
+static inline uint32_t ocfs2_clusters_in_blocks(ocfs2_filesys *fs,
uint64_t blocks)
{
int c_to_b_bits = OCFS2_RAW_SB(fs->fs_super)->s_clustersize_bits -
@@ -503,9 +503,9 @@
uint64_t ret = blocks + ((1 << c_to_b_bits) - 1);
if (ret < blocks) /* deal with wrapping */
- blocks = UINT64_MAX;
+ ret = UINT64_MAX;
- return ret >> c_to_b_bits;
+ return (uint32_t)(ret >> c_to_b_bits);
}
static inline int ocfs2_block_out_of_range(ocfs2_filesys *fs, uint64_t block)
Modified: trunk/libocfs2/openfs.c
===================================================================
--- trunk/libocfs2/openfs.c 2004-11-17 23:48:01 UTC (rev 407)
+++ trunk/libocfs2/openfs.c 2004-11-17 23:49:30 UTC (rev 408)
@@ -370,11 +370,15 @@
"\tblocksize = %d\n"
"\tclustersize = %d\n"
"\tclusters = %u\n"
- "\tblocks = %"PRIu64"\n",
+ "\tblocks = %"PRIu64"\n"
+ "\troot_blkno = %"PRIu64"\n"
+ "\tsystem_dir_blkno = %"PRIu64"\n",
fs->fs_blocksize,
fs->fs_clustersize,
fs->fs_clusters,
- fs->fs_blocks);
+ fs->fs_blocks,
+ fs->fs_root_blkno,
+ fs->fs_sysdir_blkno);
ret = ocfs2_close(fs);
if (ret) {
Modified: trunk/mkfs.ocfs2/mkfs.c
===================================================================
--- trunk/mkfs.ocfs2/mkfs.c 2004-11-17 23:48:01 UTC (rev 407)
+++ trunk/mkfs.ocfs2/mkfs.c 2004-11-17 23:49:30 UTC (rev 408)
@@ -232,7 +232,8 @@
uint32_t nr_cluster_groups;
uint16_t global_cpg;
uint16_t tail_group_bits;
- uint64_t first_cluster_group;
+ uint32_t first_cluster_group;
+ uint64_t first_cluster_group_blkno;
};
@@ -379,17 +380,6 @@
"global bitmap", tmprec);
/*
- * Set all bits up to and including the first group descriptor
- * which we currently have fixed as the block after the super block.
- * initialize_bitmap has cleared the bit that initialize_alloc_group
- * usually sets for the group desc so this alloc is sure to start
- * at cluster 0.
- */
- alloc_bytes_from_bitmap(s, (s->first_cluster_group + 1) << s->blocksize_bits,
- s->global_bm, &(crap_rec.extent_off),
- &(crap_rec.extent_len));
-
- /*
* Now allocate the global inode alloc group
*/
tmprec = &(record[GLOBAL_INODE_ALLOC_SYSTEM_INODE][0]);
@@ -1025,7 +1015,7 @@
{
AllocBitmap *bitmap;
uint64_t blkno;
- int i, j, cpg, chain;
+ int i, j, cpg, chain, c_to_b_bits;
int recs_per_inode = ocfs2_chain_recs_per_inode(s->blocksize);
int wrapped = 0;
@@ -1054,16 +1044,25 @@
memset(bitmap->groups, 0, s->nr_cluster_groups *
sizeof(AllocGroup *));
- s->first_cluster_group = OCFS2_SUPER_BLOCK_BLKNO + 1;
+ c_to_b_bits = s->cluster_size_bits - s->blocksize_bits;
+
+ s->first_cluster_group = (OCFS2_SUPER_BLOCK_BLKNO + 1);
+ s->first_cluster_group += ((1 << c_to_b_bits) - 1);
+ s->first_cluster_group >>= c_to_b_bits;
+
+ s->first_cluster_group_blkno = (uint64_t)s->first_cluster_group << c_to_b_bits;
bitmap->groups[0] = initialize_alloc_group(s, "stupid", bm_record,
- s->first_cluster_group,
+ s->first_cluster_group_blkno,
0, s->global_cpg, 1);
- /* we'll set his bit later when we initialize for the super
- * block and friends, so totally munge these values for
- * now. */
- ocfs2_clear_bit(0, bitmap->groups[0]->gd->bg_bitmap);
- bitmap->groups[0]->gd->bg_free_bits_count++;
- bm_record->bi.used_bits--;
+ /* The first bit is set by initialize_alloc_group, hence
+ * we start at 1. For this group (which contains the clusters
+ * containing the superblock and first group descriptor), we
+ * have to set these by hand. */
+ for (i = 1; i <= s->first_cluster_group; i++) {
+ ocfs2_set_bit(i, bitmap->groups[0]->gd->bg_bitmap);
+ bitmap->groups[0]->gd->bg_free_bits_count--;
+ bm_record->bi.used_bits++;
+ }
bitmap->groups[0]->chain_total = s->global_cpg;
bitmap->groups[0]->chain_free = s->global_cpg;
@@ -1206,7 +1205,7 @@
exit(1);
}
- if (gd->bg_blkno == s->first_cluster_group)
+ if (gd->bg_blkno == s->first_cluster_group_blkno)
*start = (uint64_t) start_bit;
else
*start = (uint64_t) start_bit + gd->bg_blkno;
@@ -1490,7 +1489,7 @@
di->id2.i_super.s_blocksize_bits = cpu_to_le32(s->blocksize_bits);
di->id2.i_super.s_clustersize_bits = cpu_to_le32(s->cluster_size_bits);
di->id2.i_super.s_max_nodes = cpu_to_le32(s->initial_nodes);
- di->id2.i_super.s_first_cluster_group = cpu_to_le64(s->first_cluster_group);
+ di->id2.i_super.s_first_cluster_group = cpu_to_le64(s->first_cluster_group_blkno);
strcpy(di->id2.i_super.s_label, s->vol_label);
memcpy(di->id2.i_super.s_uuid, s->uuid, 16);
@@ -1655,7 +1654,11 @@
int i;
uint64_t parent_blkno;
ocfs2_group_desc *gd;
+ char *buf = NULL;
+ buf = do_malloc(s, s->cluster_size);
+ memset(buf, 0, s->cluster_size);
+
parent_blkno = bitmap->bm_record->fe_off >> s->blocksize_bits;
for(i = 0; i < s->nr_cluster_groups; i++) {
gd = bitmap->groups[i]->gd;
@@ -1666,9 +1669,11 @@
/* Ok, we didn't get a chance to fill in the parent
* blkno until now. */
gd->bg_parent_dinode = cpu_to_le64(parent_blkno);
- do_pwrite(s, gd, s->blocksize,
+ memcpy(buf, gd, s->blocksize);
+ do_pwrite(s, buf, s->cluster_size,
gd->bg_blkno << s->blocksize_bits);
}
+ free(buf);
}
static void
More information about the Ocfs2-tools-commits
mailing list