Whamcloud - gitweb
LU-878 test: pdirop fail timeout too soon
[fs/lustre-release.git] / lustre / mdt / mdt_handler.c
index e94ade4..001ef1d 100644 (file)
@@ -2239,7 +2239,7 @@ int mdt_object_lock(struct mdt_thread_info *info, struct mdt_object *o,
         else if (unlikely(OBD_FAIL_PRECHECK(OBD_FAIL_MDS_PDO_LOCK)) &&
                  lh->mlh_pdo_hash != 0 &&
                  (lh->mlh_reg_mode == LCK_PW || lh->mlh_reg_mode == LCK_EX)) {
-                OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_PDO_LOCK, 10);
+                OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_PDO_LOCK, 15);
         }
 
         RETURN(rc);
@@ -4395,52 +4395,6 @@ static int mdt_adapt_sptlrpc_conf(struct obd_device *obd, int initial)
         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,
@@ -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";
-#ifdef HAVE_QUOTA_SUPPORT
         struct md_device          *next;
-#endif
         int                        rc;
         int                        node_id;
+        mntopt_t                   mntopts;
         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_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) {
@@ -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);
-                fsoptions_to_mdt_flags(m, lsi->lsi_lmd->lmd_opts);
                 /* 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;
+        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;
@@ -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;
 
-        /* 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);
@@ -4630,8 +4569,8 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
 
         mdt_adapt_sptlrpc_conf(obd, 1);
 
-#ifdef HAVE_QUOTA_SUPPORT
         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);
@@ -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;
 
+        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);
@@ -4670,6 +4637,9 @@ err_stop_service:
         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
@@ -4682,8 +4652,6 @@ err_capa:
         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:
@@ -5196,35 +5164,42 @@ static int mdt_init_export(struct obd_export *exp)
         cfs_spin_lock(&exp->exp_lock);
         exp->exp_connecting = 1;
         cfs_spin_unlock(&exp->exp_lock);
+
+        /* self-export doesn't need client data and ldlm initialization */
+        if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
+                                     &exp->exp_client_uuid)))
+                RETURN(0);
+
         rc = lut_client_alloc(exp);
         if (rc == 0)
                 rc = ldlm_init_export(exp);
-
         if (rc)
-                CERROR("Error %d while initializing export\n", rc);
+                CERROR("%s: Error %d while initializing export\n",
+                       exp->exp_obd->obd_name, rc);
         RETURN(rc);
 }
 
 static int mdt_destroy_export(struct obd_export *exp)
 {
-        struct mdt_export_data *med;
-        int rc = 0;
         ENTRY;
 
-        med = &exp->exp_mdt_data;
         if (exp_connect_rmtclient(exp))
                 mdt_cleanup_idmap(&exp->exp_mdt_data);
 
         target_destroy_export(exp);
+        /* destroy can be called from failed obd_setup, so
+         * checking uuid is safer than obd_self_export */
+        if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
+                                     &exp->exp_client_uuid)))
+                RETURN(0);
+
         ldlm_destroy_export(exp);
         lut_client_free(exp);
 
         LASSERT(cfs_list_empty(&exp->exp_outstanding_replies));
         LASSERT(cfs_list_empty(&exp->exp_mdt_data.med_open_head));
-        if (obd_uuid_equals(&exp->exp_client_uuid, &exp->exp_obd->obd_uuid))
-                RETURN(0);
 
-        RETURN(rc);
+        RETURN(0);
 }
 
 static void mdt_allow_cli(struct mdt_device *m, unsigned int flag)
@@ -5694,15 +5669,6 @@ LU_KEY_INIT_FINI(mdt, struct mdt_thread_info);
 /* context key: mdt_thread_key */
 LU_CONTEXT_KEY_DEFINE(mdt, LCT_MD_THREAD);
 
-/* context key constructor/destructor: mdt_txn_key_init, mdt_txn_key_fini */
-LU_KEY_INIT_FINI(mdt_txn, struct mdt_txn_info);
-
-struct lu_context_key mdt_txn_key = {
-        .lct_tags = LCT_TX_HANDLE,
-        .lct_init = mdt_txn_key_init,
-        .lct_fini = mdt_txn_key_fini
-};
-
 struct md_ucred *mdt_ucred(const struct mdt_thread_info *info)
 {
         return md_ucred(info->mti_env);
@@ -5745,7 +5711,7 @@ int mdt_cos_is_enabled(struct mdt_device *mdt)
 }
 
 /* type constructor/destructor: mdt_type_init, mdt_type_fini */
-LU_TYPE_INIT_FINI(mdt, &mdt_thread_key, &mdt_txn_key);
+LU_TYPE_INIT_FINI(mdt, &mdt_thread_key);
 
 static struct lu_device_type_operations mdt_device_type_ops = {
         .ldto_init = mdt_type_init,