X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fmdt%2Fmdt_handler.c;h=3040be6eb57463bfb441fb82a17a4eb2ee4f0539;hp=7f54b59efbdd181caca55d2ec34ae84ce44d3a3d;hb=a3b3d91b740466feea54d0fe9a397ba79c001aa7;hpb=ed4a625d88567a2498c3fe32fd340ae7985e6ad0 diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 7f54b59..3040be6 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -831,7 +831,7 @@ void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b, b->mbo_nlink = attr->la_nlink; b->mbo_valid |= OBD_MD_FLNLINK; } - if (attr->la_valid & (LA_UID|LA_GID)) { + if (attr->la_valid & (LA_UID|LA_GID|LA_PROJID)) { nodemap = nodemap_get_from_exp(exp); if (IS_ERR(nodemap)) goto out; @@ -850,8 +850,9 @@ void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b, } if (attr->la_valid & LA_PROJID) { - /* TODO, nodemap for project id */ - b->mbo_projid = attr->la_projid; + b->mbo_projid = nodemap_map_id(nodemap, NODEMAP_PROJID, + NODEMAP_FS_TO_CLIENT, + attr->la_projid); b->mbo_valid |= OBD_MD_FLPROJID; } @@ -2174,7 +2175,25 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, GOTO(out_child, rc = -ESTALE); } - if (!(info->mti_body->mbo_valid & OBD_MD_NAMEHASH) && + if (!child && is_resent) { + lock = ldlm_handle2lock(&lhc->mlh_reg_lh); + if (lock == NULL) { + /* Lock is pinned by ldlm_handle_enqueue0() as it is + * a resend case, however, it could be already destroyed + * due to client eviction or a raced cancel RPC. + */ + LDLM_DEBUG_NOLOCK("Invalid lock handle %#llx", + lhc->mlh_reg_lh.cookie); + RETURN(-ESTALE); + } + fid_extract_from_res_name(child_fid, + &lock->l_resource->lr_name); + LDLM_LOCK_PUT(lock); + child = mdt_object_find(info->mti_env, info->mti_mdt, + child_fid); + if (IS_ERR(child)) + RETURN(PTR_ERR(child)); + } else if (!(info->mti_body->mbo_valid & OBD_MD_NAMEHASH) && lu_name_is_valid(lname)) { if (info->mti_body->mbo_valid == OBD_MD_FLID) { rc = mdt_raw_lookup(info, parent, lname); @@ -2299,19 +2318,22 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, /* finally, we can get attr for child. */ rc = mdt_getattr_internal(info, child, ma_need); if (unlikely(rc != 0)) { - mdt_object_unlock(info, child, lhc, 1); + if (!is_resent) + mdt_object_unlock(info, child, lhc, 1); GOTO(out_child, rc); } rc = mdt_pack_secctx_in_reply(info, child); if (unlikely(rc)) { - mdt_object_unlock(info, child, lhc, 1); + if (!is_resent) + mdt_object_unlock(info, child, lhc, 1); GOTO(out_child, rc); } rc = mdt_pack_encctx_in_reply(info, child); if (unlikely(rc)) { - mdt_object_unlock(info, child, lhc, 1); + if (!is_resent) + mdt_object_unlock(info, child, lhc, 1); GOTO(out_child, rc); } @@ -2620,6 +2642,61 @@ out: static int mdt_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void __user *uarg); +int mdt_io_set_info(struct tgt_session_info *tsi) +{ + struct ptlrpc_request *req = tgt_ses_req(tsi); + struct ost_body *body = NULL, *repbody; + void *key, *val = NULL; + int keylen, vallen, rc = 0; + bool is_grant_shrink; + + ENTRY; + + key = req_capsule_client_get(tsi->tsi_pill, &RMF_SETINFO_KEY); + if (key == NULL) { + DEBUG_REQ(D_HA, req, "no set_info key"); + RETURN(err_serious(-EFAULT)); + } + keylen = req_capsule_get_size(tsi->tsi_pill, &RMF_SETINFO_KEY, + RCL_CLIENT); + + val = req_capsule_client_get(tsi->tsi_pill, &RMF_SETINFO_VAL); + if (val == NULL) { + DEBUG_REQ(D_HA, req, "no set_info val"); + RETURN(err_serious(-EFAULT)); + } + vallen = req_capsule_get_size(tsi->tsi_pill, &RMF_SETINFO_VAL, + RCL_CLIENT); + + is_grant_shrink = KEY_IS(KEY_GRANT_SHRINK); + if (is_grant_shrink) + /* In this case the value is actually an RMF_OST_BODY, so we + * transmutate the type of this PTLRPC */ + req_capsule_extend(tsi->tsi_pill, &RQF_OST_SET_GRANT_INFO); + + rc = req_capsule_server_pack(tsi->tsi_pill); + if (rc < 0) + RETURN(rc); + + if (is_grant_shrink) { + body = req_capsule_client_get(tsi->tsi_pill, &RMF_OST_BODY); + + repbody = req_capsule_server_get(tsi->tsi_pill, &RMF_OST_BODY); + *repbody = *body; + + /** handle grant shrink, similar to a read request */ + tgt_grant_prepare_read(tsi->tsi_env, tsi->tsi_exp, + &repbody->oa); + } else { + CERROR("%s: Unsupported key %s\n", + tgt_name(tsi->tsi_tgt), (char *)key); + rc = -EOPNOTSUPP; + } + + RETURN(rc); +} + + static int mdt_set_info(struct tgt_session_info *tsi) { struct ptlrpc_request *req = tgt_ses_req(tsi); @@ -3143,7 +3220,8 @@ static int mdt_quotactl(struct tgt_session_info *tsi) case LUSTRE_Q_SETQUOTAPOOL: case LUSTRE_Q_SETINFOPOOL: case LUSTRE_Q_SETDEFAULT_POOL: - if (!nodemap_can_setquota(nodemap)) + if (!nodemap_can_setquota(nodemap, oqctl->qc_type, + oqctl->qc_id)) GOTO(out_nodemap, rc = -EPERM); /* fallthrough */ case Q_GETINFO: @@ -3177,8 +3255,8 @@ static int mdt_quotactl(struct tgt_session_info *tsi) NODEMAP_CLIENT_TO_FS, id); break; case PRJQUOTA: - /* todo: check/map project id */ - id = oqctl->qc_id; + id = nodemap_map_id(nodemap, NODEMAP_PROJID, + NODEMAP_CLIENT_TO_FS, id); break; default: GOTO(out_nodemap, rc = -EOPNOTSUPP); @@ -4254,25 +4332,29 @@ int mdt_intent_lock_replace(struct mdt_thread_info *info, /* If possible resent found a lock, @lh is set to its handle */ new_lock = ldlm_handle2lock_long(&lh->mlh_reg_lh, 0); - if (new_lock == NULL && (flags & LDLM_FL_INTENT_ONLY)) { - lh->mlh_reg_lh.cookie = 0; - RETURN(0); - } - - if (new_lock == NULL && (flags & LDLM_FL_RESENT)) { - /* Lock is pinned by ldlm_handle_enqueue0() as it is - * a resend case, however, it could be already destroyed - * due to client eviction or a raced cancel RPC. */ - LDLM_DEBUG_NOLOCK("Invalid lock handle %#llx\n", - lh->mlh_reg_lh.cookie); + if (new_lock == NULL) { + if (flags & LDLM_FL_INTENT_ONLY) { + result = 0; + } else if (flags & LDLM_FL_RESENT) { + /* Lock is pinned by ldlm_handle_enqueue0() as it is a + * resend case, however, it could be already destroyed + * due to client eviction or a raced cancel RPC. + */ + LDLM_DEBUG_NOLOCK("Invalid lock handle %#llx\n", + lh->mlh_reg_lh.cookie); + result = -ESTALE; + } else { + CERROR("%s: Invalid lockh=%#llx flags=%#llx fid1="DFID" fid2="DFID": rc = %d\n", + mdt_obd_name(info->mti_mdt), + lh->mlh_reg_lh.cookie, flags, + PFID(&info->mti_tmp_fid1), + PFID(&info->mti_tmp_fid2), result); + result = -ESTALE; + } lh->mlh_reg_lh.cookie = 0; - RETURN(-ESTALE); + RETURN(result); } - LASSERTF(new_lock != NULL, - "lockh %#llx flags %#llx : rc = %d\n", - lh->mlh_reg_lh.cookie, flags, result); - /* * If we've already given this lock to a client once, then we should * have no readers or writers. Otherwise, we should have one reader @@ -5659,6 +5741,9 @@ TGT_OST_HDL(HAS_BODY | HAS_REPLY, OST_SYNC, mdt_data_sync), TGT_OST_HDL(HAS_BODY | HAS_REPLY | IS_MUTABLE, OST_FALLOCATE, mdt_fallocate_hdl), TGT_OST_HDL(HAS_BODY | HAS_REPLY, OST_SEEK, tgt_lseek), +TGT_RPC_HANDLER(OST_FIRST_OPC, + 0, OST_SET_INFO, mdt_io_set_info, + &RQF_OBD_SET_INFO, LUSTRE_OST_VERSION), }; static struct tgt_handler mdt_sec_ctx_ops[] = {