X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosc%2Fosc_create.c;h=557923bf5d75aa57e833fe7c7d02c34c8339a574;hb=9d4b898b1c1c7c318fda5f0c345ed726c774c06a;hp=3cd2175b574fd548a5a949604179277a147e6202;hpb=e42ff0d18b3568d5e149024a09064c81c9e8f09e;p=fs%2Flustre-release.git diff --git a/lustre/osc/osc_create.c b/lustre/osc/osc_create.c index 3cd2175..557923b 100644 --- a/lustre/osc/osc_create.c +++ b/lustre/osc/osc_create.c @@ -72,20 +72,22 @@ static int osc_interpret_create(struct ptlrpc_request *req, void *data, oscc = req->rq_async_args.pointer_arg[0]; spin_lock(&oscc->oscc_lock); + oscc->oscc_flags &= ~OSCC_FLAG_CREATING; if (body) oscc->oscc_last_id = body->oa.o_id; if (rc == -ENOSPC) { - DEBUG_REQ(D_INODE, req, "OST out of space, flagging"); oscc->oscc_flags |= OSCC_FLAG_NOSPC; + spin_unlock(&oscc->oscc_lock); + DEBUG_REQ(D_INODE, req, "OST out of space, flagging"); } else if (rc != 0 && rc != -EIO) { - DEBUG_REQ(D_ERROR, req, - "unknown rc %d from async create: failing oscc", - rc); oscc->oscc_flags |= OSCC_FLAG_RECOVERING; + spin_unlock(&oscc->oscc_lock); + DEBUG_REQ(D_ERROR, req, + "unknown rc %d from async create: failing oscc", rc); ptlrpc_fail_import(req->rq_import, req->rq_import_generation); + } else { + spin_unlock(&oscc->oscc_lock); } - oscc->oscc_flags &= ~OSCC_FLAG_CREATING; - spin_unlock(&oscc->oscc_lock); CDEBUG(D_HA, "preallocated through id "LPU64" (last used "LPU64")\n", oscc->oscc_last_id, oscc->oscc_next_id); @@ -110,7 +112,8 @@ static int oscc_internal_create(struct osc_creator *oscc) oscc->oscc_flags |= OSCC_FLAG_CREATING; spin_unlock(&oscc->oscc_lock); - request = ptlrpc_prep_req(oscc->oscc_obd->u.cli.cl_import, OST_CREATE, + request = ptlrpc_prep_req(oscc->oscc_obd->u.cli.cl_import, + LUSTRE_OBD_VERSION, OST_CREATE, 1, &size, NULL); if (request == NULL) { spin_lock(&oscc->oscc_lock); @@ -133,9 +136,9 @@ static int oscc_internal_create(struct osc_creator *oscc) body->oa.o_gr = oscc->oscc_gr; LASSERT(body->oa.o_gr > 0); body->oa.o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP; + spin_unlock(&oscc->oscc_lock); CDEBUG(D_INFO, "preallocating through id "LPU64" (last used "LPU64")\n", body->oa.o_id, oscc->oscc_next_id); - spin_unlock(&oscc->oscc_lock); request->rq_replen = lustre_msg_size(1, &size); @@ -172,7 +175,7 @@ static int oscc_wait_for_objects(struct osc_creator *oscc, int count) spin_unlock(&oscc->oscc_lock); osc_invalid = oscc->oscc_obd->u.cli.cl_import->imp_invalid; - + return have_objs || ost_full || osc_invalid; } @@ -238,17 +241,21 @@ int osc_create(struct obd_export *exp, struct obdo *oa, if (oa->o_gr == FILTER_GROUP_LLOG || oa->o_gr == FILTER_GROUP_ECHO) RETURN(osc_real_create(exp, oa, ea, oti)); - lsm = *ea; - if (lsm == NULL) { - rc = obd_alloc_memmd(exp, &lsm); - if (rc < 0) - RETURN(rc); - } - - /* this is the special case where create removes orphans */ - if ((oa->o_valid & OBD_MD_FLFLAGS) && - oa->o_flags == OBD_FL_DELORPHAN) { - CDEBUG(D_HA, "%s; oscc recovery started\n", + /* this is the special case where create removes orphans */ + if ((oa->o_valid & OBD_MD_FLFLAGS) && + oa->o_flags == OBD_FL_DELORPHAN) { + spin_lock(&oscc->oscc_lock); + if (oscc->oscc_flags & OSCC_FLAG_SYNC_IN_PROGRESS) { + spin_unlock(&oscc->oscc_lock); + return -EBUSY; + } + if (!(oscc->oscc_flags & OSCC_FLAG_RECOVERING)) { + spin_unlock(&oscc->oscc_lock); + return 0; + } + oscc->oscc_flags |= OSCC_FLAG_SYNC_IN_PROGRESS; + spin_unlock(&oscc->oscc_lock); + CDEBUG(D_HA, "%s; oscc recovery started\n", exp->exp_obd->obd_name); LASSERT(oscc->oscc_flags & OSCC_FLAG_RECOVERING); @@ -266,6 +273,7 @@ int osc_create(struct obd_export *exp, struct obdo *oa, } spin_lock(&oscc->oscc_lock); + oscc->oscc_flags &= ~OSCC_FLAG_SYNC_IN_PROGRESS; if (rc == 0 || rc == -ENOSPC) { if (rc == -ENOSPC) oscc->oscc_flags |= OSCC_FLAG_NOSPC; @@ -282,28 +290,35 @@ int osc_create(struct obd_export *exp, struct obdo *oa, } spin_unlock(&oscc->oscc_lock); - RETURN(rc); - } + RETURN(rc); + } + + lsm = *ea; + if (lsm == NULL) { + rc = obd_alloc_memmd(exp, &lsm); + if (rc < 0) + RETURN(rc); + } 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,"%s: oscc sync in progress, waiting\n", - exp->exp_obd->obd_name); - - lwi = LWI_TIMEOUT(MAX(obd_timeout * HZ, 1), NULL, NULL); - rc = l_wait_event(oscc->oscc_waitq, + + 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_HA, "%s: timed out waiting for sync\n", - exp->exp_obd->obd_name); + CDEBUG(D_HA,"%p: timeout waiting on recovery\n", + oscc); RETURN(rc); } - CDEBUG(D_HA, "%s: oscc sync over, waking up\n", + CDEBUG(D_HA, "%s: oscc recovery over, waking up\n", exp->exp_obd->obd_name); } @@ -329,8 +344,9 @@ int osc_create(struct obd_export *exp, struct obdo *oa, } if (rc == 0) - CDEBUG(D_INFO, "returning objid "LPU64"/"LPU64"\n", - lsm->lsm_object_id, lsm->lsm_object_gr); + CDEBUG(D_HA, "%s: returning objid "LPU64"\n", + oscc->oscc_obd->u.cli.cl_import->imp_target_uuid.uuid, + lsm->lsm_object_id); else if (*ea == NULL) obd_free_memmd(exp, &lsm); RETURN(rc);