[Ocfs2-commits] mfasheh commits r1554 - trunk/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Oct 7 16:08:31 CDT 2004


Author: mfasheh
Date: 2004-10-07 16:08:30 -0500 (Thu, 07 Oct 2004)
New Revision: 1554

Modified:
   trunk/src/alloc.c
   trunk/src/alloc.h
   trunk/src/journal.c
   trunk/src/ocfs.h
   trunk/src/ocfs_journal.h
Log:
* get rid of the bitmap_free_head stuff... yay!

* fix up ocfs_wait_on_mount to return sane error codes

* have recover_node use wait_on_mount again



Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c	2004-10-07 21:07:16 UTC (rev 1553)
+++ trunk/src/alloc.c	2004-10-07 21:08:30 UTC (rev 1554)
@@ -79,8 +79,6 @@
 				 struct inode *inode,
 				 ocfs2_alloc_context *meta_ac);
 
-static int ocfs_free_disk_bitmap (ocfs_super * osb, ocfs_free_rec *free_log);
-
 static int ocfs_extent_contig(struct inode *inode, ocfs2_extent_rec *ext,
 			      u64 blkno);
 
@@ -90,6 +88,7 @@
 				       u32 min_bits,
 				       u32 *bit_off,
 				       u32 *num_bits);
+
 static int ocfs_free_clusters(ocfs_super *osb,
 			      ocfs_journal_handle *handle,
 			      struct inode *bitmap_inode,
@@ -121,336 +120,6 @@
 	return (start_blkno == blkno);
 }
 
-int ocfs_process_bitmap_free_head(ocfs_super *osb, ocfs_bitmap_free_head *f) 
-{
-	struct list_head *p, *n;
-	ocfs_free_rec *log;
-	int status = 0, tmpstat;
-
-	LOG_ENTRY_ARGS("(osb=0x%p, f=0x%p, f->num_logs = %d)\n", osb, f,
-		       f->num_logs);
-
-	list_for_each_safe(p, n, &(f->free_logs)) {
-		LOG_TRACE_ARGS("f->num_logs = %d\n", f->num_logs);
-		log = list_entry(p, ocfs_free_rec, log_list);
-		tmpstat = ocfs_free_disk_bitmap(osb, log);
-		if (tmpstat)
-			status = tmpstat;
-		list_del(&(log->log_list));
-		kfree(log);
-		f->num_logs--;
-	}
-
-	LOG_EXIT_STATUS(status);
-	return(status);
-}
-
-int ocfs_add_to_bitmap_free_head(ocfs_super *osb,
-				 ocfs_bitmap_free_head *f, 
-				 u32 len, u32 fileoff,
-				 u32 nodenum, u64 blkno, u32 type)
-{
-	int status = 0, n;
-	ocfs_free_rec *log;
-	ocfs_bitmap_update *fb;
-
-	LOG_ENTRY_ARGS("(len = %u, fileoff = %u, nodenum = %u, blk = %llu" 
-		       "type=%d (\"%s\")\n", len, fileoff, nodenum,
-		       blkno, type, 
-		       (type == DISK_ALLOC_VOLUME) ? "DISK_ALLOC_VOLUME" : 
-		       "DISK_ALLOC_EXTENT_NODE");
-
-	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" : 
-		       "DISK_ALLOC_EXTENT_NODE");
-		BUG();
-	}
-
-	/* right now we don't support this. */
-	if ((type == DISK_ALLOC_EXTENT_NODE) && (nodenum != 0))
-		BUG();
-
-	log = f->tail;
-
-	/* need a new one? */
-	if (list_empty(&(f->free_logs)) || 
-	    log->num_updates >= FREE_LOG_SIZE) {
-		LOG_TRACE_STR("Adding a new list entry.");
-		log = ocfs_malloc(sizeof(ocfs_free_rec));
-		if (log == NULL) {
-			LOG_ERROR_STATUS(status = -ENOMEM);
-			goto done;
-		}
-		memset(log, 0, sizeof(ocfs_free_rec));
-		INIT_LIST_HEAD(&(log->log_list));
-		list_add_tail(&(log->log_list), &(f->free_logs));
-		f->tail = log;
-		f->num_logs++;
-	}
-
-	n = log->num_updates;
-	fb = &(log->update[n]);
-
-	fb->length   = len; 
-	fb->file_off = fileoff; 
-	fb->type     = type; 
-	fb->node_num = nodenum; 
-	fb->blkno    = blkno; 
-
-	log->num_updates++;
-done:
-	LOG_EXIT_STATUS(status);
-	return(status);
-}
-
-static inline void ocfs_copy_update(ocfs_free_rec *rec,
-				    ocfs_bitmap_update *fb2)
-{
-	int idx = rec->num_updates;
-	ocfs_bitmap_update *fb1 = &(rec->update[idx]);
-
-	fb1->length   = fb2->length;
-	fb1->file_off = fb2->file_off;
-	fb1->type     = fb2->type;
-	fb1->node_num = fb2->node_num;
-	fb1->blkno = fb2->blkno;
-	rec->num_updates++;
-	return;
-}
-
-static inline int ocfs_free_main_bitmap(ocfs_super *osb, 
-					ocfs_journal_handle *handle, 
-					struct inode *bitmap_inode,
-					struct buffer_head *bh,
-					ocfs_free_rec *freelog) 
-{
-	int i;
-	ocfs_alloc_bm *bitmap;
-	int status;
-	__u32 bitmapblocks; /* we only care about the valid blocks */
-	ocfs2_dinode *bm_lock;
-
-	LOG_ENTRY();
-
-	bitmap = &osb->cluster_bitmap;
-
-	bitmapblocks = ocfs_blocks_for_bits(osb->sb, bitmap->validbits);
-
-	status = ocfs_read_blocks(osb, osb->bitmap_blkno, bitmapblocks, 
-				  bitmap->chunk, OCFS_BH_CACHED, bitmap_inode);
-	if (status < 0) {
-		LOG_ERROR_STATUS(status);
-		goto bail;
-	}
-
-	status = ocfs_journal_access(handle, bh, 
-				     OCFS_JOURNAL_ACCESS_WRITE);
-	if (status < 0) {
-		LOG_ERROR_STATUS(status);
-		goto bail;
-	}
-	bm_lock = (ocfs2_dinode *) bh->b_data;
-
-	for (i = 0; i < freelog->num_updates; i++) {
-		ocfs_clear_bits(osb->sb, handle, bitmap,
-				freelog->update[i].file_off,
-				freelog->update[i].length);
-		bm_lock->id1.bitmap1.i_used -= freelog->update[i].length;
-	}
-
-	status = ocfs_journal_dirty(handle, bh);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto bail;
-	}
-
-	status = 0;
-bail:
-	LOG_EXIT_STATUS(status);
-	return(0);
-}
-
-/*
- * ocfs_free_disk_bitmap()
- *
- */
-static int ocfs_free_disk_bitmap (ocfs_super * osb, ocfs_free_rec *free_log)
-{
-	int status = 0;
-	int i;
-	ocfs_free_rec *ext_alloc_free = NULL;
-	ocfs_free_rec *vol_alloc_free = NULL;
-	struct inode *ext_alloc_inode = NULL;
-	struct inode *vol_inode = NULL;
-	struct buffer_head *vol_alloc_bh = NULL;
-	struct buffer_head *ext_alloc_bh = NULL;
-	ocfs_journal_handle *handle = NULL;
-	int credits = 0; /* sysfile fe's. */
-	ocfs_bitmap_update *tmp;
-
-	LOG_ENTRY_ARGS ("(0x%p, 0x%p)\n", osb, free_log);
-
-	for (i = 0; i < free_log->num_updates; i++) {
-//		OCFS_ASSERT(
-//			(free_log->update[i].type == DISK_ALLOC_EXTENT_NODE)
-//			|| (free_log->update[i].type == DISK_ALLOC_VOLUME));
-		if ((free_log->update[i].type != DISK_ALLOC_EXTENT_NODE)
-		    && (free_log->update[i].type != DISK_ALLOC_VOLUME)) {
-			printk("num_updates = %u, i=%d\n", 
-			       free_log->num_updates, i);
-			printk("length:   %llu\n", free_log->update[i].length);
-			printk("file_off: %llu\n",
-			       free_log->update[i].file_off);
-			printk("type:     %u\n", free_log->update[i].type);
-			printk("node_num: %d\n", free_log->update[i].node_num);
-			printk("blkno:    %llu\n", free_log->update[i].blkno);
-			BUG();
-		}
-
-
-		if (free_log->update[i].type == DISK_ALLOC_EXTENT_NODE) {
-			if (!ext_alloc_free) {
-				ext_alloc_free = 
-					ocfs_malloc(sizeof(ocfs_free_rec));
-				if (!ext_alloc_free) {
-					LOG_ERROR_STATUS(status = -ENOMEM);
-					goto finally;
-				}
-				ext_alloc_free->num_updates = 0;
-				credits++; /* for the fe updates */
-			}
-			credits++;
-			ocfs_copy_update(ext_alloc_free, 
-					 &(free_log->update[i]));
-		} else {
-			if (vol_alloc_free == NULL) {
-				vol_alloc_free =
-					ocfs_malloc (sizeof (ocfs_free_rec));
-				if (vol_alloc_free == NULL) {
-					LOG_ERROR_STATUS (status = -ENOMEM);
-					goto finally;
-				}
-				vol_alloc_free->num_updates = 0;
-				credits++; /* for the fe updates */
-			}
-			credits += ocfs_blocks_for_bits(osb->sb,
-							free_log->update[i].length);
-			ocfs_copy_update(vol_alloc_free, 
-					 &(free_log->update[i]));
-		}
-	}
-
-	handle = ocfs_alloc_handle(osb);
-	if (!handle) {
-		status = -ENOMEM;
-		LOG_ERROR_STATUS(status);
-		goto finally;
-	}
-
-	if (ext_alloc_free) {
-		ext_alloc_inode = 
-			ocfs_get_system_file_inode(osb, 
-						   EXTENT_ALLOC_SYSTEM_INODE, 
-						   0);
-		if (!ext_alloc_inode) {
-			status = -EINVAL;
-			LOG_ERROR_STATUS (status);
-			goto finally;
-		}
-
-		status = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE, 0,
-					    &ext_alloc_bh, ext_alloc_inode);
-		if (status < 0) {
-			if (status != -EINTR)
-				LOG_ERROR_STATUS (status);
-			goto finally;
-		}
-		ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0, 
-				     ext_alloc_inode);
-		ocfs_handle_add_inode(handle, ext_alloc_inode);
-	}
-
-	if (vol_alloc_free) {
-		vol_inode = 
-			ocfs_get_system_file_inode(osb, 
-						   GLOBAL_BITMAP_SYSTEM_INODE, 
-						   -1);
-		if (!vol_inode) {
-			status = -EINVAL;
-			LOG_ERROR_STATUS (status);
-			goto finally;
-		}
-
-		status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0,
-					   &vol_alloc_bh, vol_inode);
-		if (status < 0) {
-			iput(vol_inode);
-			vol_inode = NULL;
-
-			if (status != -EINTR)
-				LOG_ERROR_STATUS (status);
-			goto finally;
-		}
-		ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
-				     0, vol_inode);
-		ocfs_handle_add_inode(handle, vol_inode);
-	}
-
-	handle = ocfs_start_trans(osb, handle, credits);
-	if (!handle) {
-		status = -ENOMEM;
-		LOG_ERROR_STATUS(status);
-		goto finally;
-	}
-	ocfs_handle_set_always_commits(handle, 1);
-
-	if (vol_alloc_free)
-		ocfs_free_main_bitmap(osb, handle, vol_inode, 
-				      vol_alloc_bh, vol_alloc_free);
-
-	if (ext_alloc_free)
-		for (i = 0; i < ext_alloc_free->num_updates; i++) {
-			tmp = &(ext_alloc_free->update[i]);
-			status = ocfs_free_suballoc_bits(osb,
-							 handle,
-							 ext_alloc_inode,
-							 ext_alloc_bh,
-							 (unsigned int) 
-							 tmp->file_off,
-							 tmp->blkno,
-							 1);
-			if (status < 0) {
-				LOG_ERROR_STATUS (status);
-				goto finally;
-			}
-		}
-
-finally:
-	if (handle)
-		ocfs_commit_trans(handle);
-
-	if (ext_alloc_inode)
-		iput(ext_alloc_inode);
-	if (vol_inode)
-		iput(vol_inode);
-
-	if (vol_alloc_bh)
-		brelse(vol_alloc_bh);
-	if (ext_alloc_bh)
-		brelse(ext_alloc_bh);
-
-	if (ext_alloc_free)
-		kfree(ext_alloc_free);
-	if (vol_alloc_free)
-		kfree(vol_alloc_free);
-
-	LOG_EXIT_STATUS (status);
-	return status;
-}				/* ocfs_free_disk_bitmap */
-
 static int ocfs_free_clusters(ocfs_super *osb,
 			      ocfs_journal_handle *handle,
 			      struct inode *bitmap_inode,

Modified: trunk/src/alloc.h
===================================================================
--- trunk/src/alloc.h	2004-10-07 21:07:16 UTC (rev 1553)
+++ trunk/src/alloc.h	2004-10-07 21:08:30 UTC (rev 1554)
@@ -29,10 +29,6 @@
 #ifndef OCFS2_ALLOC_H
 #define OCFS2_ALLOC_H
 
-int ocfs_add_to_bitmap_free_head(ocfs_super *osb,
-				 ocfs_bitmap_free_head *f, 
-				 u32 len, u32 fileoff,
-				 u32 nodenum, u64 blkno, u32 type);
 struct _ocfs2_alloc_context;
 int ocfs_allocate_extent(ocfs_super *osb, struct buffer_head *fe_bh,
 			 ocfs_journal_handle *handle,
@@ -46,18 +42,12 @@
 int ocfs_get_leaf_extent(ocfs_super *osb, ocfs2_dinode *fe,
 			 __s64 Vbo, struct buffer_head **data_extent_bh,
 			 struct inode *inode);
-int ocfs_load_local_alloc(ocfs_super *osb);
+
 int ocfs_lookup_file_allocation(ocfs_super *osb, __s64 Vbo,
 				__s64 *Lbo, __u32 blocks,
 				__s64 *contig_bytes,
 				struct inode *inode,
 				int locked);
-int ocfs_process_bitmap_free_head(ocfs_super *osb,
-				  ocfs_bitmap_free_head *f);
-int ocfs_recover_local_alloc(ocfs_super *osb, 
-			     int node_num, 
-			     ocfs_bitmap_free_head **bits_to_free);
-void ocfs_shutdown_local_alloc(ocfs_super *osb);
 
 typedef struct _ocfs2_alloc_context {
 	struct inode *ac_inode;    /* which bitmap are we allocating from? */

Modified: trunk/src/journal.c
===================================================================
--- trunk/src/journal.c	2004-10-07 21:07:16 UTC (rev 1553)
+++ trunk/src/journal.c	2004-10-07 21:08:30 UTC (rev 1554)
@@ -399,7 +399,6 @@
 	retval->num_buffs = 0;
 	retval->num_locks = 0;
 	retval->num_co = 0;
-	retval->commit_bits = NULL;
 	retval->buffs = NULL;
 	retval->co_buffs = NULL;
 	retval->k_handle = NULL;
@@ -555,7 +554,6 @@
 	LOG_ENTRY();
 
 	OCFS_ASSERT(!(handle->flags & OCFS_HANDLE_STARTED));
-	OCFS_ASSERT(!handle->commit_bits);
 	OCFS_ASSERT(!handle->num_co);
 	OCFS_ASSERT(!handle->num_buffs);
 
@@ -583,7 +581,6 @@
 	transaction_t *kern_trans;
 	int retval, i, sync;
 	ocfs_journal *journal;
-	ocfs_bitmap_free_head *commit_head;
 	LOG_ENTRY();
 
 	OCFS_ASSERT(handle);
@@ -643,15 +640,8 @@
 	/* At this point, we don't need the copyout buffers. */
 	ocfs_handle_free_all_copyout(handle);
 
-	commit_head = handle->commit_bits;
-	handle->commit_bits = NULL;
-
 /* done: */
 
-	if (commit_head && (retval == 0))
-		ocfs_process_bitmap_free_head(osb, commit_head);
-	ocfs_free_bitmap_free_head(commit_head);
-
 	kfree(handle);
 
 bail:
@@ -780,9 +770,6 @@
 	for(i = 0; i < handle->num_buffs; i++)
 		brelse(handle->buffs[i]);
 
-	/* Should only be processed in commit. */
-	ocfs_free_bitmap_free_head(handle->commit_bits);
-
 	if (handle->buffs)
 		kfree(handle->buffs);
 	kfree(handle);
@@ -1574,7 +1561,6 @@
 	ocfs_journal * journal = NULL;
 	int recovery_lock = 0, got_lock = 0, clean_orphans = 0;
 	__u64 alloc_size;
-	ocfs_bitmap_free_head *bits_to_free = NULL;
 
 	LOG_ENTRY_ARGS("(node_num=%d, osb->node_num = %d)\n", node_num,
 		       osb->node_num);
@@ -1584,6 +1570,12 @@
 		goto done;
 	}
 
+	status = ocfs_wait_on_mount(osb);
+	if (status < 0) {
+		if (status == -EBUSY)
+			status = 0;
+		goto done;
+	}
 	journal = osb->journal;
 
 	/* Grab the local recovery resource to ensure no other thread
@@ -1736,15 +1728,6 @@
 			LOG_ERROR_STATUS(tmpstat);
 	}
 
-	/* Free bits from the bitmaps only after the node has been
-	 * removed from the recovery map. */
-	if (bits_to_free) {
-		if (!status && !ocfs_wait_on_mount(osb))
-			ocfs_process_bitmap_free_head(osb, bits_to_free);
-
-		ocfs_free_bitmap_free_head(bits_to_free);
-	}
-
 	atomic_dec(&osb->num_recovery_threads);
 
 	LOG_EXIT_STATUS(status);
@@ -1891,7 +1874,7 @@
 	 * dismount_volume() so we can trust it. */
 	if (atomic_read(&osb->vol_state) == VOLUME_DISABLED) {
 		LOG_TRACE_STR("mount error, exiting!");
-		return -EFAIL;
+		return -EBUSY;
 	}
 
 	LOG_TRACE_ARGS("vol_state = %d, waiting!\n", 

Modified: trunk/src/ocfs.h
===================================================================
--- trunk/src/ocfs.h	2004-10-07 21:07:16 UTC (rev 1553)
+++ trunk/src/ocfs.h	2004-10-07 21:08:30 UTC (rev 1554)
@@ -495,8 +495,6 @@
 }
 ocfs_vol_node_map;
 
-struct _ocfs_bitmap_free_head;
-
 typedef struct _ocfs_commit_task
 {
 	struct completion c_complete;
@@ -821,41 +819,6 @@
 	ocfs_dlm_reply_master *reply;
 } ocfs_vote_reply_ctxt;
 
-
-/* these three used as 'type' in ocfs_bitmap_update */
-#define  DISK_ALLOC_EXTENT_NODE   2
-#define  DISK_ALLOC_VOLUME        3
-
-/* a bitmap update, currently used for freeing bits */
-typedef struct ocfs_bitmap_update
-{
-	u64 length;
-	u64 file_off;
-	u32 type;
-	s16 node_num;
-	u64 blkno;
-}
-ocfs_bitmap_update;
-
-#define  FREE_LOG_SIZE            150
-
-typedef struct _ocfs_free_rec
-{
-	__u32 num_updates;
-	struct list_head log_list;
-	ocfs_bitmap_update update[FREE_LOG_SIZE];
-} 
-ocfs_free_rec;
-
-typedef struct _ocfs_bitmap_free_head
-{
-	__u32 num_logs;
-	struct _ocfs_free_rec *tail;
-	struct list_head free_logs;
-} 
-ocfs_bitmap_free_head;
-
-
 struct ocfs_ioc
 {
 	char name[255];		/* "OCFS" */
@@ -978,34 +941,6 @@
 	return (unsigned long)(blkno & (u64)ULONG_MAX);
 }
 
-static inline ocfs_bitmap_free_head * ocfs_alloc_bitmap_free_head(void)
-{
-	struct _ocfs_bitmap_free_head *f;
-
-	f = ocfs_malloc(sizeof(ocfs_bitmap_free_head));
-	if (f) {
-		f->num_logs = 0;
-		f->tail = NULL;
-		INIT_LIST_HEAD(&(f->free_logs));
-	}
-	return(f);
-}
-
-static inline void ocfs_free_bitmap_free_head(ocfs_bitmap_free_head *f)
-{
-	ocfs_free_rec *log;
-	struct list_head *p, *n;
-
-	if (f && (f->num_logs)) {
-		list_for_each_safe(p, n, &(f->free_logs)) {
-			log = list_entry(p, ocfs_free_rec, log_list);
-			list_del(&(log->log_list));
-			kfree(log);
-		}
-		kfree(f);
-	}
-}
-
 static inline int ocfs_inc_icount(struct inode *inode)
 {
 	if (atomic_read(&inode->i_count) >= 1 &&

Modified: trunk/src/ocfs_journal.h
===================================================================
--- trunk/src/ocfs_journal.h	2004-10-07 21:07:16 UTC (rev 1553)
+++ trunk/src/ocfs_journal.h	2004-10-07 21:08:30 UTC (rev 1554)
@@ -207,10 +207,6 @@
 					 * original copy back into the
 					 * buffer. */
 
-	struct _ocfs_bitmap_free_head *commit_bits; /* bits to be
-						     * freed ONLY if
-						     * we commit the
-						     * handle. */
 	struct list_head     inode_list;
 };
 
@@ -256,26 +252,7 @@
 		handle->flags &= ~OCFS_HANDLE_ALWAYS_COMMITS;
 }
 
-static inline int ocfs_handle_add_commit_bits(ocfs_journal_handle *handle,
-					      u32 len, u32 fileoff,
-					      u32 nodenum, u64 blkno,
-					      u32 type)
-{
-	int ret = 0;
-	if (!handle->commit_bits)
-		handle->commit_bits = ocfs_alloc_bitmap_free_head();
 
-	if (!handle->commit_bits)
-		ret = -ENOMEM;
-	else
-		ret = ocfs_add_to_bitmap_free_head(handle->osb,
-						   handle->commit_bits,
-						   len, fileoff,
-						   nodenum, blkno, type);
-	return ret;
-}
-
-
 /*
  *  Journal Control:
  *  Initialize, Load, Shutdown, Wipe, Create a journal.



More information about the Ocfs2-commits mailing list