X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fliblustre%2Fnamei.c;h=04606fd038f034c14124a02c9c00b9cc089068fb;hp=af4a0dc8eeaca28415f5f03bc087f27bc85f3098;hb=9d4b898b1c1c7c318fda5f0c345ed726c774c06a;hpb=57e6d88a8a8d858e2d74aeefba4c764ad08cf86d diff --git a/lustre/liblustre/namei.c b/lustre/liblustre/namei.c index af4a0dc..04606fd 100644 --- a/lustre/liblustre/namei.c +++ b/lustre/liblustre/namei.c @@ -1,9 +1,9 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * Lustre Light Super operations + * Lustre Light name resolution * - * Copyright (c) 2002, 2003 Cluster File Systems, Inc. + * Copyright (c) 2002-2004 Cluster File Systems, Inc. * * This file is part of Lustre, http://www.lustre.org. * @@ -70,6 +70,7 @@ static void ll_intent_release(struct lookup_intent *it) EXIT; } +#if 0 /* * remove the stale inode from pnode */ @@ -94,6 +95,7 @@ void unhook_stale_inode(struct pnode *pno) EXIT; return; } +#endif void llu_lookup_finish_locks(struct lookup_intent *it, struct pnode *pnode) { @@ -105,7 +107,7 @@ void llu_lookup_finish_locks(struct lookup_intent *it, struct pnode *pnode) CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%lu)\n", inode, llu_i2info(inode)->lli_st_ino, llu_i2info(inode)->lli_st_generation); - mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode); + mdc_set_lock_data(NULL, &it->d.lustre.it_lock_handle, inode); } /* drop lookup/getattr locks */ @@ -140,32 +142,30 @@ int llu_mdc_blocking_ast(struct ldlm_lock *lock, case LDLM_CB_CANCELING: { struct inode *inode = llu_inode_from_lock(lock); struct llu_inode_info *lli; + __u64 bits = lock->l_policy_data.l_inodebits.bits; /* Invalidate all dentries associated with this inode */ if (inode == NULL) break; - lli = llu_i2info(inode); + lli = llu_i2info(inode); - clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags); + if (bits & MDS_INODELOCK_UPDATE) + clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags); - if (lock->l_resource->lr_name.name[0] != lli->lli_st_ino || - lock->l_resource->lr_name.name[1] != lli->lli_st_generation) { - LDLM_ERROR(lock, "data mismatch with ino %lu/%lu", - lli->lli_st_ino, lli->lli_st_generation); + if (lock->l_resource->lr_name.name[0] != id_fid(&lli->lli_id) || + lock->l_resource->lr_name.name[1] != id_group(&lli->lli_id)) { + LDLM_ERROR(lock, "data mismatch with object "DLID4, + OLID4(&lli->lli_id)); } - if (S_ISDIR(lli->lli_st_mode)) { + if (S_ISDIR(lli->lli_st_mode) && + (bits & MDS_INODELOCK_UPDATE)) { CDEBUG(D_INODE, "invalidating inode %lu\n", lli->lli_st_ino); llu_invalidate_inode_pages(inode); } -/* - if (inode->i_sb->s_root && - inode != inode->i_sb->s_root->d_inode) - ll_unhash_aliases(inode); -*/ I_RELE(inode); break; } @@ -194,7 +194,8 @@ static int pnode_revalidate_finish(struct ptlrpc_request *req, if (it_disposition(it, DISP_LOOKUP_NEG)) RETURN(-ENOENT); - rc = mdc_req2lustre_md(req, offset, llu_i2sbi(inode)->ll_osc_exp, &md); + rc = mdc_req2lustre_md(llu_i2sbi(inode)->ll_lmv_exp, req, offset, + llu_i2sbi(inode)->ll_lov_exp, &md); if (rc) RETURN(rc); @@ -206,9 +207,8 @@ static int pnode_revalidate_finish(struct ptlrpc_request *req, int llu_pb_revalidate(struct pnode *pnode, int flags, struct lookup_intent *it) { struct pnode_base *pb = pnode->p_base; - struct ll_fid pfid, cfid; + struct lustre_id pid, cid; struct it_cb_data icbd; - struct ll_uctxt ctxt; struct ptlrpc_request *req = NULL; struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; struct obd_export *exp; @@ -226,17 +226,6 @@ int llu_pb_revalidate(struct pnode *pnode, int flags, struct lookup_intent *it) RETURN(0); } - /* check stale inode */ - if (llu_i2info(pb->pb_ino)->lli_stale_flag) - unhook_stale_inode(pnode); - - /* check again because unhook_stale_inode() might generate - * negative pnode */ - if (pb->pb_ino == NULL) { - CDEBUG(D_INODE, "negative pb\n"); - RETURN(0); - } - /* This is due to bad interaction with libsysio. remove this when we * switched to libbsdio XXX */ @@ -254,8 +243,8 @@ int llu_pb_revalidate(struct pnode *pnode, int flags, struct lookup_intent *it) } exp = llu_i2mdcexp(pb->pb_ino); - ll_inode2fid(&pfid, pnode->p_parent->p_base->pb_ino); - ll_inode2fid(&cfid, pb->pb_ino); + ll_inode2id(&pid, pnode->p_parent->p_base->pb_ino); + ll_inode2id(&cid, pb->pb_ino); icbd.icbd_parent = pnode->p_parent->p_base->pb_ino; icbd.icbd_child = pnode; @@ -264,12 +253,8 @@ int llu_pb_revalidate(struct pnode *pnode, int flags, struct lookup_intent *it) it->it_op_release = ll_intent_release; } - ll_i2uctxt(&ctxt, pnode->p_parent->p_base->pb_ino, pb->pb_ino); - - rc = mdc_intent_lock(exp, &ctxt, &pfid, - pb->pb_name.name, pb->pb_name.len, - NULL, 0, &cfid, it, flags, &req, - llu_mdc_blocking_ast); + rc = mdc_intent_lock(exp, &pid, pb->pb_name.name, pb->pb_name.len, + NULL, 0, &cid, it, flags, &req, llu_mdc_blocking_ast); /* If req is NULL, then mdc_intent_lock only tried to do a lock match; * if all was well, it will return 1 if it found locks, 0 otherwise. */ if (req == NULL && rc >= 0) @@ -299,7 +284,6 @@ int llu_pb_revalidate(struct pnode *pnode, int flags, struct lookup_intent *it) pb->pb_ino = NULL; } else { llu_lookup_finish_locks(it, pnode); - llu_i2info(pb->pb_ino)->lli_stale_flag = 0; } RETURN(rc); } @@ -314,28 +298,52 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, struct inode *inode = NULL; int rc; + /* libsysio require us generate inode right away if success. + * so if mds created new inode for us we need make sure it + * succeeded. thus for any error we can't delay to the + * llu_file_open() time. */ + if (it_disposition(it, DISP_OPEN_CREATE) && + it_open_error(DISP_OPEN_CREATE, it)) { + CDEBUG(D_INODE, "detect mds create error\n"); + return it_open_error(DISP_OPEN_CREATE, it); + } + if (it_disposition(it, DISP_OPEN_OPEN) && + it_open_error(DISP_OPEN_OPEN, it)) { + CDEBUG(D_INODE, "detect mds open error\n"); + /* undo which did by mdc_intent_lock */ + if (it_disposition(it, DISP_OPEN_CREATE) && + !it_open_error(DISP_OPEN_CREATE, it)) { + LASSERT(request); + LASSERT(atomic_read(&request->rq_refcount) > 1); + CDEBUG(D_INODE, "dec a ref of req %p\n", request); + ptlrpc_req_finished(request); + } + return it_open_error(DISP_OPEN_OPEN, it); + } + /* NB 1 request reference will be taken away by ll_intent_lock() * when I return - * Note: libsysio require the inode must be generated here */ - if ((it->it_op & IT_CREAT) || !it_disposition(it, DISP_LOOKUP_NEG)) { + if (!it_disposition(it, DISP_LOOKUP_NEG) || + (it->it_op & IT_CREAT)) { struct lustre_md md; struct llu_inode_info *lli; ENTRY; - rc = mdc_req2lustre_md(request, offset, sbi->ll_osc_exp, &md); + rc = mdc_req2lustre_md(sbi->ll_lmv_exp, request, offset, + sbi->ll_lov_exp, &md); if (rc) RETURN(rc); inode = llu_iget(parent->i_fs, &md); - if (!inode) { + if (!inode || IS_ERR(inode)) { /* free the lsm if we allocated one above */ if (md.lsm != NULL) - obd_free_memmd(sbi->ll_osc_exp, &md.lsm); - RETURN(-ENOMEM); + obd_free_memmd(sbi->ll_lov_exp, &md.lsm); + RETURN(inode ? PTR_ERR(inode) : -ENOMEM); } else if (md.lsm != NULL && llu_i2info(inode)->lli_smd != md.lsm) { - obd_free_memmd(sbi->ll_osc_exp, &md.lsm); + obd_free_memmd(sbi->ll_lov_exp, &md.lsm); } lli = llu_i2info(inode); @@ -344,7 +352,6 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, if (it->it_op == IT_GETATTR && S_ISREG(lli->lli_st_mode) && lli->lli_smd != NULL) { struct lov_stripe_md *lsm = lli->lli_smd; - struct ost_lvb lvb; ldlm_error_t rc; LASSERT(lsm->lsm_object_id != 0); @@ -352,12 +359,11 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, /* bug 2334: drop MDS lock before acquiring OST lock */ ll_intent_drop_lock(it); - rc = llu_glimpse_size(inode, &lvb); + rc = llu_glimpse_size(inode); if (rc) { I_RELE(inode); RETURN(rc); } - lli->lli_st_size = lvb.lvb_size; } } else { ENTRY; @@ -390,8 +396,7 @@ struct inode *llu_inode_from_lock(struct ldlm_lock *lock) static int llu_lookup_it(struct inode *parent, struct pnode *pnode, struct lookup_intent *it, int flags) { - struct ll_fid pfid; - struct ll_uctxt ctxt; + struct lustre_id pid; struct it_cb_data icbd; struct ptlrpc_request *req = NULL; struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; @@ -409,10 +414,9 @@ static int llu_lookup_it(struct inode *parent, struct pnode *pnode, icbd.icbd_child = pnode; icbd.icbd_parent = parent; icbd.icbd_child = pnode; - ll_inode2fid(&pfid, parent); - ll_i2uctxt(&ctxt, parent, NULL); + ll_inode2id(&pid, parent); - rc = mdc_intent_lock(llu_i2mdcexp(parent), &ctxt, &pfid, + rc = mdc_intent_lock(llu_i2mdcexp(parent), &pid, pnode->p_base->pb_name.name, pnode->p_base->pb_name.len, NULL, 0, NULL, it, flags, &req, @@ -521,6 +525,8 @@ int llu_iop_lookup(struct pnode *pnode, int rc; ENTRY; + liblustre_wait_event(0); + *inop = NULL; /* the mount root inode have no name, so don't call @@ -554,4 +560,3 @@ int llu_iop_lookup(struct pnode *pnode, RETURN(rc); } -