X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosc%2Fosc_create.c;h=c8af28936533256aab301e09fd689b16c73e4eec;hb=b0be67c716c8716666eb807d1bf658fcc1a5458d;hp=722cfc70b984345480816f835f4b3be973f98649;hpb=b92e914bd75cb62d34d7e42e8bf78864755106f2;p=fs%2Flustre-release.git diff --git a/lustre/osc/osc_create.c b/lustre/osc/osc_create.c index 722cfc7..c8af289 100644 --- a/lustre/osc/osc_create.c +++ b/lustre/osc/osc_create.c @@ -56,13 +56,24 @@ #include #include "osc_internal.h" +int oscc_recovering(struct osc_creator *oscc) +{ + int recov = 0; + + spin_lock(&oscc->oscc_lock); + recov = oscc->oscc_flags & OSCC_FLAG_RECOVERING; + spin_unlock(&oscc->oscc_lock); + + return recov; +} + /* this only is used now for deleting orphanes */ int osc_create(struct obd_export *exp, struct obdo *oa, void *acl, int acl_size, struct lov_stripe_md **ea, struct obd_trans_info *oti) { struct osc_creator *oscc = &exp->exp_obd->u.cli.cl_oscc; - int rc = 0; + int rc = 0, try_again = 1; ENTRY; LASSERT(oa); @@ -71,6 +82,12 @@ int osc_create(struct obd_export *exp, struct obdo *oa, LASSERT(oa->o_valid & OBD_MD_FLGROUP); LASSERT(acl == NULL && acl_size == 0); +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) + if (current->journal_info != NULL) + CWARN("calling osc_create() with an " + "open transaction isn't a good idea\n"); +#endif + if (oa->o_gr == FILTER_GROUP_LLOG || oa->o_gr == FILTER_GROUP_ECHO) RETURN(osc_real_create(exp, oa, ea, oti)); @@ -109,6 +126,7 @@ int osc_create(struct obd_export *exp, struct obdo *oa, oscc->oscc_flags &= ~OSCC_FLAG_RECOVERING; CDEBUG(D_HA, "%s: oscc recovery finished: %d\n", oscc->oscc_obd->obd_name, rc); + wake_up(&oscc->oscc_waitq); } else { CDEBUG(D_ERROR, "%s: oscc recovery failed: %d\n", oscc->oscc_obd->obd_name, rc); @@ -117,8 +135,52 @@ int osc_create(struct obd_export *exp, struct obdo *oa, RETURN(rc); } - LBUG(); - RETURN(0); + while (try_again) { + /* If orphans are being recovered, then we must wait until + it is finished before we can continue with create. */ + if (oscc_recovering(oscc)) { + struct l_wait_info lwi; + + CDEBUG(D_HA,"%p: oscc recovery in progress, waiting\n", + oscc); + + lwi = LWI_TIMEOUT(MAX(obd_timeout*HZ/4, 1), NULL, NULL); + rc = l_wait_event(oscc->oscc_waitq, + !oscc_recovering(oscc), &lwi); + LASSERT(rc == 0 || rc == -ETIMEDOUT); + if (rc == -ETIMEDOUT) { + CDEBUG(D_ERROR,"%p: timeout waiting on recovery\n", + oscc); + portals_debug_dumplog(); + RETURN(rc); + } + CDEBUG(D_HA, "%p: oscc recovery over, waking up\n", + oscc); + } + + spin_lock(&oscc->oscc_lock); + if (oscc->oscc_flags & OSCC_FLAG_EXITING) { + spin_unlock(&oscc->oscc_lock); + break; + } + + if (oscc->oscc_flags & OSCC_FLAG_NOSPC) { + rc = -ENOSPC; + spin_unlock(&oscc->oscc_lock); + break; + } + + oscc->oscc_next_id++; + oa->o_id = oscc->oscc_next_id; + try_again = 0; + spin_unlock(&oscc->oscc_lock); + + CDEBUG(D_HA, "%s: returning objid "LPU64"\n", + oscc->oscc_obd->u.cli.cl_import->imp_target_uuid.uuid, + oa->o_id); + } + + RETURN(rc); } void oscc_init(struct obd_device *obd) @@ -134,4 +196,5 @@ void oscc_init(struct obd_device *obd) oscc->oscc_obd = obd; spin_lock_init(&oscc->oscc_lock); oscc->oscc_flags |= OSCC_FLAG_RECOVERING; + init_waitqueue_head(&oscc->oscc_waitq); }