[Ocfs2-commits] smushran commits r3029 - branches/ocfs2-1.2/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Jun 18 16:55:43 PDT 2007


Author: smushran
Date: 2007-06-18 16:55:41 -0700 (Mon, 18 Jun 2007)
New Revision: 3029

Modified:
   branches/ocfs2-1.2/fs/ocfs2/ocfs2.h
   branches/ocfs2-1.2/fs/ocfs2/slot_map.c
   branches/ocfs2-1.2/fs/ocfs2/super.c
Log:
ocfs2: Adds preferred slot# mount option

ocfs2 will attempt to assign the node the slot# provided in the mount option.
Failure to assign the preferred slot is not an error. This feature is being
added inorder to run automated tests to test the _remove slot_ tunefs.ocfs2
functionality.

Signed-off-by: mfasheh
Signed-off-by: taoma

Modified: branches/ocfs2-1.2/fs/ocfs2/ocfs2.h
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/ocfs2.h	2007-06-11 21:25:34 UTC (rev 3028)
+++ branches/ocfs2-1.2/fs/ocfs2/ocfs2.h	2007-06-18 23:55:41 UTC (rev 3029)
@@ -236,6 +236,7 @@
 	u16 num_nodes;
 	s16 node_num;
 	s16 slot_num;
+	s16 preferred_slot;
 	int s_sectsize_bits;
 	int s_clustersize;
 	int s_clustersize_bits;

Modified: branches/ocfs2-1.2/fs/ocfs2/slot_map.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/slot_map.c	2007-06-11 21:25:34 UTC (rev 3028)
+++ branches/ocfs2-1.2/fs/ocfs2/slot_map.c	2007-06-18 23:55:41 UTC (rev 3029)
@@ -122,17 +122,25 @@
 	return ret;
 }
 
-static s16 __ocfs2_find_empty_slot(struct ocfs2_slot_info *si)
+static s16 __ocfs2_find_empty_slot(struct ocfs2_slot_info *si, s16 preferred)
 {
 	int i;
 	s16 ret = OCFS2_INVALID_SLOT;
 
+	if (preferred >= 0 && preferred < si->si_num_slots) {
+		if (OCFS2_INVALID_SLOT == si->si_global_node_nums[preferred]) {
+			ret = preferred;
+			goto out;
+		}
+	}
+
 	for(i = 0; i < si->si_num_slots; i++) {
 		if (OCFS2_INVALID_SLOT == si->si_global_node_nums[i]) {
 			ret = (s16) i;
 			break;
 		}
 	}
+out:
 	return ret;
 }
 
@@ -249,7 +257,7 @@
 	if (slot == OCFS2_INVALID_SLOT) {
 		/* if no slot yet, then just take 1st available
 		 * one. */
-		slot = __ocfs2_find_empty_slot(si);
+		slot = __ocfs2_find_empty_slot(si, osb->preferred_slot);
 		if (slot == OCFS2_INVALID_SLOT) {
 			spin_unlock(&si->si_lock);
 			mlog(ML_ERROR, "no free slots available!\n");

Modified: branches/ocfs2-1.2/fs/ocfs2/super.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/super.c	2007-06-11 21:25:34 UTC (rev 3028)
+++ branches/ocfs2-1.2/fs/ocfs2/super.c	2007-06-18 23:55:41 UTC (rev 3029)
@@ -93,7 +93,8 @@
 MODULE_LICENSE("GPL");
 
 static int ocfs2_parse_options(struct super_block *sb, char *options,
-			       unsigned long *mount_opt, int is_remount);
+			       unsigned long *mount_opt, s16 *slot,
+			       int is_remount);
 static void ocfs2_put_super(struct super_block *sb);
 static int ocfs2_mount_volume(struct super_block *sb);
 static int ocfs2_remount(struct super_block *sb, int *flags, char *data);
@@ -159,6 +160,7 @@
 	Opt_nointr,
 	Opt_hb_none,
 	Opt_hb_local,
+	Opt_slot,
 	Opt_err,
 };
 
@@ -173,6 +175,7 @@
 	{Opt_nointr, "nointr"},
 	{Opt_hb_none, OCFS2_HB_NONE},
 	{Opt_hb_local, OCFS2_HB_LOCAL},
+	{Opt_slot, "preferred_slot=%u"},
 	{Opt_err, NULL}
 };
 
@@ -374,9 +377,10 @@
 	int incompat_features;
 	int ret = 0;
 	unsigned long parsed_options;
+	s16 slot;
 	struct ocfs2_super *osb = OCFS2_SB(sb);
 
-	if (!ocfs2_parse_options(sb, data, &parsed_options, 1)) {
+	if (!ocfs2_parse_options(sb, data, &parsed_options, &slot, 1)) {
 		ret = -EINVAL;
 		goto out;
 	}
@@ -518,6 +522,7 @@
 	struct dentry *root;
 	int status, sector_size;
 	unsigned long parsed_opt;
+	s16 slot;
 	struct inode *inode = NULL;
 	struct ocfs2_super *osb = NULL;
 	struct buffer_head *bh = NULL;
@@ -547,11 +552,12 @@
 	brelse(bh);
 	bh = NULL;
 
-	if (!ocfs2_parse_options(sb, data, &parsed_opt, 0)) {
+	if (!ocfs2_parse_options(sb, data, &parsed_opt, &slot, 0)) {
 		status = -EINVAL;
 		goto read_super_error;
 	}
 	osb->s_mount_opt = parsed_opt;
+	osb->preferred_slot = slot;
 
 #ifdef OCFS2_ORACORE_WORKAROUNDS
 	if (osb->s_mount_opt & OCFS2_MOUNT_COMPAT_OCFS)
@@ -705,6 +711,7 @@
 static int ocfs2_parse_options(struct super_block *sb,
 			       char *options,
 			       unsigned long *mount_opt,
+			       s16 *slot,
 			       int is_remount)
 {
 	int status;
@@ -714,6 +721,7 @@
 		   options ? options : "(none)");
 
 	*mount_opt = 0;
+	*slot = OCFS2_INVALID_SLOT;
 
 	if (!options) {
 		status = 1;
@@ -757,6 +765,15 @@
 		case Opt_err_ro:
 			*mount_opt &= ~OCFS2_MOUNT_ERRORS_PANIC;
 			break;
+		case Opt_slot:
+			option = 0;
+			if (match_int(&args[0], &option)) {
+				status = 0;
+				goto bail;
+			}
+			if (option)
+				*slot = (s16)option;
+			break;
 #ifdef OCFS2_ORACORE_WORKAROUNDS
 		case Opt_datavolume:
 			if (is_remount) {




More information about the Ocfs2-commits mailing list