Example #1
0
struct iobuf *
quotad_serialize_reply (rpcsvc_request_t *req, void *arg, struct iovec *outmsg,
                        xdrproc_t xdrproc)
{
        struct iobuf *iob      = NULL;
        ssize_t       retlen   = 0;
        ssize_t       xdr_size = 0;

        GF_VALIDATE_OR_GOTO ("server", req, ret);

        /* First, get the io buffer into which the reply in arg will
         * be serialized.
         */
        if (arg && xdrproc) {
                xdr_size = xdr_sizeof (xdrproc, arg);
                iob = iobuf_get2 (req->svc->ctx->iobuf_pool, xdr_size);
                if (!iob) {
                        gf_log_callingfn (THIS->name, GF_LOG_ERROR,
                                          "Failed to get iobuf");
                        goto ret;
                };

                iobuf_to_iovec (iob, outmsg);
                /* Use the given serializer to translate the give C structure in arg
                 * to XDR format which will be written into the buffer in outmsg.
                 */
                /* retlen is used to received the error since size_t is unsigned and we
                 * need -1 for error notification during encoding.
                 */

                retlen = xdr_serialize_generic (*outmsg, arg, xdrproc);
                if (retlen == -1) {
                        /* Failed to Encode 'GlusterFS' msg in RPC is not exactly
                           failure of RPC return values.. client should get
                           notified about this, so there are no missing frames */
                        gf_log_callingfn ("", GF_LOG_ERROR, "Failed to encode message");
                        req->rpc_err = GARBAGE_ARGS;
                        retlen = 0;
                }
        }
        outmsg->iov_len = retlen;
ret:
        if (retlen == -1) {
                iobuf_unref (iob);
                iob = NULL;
        }

        return iob;
}
Example #2
0
int
lic_submit_request(void *req, call_frame_t *frame, rpc_clnt_prog_t *prog,
		int procnum, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc)
{
        int                     ret         = -1;
        struct iovec            iov         = {0};
        struct iobuf            *iobuf      = NULL;
        ssize_t                 xdr_size    = 0;

        if (req) {
                xdr_size = xdr_sizeof(xdrproc, req);
                iobuf = iobuf_get2(THIS->ctx->iobuf_pool, xdr_size);
                if (!iobuf) {
                        goto out;
                };

                iov.iov_base = iobuf->ptr;
                iov.iov_len  = iobuf_size (iobuf);

                /* Create the xdr payload */
                ret = xdr_serialize_generic (iov, req, xdrproc);
                if (ret == -1)
                        goto out;

                iov.iov_len = ret;
        }

	lic_await_connected(60);

        /* Send the msg */
        ret = rpc_clnt_submit (g_rpc, prog, procnum, cbkfn,
                               &iov, 1,
                               NULL, 0, NULL, frame, NULL, 0, NULL, 0, NULL);
        ret = 0;

out:
        if (iobuf)
                iobuf_unref (iobuf);
        return ret;
}
Example #3
0
int
rpc_clnt_mgmt_pmap_signout (glusterfs_ctx_t *ctx, char *brickname)
{
        int               ret = 0;
        pmap_signout_req  req = {0, };
        call_frame_t     *frame = NULL;
        cmd_args_t       *cmd_args = NULL;
        char              brick_name[PATH_MAX]  = {0,};
        struct iovec      iov = {0, };
        struct iobuf     *iobuf = NULL;
        struct iobref    *iobref = NULL;
        ssize_t           xdr_size = 0;

        frame = create_frame (THIS, ctx->pool);
        cmd_args = &ctx->cmd_args;

        if (!cmd_args->brick_port && (!cmd_args->brick_name || !brickname)) {
                gf_log ("fsd-mgmt", GF_LOG_DEBUG,
                        "portmapper signout arguments not given");
                goto out;
        }

        if (cmd_args->volfile_server_transport &&
            !strcmp(cmd_args->volfile_server_transport, "rdma")) {
                snprintf (brick_name, sizeof(brick_name), "%s.rdma",
                          cmd_args->brick_name);
                req.brick = brick_name;
        } else {
                if (brickname)
                        req.brick = brickname;
                else
                        req.brick = cmd_args->brick_name;
        }

        req.port  = cmd_args->brick_port;
        req.rdma_port = cmd_args->brick_port2;

        /* mgmt_submit_request is not available in libglusterfs.
         * Need to serialize and submit manually.
         */
        iobref = iobref_new ();
        if (!iobref) {
                goto out;
        }

        xdr_size = xdr_sizeof ((xdrproc_t)xdr_pmap_signout_req, &req);
        iobuf = iobuf_get2 (ctx->iobuf_pool, xdr_size);
        if (!iobuf) {
                goto out;
        };

        iobref_add (iobref, iobuf);

        iov.iov_base = iobuf->ptr;
        iov.iov_len  = iobuf_pagesize (iobuf);

        /* Create the xdr payload */
        ret = xdr_serialize_generic (iov, &req,
                                     (xdrproc_t)xdr_pmap_signout_req);
        if (ret == -1) {
                gf_log (THIS->name, GF_LOG_WARNING,
                        "failed to create XDR payload");
                goto out;
        }
        iov.iov_len = ret;

        ret = rpc_clnt_submit (ctx->mgmt, &clnt_pmap_signout_prog,
                               GF_PMAP_SIGNOUT, mgmt_pmap_signout_cbk,
                               &iov, 1,
                               NULL, 0, iobref, frame, NULL, 0, NULL, 0, NULL);
out:
        if (iobref)
                iobref_unref (iobref);

        if (iobuf)
                iobuf_unref (iobuf);
        return ret;
}
Example #4
0
	if (memcmp(s1, s2, size))
		gf_log("crypt", GF_LOG_DEBUG, "chunks of different data");
	GF_FREE(s1);
	GF_FREE(s2);
}

#else
#define check_iovecs(vec, count, avec, avecn, off) noop
#endif /* DEBUG_CRYPT */

static char *data_alloc_block(xlator_t *this, crypt_local_t *local,
			      int32_t block_size)
{
	struct iobuf *iobuf = NULL;

	iobuf = iobuf_get2(this->ctx->iobuf_pool, block_size);
	if (!iobuf) {
		gf_log("crypt", GF_LOG_ERROR,
		       "Failed to get iobuf");
		return NULL;
	}
	if (!local->iobref_data) {
		local->iobref_data = iobref_new();
		if (!local->iobref_data) {
			gf_log("crypt", GF_LOG_ERROR,
			       "Failed to get iobref");
			iobuf_unref(iobuf);
			return NULL;
		}
	}
	iobref_add(local->iobref_data, iobuf);