Whamcloud - gitweb
ORNL-3 mntopt: consider low-layer options for MDT ACL flags
authorFan Yong <yong.fan@whamcloud.com>
Fri, 11 Nov 2011 02:18:39 +0000 (10:18 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 11 Nov 2011 20:41:07 +0000 (15:41 -0500)
Currently, MDT layer enables ACL support by default without checking
whether low-layer (ldiskfs) enables ACL support or not, then causes
unnecessary data traffic on network and through MDS stack for ACL.

So MDT should communicate with low-layer before setting ACL flags.

Signed-off-by: Fan Yong <yong.fan@whamcloud.com>
Change-Id: I804f10bf486745ddd3b23b89e959dfd585589ac0
Reviewed-on: http://review.whamcloud.com/1211
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/darwin/lustre_lib.h
lustre/include/dt_object.h
lustre/include/lustre_lib.h
lustre/mdd/mdd_device.c
lustre/mdt/mdt_handler.c
lustre/osd-ldiskfs/osd_handler.c

index 1b76661..337de76 100644 (file)
@@ -1,3 +1,4 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
  * GPL HEADER START
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
  * GPL HEADER START
@@ -22,8 +23,6 @@
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  * CA 95054 USA or visit www.sun.com if you need additional information or
  * have any questions.
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  * CA 95054 USA or visit www.sun.com if you need additional information or
  * have any questions.
- *
- * GPL HEADER END
  */
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
index e6c6103..d02d664 100644 (file)
@@ -30,6 +30,9 @@
  * Use is subject to license terms.
  */
 /*
  * Use is subject to license terms.
  */
 /*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
@@ -68,10 +71,16 @@ struct dt_object;
 struct dt_index_features;
 struct dt_quota_ctxt;
 
 struct dt_index_features;
 struct dt_quota_ctxt;
 
+typedef enum {
+        MNTOPT_USERXATTR        = 0x00000001,
+        MNTOPT_ACL              = 0x00000002,
+} mntopt_t;
+
 struct dt_device_param {
         unsigned           ddp_max_name_len;
         unsigned           ddp_max_nlink;
         unsigned           ddp_block_shift;
 struct dt_device_param {
         unsigned           ddp_max_name_len;
         unsigned           ddp_max_nlink;
         unsigned           ddp_block_shift;
+        mntopt_t           ddp_mntopts;
 };
 
 /**
 };
 
 /**
index 6283648..be0d684 100644 (file)
@@ -537,6 +537,8 @@ static inline void obd_ioctl_freedata(char *buf, int len)
 
 #define OBD_IOC_GET_OBJ_VERSION        _IOR('f', 210, OBD_IOC_DATA_TYPE)
 
 
 #define OBD_IOC_GET_OBJ_VERSION        _IOR('f', 210, OBD_IOC_DATA_TYPE)
 
+#define OBD_IOC_GET_MNTOPT             _IOW('f', 220, mntopt_t)
+
 /* XXX _IOWR('f', 250, long) has been defined in
  * libcfs/include/libcfs/libcfs_private.h for debug, don't use it
  */
 /* XXX _IOWR('f', 250, long) has been defined in
  * libcfs/include/libcfs/libcfs_private.h for debug, don't use it
  */
index 0dbfbd4..5f3a492 100644 (file)
@@ -30,6 +30,9 @@
  * Use is subject to license terms.
  */
 /*
  * Use is subject to license terms.
  */
 /*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  *
@@ -1492,11 +1495,18 @@ static int mdd_iocontrol(const struct lu_env *env, struct md_device *m,
         mdd = lu2mdd_dev(&m->md_lu_dev);
 
         /* Doesn't use obd_ioctl_data */
         mdd = lu2mdd_dev(&m->md_lu_dev);
 
         /* Doesn't use obd_ioctl_data */
-        if (cmd == OBD_IOC_CHANGELOG_CLEAR) {
+        switch (cmd) {
+        case OBD_IOC_CHANGELOG_CLEAR: {
                 struct changelog_setinfo *cs = karg;
                 rc = mdd_changelog_user_purge(mdd, cs->cs_id, cs->cs_recno);
                 RETURN(rc);
         }
                 struct changelog_setinfo *cs = karg;
                 rc = mdd_changelog_user_purge(mdd, cs->cs_id, cs->cs_recno);
                 RETURN(rc);
         }
+        case OBD_IOC_GET_MNTOPT: {
+                mntopt_t *mntopts = (mntopt_t *)karg;
+                *mntopts = mdd->mdd_dt_conf.ddp_mntopts;
+                RETURN(0);
+        }
+        }
 
         /* Below ioctls use obd_ioctl_data */
         if (len != sizeof(*data)) {
 
         /* Below ioctls use obd_ioctl_data */
         if (len != sizeof(*data)) {
@@ -1518,7 +1528,7 @@ static int mdd_iocontrol(const struct lu_env *env, struct md_device *m,
                                               MCUD_UNREGISTER);
                 break;
         default:
                                               MCUD_UNREGISTER);
                 break;
         default:
-                rc = -EOPNOTSUPP;
+                rc = -ENOTTY;
         }
 
         RETURN (rc);
         }
 
         RETURN (rc);
index d4de547..e45abae 100644 (file)
@@ -4395,52 +4395,6 @@ static int mdt_adapt_sptlrpc_conf(struct obd_device *obd, int initial)
         return 0;
 }
 
         return 0;
 }
 
-static void fsoptions_to_mdt_flags(struct mdt_device *m, char *options)
-{
-        char *p = options;
-
-        m->mdt_opts.mo_mds_capa = 1;
-        m->mdt_opts.mo_oss_capa = 1;
-#ifdef CONFIG_FS_POSIX_ACL
-        /* ACLs should be enabled by default (b=13829) */
-        m->mdt_opts.mo_acl = 1;
-        LCONSOLE_INFO("Enabling ACL\n");
-#else
-        m->mdt_opts.mo_acl = 0;
-        LCONSOLE_INFO("Disabling ACL\n");
-#endif
-
-        if (!options)
-                return;
-
-        while (*options) {
-                int len;
-
-                while (*p && *p != ',')
-                        p++;
-
-                len = p - options;
-                if ((len == sizeof("user_xattr") - 1) &&
-                    (memcmp(options, "user_xattr", len) == 0)) {
-                        m->mdt_opts.mo_user_xattr = 1;
-                        LCONSOLE_INFO("Enabling user_xattr\n");
-                } else if ((len == sizeof("nouser_xattr") - 1) &&
-                           (memcmp(options, "nouser_xattr", len) == 0)) {
-                        m->mdt_opts.mo_user_xattr = 0;
-                        LCONSOLE_INFO("Disabling user_xattr\n");
-                } else if ((len == sizeof("noacl") - 1) &&
-                           (memcmp(options, "noacl", len) == 0)) {
-                        m->mdt_opts.mo_acl = 0;
-                        LCONSOLE_INFO("Disabling ACL\n");
-                }
-
-                if (!*p)
-                        break;
-
-                options = ++p;
-        }
-}
-
 int mdt_postrecov(const struct lu_env *, struct mdt_device *);
 
 static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
 int mdt_postrecov(const struct lu_env *, struct mdt_device *);
 
 static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
@@ -4456,11 +4410,10 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
         struct lu_site            *s;
         struct md_site            *mite;
         const char                *identity_upcall = "NONE";
         struct lu_site            *s;
         struct md_site            *mite;
         const char                *identity_upcall = "NONE";
-#ifdef HAVE_QUOTA_SUPPORT
         struct md_device          *next;
         struct md_device          *next;
-#endif
         int                        rc;
         int                        node_id;
         int                        rc;
         int                        node_id;
+        mntopt_t                   mntopts;
         ENTRY;
 
         md_device_init(&m->mdt_md_dev, ldt);
         ENTRY;
 
         md_device_init(&m->mdt_md_dev, ldt);
@@ -4486,8 +4439,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
         m->mdt_max_cookiesize = sizeof(struct llog_cookie);
         m->mdt_som_conf = 0;
 
         m->mdt_max_cookiesize = sizeof(struct llog_cookie);
         m->mdt_som_conf = 0;
 
-        m->mdt_opts.mo_user_xattr = 0;
-        m->mdt_opts.mo_acl = 0;
         m->mdt_opts.mo_cos = MDT_COS_DEFAULT;
         lmi = server_get_mount_2(dev);
         if (lmi == NULL) {
         m->mdt_opts.mo_cos = MDT_COS_DEFAULT;
         lmi = server_get_mount_2(dev);
         if (lmi == NULL) {
@@ -4495,7 +4446,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
                 RETURN(-EFAULT);
         } else {
                 lsi = s2lsi(lmi->lmi_sb);
                 RETURN(-EFAULT);
         } else {
                 lsi = s2lsi(lmi->lmi_sb);
-                fsoptions_to_mdt_flags(m, lsi->lsi_lmd->lmd_opts);
                 /* CMD is supported only in IAM mode */
                 ldd = lsi->lsi_ldd;
                 LASSERT(num);
                 /* CMD is supported only in IAM mode */
                 ldd = lsi->lsi_ldd;
                 LASSERT(num);
@@ -4513,6 +4463,8 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
 
         cfs_spin_lock_init(&m->mdt_ioepoch_lock);
         m->mdt_opts.mo_compat_resname = 0;
 
         cfs_spin_lock_init(&m->mdt_ioepoch_lock);
         m->mdt_opts.mo_compat_resname = 0;
+        m->mdt_opts.mo_mds_capa = 1;
+        m->mdt_opts.mo_oss_capa = 1;
         m->mdt_capa_timeout = CAPA_TIMEOUT;
         m->mdt_capa_alg = CAPA_HMAC_ALG_SHA1;
         m->mdt_ck_timeout = CAPA_KEY_TIMEOUT;
         m->mdt_capa_timeout = CAPA_TIMEOUT;
         m->mdt_capa_alg = CAPA_HMAC_ALG_SHA1;
         m->mdt_ck_timeout = CAPA_KEY_TIMEOUT;
@@ -4597,19 +4549,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
         /* set obd_namespace for compatibility with old code */
         obd->obd_namespace = m->mdt_namespace;
 
         /* set obd_namespace for compatibility with old code */
         obd->obd_namespace = m->mdt_namespace;
 
-        /* XXX: to support suppgid for ACL, we enable identity_upcall
-         * by default, otherwise, maybe got unexpected -EACCESS. */
-        if (m->mdt_opts.mo_acl)
-                identity_upcall = MDT_IDENTITY_UPCALL_PATH;
-
-        m->mdt_identity_cache = upcall_cache_init(obd->obd_name, identity_upcall,
-                                                  &mdt_identity_upcall_cache_ops);
-        if (IS_ERR(m->mdt_identity_cache)) {
-                rc = PTR_ERR(m->mdt_identity_cache);
-                m->mdt_identity_cache = NULL;
-                GOTO(err_free_ns, rc);
-        }
-
         cfs_timer_init(&m->mdt_ck_timer, mdt_ck_timer_callback, m);
 
         rc = mdt_ck_thread_start(m);
         cfs_timer_init(&m->mdt_ck_timer, mdt_ck_timer_callback, m);
 
         rc = mdt_ck_thread_start(m);
@@ -4630,8 +4569,8 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
 
         mdt_adapt_sptlrpc_conf(obd, 1);
 
 
         mdt_adapt_sptlrpc_conf(obd, 1);
 
-#ifdef HAVE_QUOTA_SUPPORT
         next = m->mdt_child;
         next = m->mdt_child;
+#ifdef HAVE_QUOTA_SUPPORT
         rc = next->md_ops->mdo_quota.mqo_setup(env, next, lmi->lmi_mnt);
         if (rc)
                 GOTO(err_llog_cleanup, rc);
         rc = next->md_ops->mdo_quota.mqo_setup(env, next, lmi->lmi_mnt);
         if (rc)
                 GOTO(err_llog_cleanup, rc);
@@ -4640,6 +4579,34 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
         server_put_mount_2(dev, lmi->lmi_mnt);
         lmi = NULL;
 
         server_put_mount_2(dev, lmi->lmi_mnt);
         lmi = NULL;
 
+        rc = next->md_ops->mdo_iocontrol(env, next, OBD_IOC_GET_MNTOPT, 0,
+                                         &mntopts);
+        if (rc)
+                GOTO(err_quota, rc);
+
+        if (mntopts & MNTOPT_USERXATTR)
+                m->mdt_opts.mo_user_xattr = 1;
+        else
+                m->mdt_opts.mo_user_xattr = 0;
+
+        if (mntopts & MNTOPT_ACL)
+                m->mdt_opts.mo_acl = 1;
+        else
+                m->mdt_opts.mo_acl = 0;
+
+        /* XXX: to support suppgid for ACL, we enable identity_upcall
+         * by default, otherwise, maybe got unexpected -EACCESS. */
+        if (m->mdt_opts.mo_acl)
+                identity_upcall = MDT_IDENTITY_UPCALL_PATH;
+
+        m->mdt_identity_cache = upcall_cache_init(obd->obd_name,identity_upcall,
+                                                &mdt_identity_upcall_cache_ops);
+        if (IS_ERR(m->mdt_identity_cache)) {
+                rc = PTR_ERR(m->mdt_identity_cache);
+                m->mdt_identity_cache = NULL;
+                GOTO(err_quota, rc);
+        }
+
         target_recovery_init(&m->mdt_lut, mdt_recovery_handle);
 
         rc = mdt_start_ptlrpc_service(m);
         target_recovery_init(&m->mdt_lut, mdt_recovery_handle);
 
         rc = mdt_start_ptlrpc_service(m);
@@ -4670,6 +4637,9 @@ err_stop_service:
         mdt_stop_ptlrpc_service(m);
 err_recovery:
         target_recovery_fini(obd);
         mdt_stop_ptlrpc_service(m);
 err_recovery:
         target_recovery_fini(obd);
+        upcall_cache_cleanup(m->mdt_identity_cache);
+        m->mdt_identity_cache = NULL;
+err_quota:
 #ifdef HAVE_QUOTA_SUPPORT
         next->md_ops->mdo_quota.mqo_cleanup(env, next);
 #endif
 #ifdef HAVE_QUOTA_SUPPORT
         next->md_ops->mdo_quota.mqo_cleanup(env, next);
 #endif
@@ -4682,8 +4652,6 @@ err_capa:
         cfs_timer_disarm(&m->mdt_ck_timer);
         mdt_ck_thread_stop(m);
 err_free_ns:
         cfs_timer_disarm(&m->mdt_ck_timer);
         mdt_ck_thread_stop(m);
 err_free_ns:
-        upcall_cache_cleanup(m->mdt_identity_cache);
-        m->mdt_identity_cache = NULL;
         ldlm_namespace_free(m->mdt_namespace, NULL, 0);
         obd->obd_namespace = m->mdt_namespace = NULL;
 err_fini_seq:
         ldlm_namespace_free(m->mdt_namespace, NULL, 0);
         obd->obd_namespace = m->mdt_namespace = NULL;
 err_fini_seq:
index 29764c9..9bdf41c 100644 (file)
@@ -882,12 +882,19 @@ static void osd_conf_get(const struct lu_env *env,
                          const struct dt_device *dev,
                          struct dt_device_param *param)
 {
                          const struct dt_device *dev,
                          struct dt_device_param *param)
 {
+        struct super_block *sb = osd_sb(osd_dt_dev(dev));
+
         /*
          * XXX should be taken from not-yet-existing fs abstraction layer.
          */
         /*
          * XXX should be taken from not-yet-existing fs abstraction layer.
          */
-        param->ddp_max_name_len  = LDISKFS_NAME_LEN;
-        param->ddp_max_nlink     = LDISKFS_LINK_MAX;
-        param->ddp_block_shift   = osd_sb(osd_dt_dev(dev))->s_blocksize_bits;
+        param->ddp_max_name_len = LDISKFS_NAME_LEN;
+        param->ddp_max_nlink    = LDISKFS_LINK_MAX;
+        param->ddp_block_shift  = osd_sb(osd_dt_dev(dev))->s_blocksize_bits;
+        param->ddp_mntopts      = 0;
+        if (test_opt(sb, XATTR_USER))
+                param->ddp_mntopts |= MNTOPT_USERXATTR;
+        if (test_opt(sb, POSIX_ACL))
+                param->ddp_mntopts |= MNTOPT_ACL;
 }
 
 /**
 }
 
 /**