Whamcloud - gitweb
LU-2059 llog: MGC to use OSD API for backup logs
[fs/lustre-release.git] / lustre / obdclass / obd_mount_server.c
index 86d19d7..9137219 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -48,7 +48,6 @@
 
 #include <obd.h>
 #include <lvfs.h>
-#include <lustre_fsfilt.h>
 #include <obd_class.h>
 #include <lustre/lustre_user.h>
 #include <linux/version.h>
@@ -58,6 +57,9 @@
 #ifdef HAVE_KERNEL_LOCKED
 #include <linux/smp_lock.h>
 #endif
+#ifdef HAVE_SELINUX_IS_ENABLED
+#include <linux/selinux.h>
+#endif
 
 /*********** mount lookup *********/
 
@@ -258,9 +260,14 @@ static int server_start_mgs(struct super_block *sb)
                rc = lustre_start_simple(LUSTRE_MGS_OBDNAME, LUSTRE_MGS_NAME,
                                         LUSTRE_MGS_OBDNAME, 0, 0,
                                         lsi->lsi_osd_obdname, 0);
-               /* Do NOT call server_deregister_mount() here. This leads to
-                * inability cleanup cleanly and free lsi and other stuff when
-                * mgs calls server_put_mount() in error handling case. -umka */
+               /* server_deregister_mount() is not called previously, for lsi
+                * and other stuff can't be freed cleanly when mgs calls
+                * server_put_mount() in error handling case (see b=17758),
+                * this problem is caused by a bug in mgs_init0, which forgot
+                * calling server_put_mount in error case. */
+
+               if (rc)
+                       server_deregister_mount(LUSTRE_MGS_OBDNAME);
        }
 
        if (rc)
@@ -522,8 +529,7 @@ static int lustre_lwp_connect(struct obd_device *lwp)
        data->ocd_connect_flags |= OBD_CONNECT_MDS_MDS | OBD_CONNECT_FID |
                OBD_CONNECT_AT | OBD_CONNECT_LRU_RESIZE |
                OBD_CONNECT_FULL20 | OBD_CONNECT_LVB_TYPE |
-               OBD_CONNECT_LIGHTWEIGHT |
-               OBD_CONNECT_PINGLESS;
+               OBD_CONNECT_LIGHTWEIGHT;
        OBD_ALLOC_PTR(uuid);
        if (uuid == NULL)
                GOTO(out, rc = -ENOMEM);
@@ -1385,6 +1391,8 @@ static int lsi_prepare(struct lustre_sb_info *lsi)
                LDD_F_WRITECONF : 0;
        lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_VIRGIN) ?
                LDD_F_VIRGIN : 0;
+       lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_UPDATE) ?
+               LDD_F_UPDATE : 0;
        lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_MGS) ?
                LDD_F_SV_TYPE_MGS : 0;
        lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_NO_PRIMNODE) ?
@@ -1552,6 +1560,35 @@ static struct super_operations server_ops = {
        .statfs         = server_statfs,
 };
 
+/*
+ * Xattr support for Lustre servers
+ */
+static ssize_t lustre_getxattr(struct dentry *dentry, const char *name,
+                               void *buffer, size_t size)
+{
+       if (!selinux_is_enabled())
+               return -EOPNOTSUPP;
+       return -ENODATA;
+}
+
+static int lustre_setxattr(struct dentry *dentry, const char *name,
+                           const void *value, size_t size, int flags)
+{
+       return -EOPNOTSUPP;
+}
+
+static ssize_t lustre_listxattr(struct dentry *d_entry, char *name,
+                               size_t size)
+{
+       return -EOPNOTSUPP;
+}
+
+const struct inode_operations server_inode_operations = {
+       .setxattr       = lustre_setxattr,
+       .getxattr       = lustre_getxattr,
+       .listxattr      = lustre_listxattr,
+};
+
 #define log2(n) ffz(~(n))
 #define LUSTRE_SUPER_MAGIC 0x0BD00BD1
 
@@ -1579,7 +1616,7 @@ static int server_fill_super_common(struct super_block *sb)
        /* make_bad_inode(root); -- badness - can't umount */
        /* apparently we need to be a directory for the mount to finish */
        root->i_mode = S_IFDIR;
-
+       root->i_op = &server_inode_operations;
        sb->s_root = d_make_root(root);
        if (!sb->s_root) {
                CERROR("%s: can't make root dentry\n", sb->s_id);
@@ -1626,14 +1663,18 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags)
                obd->obd_force = 1;
                class_manual_cleanup(obd);
                lsi->lsi_dt_dev = NULL;
+               RETURN(rc);
        }
 
-       /* XXX: to keep support old components relying on lsi_srv_mnt
-        *      we get this info from OSD just started */
        LASSERT(obd->obd_lu_dev);
+       lu_device_get(obd->obd_lu_dev);
        lsi->lsi_dt_dev = lu2dt_dev(obd->obd_lu_dev);
        LASSERT(lsi->lsi_dt_dev);
 
+       /* set disk context for llog usage */
+       OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
+       obd->obd_lvfs_ctxt.dt = lsi->lsi_dt_dev;
+
        dt_conf_get(NULL, lsi->lsi_dt_dev, &p);
 
        lsi->lsi_srv_mnt = p.ddp_mnt;