* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b,
const struct lu_attr *attr, const struct lu_fid *fid)
{
- struct md_attr *ma = &info->mti_attr;
-
- /*XXX should pack the reply body according to lu_valid*/
- b->valid |= OBD_MD_FLCTIME | OBD_MD_FLUID |
- OBD_MD_FLGID | OBD_MD_FLTYPE |
- OBD_MD_FLMODE | OBD_MD_FLNLINK | OBD_MD_FLFLAGS |
- OBD_MD_FLATIME | OBD_MD_FLMTIME ;
-
- if (!S_ISREG(attr->la_mode))
- b->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLRDEV;
+ struct md_attr *ma = &info->mti_attr;
- /* if no object is allocated on osts, the size on mds is valid. b=22272 */
- if (ma->ma_lmm_size == 0)
- b->valid |= OBD_MD_FLSIZE;
+ LASSERT(ma->ma_valid & MA_INODE);
b->atime = attr->la_atime;
b->mtime = attr->la_mtime;
b->nlink = attr->la_nlink;
b->rdev = attr->la_rdev;
+ /*XXX should pack the reply body according to lu_valid*/
+ b->valid |= OBD_MD_FLCTIME | OBD_MD_FLUID |
+ OBD_MD_FLGID | OBD_MD_FLTYPE |
+ OBD_MD_FLMODE | OBD_MD_FLNLINK | OBD_MD_FLFLAGS |
+ OBD_MD_FLATIME | OBD_MD_FLMTIME ;
+
+ if (!S_ISREG(attr->la_mode)) {
+ b->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLRDEV;
+ } else if (ma->ma_need & MA_LOV && ma->ma_lmm_size == 0) {
+ /* means no objects are allocated on osts. */
+ LASSERT(!(ma->ma_valid & MA_LOV));
+ /* just ignore blocks occupied by extend attributes on MDS */
+ b->blocks = 0;
+ /* if no object is allocated on osts, the size on mds is valid. b=22272 */
+ b->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
+ }
+
if (fid) {
b->fid1 = *fid;
b->valid |= OBD_MD_FLID;
repbody->eadatasize = ma->ma_lmv_size;
repbody->valid |= (OBD_MD_FLDIREA|OBD_MD_MEA);
}
- if (!(ma->ma_valid & MA_LOV) && !(ma->ma_valid & MA_LMV)) {
- repbody->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
- }
} else if (S_ISLNK(la->la_mode) &&
reqbody->valid & OBD_MD_LINKNAME) {
buffer->lb_buf = ma->ma_lmm;
* checked here.
*/
if (lustre_handle_is_used(&lhc->mlh_reg_lh)) {
+ LASSERTF(rc == 0, "Error occurred but lock handle "
+ "is still in use\n");
rep->lock_policy_res2 = 0;
rc = mdt_intent_lock_replace(info, lockp, NULL, lhc, flags);
RETURN(rc);
void *localdata)
{
struct mdt_thread_info *info;
- struct lsd_client_data *lcd;
struct obd_export *lexp;
struct lustre_handle conn = { 0 };
struct mdt_device *mdt;
rc = mdt_connect_internal(lexp, mdt, data);
if (rc == 0) {
- OBD_ALLOC_PTR(lcd);
- if (lcd != NULL) {
- struct mdt_thread_info *mti;
- mti = lu_context_key_get(&env->le_ctx,
- &mdt_thread_key);
- LASSERT(mti != NULL);
- mti->mti_exp = lexp;
- memcpy(lcd->lcd_uuid, cluuid, sizeof lcd->lcd_uuid);
- lexp->exp_target_data.ted_lcd = lcd;
- rc = mdt_client_new(env, mdt);
- if (rc == 0)
- mdt_export_stats_init(obd, lexp, localdata);
- } else {
- rc = -ENOMEM;
- }
+ struct mdt_thread_info *mti;
+ struct lsd_client_data *lcd = lexp->exp_target_data.ted_lcd;
+ LASSERT(lcd);
+ mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
+ LASSERT(mti != NULL);
+ mti->mti_exp = lexp;
+ memcpy(lcd->lcd_uuid, cluuid, sizeof lcd->lcd_uuid);
+ rc = mdt_client_new(env, mdt);
+ if (rc == 0)
+ mdt_export_stats_init(obd, lexp, localdata);
}
out:
- if (rc != 0)
+ if (rc != 0) {
class_disconnect(lexp);
- else
+ *exp = NULL;
+ } else {
*exp = lexp;
+ }
RETURN(rc);
}
cfs_spin_lock(&exp->exp_lock);
exp->exp_connecting = 1;
cfs_spin_unlock(&exp->exp_lock);
- rc = ldlm_init_export(exp);
+ rc = lut_client_alloc(exp);
+ if (rc == 0)
+ rc = ldlm_init_export(exp);
+
if (rc)
CERROR("Error %d while initializing export\n", rc);
RETURN(rc);
target_destroy_export(exp);
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);
- lut_client_free(exp);
RETURN(rc);
}