[Ocfs2-commits] rev 33 - in trunk/src: . inc

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Feb 23 19:27:20 CST 2004


Author: manish
Date: 2004-02-23 19:27:18 -0600 (Mon, 23 Feb 2004)
New Revision: 33

Modified:
   trunk/src/alloc.c
   trunk/src/dcache.c
   trunk/src/file.c
   trunk/src/hash.c
   trunk/src/inc/ocfs.h
   trunk/src/inode.c
   trunk/src/namei.c
   trunk/src/nm.c
   trunk/src/oin.c
   trunk/src/symlink.c
   trunk/src/util.c
Log:
2.6 fixes.
some inode sanity


Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c	2004-02-19 01:29:27 UTC (rev 32)
+++ trunk/src/alloc.c	2004-02-24 01:27:18 UTC (rev 33)
@@ -126,8 +126,15 @@
 		       ( (type == DISK_ALLOC_EXTENT_NODE) ? 
 		         "DISK_ALLOC_EXTENT_NODE" : "DISK_ALLOC_DIR_NODE" ));
 
-	if (len == 0)
+	if (len == 0) {
+		printk("ocfs2: Zero length delete!\n");
+		printk("(len = %u, fileoff = %u, nodenum = %u, "
+		       "type=%d (\"%s\")\n", len, fileoff, nodenum, type, 
+		       (type == DISK_ALLOC_VOLUME) ? "DISK_ALLOC_VOLUME" : 
+		       ( (type == DISK_ALLOC_EXTENT_NODE) ? 
+		         "DISK_ALLOC_EXTENT_NODE" : "DISK_ALLOC_DIR_NODE" ));
 		BUG();
+	}
 
 	log = f->tail;
 
@@ -1996,7 +2003,7 @@
 						ext->file_off = 0;
 						ext->num_bytes = 0;
 						ext->disk_off = 0;
-					} else {
+					} else if ((ext->file_off + ext->num_bytes) > newsize) {
 						/* Do we shrink it? */
 						orig_bytes = ext->num_bytes;
 						doff = ext->disk_off; 
@@ -2008,6 +2015,15 @@
 						 * for loop now */
 						total_bytes+= (orig_bytes - bytes);
 						done = true;
+					} else {
+						/* if we get here,
+						 * then we don't want
+						 * to actually delete
+						 * *anything* from
+						 * this extent. */
+						LOG_TRACE_ARGS("Not deleting extent %d, disk_off = %u.%u, num_bytes = %u.%u, file_off = %u.%u\n", i, HILO(ext->disk_off), HILO(ext->num_bytes), HILO(ext->file_off));
+						done = true;
+						goto skip_bitmap_add;
 					}
 					status = ocfs_add_to_bitmap_free_head(osb, free_head, num_sectors, bitmap_offset, -1, DISK_ALLOC_VOLUME);
 					if (status < 0) {
@@ -2015,6 +2031,7 @@
 						goto bail;
 					}
 
+skip_bitmap_add:
 					if (done) {
 						AllocExtent->next_free_ext=i+1;
 						break;
@@ -2181,8 +2198,6 @@
 				continue;
 			}
 
-			/* need to get the next offset to read */
-			AllocExtent = (ocfs_extent_group *) OCFS_BH_GET_DATA_WRITE(bh_stack[tos]); /* write */
 			AllocExtent->next_free_ext--;
 			victim = AllocExtent->next_free_ext;
 			ext = &AllocExtent->extents[victim];
@@ -2318,7 +2333,7 @@
 
 	LOG_EXIT_STATUS(status);
 	return(status);
-}
+}  /* ocfs_update_last_ext_ptr */
 
 /*
  * ocfs_free_extents_for_truncate()
@@ -2388,12 +2403,10 @@
 			FileEntry->extents[i].num_bytes = 0;
 			FileEntry->next_free_ext = i;
 		} else { /* Ok, we only want part of it. */
-			/* Actually, the truth is we might NOT want to
-			 * split this tree, but we call this function
-			 * anyways in order to update last_ext_ptr. */
-
 			LOG_TRACE_ARGS("Splitting this tree!\n");
-			status = ocfs_split_this_tree(osb, extent_bh, free_head, FileEntry, handle, inode);
+			status = ocfs_split_this_tree(osb, extent_bh, 
+						      free_head, FileEntry, 
+						      handle, inode);
 			if (status < 0) {
 				LOG_ERROR_STATUS(status);
 				goto finally;
@@ -3242,7 +3255,7 @@
 				goto leave;
 			}
 			extent = (ocfs_extent_group *) OCFS_BH_GET_DATA_READ(extent_bh); /* read */
-			if ((fe->granularity && (!IS_VALID_EXTENT_HEADER(extent))) || !IS_VALID_EXTENT_DATA(extent)) {
+			if ((fe->granularity && (!IS_VALID_EXTENT_HEADER(extent))) && !IS_VALID_EXTENT_DATA(extent)) {
 				status = -EINVAL;
 				LOG_ERROR_STATUS(status);
 				goto leave;

Modified: trunk/src/dcache.c
===================================================================
--- trunk/src/dcache.c	2004-02-19 01:29:27 UTC (rev 32)
+++ trunk/src/dcache.c	2004-02-24 01:27:18 UTC (rev 33)
@@ -43,10 +43,12 @@
 	ocfs_inode *oin;
 	ocfs_super *osb;
 	__u64 off;
-	ocfs_find_inode_args args;
         struct qstr q;
 	struct buffer_head *fe_bh = NULL;
 	int needs_trunc;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+	ocfs_find_inode_args args;
+#endif
 
         LOG_ENTRY_ARGS ("(0x%08x, %d, '%*s')\n", dentry, flags,
                         dentry->d_name.len, dentry->d_name.name);
@@ -127,7 +129,7 @@
                 LOG_TRACE_STR("found the file entry, but it has been deleted or renamed!");
                 ret = 0;  /* it is now officially stale :) */
         } else {
-#ifdef LINUX_2_5
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 		ocfs_read_locked_inode (inode, fe);
 #else
 		args.offset = fe->this_sector;

Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c	2004-02-19 01:29:27 UTC (rev 32)
+++ trunk/src/file.c	2004-02-24 01:27:18 UTC (rev 33)
@@ -311,6 +311,7 @@
         ocfs_inode *oin = NULL;
         struct dentry *dentry;
         struct inode *parent;
+	bool last_close = false;
 
 	LOG_ENTRY_ARGS ("(0x%08x, 0x%08x, '%*s')\n", inode, file,
                         file->f_dentry->d_name.len, file->f_dentry->d_name.name);
@@ -370,7 +371,9 @@
 
         ocfs_down_sem (&(oin->main_res), true);
         oin->open_hndl_cnt--;
-                
+	if (!oin->open_hndl_cnt) 
+		last_close = true;
+
         if (oin->oin_flags & OCFS_OIN_ROOT_DIRECTORY) {
                 ocfs_up_sem (&(oin->main_res));
                 goto do_parent_dec;
@@ -399,8 +402,6 @@
 #if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,18)
 		fsync_inode_data_buffers(inode);
 #endif
-		if (inode->i_data.nrpages)
-			ocfs_truncate_inode_pages(inode, 0);
         } else {
                 ocfs_up_sem (&(oin->main_res));
                 ocfs_release_cached_oin (osb, oin);
@@ -408,12 +409,13 @@
 #if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,18)
 		fsync_inode_data_buffers(inode);
 #endif
+        }
+
+	if (last_close) {
 		if (inode->i_data.nrpages)
 			ocfs_truncate_inode_pages(inode, 0);
+	}
 
-
-        }
-        
 do_parent_dec:
         if (dentry && dentry->d_parent && 
             dentry->d_parent->d_inode) {

Modified: trunk/src/hash.c
===================================================================
--- trunk/src/hash.c	2004-02-19 01:29:27 UTC (rev 32)
+++ trunk/src/hash.c	2004-02-24 01:27:18 UTC (rev 33)
@@ -1550,10 +1550,11 @@
 			       "feoff=%u.%u\n", inode->i_ino, 
 			       HILO(inum->i_voteoff), HILO(inum->i_feoff));
 	} else if (inum->i_inode != inode) {
-		LOG_ERROR_ARGS("Inum is bound to a different inode!"
-			       "(%u.%u) (%lu) (%lu)\n",
+		LOG_ERROR_ARGS("Inum is bound to a different inode! "
+			       "(%u.%u) (%lu) (%lu) (deleted = %u)\n",
 			       HILO(voteoff), inode->i_ino, 
-			       inum->i_inode->i_ino);
+			       inum->i_inode->i_ino, 
+			       INODE_DELETED(inum->i_inode));
 		BUG();
 	}
 

Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h	2004-02-19 01:29:27 UTC (rev 32)
+++ trunk/src/inc/ocfs.h	2004-02-24 01:27:18 UTC (rev 33)
@@ -1136,7 +1136,7 @@
 #define OCFS_SET_INODE_DEV(sb, inode)   (inode->i_rdev = sb->sdev)
 typedef struct block_device * ocfs_blockdev;
 typedef dev_t ocfs_dev;
-#define OCFS_NODEV     NODEV.value
+#define OCFS_NODEV     0
 #define OCFS_GET_BLOCKDEV(sb)   ((sb)->s_bdev)
 #else /* 2.4 kernel */
 #define OCFS_SET_INODE_DEV(sb, inode)   (inode->i_dev = sb->s_dev)
@@ -2506,6 +2506,10 @@
 		LOG_ERROR_ARGS("eek! i_count=%d, i_state=%d, i_ino=%d, no dentry\n",
 			       inode->i_count, inode->i_state, inode->i_ino);
 
+	LOG_ERROR_ARGS("voteoff=%u.%u, feoff=%u.%u, deleted=%u\n", 
+		       HILO(GET_INODE_VOTEOFF(inode)), 
+		       HILO(GET_INODE_FEOFF(inode)),
+		       INODE_DELETED(inode));
 	return -EINVAL;
 }
 

Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c	2004-02-19 01:29:27 UTC (rev 32)
+++ trunk/src/inode.c	2004-02-24 01:27:18 UTC (rev 33)
@@ -665,7 +665,8 @@
 	if (inode_data_is_oin(inode))
 		oin = GET_INODE_OIN(inode);
 
-	/* can we destroy the oin? */
+	/* can we destroy the oin? Uhm, shouldn't this be a test
+	 * against a count of '3'? */
 	if (oin && (atomic_read (&inode->i_count) == 2) && 
 	    (inode->i_ino != OCFS_ROOT_INODE_NUMBER)) {
 		ocfs_extent_map_destroy (&oin->map);

Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c	2004-02-19 01:29:27 UTC (rev 32)
+++ trunk/src/namei.c	2004-02-24 01:27:18 UTC (rev 33)
@@ -124,7 +124,7 @@
 		 * and insert it into the hash. It's not bound yet --
 		 * read_inode2 binds the actual inode to it. */
 		ino = ocfs_inode_hash_insert(osb, inode_off, fe_off);
-#ifdef LINUX_2_5
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 		inode = ocfs_iget (sb, &args);
 #else
 		inode =
@@ -365,13 +365,8 @@
 	fe->gid = current->fsgid;
 	fe->prot_bits = mode & 0007777;
 	if (S_ISCHR (mode) || S_ISBLK (mode)) {
-#ifdef LINUX_2_5
-		fe->dev_major = major (to_kdev_t(dev));
-		fe->dev_minor = minor (to_kdev_t(dev));
-#else
 		fe->dev_major = MAJOR (dev);
 		fe->dev_minor = MINOR (dev);
-#endif
 	} else {
 		fe->dev_major = MAJOR (dir->i_sb->s_dev);
 		fe->dev_minor = MINOR (dir->i_sb->s_dev);
@@ -976,13 +971,13 @@
 	if (oldOIN) {
 		if (oldOIN->open_hndl_cnt != 0) {
 			status = -EBUSY;
-			goto finally;
+			goto bail;
 		}
 		spin_lock(&oin_num_ext_lock);
 		if (oldOIN->num_extends) {
 			spin_unlock(&oin_num_ext_lock);
 			status = -EBUSY;
-			goto finally;
+			goto bail;
 		}
 		spin_unlock(&oin_num_ext_lock);
 	}
@@ -1007,8 +1002,8 @@
 	/* start our transaction */
 	handle = ocfs_start_trans(osb, OCFS_FILE_RENAME_CREDITS);
 	if (handle == NULL) {
-		LOG_ERROR_STATUS(-ENOMEM);
-		goto finally;
+		LOG_ERROR_STATUS(status = -ENOMEM);
+		goto bail;
 	}
 
 	/* for the (possibly two) parent directory locks, we just put
@@ -1256,7 +1251,7 @@
 
 	old_inode->i_nlink++;
 	if (new_inode) {
-		new_dir->i_mtime = new_dir->i_ctime = OCFS_CURRENT_TIME;
+		new_dir->i_mtime = new_dir->i_ctime = CURRENT_TIME;
 		if (S_ISDIR (old_inode->i_mode))
 			new_inode->i_nlink--;
 		new_inode->i_nlink--;
@@ -1266,7 +1261,7 @@
 	}
 	old_inode->i_nlink--;
 	if (S_ISDIR (old_inode->i_mode)) {
-		new_dir->i_mtime = new_dir->i_ctime = OCFS_CURRENT_TIME;
+		new_dir->i_mtime = new_dir->i_ctime = CURRENT_TIME;
 		old_dir->i_nlink--;
 	}
 
@@ -1416,11 +1411,7 @@
 		goto abort_trans;
 	}
 
-#ifdef LINUX_2_5
-	inode->i_rdev = to_kdev_t(OCFS_NODEV);
-#else
 	inode->i_rdev = OCFS_NODEV;
-#endif	
 
 	if (ocfs_inc_icount(inode) < 0)
 		BUG();

Modified: trunk/src/nm.c
===================================================================
--- trunk/src/nm.c	2004-02-19 01:29:27 UTC (rev 32)
+++ trunk/src/nm.c	2004-02-24 01:27:18 UTC (rev 33)
@@ -880,6 +880,7 @@
 						OCFS_SET_FLAG (oin->oin_flags, OCFS_OIN_NEEDS_DELETION);
 						ocfs_up_sem (oin_sem);
 						ocfs_release_lockres (lockres);
+						/* uhm, don't we want a put here?!!?!*/
 						lockres = NULL;
 						oin_sem = NULL;
 						if (needs_trunc) {
@@ -890,7 +891,8 @@
 					spin_unlock(&oin_num_ext_lock);
 				}
 			}
-			if (inode && (flags & FLAG_ACQUIRE_LOCK)) {
+
+			if (inode) {
 				SET_INODE_DELETED(inode);
 				ocfs_inode_hash_remove(&osb->inode_hash, 
 						     GET_INODE_VOTEOFF(inode));
@@ -902,7 +904,11 @@
 					inode->i_nlink = 0;
 					d_prune_aliases (inode);
 					if (oin)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+						sync_mapping_buffers(inode->i_mapping);
+#else
 						fsync_inode_buffers (inode);
+#endif
 				}
 				break;
 			}
@@ -1014,10 +1020,14 @@
 				lockres->master_node_num = node_num;
 
 			if (inode) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+				sync_mapping_buffers(inode->i_mapping);
+#else
 				fsync_inode_buffers(inode);
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,18)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,18)
 				fsync_inode_data_buffers(inode);
 #endif
+#endif
 			}
 			if (oin != NULL) {
 				lockres->lock_type = lockres->lock_state = OCFS_DLM_NO_LOCK;
@@ -1249,10 +1259,14 @@
 		       atomic_read(seq));
 
 	if (sync_buffers) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+		sync_mapping_buffers(inode->i_mapping);
+#else
 		fsync_inode_buffers(inode);
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,18)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,18)
 		fsync_inode_data_buffers(inode);
 #endif
+#endif
 	}
 }
 

Modified: trunk/src/oin.c
===================================================================
--- trunk/src/oin.c	2004-02-19 01:29:27 UTC (rev 32)
+++ trunk/src/oin.c	2004-02-24 01:27:18 UTC (rev 33)
@@ -154,7 +154,7 @@
 			    case OCFS_ATTRIB_FIFO:
 			    case OCFS_ATTRIB_SOCKET:
 			    {
-#ifdef LINUX_2_5
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 				    dev_t dev;
 #else
 				    kdev_t kdev;
@@ -168,14 +168,14 @@
 				    else if (fe->attribs == OCFS_ATTRIB_SOCKET)
 					    inode->i_mode |= S_IFSOCK;
 
-				    inode->i_rdev = NODEV;
-#ifdef LINUX_2_5
+				    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
 
-#ifdef LINUX_2_5
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 				    init_special_inode (inode, inode->i_mode,
 							dev);
 #else

Modified: trunk/src/symlink.c
===================================================================
--- trunk/src/symlink.c	2004-02-19 01:29:27 UTC (rev 32)
+++ trunk/src/symlink.c	2004-02-24 01:27:18 UTC (rev 33)
@@ -154,8 +154,15 @@
 				NULL);
 	if (IS_ERR(page))
 		goto sync_fail;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+	wait_on_page_locked(page);
+	if (!PageUptodate(page))
+
+#else
 	wait_on_page(page);
 	if (!Page_Uptodate(page))
+
+#endif
 		goto async_fail;
 	*ppage = page;
 	return kmap(page);

Modified: trunk/src/util.c
===================================================================
--- trunk/src/util.c	2004-02-19 01:29:27 UTC (rev 32)
+++ trunk/src/util.c	2004-02-24 01:27:18 UTC (rev 33)
@@ -387,12 +387,8 @@
 
 void ocfs_truncate_inode_pages(struct inode *inode, loff_t off)
 {
-#if LINUX_VERSION_CODE <= LinuxVersionCode(2,4,10)
-	LOG_TRACE_ARGS ("NOT truncating pages for inode %p from offset %u.%u\n", inode, off);
-#else
-	LOG_TRACE_ARGS ("truncating pages for inode %p from offset %u.%u\n", inode, off);
+	LOG_TRACE_ARGS ("truncating pages for inode %lu (%p) from offset %u.%u\n", inode->i_ino, inode, off);
 	truncate_inode_pages(&inode->i_data, off);
-#endif
 }				/* ocfs_truncate_inode_pages */
 
 void ocfs_end_buffer_io_sync(struct buffer_head *bh, int uptodate)



More information about the Ocfs2-commits mailing list