-/* -*- 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 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>
#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>
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;
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) {
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);
}
}
/*
* 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);
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 *
}
if (lmv->desc.ld_tgt_count == 0) {
+ lmv_init_unlock(lmv);
CERROR("%s: no targets configured.\n", obd->obd_name);
RETURN(-EINVAL);
}
(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)
* 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_down(&tgt->ltd_fid_sem);
+ mutex_lock(&tgt->ltd_fid_mutex);
if (!tgt->ltd_active)
GOTO(out, rc = -ENODEV);
EXIT;
out:
- cfs_up(&tgt->ltd_fid_sem);
+ mutex_unlock(&tgt->ltd_fid_mutex);
return rc;
}
{
struct obd_device *obd = class_exp2obd(exp);
struct lmv_obd *lmv = &obd->u.lmv;
- mdsno_t mds;
+ mdsno_t mds = 0;
int rc;
ENTRY;
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;
RETURN(-ENOMEM);
for (i = 0; i < LMV_MAX_TGT_COUNT; i++) {
- cfs_sema_init(&lmv->tgts[i].ltd_fid_sem, 1);
+ mutex_init(&lmv->tgts[i].ltd_fid_mutex);
lmv->tgts[i].ltd_idx = i;
}
lmv->max_easize = 0;
lmv->lmv_placement = PLACEMENT_CHAR_POLICY;
- cfs_spin_lock_init(&lmv->lmv_lock);
- cfs_sema_init(&lmv->init_sem, 1);
+ spin_lock_init(&lmv->lmv_lock);
+ mutex_init(&lmv->init_mutex);
rc = lmv_object_setup(obd);
if (rc) {
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;
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,
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)
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;
return id ^ (id >> 32);
}
-static int lmv_readpage(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, __u64 offset64,
- struct page **pages, unsigned npages,
- struct ptlrpc_request **request)
+static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data,
+ struct page **pages, struct ptlrpc_request **request)
{
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
- struct lu_fid rid = *fid;
struct lmv_object *obj;
- __u64 offset;
+ struct lu_fid rid = op_data->op_fid1;
+ __u64 offset = op_data->op_offset;
__u64 hash_adj = 0;
__u32 rank = 0;
__u64 seg_size = 0;
struct lu_dirent *ent;
ENTRY;
- offset = offset64;
-
rc = lmv_check_connect(obd);
if (rc)
RETURN(rc);
* [R*MAX_HASH/N ... (R + 1)*MAX_HASH/N] there for we do hash_adj
* on hash values that we get.
*/
- obj = lmv_object_find_lock(obd, fid);
+ obj = lmv_object_find_lock(obd, &rid);
if (obj) {
nr = obj->lo_objcount;
LASSERT(nr > 0);
do_div(seg_size, nr);
los = obj->lo_stripes;
tgt = lmv_get_target(lmv, los[0].ls_mds);
- rank = lmv_node_rank(tgt->ltd_exp, fid) % nr;
+ rank = lmv_node_rank(tgt->ltd_exp, &rid) % nr;
tgt_tmp = offset;
do_div(tgt_tmp, seg_size);
tgt0_idx = do_div(tgt_tmp, nr);
if (IS_ERR(tgt))
GOTO(cleanup, rc = PTR_ERR(tgt));
- rc = md_readpage(tgt->ltd_exp, &rid, oc, offset, pages, npages,
- request);
+ op_data->op_fid1 = rid;
+ rc = md_readpage(tgt->ltd_exp, op_data, pages, request);
if (rc)
GOTO(cleanup, rc);
>> CFS_PAGE_SHIFT;
nlupgs = (*request)->rq_bulk->bd_nob_transferred >> LU_PAGE_SHIFT;
LASSERT(!((*request)->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK));
- LASSERT(nrdpgs > 0 && nrdpgs <= npages);
+ LASSERT(nrdpgs > 0 && nrdpgs <= op_data->op_npages);
- CDEBUG(D_INODE, "read %d(%d)/%d pages\n", nrdpgs, nlupgs, npages);
+ CDEBUG(D_INODE, "read %d(%d)/%d pages\n", nrdpgs, nlupgs,
+ op_data->op_npages);
for (i = 0; i < nrdpgs; i++) {
#if CFS_PAGE_SIZE > LU_PAGE_SIZE
if (obj) {
lmv_hash_adjust(&dp->ldp_hash_start, hash_adj);
lmv_hash_adjust(&dp->ldp_hash_end, hash_adj);
- LASSERT(le64_to_cpu(dp->ldp_hash_start) <= offset64);
+ LASSERT(le64_to_cpu(dp->ldp_hash_start) <=
+ op_data->op_offset);
if ((tgt0_idx != nr - 1) &&
(le64_to_cpu(dp->ldp_hash_end) == MDS_DIR_END_OFF))
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;
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;
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);
}
* 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 =
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;
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;
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)
.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
};