X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fofd%2Fofd_lvb.c;h=ed8ea92b64303e96c12f5383d81457c2c5e9cfe8;hb=2a6fda5b369c59a320941848968597244b8f3583;hp=81f1e67e3809704a60fdbe8b222391d82180bf59;hpb=ccabce23bd9e366c345c852f565766a799f61238;p=fs%2Flustre-release.git diff --git a/lustre/ofd/ofd_lvb.c b/lustre/ofd/ofd_lvb.c index 81f1e67..ed8ea92 100644 --- a/lustre/ofd/ofd_lvb.c +++ b/lustre/ofd/ofd_lvb.c @@ -27,7 +27,6 @@ */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. * * lustre/ofd/ofd_lvb.c * @@ -67,6 +66,20 @@ static int ofd_lvbo_free(struct ldlm_resource *res) return 0; } +static bool ofd_resync_allowed(struct ofd_device *ofd) +{ + struct obd_device *obd = ofd_obd(ofd); + + if (obd->obd_recovery_start == 0) + return false; + + if (obd->obd_recovery_start + obd->obd_recovery_time_hard < + ktime_get_seconds()) + return false; + + return true; +} + /** * Implementation of ldlm_valblock_ops::lvbo_init for OFD. * @@ -88,9 +101,8 @@ static int ofd_lvbo_init(struct ldlm_resource *res) struct ofd_device *ofd; struct ofd_object *fo; struct ofd_thread_info *info; - struct lu_env env; - int rc = 0; - + struct lu_env *env; + int rc = 0; ENTRY; LASSERT(res); @@ -105,27 +117,43 @@ static int ofd_lvbo_init(struct ldlm_resource *res) if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_OST_LVB)) RETURN(-ENOMEM); - rc = lu_env_init(&env, LCT_DT_THREAD); - if (rc) - RETURN(rc); + env = lu_env_find(); + LASSERT(env); OBD_ALLOC_PTR(lvb); if (lvb == NULL) - GOTO(out_env, rc = -ENOMEM); + GOTO(out, rc = -ENOMEM); + info = ofd_info(env); res->lr_lvb_data = lvb; res->lr_lvb_len = sizeof(*lvb); - info = ofd_info_init(&env, NULL); ost_fid_from_resid(&info->fti_fid, &res->lr_name, ofd->ofd_lut.lut_lsd.lsd_osd_index); - fo = ofd_object_find(&env, ofd, &info->fti_fid); + fo = ofd_object_find(env, ofd, &info->fti_fid); if (IS_ERR(fo)) GOTO(out_lvb, rc = PTR_ERR(fo)); - rc = ofd_attr_get(&env, fo, &info->fti_attr); - if (rc) + rc = ofd_attr_get(env, fo, &info->fti_attr); + if (rc) { + struct ofd_seq *oseq; + __u64 seq; + + /* Object could be recreated during the first + * CLEANUP_ORPHAN request. */ + if (rc == -ENOENT) { + seq = fid_seq(&info->fti_fid); + oseq = ofd_seq_load(env, ofd, fid_seq_is_idif(seq) ? + FID_SEQ_OST_MDT0 : seq); + if (!IS_ERR_OR_NULL(oseq)) { + if (!oseq->os_last_id_synced && + ofd_resync_allowed(ofd)) + rc = -EINPROGRESS; + ofd_seq_put(env, oseq); + } + } GOTO(out_obj, rc); + } lvb->lvb_size = info->fti_attr.la_size; lvb->lvb_blocks = info->fti_attr.la_blocks; @@ -133,19 +161,23 @@ static int ofd_lvbo_init(struct ldlm_resource *res) lvb->lvb_atime = info->fti_attr.la_atime; lvb->lvb_ctime = info->fti_attr.la_ctime; - CDEBUG(D_DLMTRACE, "res: "DFID" initial lvb size: %llu, " - "mtime: %#llx, blocks: %#llx\n", - PFID(&info->fti_fid), lvb->lvb_size, - lvb->lvb_mtime, lvb->lvb_blocks); + if (fo->ofo_atime_ondisk == 0) + fo->ofo_atime_ondisk = info->fti_attr.la_atime; + + CDEBUG(D_DLMTRACE, + "res: "DFID" initial LVB size: %llu, mtime: %#llx, atime: %#llx, ctime: %#llx, blocks: %#llx\n", + PFID(&info->fti_fid), lvb->lvb_size, lvb->lvb_mtime, + lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); + + info->fti_attr.la_valid = 0; EXIT; out_obj: - ofd_object_put(&env, fo); + ofd_object_put(env, fo); out_lvb: if (rc != 0) OST_LVB_SET_ERR(lvb->lvb_blocks, rc); -out_env: - lu_env_fini(&env); +out: /* Don't free lvb data on lookup error */ return rc; } @@ -182,32 +214,30 @@ out_env: static int ofd_lvbo_update(struct ldlm_resource *res, struct ldlm_lock *lock, struct ptlrpc_request *req, int increase_only) { - struct ofd_device *ofd; - struct ofd_object *fo; - struct ofd_thread_info *info; - struct ost_lvb *lvb; - struct lu_env env; - int rc = 0; + struct ofd_thread_info *info; + struct ofd_device *ofd; + struct ofd_object *fo; + struct ost_lvb *lvb; + const struct lu_env *env; + int rc = 0; ENTRY; + env = lu_env_find(); + LASSERT(env); + info = ofd_info(env); LASSERT(res != NULL); ofd = ldlm_res_to_ns(res)->ns_lvbp; LASSERT(ofd != NULL); - rc = lu_env_init(&env, LCT_DT_THREAD); - if (rc) - RETURN(rc); - - info = ofd_info_init(&env, NULL); fid_extract_from_res_name(&info->fti_fid, &res->lr_name); lvb = res->lr_lvb_data; if (lvb == NULL) { CERROR("%s: no LVB data for "DFID"\n", ofd_name(ofd), PFID(&info->fti_fid)); - GOTO(out_env, rc = 0); + GOTO(out, rc = 0); } /* Update the LVB from the network message */ @@ -279,11 +309,11 @@ disk_update: /* Update the LVB from the disk inode */ ost_fid_from_resid(&info->fti_fid, &res->lr_name, ofd->ofd_lut.lut_lsd.lsd_osd_index); - fo = ofd_object_find(&env, ofd, &info->fti_fid); + fo = ofd_object_find(env, ofd, &info->fti_fid); if (IS_ERR(fo)) - GOTO(out_env, rc = PTR_ERR(fo)); + GOTO(out, rc = PTR_ERR(fo)); - rc = ofd_attr_get(&env, fo, &info->fti_attr); + rc = ofd_attr_get(env, fo, &info->fti_attr); if (rc) GOTO(out_obj, rc); @@ -321,10 +351,10 @@ disk_update: } unlock_res(res); + info->fti_attr.la_valid = 0; out_obj: - ofd_object_put(&env, fo); -out_env: - lu_env_fini(&env); + ofd_object_put(env, fo); +out: return rc; } @@ -352,13 +382,14 @@ static int ofd_lvbo_size(struct ldlm_lock *lock) * * This function is called to fill the given RPC buffer \a buf with LVB data * + * \param[in] env execution environment * \param[in] lock LDLM lock * \param[in] buf RPC buffer to fill * \param[in] buflen buffer length * * \retval size of LVB data written into \a buf buffer */ -static int ofd_lvbo_fill(struct ldlm_lock *lock, void *buf, int buflen) +static int ofd_lvbo_fill(struct ldlm_lock *lock, void *buf, int *buflen) { struct ldlm_resource *res = lock->l_resource; int lvb_len; @@ -370,8 +401,8 @@ static int ofd_lvbo_fill(struct ldlm_lock *lock, void *buf, int buflen) lvb_len = ofd_lvbo_size(lock); LASSERT(lvb_len <= res->lr_lvb_len); - if (lvb_len > buflen) - lvb_len = buflen; + if (lvb_len > *buflen) + lvb_len = *buflen; lock_res(res); memcpy(buf, res->lr_lvb_data, lvb_len);