]> err.no Git - linux-2.6/commitdiff
ocfs2: Add "preferred slot" mount option
authorSunil Mushran <Sunil.Mushran@oracle.com>
Tue, 19 Jun 2007 00:00:24 +0000 (17:00 -0700)
committerMark Fasheh <mark.fasheh@oracle.com>
Wed, 11 Jul 2007 00:19:54 +0000 (17:19 -0700)
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 small
feature can be useful for automated testing.

Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
fs/ocfs2/ocfs2.h
fs/ocfs2/slot_map.c
fs/ocfs2/super.c

index a860633e833fa5c07d37f6d0d7131b2681d5eddb..648ef8e45eaac3d9a3b57a4bb3d056c92d3e53aa 100644 (file)
@@ -219,6 +219,7 @@ struct ocfs2_super
        u16 max_slots;
        s16 node_num;
        s16 slot_num;
+       s16 preferred_slot;
        int s_sectsize_bits;
        int s_clustersize;
        int s_clustersize_bits;
index d8b79067dc14778a5d67556c20c62fec9a5e4de7..af4882b62cfae7c914fb4c22aad90761d039dc96 100644 (file)
@@ -121,17 +121,25 @@ static s16 __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
        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;
 }
 
@@ -248,7 +256,7 @@ int ocfs2_find_slot(struct ocfs2_super *osb)
        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");
index 86b559c7dce9a0ec697c54782c15710a8e5cb6ab..f07718a7552b8b78a442cb6f8ff08bbcf39ad75a 100644 (file)
@@ -82,7 +82,8 @@ MODULE_AUTHOR("Oracle");
 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);
@@ -140,6 +141,7 @@ enum {
        Opt_data_ordered,
        Opt_data_writeback,
        Opt_atime_quantum,
+       Opt_slot,
        Opt_err,
 };
 
@@ -154,6 +156,7 @@ static match_table_t tokens = {
        {Opt_data_ordered, "data=ordered"},
        {Opt_data_writeback, "data=writeback"},
        {Opt_atime_quantum, "atime_quantum=%u"},
+       {Opt_slot, "preferred_slot=%u"},
        {Opt_err, NULL}
 };
 
@@ -355,9 +358,10 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data)
        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;
        }
@@ -534,6 +538,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
        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;
@@ -541,7 +546,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
 
        mlog_entry("%p, %p, %i", sb, data, silent);
 
-       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;
        }
@@ -571,6 +576,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
        brelse(bh);
        bh = NULL;
        osb->s_mount_opt = parsed_opt;
+       osb->preferred_slot = slot;
 
        sb->s_magic = OCFS2_SUPER_MAGIC;
 
@@ -713,6 +719,7 @@ static struct file_system_type ocfs2_fs_type = {
 static int ocfs2_parse_options(struct super_block *sb,
                               char *options,
                               unsigned long *mount_opt,
+                              s16 *slot,
                               int is_remount)
 {
        int status;
@@ -722,6 +729,7 @@ static int ocfs2_parse_options(struct super_block *sb,
                   options ? options : "(none)");
 
        *mount_opt = 0;
+       *slot = OCFS2_INVALID_SLOT;
 
        if (!options) {
                status = 1;
@@ -782,6 +790,15 @@ static int ocfs2_parse_options(struct super_block *sb,
                        else
                                osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
                        break;
+               case Opt_slot:
+                       option = 0;
+                       if (match_int(&args[0], &option)) {
+                               status = 0;
+                               goto bail;
+                       }
+                       if (option)
+                               *slot = (s16)option;
+                       break;
                default:
                        mlog(ML_ERROR,
                             "Unrecognized mount option \"%s\" "