Whamcloud - gitweb
LU-2059 llog: MGC to use OSD API for backup logs
[fs/lustre-release.git] / lustre / obdclass / obd_mount_server.c
index f3c5368..9137219 100644 (file)
@@ -57,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 *********/
 
@@ -257,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)
@@ -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;