Lines Matching refs:c

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