[Ocfs2-commits] mfasheh commits r2237 - trunk/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu May 12 21:13:28 CDT 2005


Author: mfasheh
Signed-off-by: manish
Date: 2005-05-12 21:13:26 -0500 (Thu, 12 May 2005)
New Revision: 2237

Modified:
   trunk/fs/ocfs2/localalloc.c
   trunk/fs/ocfs2/ocfs.h
   trunk/fs/ocfs2/proc.c
   trunk/fs/ocfs2/suballoc.c
   trunk/fs/ocfs2/super.c
Log:
* local alloc really wants a tri-state as opposed to "on" or "off". This
  allows us to cleanly detect whether it needs real shutdown on umount.
 
* remove a warning, disabling local alloc with this patch will allow to you 
  cleanly shut it down.   

Signed-off-by: manish



Modified: trunk/fs/ocfs2/localalloc.c
===================================================================
--- trunk/fs/ocfs2/localalloc.c	2005-05-13 01:36:38 UTC (rev 2236)
+++ trunk/fs/ocfs2/localalloc.c	2005-05-13 02:13:26 UTC (rev 2237)
@@ -120,7 +120,7 @@
 
 int ocfs_alloc_should_use_local(ocfs_super *osb, u64 bits)
 {
-	if (osb->have_local_alloc 
+	if ((osb->local_alloc_state == OCFS2_LA_ENABLED)
 	    && (ocfs2_clusters_to_bytes(osb->sb, bits) <= OCFS_LOCAL_ALLOC_MAX_ALLOC)
 	    && (bits <= ocfs_local_alloc_window_bits(osb)))
 		return 1;
@@ -197,7 +197,7 @@
 	}
 
 	osb->local_alloc_bh = alloc_bh;
-	osb->have_local_alloc = 1;
+	osb->local_alloc_state = OCFS2_LA_ENABLED;
 
 bail:
 	if (status < 0)
@@ -244,16 +244,11 @@
 	}
 	oip = OCFS_I(local_alloc_inode);
 
-	/* Take io_sem here to turn off local alloc before another guy
-	 * can come in and start using him. */
-	down(&local_alloc_inode->i_sem);
-	if (!osb->have_local_alloc) {
-		up(&local_alloc_inode->i_sem);
+	if (osb->local_alloc_state == OCFS2_LA_UNUSED)
 		goto bail;
-	}
-	osb->have_local_alloc = 0;
-	up(&local_alloc_inode->i_sem);
 
+	osb->local_alloc_state = OCFS2_LA_DISABLED;
+
 	handle = ocfs_alloc_handle(osb);
 	if (!handle) {
 		status = -ENOMEM;
@@ -311,6 +306,7 @@
 
 	brelse(bh);
 	osb->local_alloc_bh = NULL;
+	osb->local_alloc_state = OCFS2_LA_UNUSED;
 
 	status = ocfs_sync_local_to_main(osb, handle, alloc_copy, 
 					 main_bm_inode, main_bm_bh);
@@ -508,7 +504,7 @@
 	}
 	ocfs_handle_add_inode(passed_handle, local_alloc_inode);
 
-	if (!osb->have_local_alloc) {
+	if (osb->local_alloc_state != OCFS2_LA_ENABLED) {
 		status = -ENOSPC;
 		goto bail;
 	}

Modified: trunk/fs/ocfs2/ocfs.h
===================================================================
--- trunk/fs/ocfs2/ocfs.h	2005-05-13 01:36:38 UTC (rev 2236)
+++ trunk/fs/ocfs2/ocfs.h	2005-05-13 02:13:26 UTC (rev 2237)
@@ -266,6 +266,13 @@
 	atomic_t inode_extends;
 } ocfs_alloc_stats;
 
+enum ocfs2_local_alloc_state
+{
+	OCFS2_LA_UNUSED = 0,
+	OCFS2_LA_ENABLED,
+	OCFS2_LA_DISABLED
+};
+
 struct _ocfs_journal;
 struct _ocfs2_slot_info;
 
@@ -327,7 +334,7 @@
 	atomic_t clean_buffer_seq;
 	spinlock_t clean_buffer_lock;
 
-	int have_local_alloc;
+	enum ocfs2_local_alloc_state local_alloc_state;
 	struct buffer_head *local_alloc_bh;
 
 	/* Next two fields are for local node slot recovery during

Modified: trunk/fs/ocfs2/proc.c
===================================================================
--- trunk/fs/ocfs2/proc.c	2005-05-13 01:36:38 UTC (rev 2236)
+++ trunk/fs/ocfs2/proc.c	2005-05-13 02:13:26 UTC (rev 2237)
@@ -168,8 +168,8 @@
 static int ocfs_proc_alloc_stat(char *page, char **start, off_t off,
 				int count, int *eof, void *data)
 {
-	int len;
-	int ret;
+	int len, ret;
+	char *la_state;
 	ocfs_super *osb = data;
 
 	mlog_entry_void();
@@ -179,8 +179,15 @@
 	len = sprintf(page, "%s\n", "*** Disk Allocation Stats ***");
 
 	len += sprintf(page + len, "\n%s\n", "(Data Allocs)");
-	len += sprintf(page + len, "%-25s %10s\n", "Local Alloc Enabled", 
-		       osb->have_local_alloc ? "yes" : "no");
+
+	if (osb->local_alloc_state == OCFS2_LA_ENABLED)
+		la_state = "enabled";
+	else if (osb->local_alloc_state == OCFS2_LA_DISABLED)
+		la_state = "disabled";
+	else
+		la_state = "unused";
+
+	len += sprintf(page + len, "%-25s %10s\n", "Local Alloc", la_state);
 	len += sprintf(page + len, ALLOC_STATS_HDR, "Window Moves", 
 		       atomic_read(&osb->alloc_stats.moves));
 	len += sprintf(page + len, ALLOC_STATS_HDR, "Local Allocs", 

Modified: trunk/fs/ocfs2/suballoc.c
===================================================================
--- trunk/fs/ocfs2/suballoc.c	2005-05-13 01:36:38 UTC (rev 2236)
+++ trunk/fs/ocfs2/suballoc.c	2005-05-13 02:13:26 UTC (rev 2237)
@@ -563,13 +563,14 @@
 			mlog_errno(status);
 			goto bail;
 		} else if (status == -ENOSPC) {
-#warning "need to deal with disabling local alloc better"
 			/* reserve_local_bits will return enospc with
 			 * the local alloc inode still locked, so we
 			 * can change this safely here. */
-			mlog(ML_NOTICE, "Disabling local alloc\n");
-			osb->have_local_alloc = 0;
-//			ocfs_shutdown_local_alloc(osb);
+			mlog(0, "Disabling local alloc\n");
+			/* We set to OCFS2_LA_DISABLED so that umount
+			 * can clean up what's left of the local
+			 * allocation */
+			osb->local_alloc_state = OCFS2_LA_DISABLED;
 		} 
 	}
 

Modified: trunk/fs/ocfs2/super.c
===================================================================
--- trunk/fs/ocfs2/super.c	2005-05-13 01:36:38 UTC (rev 2236)
+++ trunk/fs/ocfs2/super.c	2005-05-13 02:13:26 UTC (rev 2237)
@@ -1043,7 +1043,7 @@
 	osb->node_num = OCFS_INVALID_NODE_NUM;
 	osb->slot_num = OCFS_INVALID_NODE_NUM;
 
-	osb->have_local_alloc = 0;
+	osb->local_alloc_state = OCFS2_LA_UNUSED;
 	osb->local_alloc_bh = NULL;
 
 	init_waitqueue_head(&osb->osb_mount_event);



More information about the Ocfs2-commits mailing list