Exemple #1
0
static inline int out_check_resent(const struct lu_env *env,
				   struct dt_device *dt,
				   struct dt_object *obj,
				   struct ptlrpc_request *req,
				   out_reconstruct_t reconstruct,
				   struct object_update_reply *reply,
				   int index)
{
	if (likely(!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT)))
		return 0;

	if (req_xid_is_last(req)) {
		struct lsd_client_data *lcd;

		/* XXX this does not support mulitple transactions yet, i.e.
		 * only 1 update RPC each time betwee MDTs */
		lcd = req->rq_export->exp_target_data.ted_lcd;

		req->rq_transno = lcd->lcd_last_transno;
		req->rq_status = lcd->lcd_last_result;
		if (req->rq_status != 0)
			req->rq_transno = 0;
		lustre_msg_set_transno(req->rq_repmsg, req->rq_transno);
		lustre_msg_set_status(req->rq_repmsg, req->rq_status);

		DEBUG_REQ(D_RPCTRACE, req, "restoring transno "LPD64"status %d",
			  req->rq_transno, req->rq_status);

		reconstruct(env, dt, obj, reply, index);
		return 1;
	}
	DEBUG_REQ(D_HA, req, "no reply for RESENT req (have "LPD64")",
		 req->rq_export->exp_target_data.ted_lcd->lcd_last_xid);
	return 0;
}
Exemple #2
0
int seq_handle(struct ptlrpc_request *req)
{
	const struct lu_env *env;
	struct seq_thread_info *info;
	int rc;

	env = req->rq_svc_thread->t_env;
	LASSERT(env != NULL);

	info = lu_context_key_get(&env->le_ctx, &seq_thread_key);
	LASSERT(info != NULL);

	seq_thread_info_init(req, info);
	rc = seq_req_handle(req, env, info);
	/* XXX: we don't need replay but MDT assign transno in any case,
	 * remove it manually before reply*/
	lustre_msg_set_transno(req->rq_repmsg, 0);
	seq_thread_info_fini(info);

	return rc;
}
Exemple #3
0
/* Shrink and/or grow reply buffers */
int mdt_fix_reply(struct mdt_thread_info *info)
{
        struct req_capsule *pill = info->mti_pill;
        struct mdt_body    *body;
        int                md_size, md_packed = 0;
        int                acl_size;
        int                rc = 0;
        ENTRY;

        body = req_capsule_server_get(pill, &RMF_MDT_BODY);
        LASSERT(body != NULL);

        if (body->valid & (OBD_MD_FLDIREA | OBD_MD_FLEASIZE | OBD_MD_LINKNAME))
                md_size = body->eadatasize;
        else
                md_size = 0;

        acl_size = body->aclsize;

        /* this replay - not send info to client */
	if (info->mti_spec.no_create) {
		md_size = 0;
		acl_size = 0;
	}

        CDEBUG(D_INFO, "Shrink to md_size = %d cookie/acl_size = %d"
                        " MDSCAPA = %llx, OSSCAPA = %llx\n",
                        md_size, acl_size,
                        (unsigned long long)(body->valid & OBD_MD_FLMDSCAPA),
                        (unsigned long long)(body->valid & OBD_MD_FLOSSCAPA));
/*
            &RMF_MDT_BODY,
            &RMF_MDT_MD,
            &RMF_ACL, or &RMF_LOGCOOKIES
(optional)  &RMF_CAPA1,
(optional)  &RMF_CAPA2,
(optional)  something else
*/

        /* MDT_MD buffer may be bigger than packed value, let's shrink all
         * buffers before growing it */
	if (info->mti_big_lmm_used) {
                LASSERT(req_capsule_has_field(pill, &RMF_MDT_MD, RCL_SERVER));

                /* free big lmm if md_size is not needed */
		if (md_size == 0) {
			info->mti_big_lmm_used = 0;
		} else {
			md_packed = req_capsule_get_size(pill, &RMF_MDT_MD,
							 RCL_SERVER);
			LASSERT(md_packed > 0);
			/* buffer must be allocated separately */
			LASSERT(info->mti_attr.ma_lmm !=
				req_capsule_server_get(pill, &RMF_MDT_MD));
			req_capsule_shrink(pill, &RMF_MDT_MD, 0, RCL_SERVER);
		}
        } else if (req_capsule_has_field(pill, &RMF_MDT_MD, RCL_SERVER)) {
                req_capsule_shrink(pill, &RMF_MDT_MD, md_size, RCL_SERVER);
        }

        if (req_capsule_has_field(pill, &RMF_ACL, RCL_SERVER))
                req_capsule_shrink(pill, &RMF_ACL, acl_size, RCL_SERVER);
        else if (req_capsule_has_field(pill, &RMF_LOGCOOKIES, RCL_SERVER))
                req_capsule_shrink(pill, &RMF_LOGCOOKIES,
                                   acl_size, RCL_SERVER);

        if (req_capsule_has_field(pill, &RMF_CAPA1, RCL_SERVER) &&
            !(body->valid & OBD_MD_FLMDSCAPA))
                req_capsule_shrink(pill, &RMF_CAPA1, 0, RCL_SERVER);

        if (req_capsule_has_field(pill, &RMF_CAPA2, RCL_SERVER) &&
            !(body->valid & OBD_MD_FLOSSCAPA))
                req_capsule_shrink(pill, &RMF_CAPA2, 0, RCL_SERVER);

        /*
         * Some more field should be shrinked if needed.
         * This should be done by those who added fields to reply message.
         */

        /* Grow MD buffer if needed finally */
	if (info->mti_big_lmm_used) {
                void *lmm;

                LASSERT(md_size > md_packed);
                CDEBUG(D_INFO, "Enlarge reply buffer, need extra %d bytes\n",
                       md_size - md_packed);
                rc = req_capsule_server_grow(pill, &RMF_MDT_MD, md_size);
                if (rc) {
                        /* we can't answer with proper LOV EA, drop flags,
                         * the rc is also returned so this request is
                         * considered as failed */
                        body->valid &= ~(OBD_MD_FLDIREA | OBD_MD_FLEASIZE);
                        /* don't return transno along with error */
                        lustre_msg_set_transno(pill->rc_req->rq_repmsg, 0);
                } else {
			/* now we need to pack right LOV/LMV EA */
			lmm = req_capsule_server_get(pill, &RMF_MDT_MD);
			if (info->mti_attr.ma_valid & MA_LOV) {
				LASSERT(req_capsule_get_size(pill, &RMF_MDT_MD,
							     RCL_SERVER) ==
						info->mti_attr.ma_lmm_size);
				memcpy(lmm, info->mti_attr.ma_lmm,
				       info->mti_attr.ma_lmm_size);
			} else if (info->mti_attr.ma_valid & MA_LMV) {
				LASSERT(req_capsule_get_size(pill, &RMF_MDT_MD,
							     RCL_SERVER) ==
						info->mti_attr.ma_lmv_size);
				memcpy(lmm, info->mti_attr.ma_lmv,
				       info->mti_attr.ma_lmv_size);
			}
                }
                /* update mdt_max_mdsize so clients will be aware about that */
                if (info->mti_mdt->mdt_max_mdsize < info->mti_attr.ma_lmm_size)
                        info->mti_mdt->mdt_max_mdsize =
                                                    info->mti_attr.ma_lmm_size;
		info->mti_big_lmm_used = 0;
        }
        RETURN(rc);
}