X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fofd%2Fofd_obd.c;h=8bcbd06b09ea8ca9c0c08038e6cb07efdd079086;hb=a4e8e2f71fb64e293cbf8db07f4608646fd7acd4;hp=aa1b8f1a9eacf94e5d2e708086d73acb3a71b175;hpb=da430ce6173149b4bafcad71ea1d650d54ea39c0;p=fs%2Flustre-release.git diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index aa1b8f1..8bcbd06 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -46,6 +46,7 @@ #include "ofd_internal.h" #include #include +#include static int ofd_export_stats_init(struct ofd_device *ofd, struct obd_export *exp, void *client_nid) @@ -57,6 +58,8 @@ static int ofd_export_stats_init(struct ofd_device *ofd, ENTRY; + LASSERT(obd->obd_uses_nid_stats); + if (obd_uuid_equals(&exp->exp_client_uuid, &obd->obd_uuid)) /* Self-export gets no proc entry */ RETURN(0); @@ -76,9 +79,7 @@ static int ofd_export_stats_init(struct ofd_device *ofd, stats = exp->exp_nid_stats; LASSERT(stats != NULL); - num_stats = (sizeof(*obd->obd_type->typ_dt_ops) / sizeof(void *)) + - LPROC_OFD_LAST - 1; - + num_stats = NUM_OBD_STATS + LPROC_OFD_LAST; stats->nid_stats = lprocfs_alloc_stats(num_stats, LPROCFS_STATS_FLAG_NOPERCPU); if (stats->nid_stats == NULL) @@ -136,7 +137,6 @@ static int ofd_parse_connect_data(const struct lu_env *env, fed->fed_group = data->ocd_group; data->ocd_connect_flags &= OST_CONNECT_SUPPORTED; - exp->exp_connect_data = *data; data->ocd_version = LUSTRE_VERSION_CODE; /* Kindly make sure the SKIP_ORPHAN flag is from MDS. */ @@ -155,7 +155,7 @@ static int ofd_parse_connect_data(const struct lu_env *env, data->ocd_grant_extent = ofd->ofd_dt_conf.ddp_grant_frag >> 10; } - if (exp_connect_flags(exp) & OBD_CONNECT_GRANT) + if (data->ocd_connect_flags & OBD_CONNECT_GRANT) data->ocd_grant = ofd_grant_connect(env, exp, data->ocd_grant, new_connection); @@ -315,7 +315,7 @@ static int ofd_obd_connect(const struct lu_env *env, struct obd_export **_exp, } CDEBUG(D_HA, "%s: get connection from MDS %d\n", obd->obd_name, - data->ocd_group); + data ? data->ocd_group : -1); out: if (rc != 0) { @@ -587,10 +587,10 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp, ofd_seq_put(env, oseq); *vallen = sizeof(*last_id); } else if (KEY_IS(KEY_FIEMAP)) { - struct ofd_thread_info *info; 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( @@ -598,17 +598,16 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp, GOTO(out, rc = 0); } - info = ofd_info_init(env, exp); - rc = ostid_to_fid(&info->fti_fid, &fm_key->oa.o_oi, 0); + rc = ostid_to_fid(&fid, &fm_key->oa.o_oi, 0); if (rc != 0) GOTO(out, rc); CDEBUG(D_INODE, "get FIEMAP of object "DFID"\n", - PFID(&info->fti_fid)); + PFID(&fid)); - fo = ofd_object_find(env, ofd, &info->fti_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(&info->fti_fid)); + exp->exp_obd->obd_name, PFID(&fid)); rc = PTR_ERR(fo); } else { struct ll_user_fiemap *fiemap = val; @@ -888,18 +887,6 @@ int ofd_setattr(const struct lu_env *env, struct obd_export *exp, if (rc) GOTO(out_unlock, 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_SETATTR, oti->oti_jobid, 1); @@ -907,6 +894,19 @@ int ofd_setattr(const struct lu_env *env, struct obd_export *exp, out_unlock: ofd_object_put(env, fo); out: + if (rc == 0) { + /* we do not call this before to avoid lu_object_find() in + * ->lvbo_update() holding another reference on the object. + * otherwise concurrent destroy can make the object unavailable + * for 2nd lu_object_find() waiting for the first reference + * to go... deadlock! */ + 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); + } + } + return rc; } @@ -1002,7 +1002,8 @@ static int ofd_destroy_by_fid(const struct lu_env *env, { struct ofd_thread_info *info = ofd_info(env); struct lustre_handle lockh; - __u64 flags = LDLM_AST_DISCARD_DATA, rc = 0; + __u64 flags = LDLM_FL_AST_DISCARD_DATA; + __u64 rc = 0; ldlm_policy_data_t policy = { .l_extent = { 0, OBD_OBJECT_EOF } }; @@ -1304,6 +1305,22 @@ int ofd_create(const struct lu_env *env, struct obd_export *exp, } } + /* 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); @@ -1366,7 +1383,6 @@ int ofd_getattr(const struct lu_env *env, struct obd_export *exp, struct ofd_device *ofd = ofd_exp(exp); struct ofd_thread_info *info; struct ofd_object *fo; - __u64 curr_version; int rc = 0; ENTRY; @@ -1384,19 +1400,27 @@ int ofd_getattr(const struct lu_env *env, struct obd_export *exp, fo = ofd_object_find(env, ofd, &info->fti_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); oinfo->oi_oa->o_valid = OBD_MD_FLID; - if (rc == 0) + if (rc == 0) { + __u64 curr_version; + obdo_from_la(oinfo->oi_oa, &info->fti_attr, OFD_VALID_FLAGS | LA_UID | LA_GID); - /* Store object version in reply */ - curr_version = dt_version_get(env, ofd_object_child(fo)); - if ((__s64)curr_version != -EOPNOTSUPP) { - oinfo->oi_oa->o_valid |= OBD_MD_FLDATAVERSION; - oinfo->oi_oa->o_data_version = curr_version; + /* Store object version in reply */ + curr_version = dt_version_get(env, ofd_object_child(fo)); + if ((__s64)curr_version != -EOPNOTSUPP) { + oinfo->oi_oa->o_valid |= OBD_MD_FLDATAVERSION; + oinfo->oi_oa->o_data_version = curr_version; + } } + +out_put: ofd_object_put(env, fo); out: RETURN(rc); @@ -1545,6 +1569,24 @@ int ofd_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (rc == 0) rc = dt_ro(&env, ofd->ofd_osd); break; + case OBD_IOC_START_LFSCK: { + struct obd_ioctl_data *data = karg; + struct lfsck_start_param lsp; + + if (unlikely(data == NULL)) { + rc = -EINVAL; + break; + } + + lsp.lsp_start = (struct lfsck_start *)(data->ioc_inlbuf1); + lsp.lsp_namespace = ofd->ofd_namespace; + rc = lfsck_start(&env, ofd->ofd_osd, &lsp); + break; + } + case OBD_IOC_STOP_LFSCK: { + rc = lfsck_stop(&env, ofd->ofd_osd, false); + break; + } case OBD_IOC_GET_OBJ_VERSION: rc = ofd_ioc_get_obj_version(&env, ofd, karg); break; @@ -1603,11 +1645,11 @@ static int ofd_health_check(const struct lu_env *nul, struct obd_device *obd) GOTO(out, rc = -EROFS); #ifdef USE_HEALTH_CHECK_WRITE - OBD_ALLOC(info->fti_buf.lb_buf, CFS_PAGE_SIZE); + OBD_ALLOC(info->fti_buf.lb_buf, PAGE_CACHE_SIZE); if (info->fti_buf.lb_buf == NULL) GOTO(out, rc = -ENOMEM); - info->fti_buf.lb_len = CFS_PAGE_SIZE; + info->fti_buf.lb_len = PAGE_CACHE_SIZE; info->fti_off = 0; th = dt_trans_create(&env, ofd->ofd_osd); @@ -1626,7 +1668,7 @@ static int ofd_health_check(const struct lu_env *nul, struct obd_device *obd) } dt_trans_stop(&env, ofd->ofd_osd, th); - OBD_FREE(info->fti_buf.lb_buf, CFS_PAGE_SIZE); + OBD_FREE(info->fti_buf.lb_buf, PAGE_CACHE_SIZE); CDEBUG(D_INFO, "write 1 page synchronously for checking io rc %d\n",rc); #endif