Lines Matching defs:c
226 static int p9_fcall_init(struct p9_client *c, struct p9_fcall *fc,
229 if (likely(c->fcall_cache) && alloc_msize == c->msize) {
230 fc->sdata = kmem_cache_alloc(c->fcall_cache, GFP_NOFS);
231 fc->cache = c->fcall_cache;
263 * @c: Client session.
278 p9_tag_alloc(struct p9_client *c, int8_t type, uint t_size, uint r_size,
288 alloc_tsize = min_t(size_t, c->msize,
289 t_size ?: p9_msg_buf_size(c, type, fmt, apc));
292 alloc_rsize = min_t(size_t, c->msize,
293 r_size ?: p9_msg_buf_size(c, type + 1, fmt, ap));
298 if (p9_fcall_init(c, &req->tc, alloc_tsize))
300 if (p9_fcall_init(c, &req->rc, alloc_rsize))
316 spin_lock_irq(&c->lock);
318 tag = idr_alloc(&c->reqs, req, P9_NOTAG, P9_NOTAG + 1,
321 tag = idr_alloc(&c->reqs, req, 0, P9_NOTAG, GFP_NOWAIT);
323 spin_unlock_irq(&c->lock);
352 * @c: Client session.
358 struct p9_req_t *p9_tag_lookup(struct p9_client *c, u16 tag)
364 req = idr_find(&c->reqs, tag);
374 p9_req_put(c, req);
386 * @c: Client session.
391 static void p9_tag_remove(struct p9_client *c, struct p9_req_t *r)
396 p9_debug(P9_DEBUG_MUX, "freeing clnt %p req %p tag: %d\n", c, r, tag);
397 spin_lock_irqsave(&c->lock, flags);
398 idr_remove(&c->reqs, tag);
399 spin_unlock_irqrestore(&c->lock, flags);
402 int p9_req_put(struct p9_client *c, struct p9_req_t *r)
405 p9_tag_remove(c, r);
418 * @c: v9fs client struct
423 static void p9_tag_cleanup(struct p9_client *c)
429 idr_for_each_entry(&c->reqs, req, id) {
431 if (p9_req_put(c, req) == 0)
440 * @c: client state
445 void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status)
457 p9_req_put(c, req);
513 * @c: current client instance
522 static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
537 trace_9p_protocol_dump(c, &req->rc);
545 if (!p9_is_proto_dotl(c)) {
548 err = p9pdu_readf(&req->rc, c->proto_version, "s?d",
555 if (p9_is_proto_dotu(c) && ecode < 512)
566 err = p9pdu_readf(&req->rc, c->proto_version, "d", &ecode);
583 p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...);
587 * @c: client state
597 static int p9_client_flush(struct p9_client *c, struct p9_req_t *oldreq)
609 req = p9_client_rpc(c, P9_TFLUSH, "w", oldtag);
617 if (c->trans_mod->cancelled)
618 c->trans_mod->cancelled(c, oldreq);
621 p9_req_put(c, req);
625 static struct p9_req_t *p9_client_prepare_req(struct p9_client *c,
633 p9_debug(P9_DEBUG_MUX, "client %p op %d\n", c, type);
636 if (c->status == Disconnected)
640 if (c->status == BeginDisconnect && type != P9_TCLUNK)
644 req = p9_tag_alloc(c, type, t_size, r_size, fmt, apc);
651 err = p9pdu_vwritef(&req->tc, c->proto_version, fmt, ap);
654 p9pdu_finalize(c, &req->tc);
655 trace_9p_client_req(c, type, req->tc.tag);
658 p9_req_put(c, req);
660 p9_req_put(c, req);
666 * @c: client session
668 * @fmt: protocol format string (see protocol.c)
674 p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
688 const uint rsize = c->trans_mod->pooled_rbuffers ? c->msize : 0;
691 req = p9_client_prepare_req(c, type, tsize, rsize, fmt, ap);
706 err = c->trans_mod->request(c, req);
709 p9_req_put(c, req);
711 c->status = Disconnected;
724 if (err == -ERESTARTSYS && c->status == Connected &&
735 if (err == -ERESTARTSYS && c->status == Connected) {
740 if (c->trans_mod->cancel(c, req))
741 p9_client_flush(c, req);
756 err = p9_check_errors(c, req);
757 trace_9p_client_res(c, type, req->rc.tag, err);
761 p9_req_put(c, req);
767 * @c: client session
774 * @fmt: protocol format string (see protocol.c)
778 static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type,
793 req = p9_client_prepare_req(c, type, P9_ZC_HDR_SZ, P9_ZC_HDR_SZ, fmt, ap);
808 err = c->trans_mod->zc_request(c, req, uidata, uodata,
812 c->status = Disconnected;
820 if (err == -ERESTARTSYS && c->status == Connected) {
825 if (c->trans_mod->cancel(c, req))
826 p9_client_flush(c, req);
841 err = p9_check_errors(c, req);
842 trace_9p_client_res(c, type, req->rc.tag, err);
846 p9_req_put(c, req);
910 static int p9_client_version(struct p9_client *c)
918 c->msize, c->proto_version);
920 switch (c->proto_version) {
922 req = p9_client_rpc(c, P9_TVERSION, "ds",
923 c->msize, "9P2000.L");
926 req = p9_client_rpc(c, P9_TVERSION, "ds",
927 c->msize, "9P2000.u");
930 req = p9_client_rpc(c, P9_TVERSION, "ds",
931 c->msize, "9P2000");
940 err = p9pdu_readf(&req->rc, c->proto_version, "ds", &msize, &version);
943 trace_9p_protocol_dump(c, &req->rc);
949 c->proto_version = p9_proto_2000L;
951 c->proto_version = p9_proto_2000u;
953 c->proto_version = p9_proto_legacy;
967 if (msize < c->msize)
968 c->msize = msize;
972 p9_req_put(c, req);