diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/lmv/lmv_obd.c')
-rw-r--r-- | drivers/staging/lustre/lustre/lmv/lmv_obd.c | 121 |
1 files changed, 57 insertions, 64 deletions
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index f124f6c05ea4..271e18966f50 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -173,14 +173,7 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, */ obd->obd_self_export->exp_connect_data = *conn_data; } -#if 0 - else if (ev == OBD_NOTIFY_DISCON) { - /* - * For disconnect event, flush fld cache for failout MDS case. - */ - fld_client_flush(&lmv->lmv_fld); - } -#endif + /* * Pass the notification up the chain. */ @@ -736,16 +729,18 @@ static int lmv_hsm_req_count(struct lmv_obd *lmv, /* count how many requests must be sent to the given target */ for (i = 0; i < hur->hur_request.hr_itemcount; i++) { curr_tgt = lmv_find_target(lmv, &hur->hur_user_item[i].hui_fid); + if (IS_ERR(curr_tgt)) + return PTR_ERR(curr_tgt); if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) nr++; } return nr; } -static void lmv_hsm_req_build(struct lmv_obd *lmv, - struct hsm_user_request *hur_in, - const struct lmv_tgt_desc *tgt_mds, - struct hsm_user_request *hur_out) +static int lmv_hsm_req_build(struct lmv_obd *lmv, + struct hsm_user_request *hur_in, + const struct lmv_tgt_desc *tgt_mds, + struct hsm_user_request *hur_out) { int i, nr_out; struct lmv_tgt_desc *curr_tgt; @@ -756,6 +751,8 @@ static void lmv_hsm_req_build(struct lmv_obd *lmv, for (i = 0; i < hur_in->hur_request.hr_itemcount; i++) { curr_tgt = lmv_find_target(lmv, &hur_in->hur_user_item[i].hui_fid); + if (IS_ERR(curr_tgt)) + return PTR_ERR(curr_tgt); if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) { hur_out->hur_user_item[nr_out] = hur_in->hur_user_item[i]; @@ -765,13 +762,14 @@ static void lmv_hsm_req_build(struct lmv_obd *lmv, hur_out->hur_request.hr_itemcount = nr_out; memcpy(hur_data(hur_out), hur_data(hur_in), hur_in->hur_request.hr_data_len); + + return 0; } static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len, struct lustre_kernelcomm *lk, void __user *uarg) { - int rc = 0; __u32 i; /* unregister request (call from llapi_hsm_copytool_fini) */ @@ -791,9 +789,7 @@ static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len, * Unreached coordinators will get EPIPE on next requests * and will unregister automatically. */ - rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group); - - return rc; + return libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group); } static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, @@ -1044,15 +1040,17 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, } else { /* split fid list to their respective MDS */ for (i = 0; i < count; i++) { - unsigned int nr, reqlen; - int rc1; struct hsm_user_request *req; + size_t reqlen; + int nr, rc1; tgt = lmv->tgts[i]; if (!tgt || !tgt->ltd_exp) continue; nr = lmv_hsm_req_count(lmv, hur, tgt); + if (nr < 0) + return nr; if (nr == 0) /* nothing for this MDS */ continue; @@ -1064,10 +1062,13 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, if (!req) return -ENOMEM; - lmv_hsm_req_build(lmv, hur, tgt, req); + rc1 = lmv_hsm_req_build(lmv, hur, tgt, req); + if (rc1 < 0) + goto hsm_req_err; rc1 = obd_iocontrol(cmd, tgt->ltd_exp, reqlen, req, uarg); +hsm_req_err: if (rc1 != 0 && rc == 0) rc = rc1; kvfree(req); @@ -1276,7 +1277,6 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lmv->desc.ld_active_tgt_count = 0; lmv->max_def_easize = 0; lmv->max_easize = 0; - lmv->lmv_placement = PLACEMENT_CHAR_POLICY; spin_lock_init(&lmv->lmv_lock); mutex_init(&lmv->lmv_init_mutex); @@ -1425,8 +1425,7 @@ static int lmv_getstatus(struct obd_export *exp, if (rc) return rc; - rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid); - return rc; + return md_getstatus(lmv->tgts[0]->ltd_exp, fid); } static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -1447,10 +1446,8 @@ static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid, if (IS_ERR(tgt)) return PTR_ERR(tgt); - rc = md_getxattr(tgt->ltd_exp, fid, valid, name, input, + return md_getxattr(tgt->ltd_exp, fid, valid, name, input, input_size, output_size, flags, request); - - return rc; } static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -1472,11 +1469,9 @@ static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid, if (IS_ERR(tgt)) return PTR_ERR(tgt); - rc = md_setxattr(tgt->ltd_exp, fid, valid, name, input, + return md_setxattr(tgt->ltd_exp, fid, valid, name, input, input_size, output_size, flags, suppgid, request); - - return rc; } static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data, @@ -1500,9 +1495,7 @@ static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data, return 0; } - rc = md_getattr(tgt->ltd_exp, op_data, request); - - return rc; + return md_getattr(tgt->ltd_exp, op_data, request); } static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid) @@ -1549,8 +1542,7 @@ static int lmv_close(struct obd_export *exp, struct md_op_data *op_data, return PTR_ERR(tgt); CDEBUG(D_INODE, "CLOSE "DFID"\n", PFID(&op_data->op_fid1)); - rc = md_close(tgt->ltd_exp, op_data, mod, request); - return rc; + return md_close(tgt->ltd_exp, op_data, mod, request); } /** @@ -1743,10 +1735,8 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, CDEBUG(D_INODE, "ENQUEUE '%s' on " DFID " -> mds #%u\n", LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx); - rc = md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh, + return md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh, extra_lock_flags); - - return rc; } static int @@ -1894,9 +1884,7 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data, if (rc != 0) return rc; - rc = md_link(tgt->ltd_exp, op_data, request); - - return rc; + return md_link(tgt->ltd_exp, op_data, request); } static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, @@ -2109,8 +2097,7 @@ static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid, if (IS_ERR(tgt)) return PTR_ERR(tgt); - rc = md_sync(tgt->ltd_exp, fid, request); - return rc; + return md_sync(tgt->ltd_exp, fid, request); } /** @@ -2428,17 +2415,14 @@ static int lmv_read_page(struct obd_export *exp, struct md_op_data *op_data, return rc; if (unlikely(lsm)) { - rc = lmv_read_striped_page(exp, op_data, cb_op, offset, ppage); - return rc; + return lmv_read_striped_page(exp, op_data, cb_op, offset, ppage); } tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) return PTR_ERR(tgt); - rc = md_read_page(tgt->ltd_exp, op_data, cb_op, offset, ppage); - - return rc; + return md_read_page(tgt->ltd_exp, op_data, cb_op, offset, ppage); } /** @@ -2922,13 +2906,11 @@ static int lmv_set_lock_data(struct obd_export *exp, { struct lmv_obd *lmv = &exp->exp_obd->u.lmv; struct lmv_tgt_desc *tgt = lmv->tgts[0]; - int rc; if (!tgt || !tgt->ltd_exp) return -EINVAL; - rc = md_set_lock_data(tgt->ltd_exp, lockh, data, bits); - return rc; + return md_set_lock_data(tgt->ltd_exp, lockh, data, bits); } static enum ldlm_mode lmv_lock_match(struct obd_export *exp, __u64 flags, @@ -3033,25 +3015,40 @@ static int lmv_clear_open_replay_data(struct obd_export *exp, } static int lmv_intent_getattr_async(struct obd_export *exp, - struct md_enqueue_info *minfo, - struct ldlm_enqueue_info *einfo) + struct md_enqueue_info *minfo) { struct md_op_data *op_data = &minfo->mi_data; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct lmv_tgt_desc *tgt = NULL; + struct lmv_tgt_desc *ptgt = NULL; + struct lmv_tgt_desc *ctgt = NULL; int rc; + if (!fid_is_sane(&op_data->op_fid2)) + return -EINVAL; + rc = lmv_check_connect(obd); if (rc) return rc; - tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); - if (IS_ERR(tgt)) - return PTR_ERR(tgt); + ptgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); + if (IS_ERR(ptgt)) + return PTR_ERR(ptgt); - rc = md_intent_getattr_async(tgt->ltd_exp, minfo, einfo); - return rc; + ctgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2); + if (IS_ERR(ctgt)) + return PTR_ERR(ctgt); + + /* + * if child is on remote MDT, we need 2 async RPCs to fetch both LOOKUP + * lock on parent, and UPDATE lock on child MDT, which makes all + * complicated. Considering remote dir is rare case, and not supporting + * it in statahead won't cause any issue, drop its support for now. + */ + if (ptgt != ctgt) + return -ENOTSUPP; + + return md_intent_getattr_async(ptgt->ltd_exp, minfo); } static int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, @@ -3070,8 +3067,7 @@ static int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, if (IS_ERR(tgt)) return PTR_ERR(tgt); - rc = md_revalidate_lock(tgt->ltd_exp, it, fid, bits); - return rc; + return md_revalidate_lock(tgt->ltd_exp, it, fid, bits); } static int @@ -3113,8 +3109,7 @@ static int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, } if (oqctl->qc_cmd != Q_GETOQUOTA) { - rc = obd_quotactl(tgt->ltd_exp, oqctl); - return rc; + return obd_quotactl(tgt->ltd_exp, oqctl); } for (i = 0; i < lmv->desc.ld_tgt_count; i++) { @@ -3234,13 +3229,11 @@ static struct md_ops lmv_md_ops = { static int __init lmv_init(void) { struct lprocfs_static_vars lvars; - int rc; lprocfs_lmv_init_vars(&lvars); - rc = class_register_type(&lmv_obd_ops, &lmv_md_ops, + return class_register_type(&lmv_obd_ops, &lmv_md_ops, LUSTRE_LMV_NAME, NULL); - return rc; } static void lmv_exit(void) |