[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ocfs2-commits
Subject:    [Ocfs2-commits] mfasheh commits r879 - in trunk/src: . inc
From:       svn-commits () oss ! oracle ! com (svn-commits () oss ! oracle ! com)
Date:       2004-04-28 17:32:40
Message-ID: 200404282232.i3SMWcP2019951 () oss ! oracle ! com
[Download RAW message or body]

Author: mfasheh
Date: 2004-04-28 17:32:37 -0500 (Wed, 28 Apr 2004)
New Revision: 879

Modified:
   trunk/src/alloc.c
   trunk/src/dir.c
   trunk/src/file.c
   trunk/src/inc/ocfs.h
   trunk/src/namei.c
   trunk/src/osb.c
   trunk/src/sysfile.c
Log:
* replace file_alloc_lock and dir_alloc_lock (both ocfs_sem's) with a struct 
  semaphore -- node_alloc_sem

* Clean up ocfs_free_vol_block to only take the semaphores it needs, and for 
  a shorter amount of time.



Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c	2004-04-28 22:28:38 UTC (rev 878)
+++ trunk/src/alloc.c	2004-04-28 22:32:37 UTC (rev 879)
@@ -539,13 +539,10 @@
 	ocfs_alloc_bm *tmpbitmap = NULL;
 	__u32 i;
 	bool needs_uninit = false;
+	bool needs_unlock = false;
 
 	LOG_ENTRY ();
 
-	ocfs_down_sem (&(osb->dir_alloc_lock), true);
-	ocfs_down_sem (&(osb->file_alloc_lock), true);
-	ocfs_down_sem (&(osb->vol_alloc_lock), true);
-
 	LOG_TRACE_ARGS("Free Log Details (type = %d):\n", Type);
 	LOG_TRACE_ARGS("num_updates = %u\n", FreeLog->num_updates);
 	for(i = 0; i < FreeLog->num_updates; i++)
@@ -580,13 +577,18 @@
 	}
 
 	if (Type == DISK_ALLOC_VOLUME) {
+		ocfs_down_sem (&(osb->vol_alloc_lock), true);
+		needs_unlock = true;
+
 		/* don't need to read it here as
 		 * ocfs_free_main_bitmap handles that for us. */
 		tmpbitmap = &osb->cluster_bitmap;
 	} else {
-		/* Read in the bitmap file for the dir alloc and look for the */
-		/* required space, if found */
+		down(&(osb->node_alloc_sem));
+		needs_unlock = true;
 
+		/* Read in the bitmap file for the dir alloc and look
+		   for the required space, if found */
 		status = ocfs_get_system_file_size (osb, fileId, &fileSize, &allocSize);
 		if (status < 0) {
 			LOG_ERROR_STATUS (status);
@@ -650,9 +652,12 @@
 		}
 	}
 leave:
-	ocfs_up_sem (&(osb->vol_alloc_lock));
-	ocfs_up_sem (&(osb->file_alloc_lock));
-	ocfs_up_sem (&(osb->dir_alloc_lock));
+	if (needs_unlock) {
+		if (Type == DISK_ALLOC_VOLUME)
+			ocfs_up_sem (&(osb->vol_alloc_lock));
+		else
+			up (&(osb->node_alloc_sem));
+	}
 
 	if (needs_uninit)
 		ocfs_uninitialize_bitmap(tmpbitmap);
@@ -1203,6 +1208,7 @@
 /*
  * ocfs_allocate_extent()
  *
+ * You need to be holding node_alloc_sem!
  */
 int ocfs_allocate_extent (ocfs_super * osb, struct buffer_head *fe_bh, \
ocfs_journal_handle *handle, __u64 actualDiskOffset, __u64 actualLength, struct inode \
*inode)  {
@@ -2952,6 +2958,7 @@
 /*
  * ocfs_alloc_node_block()
  *
+ * You need to be holding node_alloc_sem!
  */
 int ocfs_alloc_node_block (ocfs_super * osb, __u64 FileSize, __u64 * DiskOffset, \
__u64 * file_off, __u32 NodeNum, __u32 Type, ocfs_journal_handle *handle)  {
@@ -2983,8 +2990,6 @@
 
 	LOG_ENTRY_ARGS("(FileSize = (%llu), Type=%d)\n", FileSize,Type);
 
-	ocfs_down_sem (&(osb->dir_alloc_lock), true);
-	ocfs_down_sem (&(osb->file_alloc_lock), true);
 	ocfs_down_sem (&(osb->vol_alloc_lock), true);
 
 	if (Type == DISK_ALLOC_DIR_NODE) {
@@ -3166,8 +3171,6 @@
 leave:
 	
         ocfs_up_sem (&(osb->vol_alloc_lock));
-	ocfs_up_sem (&(osb->file_alloc_lock));
-	ocfs_up_sem (&(osb->dir_alloc_lock));
 
 	if (needs_uninit)
 		ocfs_uninitialize_bitmap(&bitmap);

Modified: trunk/src/dir.c
===================================================================
--- trunk/src/dir.c	2004-04-28 22:28:38 UTC (rev 878)
+++ trunk/src/dir.c	2004-04-28 22:32:37 UTC (rev 879)
@@ -1236,11 +1236,13 @@
 
 			LOG_TRACE_ARGS("ocfs_insert_file: CASE 2B\n");
 
+			down(&osb->node_alloc_sem);
 			status = ocfs_alloc_node_block(osb, 
 						osb->vol_layout.dir_node_size,
 						&bitmapOffset, &fileOffset, 
 						osb->node_num,
 						DISK_ALLOC_DIR_NODE, handle);
+			up(&osb->node_alloc_sem);
 			if (status < 0) {
 				ocfs_safefree(newbhs);
 				LOG_ERROR_STATUS (status);

Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c	2004-04-28 22:28:38 UTC (rev 878)
+++ trunk/src/file.c	2004-04-28 22:32:37 UTC (rev 879)
@@ -1106,8 +1106,10 @@
 			}
 		}
 
+		down (&osb->node_alloc_sem);
 		status = ocfs_allocate_extent (osb, bh, handle,
 					actualDiskOffset, actualLength, inode);
+		up (&osb->node_alloc_sem);
 		if (status < 0) {
 			OCFS_BH_PUT_DATA(bh);
 			LOG_ERROR_STATUS (status);

Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h	2004-04-28 22:28:38 UTC (rev 878)
+++ trunk/src/inc/ocfs.h	2004-04-28 22:32:37 UTC (rev 879)
@@ -1943,8 +1943,7 @@
 	__u32 recovery_map;
 	bool disable_recovery;
 	atomic_t num_recovery_threads;
-	ocfs_sem dir_alloc_lock;
-	ocfs_sem file_alloc_lock;
+	struct semaphore node_alloc_sem;
 	ocfs_sem vol_alloc_lock;
 	struct timer_list lock_timer;
 	atomic_t lock_stop;

Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c	2004-04-28 22:28:38 UTC (rev 878)
+++ trunk/src/namei.c	2004-04-28 22:32:37 UTC (rev 879)
@@ -378,7 +378,9 @@
 		memset(dirbhs, 0, bufsize);
 
 		/* allocate directory space and setup pointers */
+		down(&osb->node_alloc_sem);
 		status = ocfs_alloc_node_block (osb, osb->vol_layout.dir_node_size, &bitmapOffset, \
&fileOffset, osb->node_num, DISK_ALLOC_DIR_NODE, handle); \
+		up(&osb->node_alloc_sem);  if (status < 0) {
 			ocfs_safefree (dirbhs);
 			OCFS_BH_PUT_DATA(lock_bh);

Modified: trunk/src/osb.c
===================================================================
--- trunk/src/osb.c	2004-04-28 22:28:38 UTC (rev 878)
+++ trunk/src/osb.c	2004-04-28 22:32:37 UTC (rev 879)
@@ -73,9 +73,6 @@
 		goto bail;
 	}
 
-
-	ocfs_init_sem (&(osb->dir_alloc_lock));
-	ocfs_init_sem (&(osb->file_alloc_lock));
 	ocfs_init_sem (&(osb->vol_alloc_lock));
 
 	init_MUTEX (&(osb->osb_res));
@@ -85,6 +82,7 @@
 	init_MUTEX (&(osb->extend_sem));
 	init_MUTEX (&(osb->cfg_lock));
 	init_MUTEX (&(osb->vote_sem));
+	init_MUTEX (&(osb->node_alloc_sem));
 
 	spin_lock_init(&osb->recovery_map_lock);
 	osb->recovery_map = 0;

Modified: trunk/src/sysfile.c
===================================================================
--- trunk/src/sysfile.c	2004-04-28 22:28:38 UTC (rev 878)
+++ trunk/src/sysfile.c	2004-04-28 22:32:37 UTC (rev 879)
@@ -250,6 +250,8 @@
  * fe_bh can be null and we'll just read it off disk.
  * of course, if you've already read it off disk, then give us fe_bh to avoid
  * an extra read. We always do the write out of the new fe.
+ *
+ * You need to be holding node_alloc_sem!
  */
 int ocfs_extend_system_file (ocfs_super * osb, __u32 FileId, __u64 FileSize, struct \
buffer_head *fe_bh, ocfs_journal_handle *handle, bool zero)  {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic