]> err.no Git - linux-2.6/blobdiff - fs/ocfs2/super.c
SL*B: drop kmem cache argument from constructor
[linux-2.6] / fs / ocfs2 / super.c
index 8f536b39ce5b2d34de31b6af9d4e69a3a8301513..2560b33889aad8380b77f35ba4f21af7220459ac 100644 (file)
@@ -87,6 +87,7 @@ struct mount_options
        unsigned int    atime_quantum;
        signed short    slot;
        unsigned int    localalloc_opt;
+       char            cluster_stack[OCFS2_STACK_LABEL_LEN + 1];
 };
 
 static int ocfs2_parse_options(struct super_block *sb, char *options,
@@ -108,7 +109,6 @@ static int ocfs2_sync_fs(struct super_block *sb, int wait);
 static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb);
 static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb);
 static void ocfs2_release_system_inodes(struct ocfs2_super *osb);
-static int ocfs2_fill_local_node_info(struct ocfs2_super *osb);
 static int ocfs2_check_volume(struct ocfs2_super *osb);
 static int ocfs2_verify_volume(struct ocfs2_dinode *di,
                               struct buffer_head *bh,
@@ -153,6 +153,7 @@ enum {
        Opt_commit,
        Opt_localalloc,
        Opt_localflocks,
+       Opt_stack,
        Opt_err,
 };
 
@@ -171,6 +172,7 @@ static match_table_t tokens = {
        {Opt_commit, "commit=%u"},
        {Opt_localalloc, "localalloc=%d"},
        {Opt_localflocks, "localflocks"},
+       {Opt_stack, "cluster_stack=%s"},
        {Opt_err, NULL}
 };
 
@@ -550,8 +552,17 @@ static int ocfs2_verify_heartbeat(struct ocfs2_super *osb)
                }
        }
 
+       if (ocfs2_userspace_stack(osb)) {
+               if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) {
+                       mlog(ML_ERROR, "Userspace stack expected, but "
+                            "o2cb heartbeat arguments passed to mount\n");
+                       return -EINVAL;
+               }
+       }
+
        if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
-               if (!ocfs2_mount_local(osb) && !ocfs2_is_hard_readonly(osb)) {
+               if (!ocfs2_mount_local(osb) && !ocfs2_is_hard_readonly(osb) &&
+                   !ocfs2_userspace_stack(osb)) {
                        mlog(ML_ERROR, "Heartbeat has to be started to mount "
                             "a read-write clustered device.\n");
                        return -EINVAL;
@@ -561,6 +572,35 @@ static int ocfs2_verify_heartbeat(struct ocfs2_super *osb)
        return 0;
 }
 
+/*
+ * If we're using a userspace stack, mount should have passed
+ * a name that matches the disk.  If not, mount should not
+ * have passed a stack.
+ */
+static int ocfs2_verify_userspace_stack(struct ocfs2_super *osb,
+                                       struct mount_options *mopt)
+{
+       if (!ocfs2_userspace_stack(osb) && mopt->cluster_stack[0]) {
+               mlog(ML_ERROR,
+                    "cluster stack passed to mount, but this filesystem "
+                    "does not support it\n");
+               return -EINVAL;
+       }
+
+       if (ocfs2_userspace_stack(osb) &&
+           strncmp(osb->osb_cluster_stack, mopt->cluster_stack,
+                   OCFS2_STACK_LABEL_LEN)) {
+               mlog(ML_ERROR,
+                    "cluster stack passed to mount (\"%s\") does not "
+                    "match the filesystem (\"%s\")\n",
+                    mopt->cluster_stack,
+                    osb->osb_cluster_stack);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
 {
        struct dentry *root;
@@ -599,6 +639,10 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
        osb->osb_commit_interval = parsed_options.commit_interval;
        osb->local_alloc_size = parsed_options.localalloc_opt;
 
+       status = ocfs2_verify_userspace_stack(osb, &parsed_options);
+       if (status)
+               goto read_super_error;
+
        sb->s_magic = OCFS2_SUPER_MAGIC;
 
        /* Hard readonly mode only if: bdev_read_only, MS_RDONLY,
@@ -753,6 +797,7 @@ static int ocfs2_parse_options(struct super_block *sb,
        mopt->atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
        mopt->slot = OCFS2_INVALID_SLOT;
        mopt->localalloc_opt = OCFS2_DEFAULT_LOCAL_ALLOC_SIZE;
+       mopt->cluster_stack[0] = '\0';
 
        if (!options) {
                status = 1;
@@ -854,6 +899,25 @@ static int ocfs2_parse_options(struct super_block *sb,
                        if (!is_remount)
                                mopt->mount_opt |= OCFS2_MOUNT_LOCALFLOCKS;
                        break;
+               case Opt_stack:
+                       /* Check both that the option we were passed
+                        * is of the right length and that it is a proper
+                        * string of the right length.
+                        */
+                       if (((args[0].to - args[0].from) !=
+                            OCFS2_STACK_LABEL_LEN) ||
+                           (strnlen(args[0].from,
+                                    OCFS2_STACK_LABEL_LEN) !=
+                            OCFS2_STACK_LABEL_LEN)) {
+                               mlog(ML_ERROR,
+                                    "Invalid cluster_stack option\n");
+                               status = 0;
+                               goto bail;
+                       }
+                       memcpy(mopt->cluster_stack, args[0].from,
+                              OCFS2_STACK_LABEL_LEN);
+                       mopt->cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0';
+                       break;
                default:
                        mlog(ML_ERROR,
                             "Unrecognized mount option \"%s\" "
@@ -912,6 +976,10 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
        if (opts & OCFS2_MOUNT_LOCALFLOCKS)
                seq_printf(s, ",localflocks,");
 
+       if (osb->osb_cluster_stack[0])
+               seq_printf(s, ",cluster_stack=%.*s", OCFS2_STACK_LABEL_LEN,
+                          osb->osb_cluster_stack);
+
        return 0;
 }
 
@@ -923,8 +991,6 @@ static int __init ocfs2_init(void)
 
        ocfs2_print_version();
 
-       dlmglue_init_stack();
-
        status = init_ocfs2_uptodate_cache();
        if (status < 0) {
                mlog_errno(status);
@@ -949,6 +1015,8 @@ static int __init ocfs2_init(void)
                mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n");
        }
 
+       ocfs2_set_locking_protocol();
+
 leave:
        if (status < 0) {
                ocfs2_free_mem_caches();
@@ -980,8 +1048,6 @@ static void __exit ocfs2_exit(void)
 
        exit_ocfs2_uptodate_cache();
 
-       dlmglue_exit_stack();
-
        mlog_exit_void();
 }
 
@@ -1052,7 +1118,7 @@ bail:
        return status;
 }
 
-static void ocfs2_inode_init_once(struct kmem_cache *cachep, void *data)
+static void ocfs2_inode_init_once(void *data)
 {
        struct ocfs2_inode_info *oi = data;
 
@@ -1126,32 +1192,6 @@ static int ocfs2_get_sector(struct super_block *sb,
        return 0;
 }
 
-/* ocfs2 1.0 only allows one cluster and node identity per kernel image. */
-static int ocfs2_fill_local_node_info(struct ocfs2_super *osb)
-{
-       int status;
-
-       /* XXX hold a ref on the node while mounte?  easy enough, if
-        * desirable. */
-       if (ocfs2_mount_local(osb))
-               osb->node_num = 0;
-       else {
-               status = ocfs2_cluster_this_node(&osb->node_num);
-               if (status < 0) {
-                       mlog_errno(status);
-                       mlog(ML_ERROR,
-                            "could not find this host's node number\n");
-                       goto bail;
-               }
-       }
-
-       mlog(0, "I am node %u\n", osb->node_num);
-
-       status = 0;
-bail:
-       return status;
-}
-
 static int ocfs2_mount_volume(struct super_block *sb)
 {
        int status = 0;
@@ -1163,12 +1203,6 @@ static int ocfs2_mount_volume(struct super_block *sb)
        if (ocfs2_is_hard_readonly(osb))
                goto leave;
 
-       status = ocfs2_fill_local_node_info(osb);
-       if (status < 0) {
-               mlog_errno(status);
-               goto leave;
-       }
-
        status = ocfs2_dlm_init(osb);
        if (status < 0) {
                mlog_errno(status);
@@ -1221,7 +1255,7 @@ leave:
 
 static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
 {
-       int tmp;
+       int tmp, hangup_needed = 0;
        struct ocfs2_super *osb = NULL;
        char nodestr[8];
 
@@ -1260,19 +1294,21 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
 
        ocfs2_release_system_inodes(osb);
 
-       if (osb->cconn)
-               ocfs2_dlm_shutdown(osb);
-
-       debugfs_remove(osb->osb_debug_root);
-
        /*
-        * This is a small hack to move ocfs2_hb_ctl into stackglue.
         * If we're dismounting due to mount error, mount.ocfs2 will clean
         * up heartbeat.  If we're a local mount, there is no heartbeat.
         * If we failed before we got a uuid_str yet, we can't stop
         * heartbeat.  Otherwise, do it.
         */
        if (!mnt_err && !ocfs2_mount_local(osb) && osb->uuid_str)
+               hangup_needed = 1;
+
+       if (osb->cconn)
+               ocfs2_dlm_shutdown(osb, hangup_needed);
+
+       debugfs_remove(osb->osb_debug_root);
+
+       if (hangup_needed)
                ocfs2_cluster_hangup(osb->uuid_str, strlen(osb->uuid_str));
 
        atomic_set(&osb->vol_state, VOLUME_DISMOUNTED);
@@ -1358,6 +1394,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
        INIT_LIST_HEAD(&osb->blocked_lock_list);
        osb->blocked_lock_count = 0;
        spin_lock_init(&osb->osb_lock);
+       ocfs2_init_inode_steal_slot(osb);
 
        atomic_set(&osb->alloc_stats.moves, 0);
        atomic_set(&osb->alloc_stats.local_data, 0);
@@ -1436,6 +1473,25 @@ static int ocfs2_initialize_super(struct super_block *sb,
                goto bail;
        }
 
+       if (ocfs2_userspace_stack(osb)) {
+               memcpy(osb->osb_cluster_stack,
+                      OCFS2_RAW_SB(di)->s_cluster_info.ci_stack,
+                      OCFS2_STACK_LABEL_LEN);
+               osb->osb_cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0';
+               if (strlen(osb->osb_cluster_stack) != OCFS2_STACK_LABEL_LEN) {
+                       mlog(ML_ERROR,
+                            "couldn't mount because of an invalid "
+                            "cluster stack label (%s) \n",
+                            osb->osb_cluster_stack);
+                       status = -EINVAL;
+                       goto bail;
+               }
+       } else {
+               /* The empty string is identical with classic tools that
+                * don't know about s_cluster_info. */
+               osb->osb_cluster_stack[0] = '\0';
+       }
+
        get_random_bytes(&osb->s_next_generation, sizeof(u32));
 
        /* FIXME
@@ -1647,7 +1703,11 @@ static int ocfs2_check_volume(struct ocfs2_super *osb)
        local = ocfs2_mount_local(osb);
 
        /* will play back anything left in the journal. */
-       ocfs2_journal_load(osb->journal, local);
+       status = ocfs2_journal_load(osb->journal, local);
+       if (status < 0) {
+               mlog(ML_ERROR, "ocfs2 journal load failed! %d\n", status);
+               goto finally;
+       }
 
        if (dirty) {
                /* recover my local alloc if we didn't unmount cleanly. */