[Ocfs2-tools-commits] zab commits r424 - in trunk: fsck.ocfs2 libocfs2 libocfs2/include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Nov 19 00:53:32 CST 2004


Author: zab
Date: 2004-11-19 00:53:30 -0600 (Fri, 19 Nov 2004)
New Revision: 424

Modified:
   trunk/fsck.ocfs2/pass1.c
   trunk/libocfs2/extents.c
   trunk/libocfs2/include/ocfs2.h
Log:
o add _inode block and extent iteration variants for callers who already have
  the dinode read.  call this in fsck in pass1 and cut pread calls by 90% and
  run time in half.


Modified: trunk/fsck.ocfs2/pass1.c
===================================================================
--- trunk/fsck.ocfs2/pass1.c	2004-11-19 06:03:18 UTC (rev 423)
+++ trunk/fsck.ocfs2/pass1.c	2004-11-19 06:53:30 UTC (rev 424)
@@ -439,8 +439,8 @@
 	else {
 		ret = o2fsck_check_extents(ost, di);
 		if (ret == 0)
-			ret = ocfs2_block_iterate(fs, blkno, 0, verify_block,
-						  &vb);
+			ret = ocfs2_block_iterate_inode(fs, di, 0,
+							verify_block, &vb);
 	}
 
 	if (ret) {

Modified: trunk/libocfs2/extents.c
===================================================================
--- trunk/libocfs2/extents.c	2004-11-19 06:03:18 UTC (rev 423)
+++ trunk/libocfs2/extents.c	2004-11-19 06:53:30 UTC (rev 424)
@@ -236,53 +236,41 @@
 }
 
 
-errcode_t ocfs2_extent_iterate(ocfs2_filesys *fs,
-			       uint64_t blkno,
-			       int flags,
-			       char *block_buf,
-			       int (*func)(ocfs2_filesys *fs,
-					   ocfs2_extent_rec *rec,
-					   int tree_depth,
-					   uint32_t ccount,
-					   uint64_t ref_blkno,
-					   int ref_recno,
-					   void *priv_data),
-			       void *priv_data)
+errcode_t ocfs2_extent_iterate_inode(ocfs2_filesys *fs,
+				     ocfs2_dinode *inode,
+				     int flags,
+				     char *block_buf,
+				     int (*func)(ocfs2_filesys *fs,
+					         ocfs2_extent_rec *rec,
+					         int tree_depth,
+					         uint32_t ccount,
+					         uint64_t ref_blkno,
+					         int ref_recno,
+					         void *priv_data),
+					         void *priv_data)
 {
 	int i;
 	int iret = 0;
-	char *buf;
-	ocfs2_dinode *inode;
 	ocfs2_extent_list *el;
 	errcode_t ret;
 	struct extent_context ctxt;
 
-	ret = ocfs2_malloc_block(fs->fs_io, &buf);
-	if (ret)
-		return ret;
-
-	ret = ocfs2_read_inode(fs, blkno, buf);
-	if (ret)
-		goto out_buf;
-
-	inode = (ocfs2_dinode *)buf;
-
 	ret = OCFS2_ET_INODE_NOT_VALID;
 	if (!(inode->i_flags & OCFS2_VALID_FL))
-		goto out_buf;
+		goto out;
 
 	ret = OCFS2_ET_INODE_CANNOT_BE_ITERATED;
 	if (inode->i_flags & (OCFS2_SUPER_BLOCK_FL |
 			      OCFS2_LOCAL_ALLOC_FL |
 			      OCFS2_CHAIN_FL))
-		goto out_buf;
+		goto out;
 
 	el = &inode->id2.i_list;
 	if (el->l_tree_depth) {
 		ret = ocfs2_malloc0(sizeof(char *) * el->l_tree_depth,
 				    &ctxt.eb_bufs);
 		if (ret)
-			goto out_buf;
+			goto out;
 
 		if (block_buf) {
 			ctxt.eb_bufs[0] = block_buf;
@@ -328,9 +316,43 @@
 		ocfs2_free(&ctxt.eb_bufs);
 	}
 
+out:
+	return ret;
+}
+
+errcode_t ocfs2_extent_iterate(ocfs2_filesys *fs,
+			       uint64_t blkno,
+			       int flags,
+			       char *block_buf,
+			       int (*func)(ocfs2_filesys *fs,
+					   ocfs2_extent_rec *rec,
+					   int tree_depth,
+					   uint32_t ccount,
+					   uint64_t ref_blkno,
+					   int ref_recno,
+					   void *priv_data),
+			       void *priv_data)
+{
+	char *buf = NULL;
+	ocfs2_dinode *inode;
+	errcode_t ret;
+
+	ret = ocfs2_malloc_block(fs->fs_io, &buf);
+	if (ret)
+		return ret;
+
+	ret = ocfs2_read_inode(fs, blkno, buf);
+	if (ret)
+		goto out_buf;
+
+	inode = (ocfs2_dinode *)buf;
+
+	ret = ocfs2_extent_iterate_inode(fs, inode, flags, block_buf,
+					 func, priv_data);
+
 out_buf:
-	ocfs2_free(&buf);
-
+	if (buf)
+		ocfs2_free(&buf);
 	return ret;
 }
 
@@ -374,6 +396,31 @@
 	return iret;
 }
 
+errcode_t ocfs2_block_iterate_inode(ocfs2_filesys *fs,
+				    ocfs2_dinode *inode,
+				    int flags,
+				    int (*func)(ocfs2_filesys *fs,
+						uint64_t blkno,
+						uint64_t bcount,
+						void *priv_data),
+				    void *priv_data)
+{
+	errcode_t ret;
+	struct block_context ctxt;
+
+	ctxt.inode = inode;
+	ctxt.flags = flags;
+	ctxt.func = func;
+	ctxt.errcode = 0;
+	ctxt.priv_data = priv_data;
+
+	ret = ocfs2_extent_iterate_inode(fs, inode,
+					 OCFS2_EXTENT_FLAG_DATA_ONLY,
+					 NULL,
+					 block_iterate_func, &ctxt);
+	return ret;
+}
+
 errcode_t ocfs2_block_iterate(ocfs2_filesys *fs,
 			      uint64_t blkno,
 			      int flags,
@@ -383,9 +430,9 @@
 					  void *priv_data),
 			      void *priv_data)
 {
+	ocfs2_dinode *inode;
 	errcode_t ret;
 	char *buf;
-	struct block_context ctxt;
 
 	ret = ocfs2_malloc_block(fs->fs_io, &buf);
 	if (ret)
@@ -395,20 +442,12 @@
 	if (ret)
 		goto out_buf;
 
-	ctxt.inode = (ocfs2_dinode *)buf;
-	ctxt.flags = flags;
-	ctxt.func = func;
-	ctxt.errcode = 0;
-	ctxt.priv_data = priv_data;
+	inode = (ocfs2_dinode *)buf;
 
-	ret = ocfs2_extent_iterate(fs, blkno,
-				   OCFS2_EXTENT_FLAG_DATA_ONLY,
-				   NULL,
-				   block_iterate_func, &ctxt);
+	ret = ocfs2_block_iterate_inode(fs, inode, flags, func, priv_data);
 
 out_buf:
 	ocfs2_free(&buf);
-
 	return ret;
 }
 

Modified: trunk/libocfs2/include/ocfs2.h
===================================================================
--- trunk/libocfs2/include/ocfs2.h	2004-11-19 06:03:18 UTC (rev 423)
+++ trunk/libocfs2/include/ocfs2.h	2004-11-19 06:53:30 UTC (rev 424)
@@ -310,6 +310,18 @@
 					   int ref_recno,
 					   void *priv_data),
 			       void *priv_data);
+errcode_t ocfs2_extent_iterate_inode(ocfs2_filesys *fs,
+				     ocfs2_dinode *inode,
+				     int flags,
+				     char *block_buf,
+				     int (*func)(ocfs2_filesys *fs,
+					         ocfs2_extent_rec *rec,
+					         int tree_depth,
+					         uint32_t ccount,
+					         uint64_t ref_blkno,
+					         int ref_recno,
+					         void *priv_data),
+					         void *priv_data);
 errcode_t ocfs2_block_iterate(ocfs2_filesys *fs,
 			      uint64_t blkno,
 			      int flags,
@@ -318,6 +330,14 @@
 					  uint64_t bcount,
 					  void *priv_data),
 			      void *priv_data);
+errcode_t ocfs2_block_iterate_inode(ocfs2_filesys *fs,
+				    ocfs2_dinode *inode,
+				    int flags,
+				    int (*func)(ocfs2_filesys *fs,
+						uint64_t blkno,
+						uint64_t bcount,
+						void *priv_data),
+				    void *priv_data);
 
 errcode_t ocfs2_read_dir_block(ocfs2_filesys *fs, uint64_t block,
 			       void *buf);



More information about the Ocfs2-tools-commits mailing list