[Ocfs2-tools-commits] jlbec commits r419 - in trunk/libocfs2: . include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Nov 18 18:19:31 CST 2004


Author: jlbec
Date: 2004-11-18 18:19:29 -0600 (Thu, 18 Nov 2004)
New Revision: 419

Modified:
   trunk/libocfs2/alloc.c
   trunk/libocfs2/include/ocfs2.h
   trunk/libocfs2/openfs.c
Log:
new_extent_block added

Modified: trunk/libocfs2/alloc.c
===================================================================
--- trunk/libocfs2/alloc.c	2004-11-19 00:12:27 UTC (rev 418)
+++ trunk/libocfs2/alloc.c	2004-11-19 00:19:29 UTC (rev 419)
@@ -121,6 +121,16 @@
 	fel->l_count = ocfs2_extent_recs_per_inode(fs->fs_blocksize);
 }
 
+static void ocfs2_init_eb(ocfs2_filesys *fs, ocfs2_extent_block *eb,
+			  uint64_t gd_blkno, uint64_t blkno)
+{
+	strcpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE);
+	eb->h_blkno = blkno;
+	eb->h_suballoc_node = 0;
+	eb->h_suballoc_bit = (uint16_t)(blkno - gd_blkno);
+	eb->h_list.l_count = ocfs2_extent_recs_per_eb(fs->fs_blocksize);
+}
+
 errcode_t ocfs2_new_inode(ocfs2_filesys *fs, uint64_t *ino, int mode)
 {
 	errcode_t ret;
@@ -257,6 +267,76 @@
 	return ret;
 }
 
+errcode_t ocfs2_new_extent_block(ocfs2_filesys *fs, uint64_t *blkno)
+{
+	errcode_t ret;
+	char *buf;
+	uint64_t gd_blkno;
+	ocfs2_extent_block *eb;
+
+	ret = ocfs2_malloc_block(fs->fs_io, &buf);
+	if (ret)
+		return ret;
+
+	ret = ocfs2_load_allocator(fs, EXTENT_ALLOC_SYSTEM_INODE,
+			   	   0, &fs->fs_eb_allocs[0]);
+	if (ret)
+		goto out;
+
+	ret = ocfs2_chain_alloc_with_io(fs, fs->fs_eb_allocs[0],
+					&gd_blkno, blkno);
+	if (ret)
+		goto out;
+
+	memset(buf, 0, fs->fs_blocksize);
+	eb = (ocfs2_extent_block *)buf;
+	ocfs2_init_eb(fs, eb, gd_blkno, *blkno);
+
+	ret = ocfs2_write_extent_block(fs, *blkno, buf);
+
+out:
+	ocfs2_free(&buf);
+
+	return ret;
+}
+
+errcode_t ocfs2_delete_extent_block(ocfs2_filesys *fs, uint64_t blkno)
+{
+	errcode_t ret;
+	char *buf;
+	ocfs2_extent_block *eb;
+	int node;
+
+	ret = ocfs2_malloc_block(fs->fs_io, &buf);
+	if (ret)
+		return ret;
+
+	ret = ocfs2_read_extent_block(fs, blkno, buf);
+	if (ret)
+		goto out;
+	eb = (ocfs2_extent_block *)buf;
+	node = eb->h_suballoc_node;
+
+	ret = ocfs2_load_allocator(fs, EXTENT_ALLOC_SYSTEM_INODE,
+				   node,
+				   &fs->fs_eb_allocs[node]);
+	if (ret)
+		goto out;
+
+	ret = ocfs2_chain_free_with_io(fs, fs->fs_eb_allocs[node],
+				       blkno);
+	if (ret)
+		goto out;
+
+	ret = ocfs2_write_extent_block(fs, eb->h_blkno, buf);
+
+out:
+	ocfs2_free(&buf);
+
+	return ret;
+}
+
+
 #ifdef DEBUG_EXE
 #include <stdio.h>
 

Modified: trunk/libocfs2/include/ocfs2.h
===================================================================
--- trunk/libocfs2/include/ocfs2.h	2004-11-19 00:12:27 UTC (rev 418)
+++ trunk/libocfs2/include/ocfs2.h	2004-11-19 00:19:29 UTC (rev 419)
@@ -185,7 +185,7 @@
 	ocfs2_cached_inode *fs_cluster_alloc;
 	ocfs2_cached_inode **fs_inode_allocs;
 	ocfs2_cached_inode *fs_system_inode_alloc;
-	ocfs2_cached_inode *fs_eb_alloc;
+	ocfs2_cached_inode **fs_eb_allocs;
 	ocfs2_cached_inode *fs_system_eb_alloc;
 
 	/* Reserved for the use of the calling application. */

Modified: trunk/libocfs2/openfs.c
===================================================================
--- trunk/libocfs2/openfs.c	2004-11-19 00:12:27 UTC (rev 418)
+++ trunk/libocfs2/openfs.c	2004-11-19 00:19:29 UTC (rev 419)
@@ -242,6 +242,12 @@
 	if (ret)
 		goto out;
 
+	ret = ocfs2_malloc0(OCFS2_RAW_SB(fs->fs_super)->s_max_nodes *
+			    sizeof(ocfs2_cached_inode *), 
+			    &fs->fs_eb_allocs);
+	if (ret)
+		goto out;
+
 	ret = OCFS2_ET_UNEXPECTED_BLOCK_SIZE;
 	if (block_size !=
 	    (1U << OCFS2_RAW_SB(fs->fs_super)->s_blocksize_bits))



More information about the Ocfs2-tools-commits mailing list