[Ocfs2-commits] mfasheh commits r926 - in trunk/src: . inc

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon May 17 21:50:29 CDT 2004


Author: mfasheh
Date: 2004-05-17 20:50:27 -0500 (Mon, 17 May 2004)
New Revision: 926

Removed:
   trunk/src/oin.c
Modified:
   trunk/src/Makefile
   trunk/src/file.c
   trunk/src/inc/ocfs.h
   trunk/src/inc/proto.h
   trunk/src/inode.c
   trunk/src/namei.c
Log:
* Move the remaining functions in oin.c into more appropriate files.

* Get rid of oin.c



Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile	2004-05-18 00:07:42 UTC (rev 925)
+++ trunk/src/Makefile	2004-05-18 01:50:27 UTC (rev 926)
@@ -138,7 +138,6 @@
 	lockres.c	\
 	namei.c		\
 	nm.c		\
-	oin.c		\
 	osb.c		\
 	proc.c		\
 	super.c		\

Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c	2004-05-18 00:07:42 UTC (rev 925)
+++ trunk/src/file.c	2004-05-18 01:50:27 UTC (rev 926)
@@ -84,6 +84,86 @@
 	return status;
 }
 
+/* 
+ * ocfs_inode_notify_open()
+ * 
+ * you should be holding i_sem and priv_sem in this function. 
+ * If needed add ourselves to the open map. Only call this 
+ * on 1st open of a file. Marks the oin as "in use"
+ */
+int ocfs_inode_notify_open(ocfs_super *osb, struct buffer_head *fe_bh, 
+			   ocfs_journal_handle *handle, struct inode *inode)
+{
+	int status = 0;
+	ocfs_file_entry *fe = NULL;
+	int local_handle = 1;
+
+	LOG_ENTRY ();
+
+	if (handle)
+		local_handle = 0;
+
+	fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(fe_bh); /* read */
+	if (!IS_VALID_FILE_ENTRY(fe)) {
+		OCFS_BH_PUT_DATA(fe_bh);
+		status = -EINVAL;
+		LOG_ERROR_STATUS(status);
+		goto leave;
+	}
+
+	/* why do we update these here? */
+	OCFS_I(inode)->alloc_size = fe->alloc_size;
+	OCFS_I(inode)->chng_seq_num = DISK_LOCK_SEQNUM (fe);
+	if (fe->this_sector == 0)
+		LOG_ERROR_STR ("this_sector=0");
+
+	OCFS_BH_PUT_DATA(fe_bh);
+
+	if (inode->i_ino == OCFS_ROOT_INODE_NUMBER)
+		goto leave;
+
+	if (local_handle) {
+		handle = ocfs_start_trans(osb, OCFS_OPEN_CREDITS);
+		if (!handle) {
+			LOG_ERROR_STATUS(status = -ENOMEM);
+			goto leave;
+		}
+		/* we want this to be a really fast transaction. */
+		ocfs_handle_set_sync(handle, 0);
+		ocfs_handle_set_checkpoint(handle, 0);
+	}
+
+	/* this will update the lock info from disk while also
+	 * ensuring that the lock level drops to something
+	 * compatible with a first-open of the file */
+	status = ocfs_wait_for_lock_release (osb, GET_INODE_FEOFF(inode), 
+					     30000, (S_ISDIR (inode->i_mode) ? 
+					      OCFS_DLM_EXCLUSIVE_LOCK : 
+					      OCFS_DLM_NO_LOCK), inode);
+	if (status < 0) {
+		if (status != -EINTR) {
+			LOG_ERROR_STR ("Lock owner is alive and taking too much time");
+			LOG_ERROR_STATUS(status);
+		}
+		goto leave;
+	}
+
+	status = ocfs_update_master_on_open (osb, inode, handle);
+	if (status < 0 && status != -EINTR)
+		LOG_ERROR_STATUS (status);
+
+leave:
+	if (local_handle && handle) {
+		if (status < 0)
+			ocfs_abort_trans(handle);
+		else
+			ocfs_commit_trans(handle);
+	}
+
+	LOG_EXIT_STATUS (status);
+	return status;
+} /* ocfs_inode_notify_open */
+
 /*
  * ocfs_file_open()
  *
@@ -131,7 +211,7 @@
 			goto leave;
 		}
 
-		status = ocfs_inode_open(osb, fe_bh, NULL, inode);
+		status = ocfs_inode_notify_open(osb, fe_bh, NULL, inode);
 		if (status < 0) {
 			up(&inode->i_sem);
 			LOG_ERROR_STATUS(status);
@@ -356,6 +436,135 @@
 	return 0;
 }				/* ocfs_file_release */
 
+/* 
+ * ocfs_inode_fill_ext_map()
+ *
+ */
+int ocfs_inode_fill_ext_map(ocfs_super * osb, struct buffer_head * fe_bh, struct inode *inode)
+{
+	int ret = 0;
+	int j;
+	__s64 tempVbo;
+	__s64 tempLbo;
+	__u64 tempSize;
+	__u64 tempoff;
+	ocfs_extent_group *extent = NULL;
+	struct buffer_head *extent_bh = NULL;
+	ocfs_file_entry *fe = NULL;
+	void *tmp;
+
+	LOG_ENTRY ();
+
+
+	/* get a copy of fe, used readonly in this path and */
+	/* ocfs_create_new_oin will deadlock if fe_bh is locked */
+	fe = ocfs_allocate_file_entry();
+	if (fe == NULL) {
+		LOG_ERROR_STATUS(ret = -ENOMEM);
+		goto leave;
+	}
+	tmp = OCFS_BH_GET_DATA_READ(fe_bh); /* read */
+	memcpy(fe, tmp, sizeof(ocfs_file_entry));
+	OCFS_BH_PUT_DATA(fe_bh);
+	tempoff = fe->this_sector;
+
+	/* we don't want to do the extent map stuff for a directory. */
+	if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
+		goto leave;
+
+	if (fe->local_ext) {
+		for (j = 0; j < fe->next_free_ext; j++) {
+			tempVbo = fe->extents[j].file_off;
+			tempLbo = fe->extents[j].disk_off;
+			tempSize = fe->extents[j].num_bytes;
+			
+			/* Add the Extent to extent map */
+			ret = ocfs_add_extent_map_entry (osb, 
+							 &OCFS_I(inode)->map,
+							  tempVbo, 
+							  tempLbo, 
+							  tempSize);
+			if (!ret) {
+				LOG_ERROR_STATUS (ret = -ENOMEM);
+				goto leave;
+			}
+		}
+	} else {
+		__u64 next_data_ext;
+		
+		/* Extents are branched and we are no longer using */
+		/* Local Extents for this File Entry. */
+		
+		ret = ocfs_get_leaf_extent (osb, fe, 0, &extent_bh, inode);
+		if (ret < 0) {
+			LOG_ERROR_STATUS (ret);
+			goto leave;
+		}
+		
+		while (1) {
+			extent = (ocfs_extent_group *) OCFS_BH_GET_DATA_READ(extent_bh); /* read */
+			
+			if (!IS_VALID_EXTENT_DATA (extent)) {
+				LOG_ERROR_STATUS(ret = -EFAIL);
+				goto leave;
+			}
+			
+			for (j = 0; j < extent->next_free_ext; j++) {
+				tempVbo = extent->extents[j].file_off;
+				tempLbo = extent->extents[j].disk_off;
+				tempSize = extent->extents[j].num_bytes;
+				
+				/* Add the Extent to extent map */
+				ret = ocfs_add_extent_map_entry (osb,
+								 &OCFS_I(inode)->map,
+								 tempVbo,
+								 tempLbo,
+								 tempSize);
+				if (!ret) {
+					LOG_ERROR_STATUS (ret =
+							  -ENOMEM);
+					goto leave;
+				}
+			}
+			
+			if (extent->next_data_ext > 0) {
+				if (!extent->next_data_ext) {
+					LOG_ERROR_STATUS (ret = -EFAIL);
+					goto leave;
+				}
+				next_data_ext = extent->next_data_ext;
+				OCFS_BH_PUT_DATA(extent_bh);
+				extent = NULL;
+				extent_bh = NULL;
+
+				ret = ocfs_read_bh(osb, 
+						   next_data_ext, 
+						   &extent_bh, 
+						   OCFS_BH_COND_CACHED, inode);
+				if (ret < 0) {
+					LOG_ERROR_STATUS(ret);
+					goto leave;
+				}
+			} else
+				break;
+		}
+	}
+
+leave:
+	/* this fe was a copy */
+	if (fe)
+		ocfs_release_file_entry (fe);
+
+	if (extent_bh) {
+		if (extent)
+			OCFS_BH_PUT_DATA(extent_bh);
+		brelse(extent_bh);
+	}
+
+	LOG_EXIT_STATUS (ret);
+	return ret;
+}				/* ocfs_inode_fill_ext_map */
+
 /*
  * ocfs_flush()
  *

Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h	2004-05-18 00:07:42 UTC (rev 925)
+++ trunk/src/inc/ocfs.h	2004-05-18 01:50:27 UTC (rev 926)
@@ -992,8 +992,8 @@
 #define OCFS_DEBUG_CONTEXT_FILE        0x00000200	/* file.c     */
 #define OCFS_DEBUG_CONTEXT_INODE       0x00000400	/* inode.c    */
 #define OCFS_DEBUG_CONTEXT_JOURNAL     0x00000800	/* journal.c  */
-#define OCFS_DEBUG_CONTEXT_OIN         0x00001000	/* oin.c      */
-#define OCFS_DEBUG_CONTEXT_SEM         0x00002000	/* sem.c      */
+#define OCFS_DEBUG_CONTEXT_UNUSED1     0x00001000	/*            */
+#define OCFS_DEBUG_CONTEXT_UNUSED2     0x00002000	/*            */
 #define OCFS_DEBUG_CONTEXT_SYSFILE     0x00004000	/* sysfile.c  */
 #define OCFS_DEBUG_CONTEXT_VOLCFG      0x00008000	/* volcfg.c   */
 #define OCFS_DEBUG_CONTEXT_DCACHE      0x00010000	/* dcache.c   */

Modified: trunk/src/inc/proto.h
===================================================================
--- trunk/src/inc/proto.h	2004-05-18 00:07:42 UTC (rev 925)
+++ trunk/src/inc/proto.h	2004-05-18 01:50:27 UTC (rev 926)
@@ -151,8 +151,8 @@
 
 int ocfs_verify_update_inode (ocfs_super * osb, struct inode * inode, int *needs_trunc, int lockres_locked);
 int ocfs_inode_fill_ext_map(ocfs_super * osb, struct buffer_head * fe_bh, struct inode *inode);
-int ocfs_inode_open(ocfs_super *osb, struct buffer_head *fe_bh, 
-		    ocfs_journal_handle *handle, struct inode *inode);
+int ocfs_inode_notify_open(ocfs_super *osb, struct buffer_head *fe_bh, 
+			   ocfs_journal_handle *handle, struct inode *inode);
 
 int ocfs_initialize_osb (ocfs_super * osb, ocfs_vol_disk_hdr * vdh, ocfs_vol_label * vol_label, __u32 sect_size);
 int ocfs_verify_volume (ocfs_vol_disk_hdr * vdh);

Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c	2004-05-18 00:07:42 UTC (rev 925)
+++ trunk/src/inode.c	2004-05-18 01:50:27 UTC (rev 926)
@@ -1706,3 +1706,209 @@
 	LOG_EXIT_STATUS(status);
 	return(status);
 }
+
+/*
+ * ocfs_verify_update_inode()
+ */ 
+int ocfs_verify_update_inode (ocfs_super * osb, struct inode * inode, int *needs_trunc, int lockres_locked)
+{
+	int status = 0;
+	struct buffer_head *fe_bh = NULL;
+	ocfs_file_entry *fe = NULL;
+	struct list_head *iter;
+	struct list_head *temp_iter;
+	int disk_len;
+	__u64 offset;
+
+	/* We are setting the oin Updated flag in the end. */
+	LOG_ENTRY ();
+
+	OCFS_ASSERT (inode);
+
+	*needs_trunc = 0;
+
+	/* This read of feoff from the inode depends on all callers to
+	 * make sure that unlink or rename can't be change it while we're
+	 * in here! */
+	offset = GET_INODE_FEOFF(inode);
+	if (offset == 0) {
+		LOG_ERROR_ARGS("inode %lu has zero offset\n", inode->i_ino);
+		status = -EINVAL;
+		goto leave;
+	}
+
+	if (INODE_DELETED(inode)) {
+		LOG_TRACE_ARGS("Inode %lu was marked as deleted!", 
+			       inode->i_ino);
+		status = -ENOENT;
+		goto leave;
+	}
+
+	status = ocfs_read_bh(osb, offset, &fe_bh, OCFS_BH_COND_CACHED, inode);
+	if (status < 0) {
+		LOG_ERROR_STATUS (status);
+		goto leave;
+	}
+	fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(fe_bh); /* read */
+
+	/* Make sure that what we found is not a directory. */
+	if ((OCFS_I(inode)->oin_flags & OCFS_OIN_DIRECTORY))
+		goto leave;
+
+	/* Add checks as needed */
+	if ((fe->sync_flags & OCFS_SYNC_FLAG_MARK_FOR_DELETION) ||
+	    (!(fe->sync_flags & OCFS_SYNC_FLAG_VALID))) {
+		if (fe->sync_flags & OCFS_SYNC_FLAG_MARK_FOR_DELETION) {
+			LOG_TRACE_STR
+				("File Entry is marked for deletion");
+		} else {
+			LOG_TRACE_STR ("File Entry is invalid");
+		}
+		status = -ENOENT;
+		goto leave;
+	}
+
+	disk_len = strlen(fe->filename);
+
+	status = -ENOENT;
+	list_for_each_safe (iter, temp_iter, &(inode->i_dentry)) {
+		struct dentry *dentry = list_entry (iter, struct dentry, d_alias);
+		if (dentry->d_name.len == disk_len &&
+		    strncmp(dentry->d_name.name, fe->filename, disk_len)==0)
+				status = 0;
+	}
+
+	/* isn't it OK for an inode to have no dentry yet? */
+	if (list_empty(&inode->i_dentry))
+		status = 0;
+
+	if (status < 0) {
+		LOG_TRACE_STR ("file entry name did not match inode");
+		goto leave;
+	}
+
+	if ((OCFS_I(inode)->alloc_size != (__s64) fe->alloc_size) ||
+	    (inode->i_size != (__s64) fe->file_size) ||
+	    (OCFS_I(inode)->chng_seq_num != DISK_LOCK_SEQNUM (fe)) ||
+	    inode->i_uid != fe->uid ||
+	    inode->i_gid != fe->gid || inode->i_mode != fe->prot_bits){
+
+		if (OCFS_I(inode)->alloc_size > (__s64)fe->alloc_size){
+			ocfs_extent_map_destroy (&OCFS_I(inode)->map);
+			ocfs_extent_map_init (&OCFS_I(inode)->map);
+		}
+
+		LOG_TRACE_STR("Allocsize, filesize or seq no did not match");
+		OCFS_I(inode)->alloc_size = fe->alloc_size;
+		inode->i_size = fe->file_size;
+		OCFS_I(inode)->chng_seq_num = DISK_LOCK_SEQNUM (fe);
+
+		inode->i_blocks = (inode->i_size + osb->sect_size) >> osb->sect_size_bits;
+		inode->i_uid = fe->uid;
+		inode->i_gid = fe->gid;
+		inode->i_mode = fe->prot_bits;
+		inode->i_blksize = (__u32) osb->vol_layout.cluster_size;
+		OCFS_SET_INODE_TIME(inode, i_ctime, fe->create_time);
+		OCFS_SET_INODE_TIME(inode, i_atime, fe->modify_time);
+		OCFS_SET_INODE_TIME(inode, i_mtime, fe->modify_time);
+		if (!S_ISDIR (inode->i_mode) &&
+		    (OCFS_I(inode)->alloc_size != (__s64) fe->alloc_size ||
+		     inode->i_size != (__s64) fe->file_size ||
+		     OCFS_I(inode)->chng_seq_num != DISK_LOCK_SEQNUM (fe))) {
+			*needs_trunc = 1;
+		}
+
+		switch (fe->attribs) {
+		case OCFS_ATTRIB_DIRECTORY:
+			inode->i_size = OCFS_DEFAULT_DIR_NODE_SIZE;
+			inode->i_blocks = (inode->i_size + osb->sect_size) >> osb->sect_size_bits;
+			inode->i_mode |= S_IFDIR;
+			break;
+		case OCFS_ATTRIB_SYMLINK:
+			inode->i_mode |= S_IFLNK;
+			break;
+		case OCFS_ATTRIB_REG:
+			inode->i_mode |= S_IFREG;
+			break;
+		case OCFS_ATTRIB_CHAR:
+		case OCFS_ATTRIB_BLOCK:
+		case OCFS_ATTRIB_FIFO:
+		case OCFS_ATTRIB_SOCKET:
+		{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+			dev_t dev;
+#else
+			kdev_t kdev;
+#endif
+			if (fe->attribs == OCFS_ATTRIB_CHAR)
+				inode->i_mode |= S_IFCHR;
+			else if (fe->attribs == OCFS_ATTRIB_BLOCK)
+				inode->i_mode |= S_IFBLK;
+			else if (fe->attribs == OCFS_ATTRIB_FIFO)
+				inode->i_mode |= S_IFIFO;
+			else if (fe->attribs == OCFS_ATTRIB_SOCKET)
+				inode->i_mode |= S_IFSOCK;
+
+			inode->i_rdev = OCFS_NODEV;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+			dev = MKDEV (fe->dev_major, fe->dev_minor);
+#else
+			kdev = MKDEV (fe->dev_major, fe->dev_minor);
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+			init_special_inode (inode, inode->i_mode, dev);
+#else
+			init_special_inode (inode, inode->i_mode, 
+					    kdev_t_to_nr(kdev));
+#endif
+			break;
+		}
+		default:
+			LOG_ERROR_ARGS ("attribs=%d", fe->attribs);
+			inode->i_mode |= S_IFREG;
+			break;
+		}
+
+		if (fe->local_ext) {
+			__s64 tempVbo;
+			__s64 tempLbo;
+			__u64 tempSize;
+			__u32 j;
+
+			/* Add the Extents to extent map */
+			for (j = 0; j < fe->next_free_ext; j++) {
+				tempVbo = fe->extents[j].file_off;
+				tempLbo = fe->extents[j].disk_off;
+				tempSize = fe->extents[j].num_bytes;
+
+				if (!ocfs_add_extent_map_entry (osb, 
+								&OCFS_I(inode)->map,
+								tempVbo, tempLbo,
+								tempSize))
+					goto leave;
+			}
+		}
+	}
+
+	OCFS_BH_PUT_DATA(fe_bh);
+	fe = NULL;
+
+	status = ocfs_update_lockres (osb, GET_INODE_FEOFF(inode), &fe_bh, 
+				      NULL, 0, inode, 0, lockres_locked);
+
+	status = 0;
+leave:
+	if (status == 0)
+		OCFS_I(inode)->needs_verification = 0;
+
+	if (fe_bh) {
+		if (fe)
+			OCFS_BH_PUT_DATA(fe_bh);
+		brelse(fe_bh);
+	}
+
+	LOG_EXIT_STATUS (status);
+	return status;
+}				/* ocfs_verify_update_inode */
+

Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c	2004-05-18 00:07:42 UTC (rev 925)
+++ trunk/src/namei.c	2004-05-18 01:50:27 UTC (rev 926)
@@ -1256,7 +1256,7 @@
 	inode->i_blocks = (newsize + sb->s_blocksize) >> sb->s_blocksize_bits;
 
 	ocfs_init_lockres (osb, inode);
-	status = ocfs_inode_open(osb, new_fe_bh, handle, inode);
+	status = ocfs_inode_notify_open(osb, new_fe_bh, handle, inode);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto abort_trans;

Deleted: trunk/src/oin.c
===================================================================
--- trunk/src/oin.c	2004-05-18 00:07:42 UTC (rev 925)
+++ trunk/src/oin.c	2004-05-18 01:50:27 UTC (rev 926)
@@ -1,444 +0,0 @@
-/*
- * oin.c
- *
- * Create, verify, release oin
- *
- * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Mark Fasheh, Sunil Mushran, Wim Coekaerts,
- *	    Manish Singh, Neeraj Goyal, Suchit Kaura
- */
-
-#include "inc/ocfs.h"
-
-#define OCFS_DEBUG_CONTEXT      OCFS_DEBUG_CONTEXT_OIN
-
-extern spinlock_t oin_num_ext_lock;
-
-/*
- * ocfs_verify_update_inode()
- */ 
-int ocfs_verify_update_inode (ocfs_super * osb, struct inode * inode, int *needs_trunc, int lockres_locked)
-{
-	int status = 0;
-	struct buffer_head *fe_bh = NULL;
-	ocfs_file_entry *fe = NULL;
-	struct list_head *iter;
-	struct list_head *temp_iter;
-	int disk_len;
-	__u64 offset;
-
-	/* We are setting the oin Updated flag in the end. */
-	LOG_ENTRY ();
-
-	OCFS_ASSERT (inode);
-
-	*needs_trunc = 0;
-
-	/* This read of feoff from the inode depends on all callers to
-	 * make sure that unlink or rename can't be change it while we're
-	 * in here! */
-	offset = GET_INODE_FEOFF(inode);
-	if (offset == 0) {
-		LOG_ERROR_ARGS("inode %lu has zero offset\n", inode->i_ino);
-		status = -EINVAL;
-		goto leave;
-	}
-
-	if (INODE_DELETED(inode)) {
-		LOG_TRACE_ARGS("Inode %lu was marked as deleted!", 
-			       inode->i_ino);
-		status = -ENOENT;
-		goto leave;
-	}
-
-	status = ocfs_read_bh(osb, offset, &fe_bh, OCFS_BH_COND_CACHED, inode);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-	fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(fe_bh); /* read */
-
-	/* Make sure that what we found is not a directory. */
-	if ((OCFS_I(inode)->oin_flags & OCFS_OIN_DIRECTORY))
-		goto leave;
-
-	/* Add checks as needed */
-	if ((fe->sync_flags & OCFS_SYNC_FLAG_MARK_FOR_DELETION) ||
-	    (!(fe->sync_flags & OCFS_SYNC_FLAG_VALID))) {
-		if (fe->sync_flags & OCFS_SYNC_FLAG_MARK_FOR_DELETION) {
-			LOG_TRACE_STR
-				("File Entry is marked for deletion");
-		} else {
-			LOG_TRACE_STR ("File Entry is invalid");
-		}
-		status = -ENOENT;
-		goto leave;
-	}
-
-	disk_len = strlen(fe->filename);
-
-	status = -ENOENT;
-	list_for_each_safe (iter, temp_iter, &(inode->i_dentry)) {
-		struct dentry *dentry = list_entry (iter, struct dentry, d_alias);
-		if (dentry->d_name.len == disk_len &&
-		    strncmp(dentry->d_name.name, fe->filename, disk_len)==0)
-				status = 0;
-	}
-
-	/* isn't it OK for an inode to have no dentry yet? */
-	if (list_empty(&inode->i_dentry))
-		status = 0;
-
-	if (status < 0) {
-		LOG_TRACE_STR ("file entry name did not match inode");
-		goto leave;
-	}
-
-	if ((OCFS_I(inode)->alloc_size != (__s64) fe->alloc_size) ||
-	    (inode->i_size != (__s64) fe->file_size) ||
-	    (OCFS_I(inode)->chng_seq_num != DISK_LOCK_SEQNUM (fe)) ||
-	    inode->i_uid != fe->uid ||
-	    inode->i_gid != fe->gid || inode->i_mode != fe->prot_bits){
-
-		if (OCFS_I(inode)->alloc_size > (__s64)fe->alloc_size){
-			ocfs_extent_map_destroy (&OCFS_I(inode)->map);
-			ocfs_extent_map_init (&OCFS_I(inode)->map);
-		}
-
-		LOG_TRACE_STR("Allocsize, filesize or seq no did not match");
-		OCFS_I(inode)->alloc_size = fe->alloc_size;
-		inode->i_size = fe->file_size;
-		OCFS_I(inode)->chng_seq_num = DISK_LOCK_SEQNUM (fe);
-
-		inode->i_blocks = (inode->i_size + osb->sect_size) >> osb->sect_size_bits;
-		inode->i_uid = fe->uid;
-		inode->i_gid = fe->gid;
-		inode->i_mode = fe->prot_bits;
-		inode->i_blksize = (__u32) osb->vol_layout.cluster_size;
-		OCFS_SET_INODE_TIME(inode, i_ctime, fe->create_time);
-		OCFS_SET_INODE_TIME(inode, i_atime, fe->modify_time);
-		OCFS_SET_INODE_TIME(inode, i_mtime, fe->modify_time);
-		if (!S_ISDIR (inode->i_mode) &&
-		    (OCFS_I(inode)->alloc_size != (__s64) fe->alloc_size ||
-		     inode->i_size != (__s64) fe->file_size ||
-		     OCFS_I(inode)->chng_seq_num != DISK_LOCK_SEQNUM (fe))) {
-			*needs_trunc = 1;
-		}
-
-		switch (fe->attribs) {
-		case OCFS_ATTRIB_DIRECTORY:
-			inode->i_size = OCFS_DEFAULT_DIR_NODE_SIZE;
-			inode->i_blocks = (inode->i_size + osb->sect_size) >> osb->sect_size_bits;
-			inode->i_mode |= S_IFDIR;
-			break;
-		case OCFS_ATTRIB_SYMLINK:
-			inode->i_mode |= S_IFLNK;
-			break;
-		case OCFS_ATTRIB_REG:
-			inode->i_mode |= S_IFREG;
-			break;
-		case OCFS_ATTRIB_CHAR:
-		case OCFS_ATTRIB_BLOCK:
-		case OCFS_ATTRIB_FIFO:
-		case OCFS_ATTRIB_SOCKET:
-		{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-			dev_t dev;
-#else
-			kdev_t kdev;
-#endif
-			if (fe->attribs == OCFS_ATTRIB_CHAR)
-				inode->i_mode |= S_IFCHR;
-			else if (fe->attribs == OCFS_ATTRIB_BLOCK)
-				inode->i_mode |= S_IFBLK;
-			else if (fe->attribs == OCFS_ATTRIB_FIFO)
-				inode->i_mode |= S_IFIFO;
-			else if (fe->attribs == OCFS_ATTRIB_SOCKET)
-				inode->i_mode |= S_IFSOCK;
-
-			inode->i_rdev = OCFS_NODEV;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-			dev = MKDEV (fe->dev_major, fe->dev_minor);
-#else
-			kdev = MKDEV (fe->dev_major, fe->dev_minor);
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-			init_special_inode (inode, inode->i_mode, dev);
-#else
-			init_special_inode (inode, inode->i_mode, 
-					    kdev_t_to_nr(kdev));
-#endif
-			break;
-		}
-		default:
-			LOG_ERROR_ARGS ("attribs=%d", fe->attribs);
-			inode->i_mode |= S_IFREG;
-			break;
-		}
-
-		if (fe->local_ext) {
-			__s64 tempVbo;
-			__s64 tempLbo;
-			__u64 tempSize;
-			__u32 j;
-
-			/* Add the Extents to extent map */
-			for (j = 0; j < fe->next_free_ext; j++) {
-				tempVbo = fe->extents[j].file_off;
-				tempLbo = fe->extents[j].disk_off;
-				tempSize = fe->extents[j].num_bytes;
-
-				if (!ocfs_add_extent_map_entry (osb, 
-								&OCFS_I(inode)->map,
-								tempVbo, tempLbo,
-								tempSize))
-					goto leave;
-			}
-		}
-	}
-
-	OCFS_BH_PUT_DATA(fe_bh);
-	fe = NULL;
-
-	status = ocfs_update_lockres (osb, GET_INODE_FEOFF(inode), &fe_bh, 
-				      NULL, 0, inode, 0, lockres_locked);
-
-	status = 0;
-leave:
-	if (status == 0)
-		OCFS_I(inode)->needs_verification = 0;
-
-	if (fe_bh) {
-		if (fe)
-			OCFS_BH_PUT_DATA(fe_bh);
-		brelse(fe_bh);
-	}
-
-	LOG_EXIT_STATUS (status);
-	return status;
-}				/* ocfs_verify_update_inode */
-
-/* you should be holding i_sem and priv_sem in this function. 
- *
- * If needed add ourselves to the open map. Only call this 
- * on 1st open of a file. Marks the oin as "in use"
- */
-int ocfs_inode_open(ocfs_super *osb, struct buffer_head *fe_bh, 
-		    ocfs_journal_handle *handle, struct inode *inode)
-{
-	int status = 0;
-	ocfs_file_entry *fe = NULL;
-	int local_handle = 1;
-
-	LOG_ENTRY ();
-
-	if (handle)
-		local_handle = 0;
-
-	fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(fe_bh); /* read */
-	if (!IS_VALID_FILE_ENTRY(fe)) {
-		OCFS_BH_PUT_DATA(fe_bh);
-		status = -EINVAL;
-		LOG_ERROR_STATUS(status);
-		goto leave;
-	}
-
-	/* why do we update these here? */
-	OCFS_I(inode)->alloc_size = fe->alloc_size;
-	OCFS_I(inode)->chng_seq_num = DISK_LOCK_SEQNUM (fe);
-	if (fe->this_sector == 0)
-		LOG_ERROR_STR ("this_sector=0");
-
-	OCFS_BH_PUT_DATA(fe_bh);
-
-	if (inode->i_ino == OCFS_ROOT_INODE_NUMBER)
-		goto leave;
-
-	if (local_handle) {
-		handle = ocfs_start_trans(osb, OCFS_OPEN_CREDITS);
-		if (!handle) {
-			LOG_ERROR_STATUS(status = -ENOMEM);
-			goto leave;
-		}
-		/* we want this to be a really fast transaction. */
-		ocfs_handle_set_sync(handle, 0);
-		ocfs_handle_set_checkpoint(handle, 0);
-	}
-
-	/* this will update the lock info from disk while also
-	 * ensuring that the lock level drops to something
-	 * compatible with a first-open of the file */
-	status = ocfs_wait_for_lock_release (osb, GET_INODE_FEOFF(inode), 
-					     30000, (S_ISDIR (inode->i_mode) ? 
-					      OCFS_DLM_EXCLUSIVE_LOCK : 
-					      OCFS_DLM_NO_LOCK), inode);
-	if (status < 0) {
-		if (status != -EINTR) {
-			LOG_ERROR_STR ("Lock owner is alive and taking too much time");
-			LOG_ERROR_STATUS(status);
-		}
-		goto leave;
-	}
-
-	status = ocfs_update_master_on_open (osb, inode, handle);
-	if (status < 0 && status != -EINTR)
-		LOG_ERROR_STATUS (status);
-
-leave:
-	if (local_handle && handle) {
-		if (status < 0)
-			ocfs_abort_trans(handle);
-		else
-			ocfs_commit_trans(handle);
-	}
-
-	LOG_EXIT_STATUS (status);
-	return status;
-}
-
-
-
-/* ocfs_inode_fill_ext_map()
- *
- */
-int ocfs_inode_fill_ext_map(ocfs_super * osb, struct buffer_head * fe_bh, struct inode *inode)
-{
-	int ret = 0;
-	int j;
-	__s64 tempVbo;
-	__s64 tempLbo;
-	__u64 tempSize;
-	__u64 tempoff;
-	ocfs_extent_group *extent = NULL;
-	struct buffer_head *extent_bh = NULL;
-	ocfs_file_entry *fe = NULL;
-	void *tmp;
-
-	LOG_ENTRY ();
-
-
-	/* get a copy of fe, used readonly in this path and */
-	/* ocfs_create_new_oin will deadlock if fe_bh is locked */
-	fe = ocfs_allocate_file_entry();
-	if (fe == NULL) {
-		LOG_ERROR_STATUS(ret = -ENOMEM);
-		goto leave;
-	}
-	tmp = OCFS_BH_GET_DATA_READ(fe_bh); /* read */
-	memcpy(fe, tmp, sizeof(ocfs_file_entry));
-	OCFS_BH_PUT_DATA(fe_bh);
-	tempoff = fe->this_sector;
-
-	/* we don't want to do the extent map stuff for a directory. */
-	if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
-		goto leave;
-
-	if (fe->local_ext) {
-		for (j = 0; j < fe->next_free_ext; j++) {
-			tempVbo = fe->extents[j].file_off;
-			tempLbo = fe->extents[j].disk_off;
-			tempSize = fe->extents[j].num_bytes;
-			
-			/* Add the Extent to extent map */
-			ret = ocfs_add_extent_map_entry (osb, 
-							 &OCFS_I(inode)->map,
-							  tempVbo, 
-							  tempLbo, 
-							  tempSize);
-			if (!ret) {
-				LOG_ERROR_STATUS (ret = -ENOMEM);
-				goto leave;
-			}
-		}
-	} else {
-		__u64 next_data_ext;
-		
-		/* Extents are branched and we are no longer using */
-		/* Local Extents for this File Entry. */
-		
-		ret = ocfs_get_leaf_extent (osb, fe, 0, &extent_bh, inode);
-		if (ret < 0) {
-			LOG_ERROR_STATUS (ret);
-			goto leave;
-		}
-		
-		while (1) {
-			extent = (ocfs_extent_group *) OCFS_BH_GET_DATA_READ(extent_bh); /* read */
-			
-			if (!IS_VALID_EXTENT_DATA (extent)) {
-				LOG_ERROR_STATUS(ret = -EFAIL);
-				goto leave;
-			}
-			
-			for (j = 0; j < extent->next_free_ext; j++) {
-				tempVbo = extent->extents[j].file_off;
-				tempLbo = extent->extents[j].disk_off;
-				tempSize = extent->extents[j].num_bytes;
-				
-				/* Add the Extent to extent map */
-				ret = ocfs_add_extent_map_entry (osb,
-								 &OCFS_I(inode)->map,
-								 tempVbo,
-								 tempLbo,
-								 tempSize);
-				if (!ret) {
-					LOG_ERROR_STATUS (ret =
-							  -ENOMEM);
-					goto leave;
-				}
-			}
-			
-			if (extent->next_data_ext > 0) {
-				if (!extent->next_data_ext) {
-					LOG_ERROR_STATUS (ret = -EFAIL);
-					goto leave;
-				}
-				next_data_ext = extent->next_data_ext;
-				OCFS_BH_PUT_DATA(extent_bh);
-				extent = NULL;
-				extent_bh = NULL;
-
-				ret = ocfs_read_bh(osb, 
-						   next_data_ext, 
-						   &extent_bh, 
-						   OCFS_BH_COND_CACHED, inode);
-				if (ret < 0) {
-					LOG_ERROR_STATUS(ret);
-					goto leave;
-				}
-			} else
-				break;
-		}
-	}
-
-leave:
-	/* this fe was a copy */
-	if (fe)
-		ocfs_release_file_entry (fe);
-
-	if (extent_bh) {
-		if (extent)
-			OCFS_BH_PUT_DATA(extent_bh);
-		brelse(extent_bh);
-	}
-
-	LOG_EXIT_STATUS (ret);
-	return ret;
-}				/* ocfs_inode_fill_ext_map */



More information about the Ocfs2-commits mailing list