[Ocfs2-commits] mfasheh commits r1483 - branches/dlm-changes/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Sep 24 18:13:28 CDT 2004


Author: mfasheh
Date: 2004-09-24 18:13:26 -0500 (Fri, 24 Sep 2004)
New Revision: 1483

Modified:
   branches/dlm-changes/src/inode.c
   branches/dlm-changes/src/inode.h
Log:
* don't use BKL in delete_inode for now. There's a warning and some ugly
  commented out code so we know to come back to it. I think this may improve
  performance under certain conditions.

* add a pair of warnings about needing to fix up inode delete path now ;)   
  
* add ocfs_mark_inode_dirty to update an fe from a struct inode. We should  
  try using this as much as possible now.

* bread no longer needs to extend directories in line. This will be handled
  by ocfs_prepare_dir_for_insert.



Modified: branches/dlm-changes/src/inode.c
===================================================================
--- branches/dlm-changes/src/inode.c	2004-09-24 23:06:19 UTC (rev 1482)
+++ branches/dlm-changes/src/inode.c	2004-09-24 23:13:26 UTC (rev 1483)
@@ -629,7 +629,8 @@
 		goto clear_inode;
 	}
 
-	lock_kernel();
+#warning "is BKL really necessary here? lets get rid of it for now."
+//	lock_kernel();
 
 	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0,
 				   &orphan_dir_bh, orphan_dir_inode);
@@ -667,10 +668,12 @@
 		goto bail_locked;
 	}
 
-	status = ocfs_handle_add_commit_bits(handle, 1,
-					     fe->i_suballoc_blkno << osb->sb->s_blocksize_bits,
-					     fe->i_suballoc_node,
-					     DISK_ALLOC_INODE);
+#warning "need to delete inodes here!"
+#warning "when this is added, just make it a part of the current transaction."
+//	status = ocfs_handle_add_commit_bits(handle, 1,
+//					     fe->i_suballoc_blkno << osb->sb->s_blocksize_bits,
+//					     fe->i_suballoc_node,
+//					     DISK_ALLOC_INODE);
 	if (status < 0)
 		LOG_ERROR_STATUS(status);
 
@@ -680,7 +683,7 @@
 	else if (handle)
 		ocfs_abort_trans(handle);
 
-	unlock_kernel();
+//	unlock_kernel();
 
 clear_inode:
 	if (orphan_dir_bh)
@@ -766,11 +769,11 @@
  * stuff in ocfs_get_block (that is, ocfs_get_block pretty much
  * expects never to extend).
  */
-struct buffer_head *ocfs_bread(ocfs_journal_handle *handle, struct inode * inode, 
-			       int block, int create, int *err, int reada)
+struct buffer_head *ocfs_bread(struct inode * inode, 
+			       int block, int *err, int reada)
 {
 	struct buffer_head * bh = NULL;
-	int fatal = 0, tmperr, new = 0;
+	int tmperr;
 	ocfs_super *osb;
 	__s64 vbo, lbo;
 	int readflags = OCFS_BH_CACHED;
@@ -778,79 +781,35 @@
 	osb = OCFS_SB(inode->i_sb);
 	vbo = (__s64) block << inode->i_sb->s_blocksize_bits;
 
-	OCFS_ASSERT(!create || handle);
-
 #warning only turn this on if we know we can deal with read_bh returning nothing
 #if 0
 	if (reada)
 		readflags |= OCFS_BH_READAHEAD;
 #endif
 
-	if (vbo >= inode->i_size) {
-		if (!create) {
-			*err = -ENOSPC;
-			return NULL;
-		}
-		new = 1;
-	}
+	printk("bread inode %llu, i_size = %llu, block = %d\n", 
+	       OCFS_I(inode)->ip_blkno, inode->i_size, block);
 
-	/* ???: do we need ip_sem?  should have i_sem i think */
-	if (vbo >= OCFS_I(inode)->ip_alloc_size) {
-		int vbo_pad;
-		
-		vbo_pad = inode->i_sb->s_blocksize;
-		vbo_pad -= vbo & (s64)(inode->i_sb->s_blocksize - 1);
+	OCFS_ASSERT((vbo < inode->i_size) || reada);
+	if (vbo >= inode->i_size)
+		return(NULL);
 
-		*err = ocfs_extend_file(osb, 
-					vbo + vbo_pad, 
-				        handle, inode, NULL, 0, NULL);
-		if (*err < 0) {
-			*err = -ENOSPC;
-			return NULL;
-		}
-		/*
-		 * fe->i_size will be vbo + padding to blocksize here,
-		 * and i_blocks will be whatever is actually allocated.
-		 * i_size will be changed by caller (ocfs_add_entry) if
-		 * we return !NULL.
-		 */
-	}
-
 	/* do we need extend sem?  no extend dlm message for dirs */
 	/*
 	 * UGLY: last argument to lookup_file_allocation() (locked) is
 	 * forced to '1' here, even though we don't have the lock.  This
 	 * is to force fast, unlocked operation.  Get A Real DLM.
 	 */
-	tmperr = ocfs_lookup_file_allocation(osb, vbo, &lbo, osb->sb->s_blocksize, NULL,
+	tmperr = ocfs_lookup_file_allocation(osb, vbo, &lbo, 
+					     osb->sb->s_blocksize, NULL,
 					     inode, 1);
 	if (tmperr < 0)
 		goto fail;
 
-	if (new) {
-		bh = sb_getblk(osb->sb, lbo >> osb->sb->s_blocksize_bits);
-		if (!bh) {
-			tmperr = -EIO;
-			goto fail;
-		}
-		set_buffer_uptodate(bh);
-		SET_BH_SEQNUM(inode, bh);
+	tmperr = ocfs_read_bh(osb, lbo, &bh, readflags, inode);
+	if (tmperr < 0)
+		goto fail;
 
-		fatal = ocfs_journal_access(handle, bh,
-					   OCFS_JOURNAL_ACCESS_CREATE);
-		if (fatal)
-			goto fail;
-
-		memset(bh->b_data, 0, osb->sb->s_blocksize);
-		fatal = ocfs_journal_dirty(handle, bh);	
-		if (fatal)
-			goto fail;
-	} else {
-		tmperr = ocfs_read_bh(osb, lbo, &bh, readflags, inode);
-		if (tmperr < 0)
-			goto fail;
-	}
-
 	tmperr = 0;
 
 	*err = 0;
@@ -935,6 +894,67 @@
 }				/* ocfs_inode_revalidate */
 
 /*
+ * ocfs_mark_inode_dirty
+ * 
+ * Updates a disk inode from a 
+ * struct inode.
+ * Only takes ip_sem. 
+ */
+int ocfs_mark_inode_dirty(ocfs_journal_handle *handle, 
+			  struct inode *inode, 
+			  struct buffer_head *bh)
+{
+	int status;
+	ocfs2_dinode *fe = (ocfs2_dinode *) bh->b_data;
+	ocfs_super *osb = OCFS_SB(inode->i_sb);
+
+#warning "need to check the casts and the endian-ness in this function"
+	LOG_ENTRY_ARGS("(inode %llu)\n", OCFS_I(inode)->ip_blkno);
+
+	status = ocfs_journal_access(handle, bh, OCFS_JOURNAL_ACCESS_WRITE);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto leave;
+	}
+
+	down(&OCFS_I(inode)->ip_sem);
+	if (le32_to_cpu(fe->i_flags) & OCFS2_BITMAP_FL) {
+		fe->id1.bitmap1.i_used = 
+			cpu_to_le32(OCFS_I(inode)->u.ip_bitinfo.used_bits);
+		fe->id1.bitmap1.i_total = 
+			cpu_to_le32(OCFS_I(inode)->u.ip_bitinfo.total_bits);
+	}
+
+	fe->i_clusters = 
+		(u32)OCFS_I(inode)->ip_alloc_size >> osb->s_clustersize_bits;
+	up(&OCFS_I(inode)->ip_sem);
+
+	fe->i_size = (u64)inode->i_size;
+	fe->i_links_count = inode->i_nlink;
+	fe->i_uid = inode->i_uid;
+	fe->i_gid = inode->i_gid;
+	fe->i_mode = inode->i_mode;
+	fe->i_atime = ocfs_get_seconds(inode->i_atime);
+	fe->i_ctime = ocfs_get_seconds(inode->i_ctime);
+	fe->i_mtime = ocfs_get_seconds(inode->i_mtime);
+#warning "do we want to update these here?"
+//	fe->i_dtime = ocfs_get_seconds(inode->i_dtime);
+//	fe->i_generation = inode->i_generation;
+
+	status = ocfs_journal_dirty(handle, bh);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto leave;
+	}
+
+	status = 0;
+leave:
+
+	LOG_EXIT_STATUS(status);
+	return(status);
+}				/* ocfs_mark_inode_dirty */
+
+/*
  * ocfs_refresh_inode
  * 
  * Updates a struct inode from a disk inode.

Modified: branches/dlm-changes/src/inode.h
===================================================================
--- branches/dlm-changes/src/inode.h	2004-09-24 23:06:19 UTC (rev 1482)
+++ branches/dlm-changes/src/inode.h	2004-09-24 23:13:26 UTC (rev 1483)
@@ -29,9 +29,8 @@
 #ifndef OCFS2_INODE_H
 #define OCFS2_INODE_H
 
-struct buffer_head *ocfs_bread(ocfs_journal_handle *handle,
-			       struct inode * inode, int block,
-			       int create, int *err, int reada);
+struct buffer_head *ocfs_bread(struct inode * inode, int block,
+			       int *err, int reada);
 void ocfs_clear_inode(struct inode *inode);
 void ocfs_delete_inode(struct inode *inode);
 struct inode *ocfs_iget(ocfs_super *osb, __u64 feoff);
@@ -47,7 +46,10 @@
 void ocfs_sync_blockdev(struct super_block *sb);
 int ocfs_verify_update_inode(ocfs_super *osb, struct inode *inode);
 int ocfs_refresh_inode(struct inode *inode, 
-				ocfs2_dinode *fe);
+		       ocfs2_dinode *fe);
+int ocfs_mark_inode_dirty(ocfs_journal_handle *handle, 
+			  struct inode *inode, 
+			  struct buffer_head *bh);
 #ifdef AIO_ENABLED
 int ocfs_kvec_read(struct file *file, kvec_cb_t cb, size_t size, loff_t pos); 
 int ocfs_kvec_write(struct file *file, kvec_cb_t cb, size_t size, loff_t pos); 



More information about the Ocfs2-commits mailing list