From 14cbce4b70833ee259427fa5a2ba826b75bb5c58 Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Sat, 14 Dec 2013 13:42:47 +0400 Subject: [PATCH] LU-3467 ofd: remove obsoleted OBD methods Remove unused OBD methods from OFD, keep those needed for echo client and rename them to indicate that ofd_get_info() and ofd_set_info_async() are only needed for local calls with single key. Clean the usage of fti_fid, don't copy FID to it when it is possible to point on FID in request buffers directly. Signed-off-by: Mikhail Pershin Change-Id: I5622e14bccacb809bca1c10499c23bcaf72e2a68 Reviewed-on: http://review.whamcloud.com/8580 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong --- lustre/include/lu_target.h | 1 - lustre/obdecho/echo_client.c | 1 + lustre/ofd/ofd_capa.c | 4 +- lustre/ofd/ofd_dev.c | 87 ++++- lustre/ofd/ofd_fmd.c | 6 +- lustre/ofd/ofd_internal.h | 16 +- lustre/ofd/ofd_io.c | 32 +- lustre/ofd/ofd_obd.c | 732 ++++++------------------------------------- lustre/target/tgt_handler.c | 7 +- 9 files changed, 202 insertions(+), 684 deletions(-) diff --git a/lustre/include/lu_target.h b/lustre/include/lu_target.h index d4a814e..9d952bf 100644 --- a/lustre/include/lu_target.h +++ b/lustre/include/lu_target.h @@ -103,7 +103,6 @@ struct tgt_session_info { struct lu_object *tsi_corpus; struct lu_fid tsi_fid; - struct lu_fid tsi_fid2; struct ldlm_res_id tsi_resid; /* object affected by VBR, for last_rcvd_update */ diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index bd0ccdc..eba406f 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -2821,6 +2821,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, tsi = tgt_ses_info(env); tsi->tsi_exp = ec->ec_exp; + tsi->tsi_jobid = NULL; #endif switch (cmd) { case OBD_IOC_CREATE: /* may create echo object */ diff --git a/lustre/ofd/ofd_capa.c b/lustre/ofd/ofd_capa.c index 810f123..d9a645f 100644 --- a/lustre/ofd/ofd_capa.c +++ b/lustre/ofd/ofd_capa.c @@ -103,8 +103,8 @@ int ofd_update_capa_key(struct ofd_device *ofd, struct lustre_capa_key *new) RETURN(0); } -int ofd_auth_capa(struct obd_export *exp, struct lu_fid *fid, obd_seq seq, - struct lustre_capa *capa, __u64 opc) +int ofd_auth_capa(struct obd_export *exp, const struct lu_fid *fid, + obd_seq seq, struct lustre_capa *capa, __u64 opc) { struct filter_obd *filter = &exp->exp_obd->u.filter; struct filter_capa_key *k; diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index cb58b99..afe056e 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -393,12 +393,6 @@ static int ofd_prepare(const struct lu_env *env, struct lu_device *pdev, ENTRY; - rc = lu_env_refill((struct lu_env *)env); - if (rc != 0) { - CERROR("Failure to refill session: '%d'\n", rc); - RETURN(rc); - } - info = ofd_info_init(env, NULL); if (info == NULL) RETURN(-EFAULT); @@ -721,8 +715,8 @@ int ofd_set_info_hdl(struct tgt_session_info *tsi) RETURN(rc); } -static int ofd_fiemap_get(const struct lu_env *env, struct ofd_device *ofd, - struct lu_fid *fid, struct ll_user_fiemap *fiemap) +int ofd_fiemap_get(const struct lu_env *env, struct ofd_device *ofd, + struct lu_fid *fid, struct ll_user_fiemap *fiemap) { struct ofd_object *fo; int rc; @@ -863,7 +857,7 @@ int ofd_get_info_hdl(struct tgt_session_info *tsi) } else if (KEY_IS(KEY_FIEMAP)) { struct ll_fiemap_info_key *fm_key; struct ll_user_fiemap *fiemap; - struct lu_fid *fid = &fti->fti_fid; + struct lu_fid *fid; req_capsule_extend(tsi->tsi_pill, &RQF_OST_GET_INFO_FIEMAP); @@ -872,7 +866,7 @@ int ofd_get_info_hdl(struct tgt_session_info *tsi) if (rc) RETURN(err_serious(rc)); - *fid = fm_key->oa.o_oi.oi_fid; + fid = &fm_key->oa.o_oi.oi_fid; CDEBUG(D_INODE, "get FIEMAP of object "DFID"\n", PFID(fid)); @@ -1109,6 +1103,79 @@ out: return rc; } +static int ofd_orphans_destroy(const struct lu_env *env, + struct obd_export *exp, + struct ofd_device *ofd, struct obdo *oa) +{ + struct ofd_thread_info *info = ofd_info(env); + struct lu_fid *fid = &info->fti_fid; + struct ost_id *oi = &oa->o_oi; + struct ofd_seq *oseq; + obd_seq seq = ostid_seq(oi); + obd_id end_id = ostid_id(oi); + obd_id last; + obd_id oid; + int skip_orphan; + int rc = 0; + + ENTRY; + + oseq = ofd_seq_get(ofd, seq); + if (oseq == NULL) { + CERROR("%s: Can not find seq for "DOSTID"\n", + ofd_name(ofd), POSTID(oi)); + RETURN(-EINVAL); + } + + *fid = oi->oi_fid; + last = ofd_seq_last_oid(oseq); + oid = last; + + LASSERT(exp != NULL); + skip_orphan = !!(exp_connect_flags(exp) & OBD_CONNECT_SKIP_ORPHAN); + + LCONSOLE(D_INFO, "%s: deleting orphan objects from "DOSTID + " to "DOSTID"\n", ofd_name(ofd), seq, end_id + 1, seq, last); + + while (oid > end_id) { + rc = fid_set_id(fid, oid); + if (unlikely(rc != 0)) + GOTO(out_put, rc); + + rc = ofd_destroy_by_fid(env, ofd, fid, 1); + if (rc != 0 && rc != -ENOENT) /* this is pretty fatal... */ + CEMERG("%s: error destroying precreated id "DFID + ": rc = %d\n", ofd_name(ofd), PFID(fid), rc); + + oid--; + if (!skip_orphan) { + ofd_seq_last_oid_set(oseq, oid); + /* update last_id on disk periodically so that if we + * restart * we don't need to re-scan all of the just + * deleted objects. */ + if ((oid & 511) == 0) + ofd_seq_last_oid_write(env, ofd, oseq); + } + } + + CDEBUG(D_HA, "%s: after destroy: set last_id to "DOSTID"\n", + ofd_name(ofd), seq, oid); + + if (!skip_orphan) { + rc = ofd_seq_last_oid_write(env, ofd, oseq); + } else { + /* don't reuse orphan object, return last used objid */ + ostid_set_id(oi, last); + rc = 0; + } + + GOTO(out_put, rc); + +out_put: + ofd_seq_put(env, oseq); + return rc; +} + static int ofd_create_hdl(struct tgt_session_info *tsi) { struct ost_body *repbody; diff --git a/lustre/ofd/ofd_fmd.c b/lustre/ofd/ofd_fmd.c index f25ce93..b546732 100644 --- a/lustre/ofd/ofd_fmd.c +++ b/lustre/ofd/ofd_fmd.c @@ -134,7 +134,7 @@ static struct ofd_mod_data *ofd_fmd_find_nolock(struct obd_export *exp, /* Find fmd based on fid or return NULL if not found. */ struct ofd_mod_data *ofd_fmd_find(struct obd_export *exp, - struct lu_fid *fid) + const struct lu_fid *fid) { struct filter_export_data *fed = &exp->exp_filter_data; struct ofd_mod_data *fmd; @@ -153,7 +153,7 @@ struct ofd_mod_data *ofd_fmd_find(struct obd_export *exp, * or if fid = 0 is passed (which will only cause old entries to expire). * Currently this is not fatal because any fmd state is transient and * may also be freed when it gets sufficiently old. */ -struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, struct lu_fid *fid) +struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, const struct lu_fid *fid) { struct filter_export_data *fed = &exp->exp_filter_data; struct ofd_device *ofd = ofd_exp(exp); @@ -192,7 +192,7 @@ struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, struct lu_fid *fid) * This isn't so critical because it would in fact only affect the one client * that is doing the unlink and at worst we have an stale entry referencing * an object that should never be used again. */ -void ofd_fmd_drop(struct obd_export *exp, struct lu_fid *fid) +void ofd_fmd_drop(struct obd_export *exp, const struct lu_fid *fid) { struct filter_export_data *fed = &exp->exp_filter_data; struct ofd_mod_data *found = NULL; diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index 394efc9..e19d357 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -321,21 +321,21 @@ extern void target_recovery_init(struct lu_target *lut, svc_handler_t handler); /* ofd_capa.c */ int ofd_update_capa_key(struct ofd_device *ofd, struct lustre_capa_key *key); -int ofd_auth_capa(struct obd_export *exp, struct lu_fid *fid, obd_seq seq, - struct lustre_capa *capa, __u64 opc); +int ofd_auth_capa(struct obd_export *exp, const struct lu_fid *fid, + obd_seq seq, struct lustre_capa *capa, __u64 opc); void ofd_free_capa_keys(struct ofd_device *ofd); /* ofd_dev.c */ extern struct lu_context_key ofd_thread_key; int ofd_postrecov(const struct lu_env *env, struct ofd_device *ofd); +int ofd_fiemap_get(const struct lu_env *env, struct ofd_device *ofd, + struct lu_fid *fid, struct ll_user_fiemap *fiemap); /* ofd_obd.c */ extern struct obd_ops ofd_obd_ops; int ofd_statfs_internal(const struct lu_env *env, struct ofd_device *ofd, struct obd_statfs *osfs, __u64 max_age, int *from_cache); -int ofd_orphans_destroy(const struct lu_env *env, struct obd_export *exp, - struct ofd_device *ofd, struct obdo *oa); int ofd_destroy_by_fid(const struct lu_env *env, struct ofd_device *ofd, const struct lu_fid *fid, int orphan); int ofd_statfs(const struct lu_env *env, struct obd_export *exp, @@ -420,7 +420,7 @@ int ofd_attr_handle_ugid(const struct lu_env *env, struct ofd_object *fo, static inline struct ofd_object *ofd_object_find_exists(const struct lu_env *env, struct ofd_device *ofd, - struct lu_fid *fid) + const struct lu_fid *fid) { struct ofd_object *fo; @@ -490,14 +490,14 @@ int ofd_grant_create(const struct lu_env *env, struct obd_export *exp, int *nr); int ofd_fmd_init(void); void ofd_fmd_exit(void); struct ofd_mod_data *ofd_fmd_find(struct obd_export *exp, - struct lu_fid *fid); + const struct lu_fid *fid); struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, - struct lu_fid *fid); + const struct lu_fid *fid); void ofd_fmd_put(struct obd_export *exp, struct ofd_mod_data *fmd); void ofd_fmd_expire(struct obd_export *exp); void ofd_fmd_cleanup(struct obd_export *exp); #ifdef DO_FMD_DROP -void ofd_fmd_drop(struct obd_export *exp, struct lu_fid *fid); +void ofd_fmd_drop(struct obd_export *exp, const struct lu_fid *fid); #else #define ofd_fmd_drop(exp, fid) do {} while (0) #endif diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index c21c903..afda149 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -43,7 +43,7 @@ #include "ofd_internal.h" static int ofd_preprw_read(const struct lu_env *env, struct obd_export *exp, - struct ofd_device *ofd, struct lu_fid *fid, + struct ofd_device *ofd, const struct lu_fid *fid, struct lu_attr *la, int niocount, struct niobuf_remote *rnb, int *nr_local, struct niobuf_local *lnb, char *jobid) @@ -100,7 +100,7 @@ unlock: } static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp, - struct ofd_device *ofd, struct lu_fid *fid, + struct ofd_device *ofd, const struct lu_fid *fid, struct lu_attr *la, struct obdo *oa, int objcount, struct obd_ioobj *obj, struct niobuf_remote *rnb, int *nr_local, @@ -207,6 +207,7 @@ int ofd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, struct ofd_device *ofd = ofd_exp(exp); struct ofd_thread_info *info; char *jobid; + const struct lu_fid *fid = &oa->o_oi.oi_fid; int rc = 0; if (*nr_local > PTLRPC_MAX_BRW_PAGES) { @@ -218,7 +219,6 @@ int ofd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, if (tgt_ses_req(tsi) == NULL) { /* echo client case */ LASSERT(oti != NULL); - lu_env_refill((struct lu_env *)env); info = ofd_info_init(env, exp); ofd_oti2info(info, oti); jobid = oti->oti_jobid; @@ -253,22 +253,21 @@ int ofd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, LASSERT(objcount == 1); LASSERT(obj->ioo_bufcnt > 0); - info->fti_fid = oa->o_oi.oi_fid; if (cmd == OBD_BRW_WRITE) { - rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oa->o_oi), + rc = ofd_auth_capa(exp, fid, ostid_seq(&oa->o_oi), capa, CAPA_OPC_OSS_WRITE); if (rc == 0) { la_from_obdo(&info->fti_attr, oa, OBD_MD_FLGETATTR); - rc = ofd_preprw_write(env, exp, ofd, &info->fti_fid, + rc = ofd_preprw_write(env, exp, ofd, fid, &info->fti_attr, oa, objcount, obj, rnb, nr_local, lnb, jobid); } } else if (cmd == OBD_BRW_READ) { - rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oa->o_oi), + rc = ofd_auth_capa(exp, fid, ostid_seq(&oa->o_oi), capa, CAPA_OPC_OSS_READ); if (rc == 0) { ofd_grant_prepare_read(env, exp, oa); - rc = ofd_preprw_read(env, exp, ofd, &info->fti_fid, + rc = ofd_preprw_read(env, exp, ofd, fid, &info->fti_attr, obj->ioo_bufcnt, rnb, nr_local, lnb, jobid); obdo_from_la(oa, &info->fti_attr, LA_ATIME); @@ -283,7 +282,7 @@ int ofd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, static int ofd_commitrw_read(const struct lu_env *env, struct ofd_device *ofd, - struct lu_fid *fid, int objcount, int niocount, + const struct lu_fid *fid, int objcount, int niocount, struct niobuf_local *lnb) { struct ofd_object *fo; @@ -441,7 +440,7 @@ static int ofd_soft_sync_cb_add(struct thandle *th, struct obd_export *exp) static int ofd_commitrw_write(const struct lu_env *env, struct obd_export *exp, - struct ofd_device *ofd, struct lu_fid *fid, + struct ofd_device *ofd, const struct lu_fid *fid, struct lu_attr *la, struct filter_fid *ff, int objcount, int niocount, struct niobuf_local *lnb, int old_rc) { @@ -577,11 +576,11 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, __u64 valid; struct ofd_device *ofd = ofd_exp(exp); struct filter_fid *ff = NULL; + const struct lu_fid *fid = &oa->o_oi.oi_fid; int rc = 0; LASSERT(npages > 0); - info->fti_fid = oa->o_oi.oi_fid; if (cmd == OBD_BRW_WRITE) { /* Don't update timestamps if this write is older than a * setattr which modifies the timestamps. b=10150 */ @@ -591,7 +590,7 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, * doesn't already exist so we can store the reservation handle * there. */ valid = OBD_MD_FLUID | OBD_MD_FLGID; - fmd = ofd_fmd_find(exp, &info->fti_fid); + fmd = ofd_fmd_find(exp, fid); if (!fmd || fmd->fmd_mactime_xid < info->fti_xid) valid |= OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME; @@ -603,9 +602,8 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, ofd_prepare_fidea(ff, oa); } - rc = ofd_commitrw_write(env, exp, ofd, &info->fti_fid, - &info->fti_attr, ff, objcount, npages, - lnb, old_rc); + rc = ofd_commitrw_write(env, exp, ofd, fid, &info->fti_attr, + ff, objcount, npages, lnb, old_rc); if (rc == 0) obdo_from_la(oa, &info->fti_attr, OFD_VALID_FLAGS | LA_GID | LA_UID); @@ -642,7 +640,7 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, if (oa && ns && ns->ns_lvbo && ns->ns_lvbo->lvbo_update) { struct ldlm_resource *rs = NULL; - ost_fid_build_resid(&info->fti_fid, &info->fti_resid); + ost_fid_build_resid(fid, &info->fti_resid); rs = ldlm_resource_get(ns, NULL, &info->fti_resid, LDLM_EXTENT, 0); if (rs != NULL) { @@ -650,7 +648,7 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, ldlm_resource_putref(rs); } } - rc = ofd_commitrw_read(env, ofd, &info->fti_fid, objcount, + rc = ofd_commitrw_read(env, ofd, fid, objcount, npages, lnb); if (old_rc) rc = old_rc; diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index 599d9f5..9137427 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -433,48 +433,14 @@ int ofd_obd_postrecov(struct obd_device *obd) RETURN(rc); } -static int ofd_adapt_sptlrpc_conf(const struct lu_env *env, - struct obd_device *obd, int initial) -{ - struct filter_obd *fo = &obd->u.filter; - struct sptlrpc_rule_set tmp_rset; - int rc; - - sptlrpc_rule_set_init(&tmp_rset); - rc = sptlrpc_conf_target_get_rules(obd, &tmp_rset, initial); - if (rc) { - CERROR("%s: failed get sptlrpc rules: rc = %d\n", - obd->obd_name, rc); - return rc; - } - - sptlrpc_target_update_exp_flavor(obd, &tmp_rset); - - write_lock(&fo->fo_sptlrpc_lock); - sptlrpc_rule_set_free(&fo->fo_sptlrpc_rset); - fo->fo_sptlrpc_rset = tmp_rset; - write_unlock(&fo->fo_sptlrpc_lock); - - return 0; -} - -static int ofd_set_mds_conn(struct obd_export *exp, void *val) -{ - int rc = 0; - - ENTRY; - - LCONSOLE_WARN("%s: received MDS connection from %s\n", - exp->exp_obd->obd_name, obd_export_nid2str(exp)); - RETURN(rc); -} - +/* This is not called from request handler, check ofd_set_info_hdl() instead + * this OBD functions is only used by class_notify_sptlrpc_conf() locally + * by direct obd_set_info_async() call */ static int ofd_set_info_async(const struct lu_env *env, struct obd_export *exp, __u32 keylen, void *key, __u32 vallen, void *val, struct ptlrpc_request_set *set) { - struct ofd_device *ofd; - int rc = 0; + int rc = 0; ENTRY; @@ -483,38 +449,26 @@ static int ofd_set_info_async(const struct lu_env *env, struct obd_export *exp, RETURN(-EINVAL); } - ofd = ofd_exp(exp); - - if (KEY_IS(KEY_CAPA_KEY)) { - rc = ofd_update_capa_key(ofd, val); - if (rc) - CERROR("%s: update capability key failed: rc = %d\n", - exp->exp_obd->obd_name, rc); - } else if (KEY_IS(KEY_SPTLRPC_CONF)) { - ofd_adapt_sptlrpc_conf(env, exp->exp_obd, 0); - } else if (KEY_IS(KEY_MDS_CONN)) { - rc = ofd_set_mds_conn(exp, val); - } else if (KEY_IS(KEY_GRANT_SHRINK)) { - struct ost_body *body = val; - - ofd_info_init(env, exp); - /** handle grant shrink, similar to a read request */ - ofd_grant_prepare_read(env, exp, &body->oa); + if (KEY_IS(KEY_SPTLRPC_CONF)) { + rc = tgt_adapt_sptlrpc_conf(class_exp2tgt(exp), 0); } else { CERROR("%s: Unsupported key %s\n", exp->exp_obd->obd_name, (char*)key); rc = -EOPNOTSUPP; } - RETURN(rc); } +/* used by nrs_orr_range_fill_physical() in ptlrpc, see LU-3239 */ static int ofd_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 ofd_device *ofd; - int rc = 0; + struct ofd_thread_info *info; + struct ofd_device *ofd; + struct ll_fiemap_info_key *fm_key = key; + struct ll_user_fiemap *fiemap = val; + int rc = 0; ENTRY; @@ -523,130 +477,22 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp, RETURN(-EINVAL); } - /* Because ofd_get_info might be called from - * handle_request_in as well(see LU-3239), where env might - * not be initilaized correctly, and le_ses might be in - * an un-initialized state, so only refill le_ctx here */ - rc = lu_env_refill((struct lu_env *)env); - if (rc != 0) - RETURN(rc); - ofd = ofd_exp(exp); - if (KEY_IS(KEY_BLOCKSIZE)) { - __u32 *blocksize = val; - if (blocksize) { - if (*vallen < sizeof(*blocksize)) - GOTO(out, rc = -EOVERFLOW); - *blocksize = 1 << ofd->ofd_dt_conf.ddp_block_shift; - } - *vallen = sizeof(*blocksize); - } else if (KEY_IS(KEY_BLOCKSIZE_BITS)) { - __u32 *blocksize_bits = val; - if (blocksize_bits) { - if (*vallen < sizeof(*blocksize_bits)) - GOTO(out, rc = -EOVERFLOW); - *blocksize_bits = ofd->ofd_dt_conf.ddp_block_shift; - } - *vallen = sizeof(*blocksize_bits); - } else if (KEY_IS(KEY_LAST_ID)) { - obd_id *last_id = val; - struct ofd_seq *oseq; - - if (val == NULL) { - *vallen = sizeof(obd_id); - GOTO(out, rc = 0); - } - ofd_info_init(env, exp); - oseq = ofd_seq_load(env, ofd, - (obd_seq)exp->exp_filter_data.fed_group); - LASSERT(!IS_ERR(oseq)); - if (last_id) { - if (*vallen < sizeof(*last_id)) { - ofd_seq_put(env, oseq); - GOTO(out, rc = -EOVERFLOW); - } - *last_id = ofd_seq_last_oid(oseq); - } - ofd_seq_put(env, oseq); - *vallen = sizeof(*last_id); - } else if (KEY_IS(KEY_FIEMAP)) { - struct ofd_device *ofd = ofd_exp(exp); - struct ofd_object *fo; - struct ll_fiemap_info_key *fm_key = key; - struct lu_fid fid; - - if (val == NULL) { - *vallen = fiemap_count_to_size( - fm_key->fiemap.fm_extent_count); - GOTO(out, rc = 0); - } + if (KEY_IS(KEY_FIEMAP)) { + info = ofd_info_init(env, exp); - rc = ostid_to_fid(&fid, &fm_key->oa.o_oi, + rc = ostid_to_fid(&info->fti_fid, &fm_key->oa.o_oi, ofd->ofd_lut.lut_lsd.lsd_osd_index); if (rc != 0) - GOTO(out, rc); - CDEBUG(D_INODE, "get FIEMAP of object "DFID"\n", - PFID(&fid)); - - fo = ofd_object_find(env, ofd, &fid); - if (IS_ERR(fo)) { - CERROR("%s: error finding object "DFID"\n", - exp->exp_obd->obd_name, PFID(&fid)); - rc = PTR_ERR(fo); - } else { - struct ll_user_fiemap *fiemap = val; - - ofd_read_lock(env, fo); - if (ofd_object_exists(fo)) { - *fiemap = fm_key->fiemap; - rc = dt_fiemap_get(env, - ofd_object_child(fo), - fiemap); - } else { - rc = -ENOENT; - } - ofd_read_unlock(env, fo); - ofd_object_put(env, fo); - } - } else if (KEY_IS(KEY_LAST_FID)) { - struct ofd_device *ofd = ofd_exp(exp); - struct ofd_seq *oseq; - struct lu_fid *fid = val; - int rc; - - if (fid == NULL) { - *vallen = sizeof(struct lu_fid); - GOTO(out, rc = 0); - } - - if (*vallen < sizeof(*fid)) - GOTO(out, rc = -EOVERFLOW); - - ofd_info_init(env, exp); - - fid_le_to_cpu(fid, fid); - - oseq = ofd_seq_load(env, ofd, - ostid_seq((struct ost_id *)fid)); - if (IS_ERR(oseq)) - GOTO(out, rc = PTR_ERR(oseq)); + RETURN(rc); - rc = ostid_to_fid(fid, &oseq->os_oi, - ofd->ofd_lut.lut_lsd.lsd_osd_index); - if (rc != 0) - GOTO(out_put, rc); - - CDEBUG(D_HA, "%s: LAST FID is "DFID"\n", ofd_name(ofd), - PFID(fid)); - *vallen = sizeof(*fid); -out_put: - ofd_seq_put(env, oseq); + rc = ofd_fiemap_get(env, ofd, &info->fti_fid, fiemap); } else { - CERROR("Not supported key %s\n", (char*)key); + CERROR("%s: not supported key %s\n", ofd_name(ofd), (char*)key); rc = -EOPNOTSUPP; } -out: + RETURN(rc); } @@ -803,8 +649,9 @@ out: return rc; } -int ofd_setattr(const struct lu_env *env, struct obd_export *exp, - struct obd_info *oinfo, struct obd_trans_info *oti) +/* needed by echo client only for now, RPC handler uses ofd_setattr_hdl() */ +int ofd_echo_setattr(const struct lu_env *env, struct obd_export *exp, + struct obd_info *oinfo, struct obd_trans_info *oti) { struct ofd_thread_info *info; struct ofd_device *ofd = ofd_exp(exp); @@ -812,48 +659,43 @@ int ofd_setattr(const struct lu_env *env, struct obd_export *exp, struct ldlm_resource *res; struct ofd_object *fo; struct obdo *oa = oinfo->oi_oa; + struct lu_fid *fid = &oa->o_oi.oi_fid; struct filter_fid *ff = NULL; int rc = 0; ENTRY; info = ofd_info_init(env, exp); - ofd_oti2info(info, oti); - info->fti_fid = oinfo->oi_oa->o_oi.oi_fid; - ost_fid_build_resid(&info->fti_fid, &info->fti_resid); - rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oa->o_oi), - oinfo_capa(oinfo), CAPA_OPC_META_WRITE); - if (rc) - GOTO(out, rc); + ost_fid_build_resid(fid, &info->fti_resid); /* This would be very bad - accidentally truncating a file when * changing the time or similar - bug 12203. */ - if (oinfo->oi_oa->o_valid & OBD_MD_FLSIZE && + if (oa->o_valid & OBD_MD_FLSIZE && oinfo->oi_policy.l_extent.end != OBD_OBJECT_EOF) { static char mdsinum[48]; - if (oinfo->oi_oa->o_valid & OBD_MD_FLFID) + if (oa->o_valid & OBD_MD_FLFID) snprintf(mdsinum, sizeof(mdsinum) - 1, - "of parent "DFID, oinfo->oi_oa->o_parent_seq, - oinfo->oi_oa->o_parent_oid, 0); + "of parent "DFID, oa->o_parent_seq, + oa->o_parent_oid, 0); else mdsinum[0] = '\0'; CERROR("%s: setattr from %s trying to truncate object "DFID - " %s\n", exp->exp_obd->obd_name, - obd_export_nid2str(exp), PFID(&info->fti_fid), mdsinum); + " %s\n", ofd_name(ofd), obd_export_nid2str(exp), + PFID(fid), mdsinum); GOTO(out, rc = -EPERM); } - fo = ofd_object_find(env, ofd, &info->fti_fid); + fo = ofd_object_find_exists(env, ofd, fid); if (IS_ERR(fo)) { CERROR("%s: can't find object "DFID"\n", - exp->exp_obd->obd_name, PFID(&info->fti_fid)); + ofd_name(ofd), PFID(fid)); GOTO(out, rc = PTR_ERR(fo)); } - la_from_obdo(&info->fti_attr, oinfo->oi_oa, oinfo->oi_oa->o_valid); + la_from_obdo(&info->fti_attr, oa, oa->o_valid); info->fti_attr.la_valid &= ~LA_TYPE; if (oa->o_valid & OBD_MD_FLFID) { @@ -866,9 +708,7 @@ int ofd_setattr(const struct lu_env *env, struct obd_export *exp, if (rc) GOTO(out_unlock, rc); - ofd_info2oti(info, oti); - - ofd_counter_incr(exp, LPROC_OFD_STATS_SETATTR, oti->oti_jobid, 1); + ofd_counter_incr(exp, LPROC_OFD_STATS_SETATTR, NULL, 1); EXIT; out_unlock: ofd_object_put(env, fo); @@ -889,90 +729,6 @@ out: return rc; } -static int ofd_punch(const struct lu_env *env, struct obd_export *exp, - struct obd_info *oinfo, struct obd_trans_info *oti, - struct ptlrpc_request_set *rqset) -{ - struct ofd_thread_info *info; - struct ofd_device *ofd = ofd_exp(exp); - struct ldlm_namespace *ns = ofd->ofd_namespace; - struct ldlm_resource *res; - struct ofd_object *fo; - struct filter_fid *ff = NULL; - int rc = 0; - - ENTRY; - - info = ofd_info_init(env, exp); - ofd_oti2info(info, oti); - - info->fti_fid = oinfo->oi_oa->o_oi.oi_fid; - ost_fid_build_resid(&info->fti_fid, &info->fti_resid); - - CDEBUG(D_INODE, "calling punch for object "DFID", valid = "LPX64 - ", start = "LPD64", end = "LPD64"\n", PFID(&info->fti_fid), - oinfo->oi_oa->o_valid, oinfo->oi_policy.l_extent.start, - oinfo->oi_policy.l_extent.end); - - rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oinfo->oi_oa->o_oi), - oinfo_capa(oinfo), CAPA_OPC_OSS_TRUNC); - if (rc) - GOTO(out_env, rc); - - fo = ofd_object_find(env, ofd, &info->fti_fid); - if (IS_ERR(fo)) { - CERROR("%s: error finding object "DFID": rc = %ld\n", - exp->exp_obd->obd_name, PFID(&info->fti_fid), - PTR_ERR(fo)); - GOTO(out_env, rc = PTR_ERR(fo)); - } - - LASSERT(oinfo->oi_policy.l_extent.end == OBD_OBJECT_EOF); - if (oinfo->oi_policy.l_extent.end == OBD_OBJECT_EOF) { - /* Truncate case */ - oinfo->oi_oa->o_size = oinfo->oi_policy.l_extent.start; - } else if (oinfo->oi_policy.l_extent.end >= oinfo->oi_oa->o_size) { - oinfo->oi_oa->o_size = oinfo->oi_policy.l_extent.end; - } - - la_from_obdo(&info->fti_attr, oinfo->oi_oa, - OBD_MD_FLMTIME | OBD_MD_FLATIME | OBD_MD_FLCTIME); - info->fti_attr.la_valid &= ~LA_TYPE; - info->fti_attr.la_size = oinfo->oi_policy.l_extent.start; - info->fti_attr.la_valid |= LA_SIZE; - - if (oinfo->oi_oa->o_valid & OBD_MD_FLFID) { - ff = &info->fti_mds_fid; - ofd_prepare_fidea(ff, oinfo->oi_oa); - } - - rc = ofd_object_punch(env, fo, oinfo->oi_policy.l_extent.start, - oinfo->oi_policy.l_extent.end, &info->fti_attr, - ff); - if (rc) - GOTO(out, rc); - - res = ldlm_resource_get(ns, NULL, &info->fti_resid, LDLM_EXTENT, 0); - if (res != NULL) { - ldlm_res_lvbo_update(res, NULL, 0); - ldlm_resource_putref(res); - } - - oinfo->oi_oa->o_valid = OBD_MD_FLID; - /* Quota release needs uid/gid info */ - rc = ofd_attr_get(env, fo, &info->fti_attr); - obdo_from_la(oinfo->oi_oa, &info->fti_attr, - OFD_VALID_FLAGS | LA_UID | LA_GID); - ofd_info2oti(info, oti); - - ofd_counter_incr(exp, LPROC_OFD_STATS_PUNCH, oti->oti_jobid, 1); - EXIT; -out: - ofd_object_put(env, fo); -out_env: - return rc; -} - int ofd_destroy_by_fid(const struct lu_env *env, struct ofd_device *ofd, const struct lu_fid *fid, int orphan) { @@ -987,11 +743,9 @@ int ofd_destroy_by_fid(const struct lu_env *env, struct ofd_device *ofd, ENTRY; - fo = ofd_object_find(env, ofd, fid); + fo = ofd_object_find_exists(env, ofd, fid); if (IS_ERR(fo)) RETURN(PTR_ERR(fo)); - if (!ofd_object_exists(fo)) - GOTO(out, rc = -ENOENT); /* Tell the clients that the object is gone now and that they should * throw away any cached pages. */ @@ -1009,166 +763,61 @@ int ofd_destroy_by_fid(const struct lu_env *env, struct ofd_device *ofd, rc = ofd_object_destroy(env, fo, orphan); EXIT; -out: + ofd_object_put(env, fo); RETURN(rc); } -int ofd_destroy(const struct lu_env *env, struct obd_export *exp, - struct obdo *oa, struct lov_stripe_md *md, - struct obd_trans_info *oti, struct obd_export *md_exp, - void *capa) +/* needed by echo client only for now, RPC handler uses ofd_destroy_hdl() */ +int ofd_echo_destroy(const struct lu_env *env, struct obd_export *exp, + struct obdo *oa, struct lov_stripe_md *md, + struct obd_trans_info *oti, struct obd_export *md_exp, + void *capa) { struct ofd_device *ofd = ofd_exp(exp); - struct ofd_thread_info *info; - struct lu_fid *fid; - obd_id oid; - obd_count count; + struct lu_fid *fid = &oa->o_oi.oi_fid; int rc = 0; ENTRY; - info = ofd_info_init(env, exp); - ofd_oti2info(info, oti); - fid = &info->fti_fid; - - if (!(oa->o_valid & OBD_MD_FLGROUP)) - ostid_set_seq_mdt0(&oa->o_oi); - - *fid = oa->o_oi.oi_fid; - oid = ostid_id(&oa->o_oi); - LASSERT(oid != 0); - - /* check that o_misc makes sense */ - if (oa->o_valid & OBD_MD_FLOBJCOUNT) - count = oa->o_misc; - else - count = 1; /* default case - single destroy */ - - CDEBUG(D_INODE, "%s: Destroy object "DOSTID" count %d\n", ofd_name(ofd), - POSTID(&oa->o_oi), count); - - while (count > 0) { - int lrc; - - lrc = ofd_destroy_by_fid(env, ofd, fid, 0); - if (lrc == -ENOENT) { - CDEBUG(D_INODE, - "%s: destroying non-existent object "DFID"\n", - ofd_obd(ofd)->obd_name, PFID(fid)); - /* rewrite rc with -ENOENT only if it is 0 */ - if (rc == 0) - rc = lrc; - } else if (lrc != 0) { - CERROR("%s: error destroying object "DFID": %d\n", - ofd_obd(ofd)->obd_name, PFID(fid), - rc); - rc = lrc; - } - - count--; - oid++; - lrc = fid_set_id(fid, oid); - if (unlikely(lrc != 0 && count > 0)) - GOTO(out, rc = lrc); - } - - GOTO(out, rc); - -out: - ofd_info2oti(info, oti); - fid_to_ostid(fid, &oa->o_oi); - return rc; -} - -int ofd_orphans_destroy(const struct lu_env *env, struct obd_export *exp, - struct ofd_device *ofd, struct obdo *oa) -{ - struct ofd_thread_info *info = ofd_info(env); - struct lu_fid *fid = &info->fti_fid; - struct ost_id *oi = &oa->o_oi; - struct ofd_seq *oseq; - obd_seq seq = ostid_seq(oi); - obd_id end_id = ostid_id(oi); - obd_id last; - obd_id oid; - int skip_orphan; - int rc = 0; - ENTRY; - - oseq = ofd_seq_get(ofd, seq); - if (oseq == NULL) { - CERROR("%s: Can not find seq for "DOSTID"\n", - ofd_name(ofd), POSTID(oi)); - RETURN(-EINVAL); - } - - *fid = oi->oi_fid; - last = ofd_seq_last_oid(oseq); - oid = last; - - LASSERT(exp != NULL); - skip_orphan = !!(exp_connect_flags(exp) & OBD_CONNECT_SKIP_ORPHAN); - - LCONSOLE(D_INFO, "%s: deleting orphan objects from "DOSTID - " to "DOSTID"\n", ofd_name(ofd), seq, end_id + 1, seq, last); - - while (oid > end_id) { - rc = fid_set_id(fid, oid); - if (unlikely(rc != 0)) - GOTO(out_put, rc); - - rc = ofd_destroy_by_fid(env, ofd, fid, 1); - if (rc != 0 && rc != -ENOENT) /* this is pretty fatal... */ - CEMERG("%s: error destroying precreated id "DFID - ": rc = %d\n", ofd_name(ofd), PFID(fid), rc); - - oid--; - if (!skip_orphan) { - ofd_seq_last_oid_set(oseq, oid); - /* update last_id on disk periodically so that if we - * restart * we don't need to re-scan all of the just - * deleted objects. */ - if ((oid & 511) == 0) - ofd_seq_last_oid_write(env, ofd, oseq); - } - } + ofd_info_init(env, exp); - CDEBUG(D_HA, "%s: after destroy: set last_id to "DOSTID"\n", - ofd_obd(ofd)->obd_name, seq, oid); + CDEBUG(D_HA, "%s: Destroy object "DFID"\n", ofd_name(ofd), PFID(fid)); - if (!skip_orphan) { - rc = ofd_seq_last_oid_write(env, ofd, oseq); - } else { - /* don't reuse orphan object, return last used objid */ - ostid_set_id(oi, last); - rc = 0; + rc = ofd_destroy_by_fid(env, ofd, fid, 0); + if (rc == -ENOENT) { + CDEBUG(D_INODE, "%s: destroying non-existent object "DFID"\n", + ofd_name(ofd), PFID(fid)); + GOTO(out, rc); + } else if (rc != 0) { + CERROR("%s: error destroying object "DFID": %d\n", + ofd_name(ofd), PFID(fid), rc); + GOTO(out, rc); } - - GOTO(out_put, rc); - -out_put: - ofd_seq_put(env, oseq); + EXIT; +out: return rc; } -int ofd_create(const struct lu_env *env, struct obd_export *exp, - struct obdo *oa, struct lov_stripe_md **ea, - struct obd_trans_info *oti) +/* needed by echo client only for now, RPC handler uses ofd_create_hdl() + * It is much simpler and just create objects */ +int ofd_echo_create(const struct lu_env *env, struct obd_export *exp, + struct obdo *oa, struct lov_stripe_md **ea, + struct obd_trans_info *oti) { struct ofd_device *ofd = ofd_exp(exp); struct ofd_thread_info *info; - obd_seq seq = ostid_seq(&oa->o_oi); + obd_seq seq = ostid_seq(&oa->o_oi); struct ofd_seq *oseq; - int rc = 0, diff; - int sync_trans = 0; + int rc = 0, diff = 1; + obd_id next_id; + int count; ENTRY; info = ofd_info_init(env, exp); - ofd_oti2info(info, oti); - LASSERT(ostid_seq(&oa->o_oi) >= FID_SEQ_OST_MDT0); + LASSERT(seq == FID_SEQ_ECHO); LASSERT(oa->o_valid & OBD_MD_FLGROUP); CDEBUG(D_INFO, "ofd_create("DOSTID")\n", POSTID(&oa->o_oi)); @@ -1180,164 +829,31 @@ int ofd_create(const struct lu_env *env, struct obd_export *exp, RETURN(-EINVAL); } - if ((oa->o_valid & OBD_MD_FLFLAGS) && - (oa->o_flags & OBD_FL_RECREATE_OBJS)) { - if (!ofd_obd(ofd)->obd_recovering || - ostid_id(&oa->o_oi) > ofd_seq_last_oid(oseq)) { - CERROR("recreate objid "DOSTID" > last id "LPU64"\n", - POSTID(&oa->o_oi), ofd_seq_last_oid(oseq)); - GOTO(out_nolock, rc = -EINVAL); - } - /* do nothing because we create objects during first write */ - GOTO(out_nolock, rc = 0); - } - /* former ofd_handle_precreate */ - if ((oa->o_valid & OBD_MD_FLFLAGS) && - (oa->o_flags & OBD_FL_DELORPHAN)) { - /* destroy orphans */ - if (oti->oti_conn_cnt < exp->exp_conn_cnt) { - CERROR("%s: dropping old orphan cleanup request\n", - ofd_name(ofd)); - GOTO(out_nolock, rc = 0); - } - /* This causes inflight precreates to abort and drop lock */ - oseq->os_destroys_in_progress = 1; - mutex_lock(&oseq->os_create_lock); - if (!oseq->os_destroys_in_progress) { - CERROR("%s:["LPU64"] destroys_in_progress already" - " cleared\n", exp->exp_obd->obd_name, - ostid_seq(&oa->o_oi)); - ostid_set_id(&oa->o_oi, ofd_seq_last_oid(oseq)); - GOTO(out, rc = 0); - } - diff = ostid_id(&oa->o_oi) - ofd_seq_last_oid(oseq); - CDEBUG(D_HA, "ofd_last_id() = "LPU64" -> diff = %d\n", - ofd_seq_last_oid(oseq), diff); - if (-diff > OST_MAX_PRECREATE) { - /* FIXME: should reset precreate_next_id on MDS */ - rc = 0; - } else if (diff < 0) { - rc = ofd_orphans_destroy(env, exp, ofd, oa); - oseq->os_destroys_in_progress = 0; - } else { - /* XXX: Used by MDS for the first time! */ - oseq->os_destroys_in_progress = 0; - } - } else { - mutex_lock(&oseq->os_create_lock); - if (oti->oti_conn_cnt < exp->exp_conn_cnt) { - CERROR("%s: dropping old precreate request\n", - ofd_obd(ofd)->obd_name); - GOTO(out, rc = 0); - } - /* only precreate if seq is 0, IDIF or normal and also o_id - * must be specfied */ - if ((!fid_seq_is_mdt(ostid_seq(&oa->o_oi)) && - !fid_seq_is_norm(ostid_seq(&oa->o_oi)) && - !fid_seq_is_idif(ostid_seq(&oa->o_oi))) || - ostid_id(&oa->o_oi) == 0) { - diff = 1; /* shouldn't we create this right now? */ - } else { - diff = ostid_id(&oa->o_oi) - ofd_seq_last_oid(oseq); - /* Do sync create if the seq is about to used up */ - if (fid_seq_is_idif(ostid_seq(&oa->o_oi)) || - fid_seq_is_mdt0(ostid_seq(&oa->o_oi))) { - if (unlikely(ostid_id(&oa->o_oi) >= IDIF_MAX_OID - 1)) - sync_trans = 1; - } else if (fid_seq_is_norm(ostid_seq(&oa->o_oi))) { - if (unlikely(ostid_id(&oa->o_oi) >= - LUSTRE_DATA_SEQ_MAX_WIDTH - 1)) - sync_trans = 1; - } else { - CERROR("%s : invalid o_seq "DOSTID": rc = %d\n", - ofd_name(ofd), POSTID(&oa->o_oi), -EINVAL); - GOTO(out, rc = -EINVAL); - } - } + mutex_lock(&oseq->os_create_lock); + rc = ofd_grant_create(env, ofd_obd(ofd)->obd_self_export, &diff); + if (rc < 0) { + CDEBUG(D_HA, "%s: failed to acquire grant space for " + "precreate (%d): rc = %d\n", ofd_name(ofd), diff, rc); + diff = 0; + GOTO(out, rc); } - if (diff > 0) { - cfs_time_t enough_time = cfs_time_shift(DISK_TIMEOUT); - obd_id next_id; - int created = 0; - int count; - - if (!(oa->o_valid & OBD_MD_FLFLAGS) || - !(oa->o_flags & OBD_FL_DELORPHAN)) { - /* don't enforce grant during orphan recovery */ - rc = ofd_grant_create(env, - ofd_obd(ofd)->obd_self_export, - &diff); - if (rc) { - CDEBUG(D_HA, "%s: failed to acquire grant " - "space for precreate (%d): rc = %d\n", - ofd_name(ofd), diff, rc); - diff = 0; - } - } - /* This can happen if a new OST is formatted and installed - * in place of an old one at the same index. Instead of - * precreating potentially millions of deleted old objects - * (possibly filling the OST), only precreate the last batch. - * LFSCK will eventually clean up any orphans. LU-14 */ - if (diff > 5 * OST_MAX_PRECREATE) { - diff = OST_MAX_PRECREATE / 2; - LCONSOLE_WARN("%s: precreate FID "DOSTID" is over %u " - "larger than the LAST_ID "DOSTID", only " - "precreating the last %u objects.\n", - ofd_name(ofd), POSTID(&oa->o_oi), - 5 * OST_MAX_PRECREATE, - POSTID(&oseq->os_oi), diff); - ofd_seq_last_oid_set(oseq, ostid_id(&oa->o_oi) - diff); - } - - while (diff > 0) { - next_id = ofd_seq_last_oid(oseq) + 1; - count = ofd_precreate_batch(ofd, diff); - - CDEBUG(D_HA, "%s: reserve %d objects in group "LPX64 - " at "LPU64"\n", ofd_obd(ofd)->obd_name, - count, ostid_seq(&oa->o_oi), next_id); - - if (cfs_time_after(jiffies, enough_time)) { - LCONSOLE_WARN("%s: Slow creates, %d/%d objects" - " created at a rate of %d/s\n", - ofd_obd(ofd)->obd_name, - created, diff + created, - created / DISK_TIMEOUT); - break; - } - - rc = ofd_precreate_objects(env, ofd, next_id, - oseq, count, sync_trans); - if (rc > 0) { - created += rc; - diff -= rc; - } else if (rc < 0) { - break; - } - } - if (created > 0) - /* some objects got created, we can return - * them, even if last creation failed */ - rc = 0; - else - CERROR("%s: unable to precreate: rc = %d\n", - ofd_name(ofd), rc); + next_id = ofd_seq_last_oid(oseq) + 1; + count = ofd_precreate_batch(ofd, diff); + rc = ofd_precreate_objects(env, ofd, next_id, oseq, count, 0); + if (rc < 0) { + CERROR("%s: unable to precreate: rc = %d\n", + ofd_name(ofd), rc); + } else { ostid_set_id(&oa->o_oi, ofd_seq_last_oid(oseq)); oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP; - - if (!(oa->o_valid & OBD_MD_FLFLAGS) || - !(oa->o_flags & OBD_FL_DELORPHAN)) - ofd_grant_commit(env, ofd_obd(ofd)->obd_self_export, - rc); + rc = 0; } - ofd_info2oti(info, oti); + ofd_grant_commit(env, ofd_obd(ofd)->obd_self_export, rc); out: mutex_unlock(&oseq->os_create_lock); -out_nolock: if (rc == 0 && ea != NULL) { struct lov_stripe_md *lsm = *ea; @@ -1347,11 +863,13 @@ out_nolock: RETURN(rc); } -int ofd_getattr(const struct lu_env *env, struct obd_export *exp, - struct obd_info *oinfo) +/* needed by echo client only for now, RPC handler uses ofd_getattr_hdl() */ +int ofd_echo_getattr(const struct lu_env *env, struct obd_export *exp, + struct obd_info *oinfo) { struct ofd_device *ofd = ofd_exp(exp); struct ofd_thread_info *info; + struct lu_fid *fid = &oinfo->oi_oa->o_oi.oi_fid; struct ofd_object *fo; int rc = 0; @@ -1359,17 +877,9 @@ int ofd_getattr(const struct lu_env *env, struct obd_export *exp, info = ofd_info_init(env, exp); - info->fti_fid = oinfo->oi_oa->o_oi.oi_fid; - rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oinfo->oi_oa->o_oi), - oinfo_capa(oinfo), CAPA_OPC_META_READ); - if (rc) - GOTO(out, rc); - - fo = ofd_object_find(env, ofd, &info->fti_fid); + fo = ofd_object_find_exists(env, ofd, fid); if (IS_ERR(fo)) GOTO(out, rc = PTR_ERR(fo)); - if (!ofd_object_exists(fo)) - GOTO(out_put, rc = -ENOENT); LASSERT(fo != NULL); rc = ofd_attr_get(env, fo, &info->fti_attr); @@ -1388,66 +898,11 @@ int ofd_getattr(const struct lu_env *env, struct obd_export *exp, } } -out_put: ofd_object_put(env, fo); out: RETURN(rc); } -static int ofd_sync(const struct lu_env *env, struct obd_export *exp, - struct obd_info *oinfo, obd_size start, obd_size end, - struct ptlrpc_request_set *set) -{ - struct ofd_device *ofd = ofd_exp(exp); - struct ofd_thread_info *info; - struct ofd_object *fo; - int rc = 0; - - ENTRY; - - /* if no objid is specified, it means "sync whole filesystem" */ - if (oinfo->oi_oa == NULL || !(oinfo->oi_oa->o_valid & OBD_MD_FLID)) { - rc = dt_sync(env, ofd->ofd_osd); - GOTO(out, rc); - } - - info = ofd_info_init(env, exp); - info->fti_fid = oinfo->oi_oa->o_oi.oi_fid; - rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oinfo->oi_oa->o_oi), - oinfo_capa(oinfo), CAPA_OPC_OSS_TRUNC); - if (rc) - GOTO(out, rc); - - fo = ofd_object_find(env, ofd, &info->fti_fid); - if (IS_ERR(fo)) { - CERROR("%s: error finding object "DFID": rc = %ld\n", - exp->exp_obd->obd_name, PFID(&info->fti_fid), - PTR_ERR(fo)); - GOTO(out, rc = PTR_ERR(fo)); - } - - if (!ofd_object_exists(fo)) - GOTO(put, rc = -ENOENT); - - if (dt_version_get(env, ofd_object_child(fo)) > - ofd_obd(ofd)->obd_last_committed) { - rc = dt_object_sync(env, ofd_object_child(fo)); - if (rc) - GOTO(put, rc); - } - - oinfo->oi_oa->o_valid = OBD_MD_FLID; - rc = ofd_attr_get(env, fo, &info->fti_attr); - obdo_from_la(oinfo->oi_oa, &info->fti_attr, OFD_VALID_FLAGS); - - ofd_counter_incr(exp, LPROC_OFD_STATS_SYNC, oinfo->oi_jobid, 1); - EXIT; -put: - ofd_object_put(env, fo); -out: - return rc; -} - static int ofd_ioc_get_obj_version(const struct lu_env *env, struct ofd_device *ofd, void *karg) { @@ -1678,23 +1133,20 @@ struct obd_ops ofd_obd_ops = { .o_connect = ofd_obd_connect, .o_reconnect = ofd_obd_reconnect, .o_disconnect = ofd_obd_disconnect, - .o_set_info_async = ofd_set_info_async, - .o_get_info = ofd_get_info, - .o_create = ofd_create, - .o_statfs = ofd_statfs, - .o_setattr = ofd_setattr, + .o_create = ofd_echo_create, + .o_setattr = ofd_echo_setattr, .o_preprw = ofd_preprw, .o_commitrw = ofd_commitrw, - .o_destroy = ofd_destroy, + .o_destroy = ofd_echo_destroy, .o_init_export = ofd_init_export, .o_destroy_export = ofd_destroy_export, .o_postrecov = ofd_obd_postrecov, - .o_punch = ofd_punch, - .o_getattr = ofd_getattr, - .o_sync = ofd_sync, + .o_getattr = ofd_echo_getattr, .o_iocontrol = ofd_iocontrol, .o_precleanup = ofd_precleanup, .o_ping = ofd_ping, .o_health_check = ofd_health_check, .o_quotactl = ofd_quotactl, + .o_set_info_async = ofd_set_info_async, + .o_get_info = ofd_get_info, }; diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index 5a837a6..6f65b62 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -148,7 +148,7 @@ int tgt_validate_obdo(struct tgt_session_info *tsi, struct obdo *oa) oi->oi_fid.f_oid = id ?: 1; oi->oi_fid.f_ver = 0; } else { - struct lu_fid *fid = &tsi->tsi_fid2; + struct tgt_thread_info *tti = tgt_th_info(tsi->tsi_env); if (unlikely((oa->o_valid & OBD_MD_FLID) && id == 0)) GOTO(out, rc = -EPROTO); @@ -165,11 +165,12 @@ int tgt_validate_obdo(struct tgt_session_info *tsi, struct obdo *oa) fid_seq_is_norm(seq) || fid_seq_is_echo(seq)))) GOTO(out, rc = -EPROTO); - rc = ostid_to_fid(fid, oi, tsi->tsi_tgt->lut_lsd.lsd_osd_index); + rc = ostid_to_fid(&tti->tti_fid1, oi, + tsi->tsi_tgt->lut_lsd.lsd_osd_index); if (unlikely(rc != 0)) GOTO(out, rc); - oi->oi_fid = *fid; + oi->oi_fid = tti->tti_fid1; } RETURN(0); -- 1.8.3.1