Whamcloud - gitweb
LU-1445 fid: Add DATA fid type in fid_request.
[fs/lustre-release.git] / lustre / lmv / lmv_obd.c
index 079bd74..e8044f9 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
+ * Copyright (c) 2011, 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
 #define DEBUG_SUBSYSTEM S_LMV
 #ifdef __KERNEL__
 #include <linux/slab.h>
@@ -54,7 +49,7 @@
 #include <liblustre.h>
 #endif
 
-#include <lustre_log.h>
+#include <lustre/lustre_idl.h>
 #include <obd_support.h>
 #include <lustre_lib.h>
 #include <lustre_net.h>
@@ -98,7 +93,7 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid,
         CDEBUG(D_INFO, "Searching in lmv %p for uuid %s (activate=%d)\n",
                lmv, uuid->uuid, activate);
 
-        cfs_spin_lock(&lmv->lmv_lock);
+       spin_lock(&lmv->lmv_lock);
         for (i = 0, tgt = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgt++) {
                 if (tgt->ltd_exp == NULL)
                         continue;
@@ -134,31 +129,31 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid,
         EXIT;
 
  out_lmv_lock:
-        cfs_spin_unlock(&lmv->lmv_lock);
-        return rc;
+       spin_unlock(&lmv->lmv_lock);
+       return rc;
 }
 
 static int lmv_set_mdc_data(struct lmv_obd *lmv, struct obd_uuid *uuid,
-                            struct obd_connect_data *data)
+                           struct obd_connect_data *data)
 {
-        struct lmv_tgt_desc    *tgt;
-        int                     i;
-        ENTRY;
+       struct lmv_tgt_desc    *tgt;
+       int                     i;
+       ENTRY;
 
-        LASSERT(data != NULL);
+       LASSERT(data != NULL);
 
-        cfs_spin_lock(&lmv->lmv_lock);
-        for (i = 0, tgt = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgt++) {
-                if (tgt->ltd_exp == NULL)
-                        continue;
+       spin_lock(&lmv->lmv_lock);
+       for (i = 0, tgt = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgt++) {
+               if (tgt->ltd_exp == NULL)
+                       continue;
 
-                if (obd_uuid_equals(uuid, &tgt->ltd_uuid)) {
-                        lmv->datas[tgt->ltd_idx] = *data;
-                        break;
-                }
-        }
-        cfs_spin_unlock(&lmv->lmv_lock);
-        RETURN(0);
+               if (obd_uuid_equals(uuid, &tgt->ltd_uuid)) {
+                       lmv->datas[tgt->ltd_idx] = *data;
+                       break;
+               }
+       }
+       spin_unlock(&lmv->lmv_lock);
+       RETURN(0);
 }
 
 struct obd_uuid *lmv_get_uuid(struct obd_export *exp) {
@@ -324,7 +319,7 @@ static void lmv_set_timeouts(struct obd_device *obd)
                 if (tgts->ltd_exp == NULL)
                         continue;
 
-                obd_set_info_async(tgts->ltd_exp, sizeof(KEY_INTERMDS),
+                obd_set_info_async(NULL, tgts->ltd_exp, sizeof(KEY_INTERMDS),
                                    KEY_INTERMDS, 0, NULL, NULL);
         }
 }
@@ -418,7 +413,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
         /*
          * Init fid sequence client for this mdc and add new fld target.
          */
-        rc = obd_fid_init(mdc_exp);
+       rc = obd_fid_init(mdc_exp, LUSTRE_SEQ_METADATA);
         if (rc)
                 RETURN(rc);
 
@@ -519,25 +514,19 @@ int lmv_add_target(struct obd_device *obd, struct obd_uuid *tgt_uuid)
                         CERROR("Target %s not attached\n", tgt_uuid->uuid);
                         RETURN(-EINVAL);
                 }
-
-                rc = obd_llog_init(obd, &obd->obd_olg, mdc_obd, NULL);
-                if (rc) {
-                        lmv_init_unlock(lmv);
-                        CERROR("lmv failed to setup llogging subsystems\n");
-                }
         }
-        cfs_spin_lock(&lmv->lmv_lock);
-        tgt = lmv->tgts + lmv->desc.ld_tgt_count++;
-        tgt->ltd_uuid = *tgt_uuid;
-        cfs_spin_unlock(&lmv->lmv_lock);
-
-        if (lmv->connected) {
-                rc = lmv_connect_mdc(obd, tgt);
-                if (rc) {
-                        cfs_spin_lock(&lmv->lmv_lock);
-                        lmv->desc.ld_tgt_count--;
-                        memset(tgt, 0, sizeof(*tgt));
-                        cfs_spin_unlock(&lmv->lmv_lock);
+       spin_lock(&lmv->lmv_lock);
+       tgt = lmv->tgts + lmv->desc.ld_tgt_count++;
+       tgt->ltd_uuid = *tgt_uuid;
+       spin_unlock(&lmv->lmv_lock);
+
+       if (lmv->connected) {
+               rc = lmv_connect_mdc(obd, tgt);
+               if (rc) {
+                       spin_lock(&lmv->lmv_lock);
+                       lmv->desc.ld_tgt_count--;
+                       memset(tgt, 0, sizeof(*tgt));
+                       spin_unlock(&lmv->lmv_lock);
                 } else {
                         int easize = sizeof(struct lmv_stripe_md) +
                                      lmv->desc.ld_tgt_count *
@@ -759,7 +748,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
                                          (int) sizeof(struct obd_uuid))))
                         RETURN(-EFAULT);
 
-                rc = obd_statfs(mdc_obd, &stat_buf,
+                rc = obd_statfs(NULL, lmv->tgts[index].ltd_exp, &stat_buf,
                                 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                                 0);
                 if (rc)
@@ -992,7 +981,7 @@ int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid,
          * New seq alloc and FLD setup should be atomic. Otherwise we may find
          * on server that seq in new allocated fid is not yet known.
          */
-        cfs_mutex_lock(&tgt->ltd_fid_mutex);
+       mutex_lock(&tgt->ltd_fid_mutex);
 
         if (!tgt->ltd_active)
                 GOTO(out, rc = -ENODEV);
@@ -1008,7 +997,7 @@ int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid,
 
         EXIT;
 out:
-        cfs_mutex_unlock(&tgt->ltd_fid_mutex);
+       mutex_unlock(&tgt->ltd_fid_mutex);
         return rc;
 }
 
@@ -1040,17 +1029,6 @@ int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
         RETURN(rc);
 }
 
-static int lmv_fid_delete(struct obd_export *exp, const struct lu_fid *fid)
-{
-        ENTRY;
-        LASSERT(exp != NULL && fid != NULL);
-        if (lmv_object_delete(exp, fid)) {
-                CDEBUG(D_INODE, "Object "DFID" is destroyed.\n",
-                       PFID(fid));
-        }
-        RETURN(0);
-}
-
 static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
         struct lmv_obd             *lmv = &obd->u.lmv;
@@ -1079,7 +1057,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
                 RETURN(-ENOMEM);
 
         for (i = 0; i < LMV_MAX_TGT_COUNT; i++) {
-                cfs_mutex_init(&lmv->tgts[i].ltd_fid_mutex);
+               mutex_init(&lmv->tgts[i].ltd_fid_mutex);
                 lmv->tgts[i].ltd_idx = i;
         }
 
@@ -1097,8 +1075,8 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         lmv->max_easize = 0;
         lmv->lmv_placement = PLACEMENT_CHAR_POLICY;
 
-        cfs_spin_lock_init(&lmv->lmv_lock);
-        cfs_mutex_init(&lmv->init_mutex);
+       spin_lock_init(&lmv->lmv_lock);
+       mutex_init(&lmv->init_mutex);
 
         rc = lmv_object_setup(obd);
         if (rc) {
@@ -1172,9 +1150,10 @@ out:
         RETURN(rc);
 }
 
-static int lmv_statfs(struct obd_device *obd, struct obd_statfs *osfs,
-                      __u64 max_age, __u32 flags)
+static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
+                      struct obd_statfs *osfs, __u64 max_age, __u32 flags)
 {
+        struct obd_device     *obd = class_exp2obd(exp);
         struct lmv_obd        *lmv = &obd->u.lmv;
         struct obd_statfs     *temp;
         int                    rc = 0;
@@ -1193,7 +1172,7 @@ static int lmv_statfs(struct obd_device *obd, struct obd_statfs *osfs,
                 if (lmv->tgts[i].ltd_exp == NULL)
                         continue;
 
-                rc = obd_statfs(lmv->tgts[i].ltd_exp->exp_obd, temp,
+                rc = obd_statfs(env, lmv->tgts[i].ltd_exp, temp,
                                 max_age, flags);
                 if (rc) {
                         CERROR("can't stat MDS #%d (%s), error %d\n", i,
@@ -1305,10 +1284,10 @@ static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data,
         if (IS_ERR(tgt))
                 RETURN(PTR_ERR(tgt));
 
-        if (op_data->op_valid & OBD_MD_MDTIDX) {
-                op_data->op_mds = tgt->ltd_idx;
-                RETURN(0);
-        }
+       if (op_data->op_flags & MF_GET_MDT_IDX) {
+               op_data->op_mds = tgt->ltd_idx;
+               RETURN(0);
+       }
 
         rc = md_getattr(tgt->ltd_exp, op_data, request);
         if (rc)
@@ -1742,7 +1721,7 @@ static int
 lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
             struct lookup_intent *it, struct md_op_data *op_data,
             struct lustre_handle *lockh, void *lmm, int lmmsize,
-            struct ptlrpc_request **req, int extra_lock_flags)
+           struct ptlrpc_request **req, __u64 extra_lock_flags)
 {
         struct obd_device        *obd = exp->exp_obd;
         struct lmv_obd           *lmv = &obd->u.lmv;
@@ -2640,9 +2619,6 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
         case OBD_CLEANUP_EXPORTS:
                 fld_client_proc_fini(&lmv->lmv_fld);
                 lprocfs_obd_cleanup(obd);
-                rc = obd_llog_finish(obd, 0);
-                if (rc != 0)
-                        CERROR("failed to cleanup llogging subsystems\n");
                 break;
         default:
                 break;
@@ -2650,8 +2626,8 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
         RETURN(rc);
 }
 
-static int lmv_get_info(struct obd_export *exp, __u32 keylen,
-                        void *key, __u32 *vallen, void *val,
+static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
+                        __u32 keylen, void *key, __u32 *vallen, void *val,
                         struct lov_stripe_md *lsm)
 {
         struct obd_device       *obd;
@@ -2687,7 +2663,7 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen,
                                 continue;
                         }
 
-                        if (!obd_get_info(tgts->ltd_exp, keylen, key,
+                        if (!obd_get_info(env, tgts->ltd_exp, keylen, key,
                                           vallen, val, NULL))
                                 RETURN(0);
                 }
@@ -2701,7 +2677,7 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen,
                  * Forwarding this request to first MDS, it should know LOV
                  * desc.
                  */
-                rc = obd_get_info(lmv->tgts[0].ltd_exp, keylen, key,
+                rc = obd_get_info(env, lmv->tgts[0].ltd_exp, keylen, key,
                                   vallen, val, NULL);
                 if (!rc && KEY_IS(KEY_CONN_DATA)) {
                         exp->exp_connect_flags =
@@ -2717,9 +2693,9 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen,
         RETURN(-EINVAL);
 }
 
-int lmv_set_info_async(struct obd_export *exp, obd_count keylen,
-                       void *key, obd_count vallen, void *val,
-                       struct ptlrpc_request_set *set)
+int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp,
+                       obd_count keylen, void *key, obd_count vallen,
+                       void *val, struct ptlrpc_request_set *set)
 {
         struct lmv_tgt_desc    *tgt;
         struct obd_device      *obd;
@@ -2744,7 +2720,7 @@ int lmv_set_info_async(struct obd_export *exp, obd_count keylen,
                         if (!tgt->ltd_exp)
                                 continue;
 
-                        err = obd_set_info_async(tgt->ltd_exp,
+                        err = obd_set_info_async(env, tgt->ltd_exp,
                                                  keylen, key, vallen, val, set);
                         if (err && rc == 0)
                                 rc = err;
@@ -2897,7 +2873,7 @@ int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data,
         RETURN(rc);
 }
 
-ldlm_mode_t lmv_lock_match(struct obd_export *exp, int flags,
+ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags,
                            const struct lu_fid *fid, ldlm_type_t type,
                            ldlm_policy_data_t *policy, ldlm_mode_t mode,
                            struct lustre_handle *lockh)
@@ -3190,7 +3166,6 @@ struct obd_ops lmv_obd_ops = {
         .o_notify               = lmv_notify,
         .o_get_uuid             = lmv_get_uuid,
         .o_iocontrol            = lmv_iocontrol,
-        .o_fid_delete           = lmv_fid_delete,
         .o_quotacheck           = lmv_quotacheck,
         .o_quotactl             = lmv_quotactl
 };