Lines Matching +full:dsd +full:- +full:path
1 // SPDX-License-Identifier: GPL-2.0-only
39 * - a little lazy - parse all client options
60 return clnt->proto_version == p9_proto_2000L; in p9_is_proto_dotl()
66 return clnt->proto_version == p9_proto_2000u; in p9_is_proto_dotu()
72 if (clnt->msize != DEFAULT_MSIZE) in p9_show_client_options()
73 seq_printf(m, ",msize=%u", clnt->msize); in p9_show_client_options()
74 seq_printf(m, ",trans=%s", clnt->trans_mod->name); in p9_show_client_options()
76 switch (clnt->proto_version) { in p9_show_client_options()
88 if (clnt->trans_mod->show_options) in p9_show_client_options()
89 return clnt->trans_mod->show_options(m, clnt); in p9_show_client_options()
99 if (err > 0 || err < -MAX_ERRNO) { in safe_errno()
101 return -EPROTO; in safe_errno()
109 int version = -EINVAL; in get_protocol_version()
128 * parse_opts - parse mount options into client structure
132 * Return 0 upon success, -ERRNO upon failure
144 clnt->proto_version = p9_proto_2000L; in parse_opts()
145 clnt->msize = DEFAULT_MSIZE; in parse_opts()
152 return -ENOMEM; in parse_opts()
173 ret = -EINVAL; in parse_opts()
176 clnt->msize = option; in parse_opts()
181 ret = -ENOMEM; in parse_opts()
187 v9fs_put_trans(clnt->trans_mod); in parse_opts()
188 clnt->trans_mod = v9fs_get_trans_by_name(s); in parse_opts()
189 if (!clnt->trans_mod) { in parse_opts()
192 ret = -EINVAL; in parse_opts()
197 clnt->proto_version = p9_proto_legacy; in parse_opts()
202 ret = -ENOMEM; in parse_opts()
211 clnt->proto_version = r; in parse_opts()
221 v9fs_put_trans(clnt->trans_mod); in parse_opts()
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()
233 fc->sdata = kmalloc(alloc_msize, GFP_NOFS); in p9_fcall_init()
234 fc->cache = NULL; in p9_fcall_init()
236 if (!fc->sdata) in p9_fcall_init()
237 return -ENOMEM; in p9_fcall_init()
238 fc->capacity = alloc_msize; in p9_fcall_init()
239 fc->id = 0; in p9_fcall_init()
240 fc->tag = P9_NOTAG; in p9_fcall_init()
247 * and kmem_cache_free does not do NULL-check for us in p9_fcall_fini()
249 if (unlikely(!fc->sdata)) in p9_fcall_fini()
252 if (fc->cache) in p9_fcall_fini()
253 kmem_cache_free(fc->cache, fc->sdata); in p9_fcall_fini()
255 kfree(fc->sdata); in p9_fcall_fini()
262 * p9_tag_alloc - Allocate a new request.
288 alloc_tsize = min_t(size_t, c->msize, in p9_tag_alloc()
292 alloc_rsize = min_t(size_t, c->msize, in p9_tag_alloc()
296 return ERR_PTR(-ENOMEM); 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()
303 p9pdu_reset(&req->tc); in p9_tag_alloc()
304 p9pdu_reset(&req->rc); in p9_tag_alloc()
305 req->t_err = 0; in p9_tag_alloc()
306 req->status = REQ_STATUS_ALLOC; in p9_tag_alloc()
311 refcount_set(&req->refcount, 0); in p9_tag_alloc()
312 init_waitqueue_head(&req->wq); in p9_tag_alloc()
313 INIT_LIST_HEAD(&req->req_list); 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()
322 req->tc.tag = tag; in p9_tag_alloc()
323 spin_unlock_irq(&c->lock); in p9_tag_alloc()
338 refcount_set(&req->refcount, 2); in p9_tag_alloc()
343 p9_fcall_fini(&req->tc); in p9_tag_alloc()
344 p9_fcall_fini(&req->rc); in p9_tag_alloc()
347 return ERR_PTR(-ENOMEM); in p9_tag_alloc()
351 * p9_tag_lookup - Look up a request by tag.
364 req = idr_find(&c->reqs, tag); in p9_tag_lookup()
373 if (req->tc.tag != tag) { in p9_tag_lookup()
385 * p9_tag_remove - Remove a tag.
394 u16 tag = r->tc.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()
404 if (refcount_dec_and_test(&r->refcount)) { in p9_req_put()
407 p9_fcall_fini(&r->tc); in p9_req_put()
408 p9_fcall_fini(&r->rc); in p9_req_put()
417 * p9_tag_cleanup - cleans up tags structure and reclaims resources
429 idr_for_each_entry(&c->reqs, req, id) { in p9_tag_cleanup()
433 req->tc.tag); in p9_tag_cleanup()
439 * p9_client_cb - call back from transport to client
447 p9_debug(P9_DEBUG_MUX, " tag %d\n", req->tc.tag); in p9_client_cb()
453 WRITE_ONCE(req->status, status); in p9_client_cb()
455 wake_up(&req->wq); in p9_client_cb()
456 p9_debug(P9_DEBUG_MUX, "wakeup: %d\n", req->tc.tag); in p9_client_cb()
462 * p9_parse_header - parse header arguments out of a packet
477 int offset = pdu->offset; in p9_parse_header()
480 pdu->offset = 0; in p9_parse_header()
493 if (pdu->size != r_size || r_size < 7) { in p9_parse_header()
494 err = -EINVAL; in p9_parse_header()
498 pdu->id = r_type; in p9_parse_header()
499 pdu->tag = r_tag; in p9_parse_header()
502 pdu->size, pdu->id, pdu->tag); in p9_parse_header()
506 pdu->offset = offset; in p9_parse_header()
512 * p9_check_errors - check 9p packet for error return and process it
528 err = p9_parse_header(&req->rc, NULL, &type, NULL, 0); in p9_check_errors()
529 if (req->rc.size > req->rc.capacity && !req->rc.zc) { in p9_check_errors()
531 req->rc.size, req->rc.capacity, req->rc.id); in p9_check_errors()
532 return -EIO; in p9_check_errors()
537 trace_9p_protocol_dump(c, &req->rc); in p9_check_errors()
548 err = p9pdu_readf(&req->rc, c->proto_version, "s?d", in p9_check_errors()
556 err = -ecode; in p9_check_errors()
562 -ecode, ename); in p9_check_errors()
566 err = p9pdu_readf(&req->rc, c->proto_version, "d", &ecode); in p9_check_errors()
569 err = -ecode; in p9_check_errors()
571 p9_debug(P9_DEBUG_9P, "<<< RLERROR (%d)\n", -ecode); in p9_check_errors()
586 * p9_client_flush - flush (cancel) a request
603 err = p9_parse_header(&oldreq->tc, NULL, NULL, &oldtag, 1); in p9_client_flush()
616 if (READ_ONCE(oldreq->status) == REQ_STATUS_SENT) { 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()
636 if (c->status == Disconnected) in p9_client_prepare_req()
637 return ERR_PTR(-EIO); in p9_client_prepare_req()
640 if (c->status == BeginDisconnect && type != P9_TCLUNK) in p9_client_prepare_req()
641 return ERR_PTR(-EIO); in p9_client_prepare_req()
650 p9pdu_prepare(&req->tc, req->tc.tag, type); 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()
665 * p9_client_rpc - issue a request and wait for a response
688 const uint rsize = c->trans_mod->pooled_rbuffers ? c->msize : 0; in p9_client_rpc()
696 req->tc.zc = false; in p9_client_rpc()
697 req->rc.zc = false; in p9_client_rpc()
706 err = c->trans_mod->request(c, req); in p9_client_rpc()
710 if (err != -ERESTARTSYS && err != -EFAULT) in p9_client_rpc()
711 c->status = Disconnected; in p9_client_rpc()
716 err = wait_event_killable(req->wq, in p9_client_rpc()
717 READ_ONCE(req->status) >= REQ_STATUS_RCVD); in p9_client_rpc()
720 * threads - echoes to wmb() in the callback in p9_client_rpc()
724 if (err == -ERESTARTSYS && c->status == Connected && in p9_client_rpc()
731 if (READ_ONCE(req->status) == REQ_STATUS_ERROR) { in p9_client_rpc()
732 p9_debug(P9_DEBUG_ERROR, "req_status error %d\n", req->t_err); in p9_client_rpc()
733 err = req->t_err; 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()
744 if (READ_ONCE(req->status) == REQ_STATUS_RCVD) in p9_client_rpc()
749 spin_lock_irqsave(¤t->sighand->siglock, flags); in p9_client_rpc()
751 spin_unlock_irqrestore(¤t->sighand->siglock, flags); in p9_client_rpc()
757 trace_9p_client_res(c, type, req->rc.tag, err); in p9_client_rpc()
766 * p9_client_zc_rpc - issue a request and wait for a response
791 * The actual content is passed in zero-copy fashion. in p9_client_zc_rpc()
798 req->tc.zc = true; in p9_client_zc_rpc()
799 req->rc.zc = true; in p9_client_zc_rpc()
808 err = c->trans_mod->zc_request(c, req, uidata, uodata, in p9_client_zc_rpc()
811 if (err == -EIO) in p9_client_zc_rpc()
812 c->status = Disconnected; in p9_client_zc_rpc()
813 if (err != -ERESTARTSYS) in p9_client_zc_rpc()
816 if (READ_ONCE(req->status) == REQ_STATUS_ERROR) { in p9_client_zc_rpc()
817 p9_debug(P9_DEBUG_ERROR, "req_status error %d\n", req->t_err); in p9_client_zc_rpc()
818 err = req->t_err; 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()
829 if (READ_ONCE(req->status) == REQ_STATUS_RCVD) in p9_client_zc_rpc()
834 spin_lock_irqsave(¤t->sighand->siglock, flags); in p9_client_zc_rpc()
836 spin_unlock_irqrestore(¤t->sighand->siglock, flags); in p9_client_zc_rpc()
842 trace_9p_client_res(c, type, req->rc.tag, err); in p9_client_zc_rpc()
860 fid->mode = -1; in p9_fid_create()
861 fid->uid = current_fsuid(); in p9_fid_create()
862 fid->clnt = clnt; in p9_fid_create()
863 refcount_set(&fid->count, 1); in p9_fid_create()
866 spin_lock_irq(&clnt->lock); in p9_fid_create()
867 ret = idr_alloc_u32(&clnt->fids, fid, &fid->fid, P9_NOFID - 1, in p9_fid_create()
869 spin_unlock_irq(&clnt->lock); in p9_fid_create()
885 p9_debug(P9_DEBUG_FID, "fid %d\n", fid->fid); in p9_fid_destroy()
887 clnt = fid->clnt; in p9_fid_destroy()
888 spin_lock_irqsave(&clnt->lock, flags); in p9_fid_destroy()
889 idr_remove(&clnt->fids, fid->fid); in p9_fid_destroy()
890 spin_unlock_irqrestore(&clnt->lock, flags); in p9_fid_destroy()
891 kfree(fid->rdir); in p9_fid_destroy()
918 c->msize, c->proto_version); in p9_client_version()
920 switch (c->proto_version) { in p9_client_version()
923 c->msize, "9P2000.L"); in p9_client_version()
927 c->msize, "9P2000.u"); in p9_client_version()
931 c->msize, "9P2000"); in p9_client_version()
934 return -EINVAL; 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()
957 err = -EREMOTEIO; in p9_client_version()
964 err = -EREMOTEIO; in p9_client_version()
967 if (msize < c->msize) in p9_client_version()
968 c->msize = msize; in p9_client_version()
987 return ERR_PTR(-ENOMEM); in p9_client_create()
989 clnt->trans_mod = NULL; in p9_client_create()
990 clnt->trans = NULL; in p9_client_create()
991 clnt->fcall_cache = NULL; in p9_client_create()
993 client_id = utsname()->nodename; in p9_client_create()
994 memcpy(clnt->name, client_id, strlen(client_id) + 1); in p9_client_create()
996 spin_lock_init(&clnt->lock); in p9_client_create()
997 idr_init(&clnt->fids); in p9_client_create()
998 idr_init(&clnt->reqs); in p9_client_create()
1004 if (!clnt->trans_mod) in p9_client_create()
1005 clnt->trans_mod = v9fs_get_default_trans(); in p9_client_create()
1007 if (!clnt->trans_mod) { in p9_client_create()
1008 err = -EPROTONOSUPPORT; in p9_client_create()
1015 clnt, clnt->trans_mod, clnt->msize, clnt->proto_version); in p9_client_create()
1017 err = clnt->trans_mod->create(clnt, dev_name, options); in p9_client_create()
1021 if (clnt->msize > clnt->trans_mod->maxsize) { in p9_client_create()
1022 clnt->msize = clnt->trans_mod->maxsize; in p9_client_create()
1025 clnt->msize, clnt->trans_mod->name in p9_client_create()
1029 if (clnt->msize < 4096) { in p9_client_create()
1032 err = -EINVAL; in p9_client_create()
1041 "9p-fcall-cache-%u", atomic_inc_return(&seqno)); in p9_client_create()
1043 err = -ENOMEM; in p9_client_create()
1050 clnt->fcall_cache = in p9_client_create()
1051 kmem_cache_create_usercopy(cache_name, clnt->msize, in p9_client_create()
1053 clnt->msize - (P9_HDRSZ + 4), in p9_client_create()
1060 clnt->trans_mod->close(clnt); in p9_client_create()
1062 v9fs_put_trans(clnt->trans_mod); in p9_client_create()
1076 if (clnt->trans_mod) in p9_client_destroy()
1077 clnt->trans_mod->close(clnt); in p9_client_destroy()
1079 v9fs_put_trans(clnt->trans_mod); in p9_client_destroy()
1081 idr_for_each_entry(&clnt->fids, fid, id) { in p9_client_destroy()
1082 pr_info("Found fid %d not clunked\n", fid->fid); in p9_client_destroy()
1088 kmem_cache_destroy(clnt->fcall_cache); in p9_client_destroy()
1096 clnt->status = Disconnected; in p9_client_disconnect()
1103 clnt->status = BeginDisconnect; in p9_client_begin_disconnect()
1117 afid ? afid->fid : -1, uname, aname); in p9_client_attach()
1120 err = -ENOMEM; in p9_client_attach()
1123 fid->uid = n_uname; in p9_client_attach()
1125 req = p9_client_rpc(clnt, P9_TATTACH, "ddss?u", fid->fid, in p9_client_attach()
1126 afid ? afid->fid : P9_NOFID, uname, aname, n_uname); in p9_client_attach()
1132 err = p9pdu_readf(&req->rc, clnt->proto_version, "Q", &qid); in p9_client_attach()
1134 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_attach()
1140 qid.type, qid.path, qid.version); in p9_client_attach()
1142 memmove(&fid->qid, &qid, sizeof(struct p9_qid)); in p9_client_attach()
1165 clnt = oldfid->clnt; in p9_client_walk()
1169 err = -ENOMEM; in p9_client_walk()
1173 fid->uid = oldfid->uid; in p9_client_walk()
1179 oldfid->fid, fid->fid, nwname, wnames ? wnames[0] : NULL); in p9_client_walk()
1180 req = p9_client_rpc(clnt, P9_TWALK, "ddT", oldfid->fid, fid->fid, in p9_client_walk()
1187 err = p9pdu_readf(&req->rc, clnt->proto_version, "R", &nwqids, &wqids); in p9_client_walk()
1189 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_walk()
1198 err = -ENOENT; in p9_client_walk()
1205 wqids[count].path, in p9_client_walk()
1209 memmove(&fid->qid, &wqids[nwqids - 1], sizeof(struct p9_qid)); in p9_client_walk()
1211 memmove(&fid->qid, &oldfid->qid, sizeof(struct p9_qid)); in p9_client_walk()
1237 clnt = fid->clnt; in p9_client_open()
1239 p9_is_proto_dotl(clnt) ? "TLOPEN" : "TOPEN", fid->fid, mode); in p9_client_open()
1241 if (fid->mode != -1) in p9_client_open()
1242 return -EINVAL; in p9_client_open()
1245 req = p9_client_rpc(clnt, P9_TLOPEN, "dd", fid->fid, mode & P9L_MODE_MASK); in p9_client_open()
1247 req = p9_client_rpc(clnt, P9_TOPEN, "db", fid->fid, mode & P9L_MODE_MASK); in p9_client_open()
1253 err = p9pdu_readf(&req->rc, clnt->proto_version, "Qd", &qid, &iounit); in p9_client_open()
1255 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_open()
1261 qid.path, qid.version, iounit); in p9_client_open()
1263 memmove(&fid->qid, &qid, sizeof(struct p9_qid)); in p9_client_open()
1264 fid->mode = mode; in p9_client_open()
1265 fid->iounit = iounit; in p9_client_open()
1284 ofid->fid, name, flags, mode, in p9_client_create_dotl()
1286 clnt = ofid->clnt; in p9_client_create_dotl()
1288 if (ofid->mode != -1) in p9_client_create_dotl()
1289 return -EINVAL; in p9_client_create_dotl()
1291 req = p9_client_rpc(clnt, P9_TLCREATE, "dsddg", ofid->fid, name, flags, in p9_client_create_dotl()
1298 err = p9pdu_readf(&req->rc, clnt->proto_version, "Qd", qid, &iounit); in p9_client_create_dotl()
1300 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_create_dotl()
1305 qid->type, qid->path, qid->version, iounit); in p9_client_create_dotl()
1307 memmove(&ofid->qid, qid, sizeof(struct p9_qid)); in p9_client_create_dotl()
1308 ofid->mode = flags; in p9_client_create_dotl()
1309 ofid->iounit = iounit; in p9_client_create_dotl()
1328 fid->fid, name, perm, mode); in p9_client_fcreate()
1329 clnt = fid->clnt; in p9_client_fcreate()
1331 if (fid->mode != -1) in p9_client_fcreate()
1332 return -EINVAL; in p9_client_fcreate()
1334 req = p9_client_rpc(clnt, P9_TCREATE, "dsdb?s", fid->fid, name, perm, in p9_client_fcreate()
1341 err = p9pdu_readf(&req->rc, clnt->proto_version, "Qd", &qid, &iounit); in p9_client_fcreate()
1343 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_fcreate()
1348 qid.type, qid.path, qid.version, iounit); in p9_client_fcreate()
1350 memmove(&fid->qid, &qid, sizeof(struct p9_qid)); in p9_client_fcreate()
1351 fid->mode = mode; in p9_client_fcreate()
1352 fid->iounit = iounit; in p9_client_fcreate()
1369 dfid->fid, name, symtgt); in p9_client_symlink()
1370 clnt = dfid->clnt; in p9_client_symlink()
1372 req = p9_client_rpc(clnt, P9_TSYMLINK, "dssg", dfid->fid, name, symtgt, in p9_client_symlink()
1379 err = p9pdu_readf(&req->rc, clnt->proto_version, "Q", qid); in p9_client_symlink()
1381 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_symlink()
1386 qid->type, qid->path, qid->version); in p9_client_symlink()
1401 dfid->fid, oldfid->fid, newname); in p9_client_link()
1402 clnt = dfid->clnt; in p9_client_link()
1403 req = p9_client_rpc(clnt, P9_TLINK, "dds", dfid->fid, oldfid->fid, in p9_client_link()
1421 fid->fid, datasync); in p9_client_fsync()
1422 clnt = fid->clnt; in p9_client_fsync()
1424 req = p9_client_rpc(clnt, P9_TFSYNC, "dd", fid->fid, datasync); in p9_client_fsync()
1430 p9_debug(P9_DEBUG_9P, "<<< RFSYNC fid %d\n", fid->fid); in p9_client_fsync()
1448 fid->fid, retries); in p9_client_clunk()
1449 clnt = fid->clnt; in p9_client_clunk()
1451 req = p9_client_rpc(clnt, P9_TCLUNK, "d", fid->fid); in p9_client_clunk()
1457 p9_debug(P9_DEBUG_9P, "<<< RCLUNK fid %d\n", fid->fid); in p9_client_clunk()
1465 if (err == -ERESTARTSYS) { in p9_client_clunk()
1481 p9_debug(P9_DEBUG_9P, ">>> TREMOVE fid %d\n", fid->fid); in p9_client_remove()
1482 clnt = fid->clnt; in p9_client_remove()
1484 req = p9_client_rpc(clnt, P9_TREMOVE, "d", fid->fid); in p9_client_remove()
1490 p9_debug(P9_DEBUG_9P, "<<< RREMOVE fid %d\n", fid->fid); in p9_client_remove()
1494 if (err == -ERESTARTSYS) in p9_client_remove()
1509 dfid->fid, name, flags); in p9_client_unlinkat()
1511 clnt = dfid->clnt; in p9_client_unlinkat()
1512 req = p9_client_rpc(clnt, P9_TUNLINKAT, "dsd", dfid->fid, name, flags); in p9_client_unlinkat()
1517 p9_debug(P9_DEBUG_9P, "<<< RUNLINKAT fid %d %s\n", dfid->fid, name); in p9_client_unlinkat()
1548 struct p9_client *clnt = fid->clnt; in p9_client_read_once()
1556 fid->fid, offset, iov_iter_count(to)); in p9_client_read_once()
1558 rsize = fid->iounit; in p9_client_read_once()
1559 if (!rsize || rsize > clnt->msize - P9_IOHDRSZ) in p9_client_read_once()
1560 rsize = clnt->msize - P9_IOHDRSZ; in p9_client_read_once()
1566 if (clnt->trans_mod->zc_request && rsize > 1024) { in p9_client_read_once()
1571 0, 11, "dqd", fid->fid, in p9_client_read_once()
1575 req = p9_client_rpc(clnt, P9_TREAD, "dqd", fid->fid, offset, in p9_client_read_once()
1581 iov_iter_revert(to, count - iov_iter_count(to)); in p9_client_read_once()
1585 *err = p9pdu_readf(&req->rc, clnt->proto_version, in p9_client_read_once()
1589 iov_iter_revert(to, count - iov_iter_count(to)); in p9_client_read_once()
1590 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_read_once()
1605 *err = -EFAULT; in p9_client_read_once()
1610 iov_iter_revert(to, count - received - iov_iter_count(to)); in p9_client_read_once()
1620 struct p9_client *clnt = fid->clnt; in p9_client_write()
1627 int rsize = fid->iounit; in p9_client_write()
1630 if (!rsize || rsize > clnt->msize - P9_IOHDRSZ) in p9_client_write()
1631 rsize = clnt->msize - P9_IOHDRSZ; in p9_client_write()
1637 fid->fid, offset, rsize, count); in p9_client_write()
1640 if (clnt->trans_mod->zc_request && rsize > 1024) { in p9_client_write()
1643 fid->fid, offset, rsize); in p9_client_write()
1645 req = p9_client_rpc(clnt, P9_TWRITE, "dqV", fid->fid, in p9_client_write()
1649 iov_iter_revert(from, count - iov_iter_count(from)); in p9_client_write()
1654 *err = p9pdu_readf(&req->rc, clnt->proto_version, "d", &written); in p9_client_write()
1656 iov_iter_revert(from, count - iov_iter_count(from)); in p9_client_write()
1657 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_write()
1669 iov_iter_revert(from, count - written - iov_iter_count(from)); in p9_client_write()
1680 struct netfs_io_request *wreq = subreq->rreq; in p9_client_write_subreq()
1681 struct p9_fid *fid = wreq->netfs_priv; in p9_client_write_subreq()
1682 struct p9_client *clnt = fid->clnt; in p9_client_write_subreq()
1684 unsigned long long start = subreq->start + subreq->transferred; in p9_client_write_subreq()
1685 int written, len = subreq->len - subreq->transferred; in p9_client_write_subreq()
1689 fid->fid, start, len); in p9_client_write_subreq()
1692 if (clnt->trans_mod->zc_request && len > 1024) { in p9_client_write_subreq()
1693 req = p9_client_zc_rpc(clnt, P9_TWRITE, NULL, &subreq->io_iter, in p9_client_write_subreq()
1694 0, wreq->len, P9_ZC_HDR_SZ, "dqd", in p9_client_write_subreq()
1695 fid->fid, start, len); in p9_client_write_subreq()
1697 req = p9_client_rpc(clnt, P9_TWRITE, "dqV", fid->fid, in p9_client_write_subreq()
1698 start, len, &subreq->io_iter); in p9_client_write_subreq()
1705 err = p9pdu_readf(&req->rc, clnt->proto_version, "d", &written); in p9_client_write_subreq()
1707 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_write_subreq()
1733 p9_debug(P9_DEBUG_9P, ">>> TSTAT fid %d\n", fid->fid); in p9_client_stat()
1737 return ERR_PTR(-ENOMEM); in p9_client_stat()
1739 clnt = fid->clnt; in p9_client_stat()
1741 req = p9_client_rpc(clnt, P9_TSTAT, "d", fid->fid); in p9_client_stat()
1747 err = p9pdu_readf(&req->rc, clnt->proto_version, "wS", &ignored, ret); in p9_client_stat()
1749 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_stat()
1759 ret->size, ret->type, ret->dev, ret->qid.type, ret->qid.path, in p9_client_stat()
1760 ret->qid.version, ret->mode, in p9_client_stat()
1761 ret->atime, ret->mtime, ret->length, in p9_client_stat()
1762 ret->name, ret->uid, ret->gid, ret->muid, ret->extension, in p9_client_stat()
1763 from_kuid(&init_user_ns, ret->n_uid), in p9_client_stat()
1764 from_kgid(&init_user_ns, ret->n_gid), in p9_client_stat()
1765 from_kuid(&init_user_ns, ret->n_muid)); in p9_client_stat()
1785 fid->fid, request_mask); in p9_client_getattr_dotl()
1789 return ERR_PTR(-ENOMEM); in p9_client_getattr_dotl()
1791 clnt = fid->clnt; in p9_client_getattr_dotl()
1793 req = p9_client_rpc(clnt, P9_TGETATTR, "dq", fid->fid, request_mask); in p9_client_getattr_dotl()
1799 err = p9pdu_readf(&req->rc, clnt->proto_version, "A", ret); in p9_client_getattr_dotl()
1801 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_getattr_dotl()
1816 ret->st_result_mask, in p9_client_getattr_dotl()
1817 ret->qid.type, ret->qid.path, ret->qid.version, in p9_client_getattr_dotl()
1818 ret->st_mode, ret->st_nlink, in p9_client_getattr_dotl()
1819 from_kuid(&init_user_ns, ret->st_uid), in p9_client_getattr_dotl()
1820 from_kgid(&init_user_ns, ret->st_gid), in p9_client_getattr_dotl()
1821 ret->st_rdev, ret->st_size, ret->st_blksize, ret->st_blocks, in p9_client_getattr_dotl()
1822 ret->st_atime_sec, ret->st_atime_nsec, in p9_client_getattr_dotl()
1823 ret->st_mtime_sec, ret->st_mtime_nsec, in p9_client_getattr_dotl()
1824 ret->st_ctime_sec, ret->st_ctime_nsec, in p9_client_getattr_dotl()
1825 ret->st_btime_sec, ret->st_btime_nsec, in p9_client_getattr_dotl()
1826 ret->st_gen, ret->st_data_version); in p9_client_getattr_dotl()
1847 if (wst->name) in p9_client_statsize()
1848 ret += strlen(wst->name); in p9_client_statsize()
1849 if (wst->uid) in p9_client_statsize()
1850 ret += strlen(wst->uid); in p9_client_statsize()
1851 if (wst->gid) in p9_client_statsize()
1852 ret += strlen(wst->gid); in p9_client_statsize()
1853 if (wst->muid) in p9_client_statsize()
1854 ret += strlen(wst->muid); in p9_client_statsize()
1860 if (wst->extension) in p9_client_statsize()
1861 ret += strlen(wst->extension); in p9_client_statsize()
1873 clnt = fid->clnt; in p9_client_wstat()
1874 wst->size = p9_client_statsize(wst, clnt->proto_version); in p9_client_wstat()
1876 fid->fid); in p9_client_wstat()
1882 wst->size, wst->type, wst->dev, wst->qid.type, in p9_client_wstat()
1883 wst->qid.path, wst->qid.version, in p9_client_wstat()
1884 wst->mode, wst->atime, wst->mtime, wst->length, in p9_client_wstat()
1885 wst->name, wst->uid, wst->gid, wst->muid, wst->extension, in p9_client_wstat()
1886 from_kuid(&init_user_ns, wst->n_uid), in p9_client_wstat()
1887 from_kgid(&init_user_ns, wst->n_gid), in p9_client_wstat()
1888 from_kuid(&init_user_ns, wst->n_muid)); in p9_client_wstat()
1891 fid->fid, wst->size + 2, wst); in p9_client_wstat()
1897 p9_debug(P9_DEBUG_9P, "<<< RWSTAT fid %d\n", fid->fid); in p9_client_wstat()
1911 clnt = fid->clnt; in p9_client_setattr()
1912 p9_debug(P9_DEBUG_9P, ">>> TSETATTR fid %d\n", fid->fid); in p9_client_setattr()
1914 p9attr->valid, p9attr->mode, in p9_client_setattr()
1915 from_kuid(&init_user_ns, p9attr->uid), in p9_client_setattr()
1916 from_kgid(&init_user_ns, p9attr->gid), in p9_client_setattr()
1917 p9attr->size); in p9_client_setattr()
1919 p9attr->atime_sec, p9attr->atime_nsec); in p9_client_setattr()
1921 p9attr->mtime_sec, p9attr->mtime_nsec); in p9_client_setattr()
1923 req = p9_client_rpc(clnt, P9_TSETATTR, "dI", fid->fid, p9attr); in p9_client_setattr()
1929 p9_debug(P9_DEBUG_9P, "<<< RSETATTR fid %d\n", fid->fid); in p9_client_setattr()
1942 clnt = fid->clnt; in p9_client_statfs()
1944 p9_debug(P9_DEBUG_9P, ">>> TSTATFS fid %d\n", fid->fid); in p9_client_statfs()
1946 req = p9_client_rpc(clnt, P9_TSTATFS, "d", fid->fid); in p9_client_statfs()
1952 err = p9pdu_readf(&req->rc, clnt->proto_version, "ddqqqqqqd", &sb->type, in p9_client_statfs()
1953 &sb->bsize, &sb->blocks, &sb->bfree, &sb->bavail, in p9_client_statfs()
1954 &sb->files, &sb->ffree, &sb->fsid, &sb->namelen); in p9_client_statfs()
1956 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_statfs()
1963 fid->fid, sb->type, sb->bsize, sb->blocks, sb->bfree, in p9_client_statfs()
1964 sb->bavail, sb->files, sb->ffree, sb->fsid, sb->namelen); in p9_client_statfs()
1979 clnt = fid->clnt; in p9_client_rename()
1982 fid->fid, newdirfid->fid, name); in p9_client_rename()
1984 req = p9_client_rpc(clnt, P9_TRENAME, "dds", fid->fid, in p9_client_rename()
1985 newdirfid->fid, name); in p9_client_rename()
1991 p9_debug(P9_DEBUG_9P, "<<< RRENAME fid %d\n", fid->fid); in p9_client_rename()
2006 clnt = olddirfid->clnt; in p9_client_renameat()
2010 olddirfid->fid, old_name, newdirfid->fid, new_name); in p9_client_renameat()
2012 req = p9_client_rpc(clnt, P9_TRENAMEAT, "dsds", olddirfid->fid, in p9_client_renameat()
2013 old_name, newdirfid->fid, new_name); in p9_client_renameat()
2020 newdirfid->fid, new_name); in p9_client_renameat()
2038 clnt = file_fid->clnt; in p9_client_xattrwalk()
2041 err = -ENOMEM; in p9_client_xattrwalk()
2046 file_fid->fid, attr_fid->fid, attr_name); in p9_client_xattrwalk()
2049 file_fid->fid, attr_fid->fid, attr_name); in p9_client_xattrwalk()
2054 err = p9pdu_readf(&req->rc, clnt->proto_version, "q", attr_size); in p9_client_xattrwalk()
2056 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_xattrwalk()
2062 attr_fid->fid, *attr_size); in p9_client_xattrwalk()
2084 fid->fid, name, attr_size, flags); in p9_client_xattrcreate()
2085 clnt = fid->clnt; in p9_client_xattrcreate()
2087 fid->fid, name, attr_size, flags); in p9_client_xattrcreate()
2092 p9_debug(P9_DEBUG_9P, "<<< RXATTRCREATE fid %d\n", fid->fid); in p9_client_xattrcreate()
2111 fid->fid, offset, count); in p9_client_readdir()
2113 clnt = fid->clnt; in p9_client_readdir()
2115 rsize = fid->iounit; in p9_client_readdir()
2116 if (!rsize || rsize > clnt->msize - P9_READDIRHDRSZ) in p9_client_readdir()
2117 rsize = clnt->msize - P9_READDIRHDRSZ; in p9_client_readdir()
2123 if (clnt->trans_mod->zc_request && rsize > 1024) { in p9_client_readdir()
2128 11, "dqd", fid->fid, offset, rsize); in p9_client_readdir()
2131 req = p9_client_rpc(clnt, P9_TREADDIR, "dqd", fid->fid, in p9_client_readdir()
2139 err = p9pdu_readf(&req->rc, clnt->proto_version, "D", &count, &dataptr); in p9_client_readdir()
2141 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_readdir()
2171 clnt = fid->clnt; in p9_client_mknod_dotl()
2174 fid->fid, name, mode, MAJOR(rdev), MINOR(rdev)); in p9_client_mknod_dotl()
2175 req = p9_client_rpc(clnt, P9_TMKNOD, "dsdddg", fid->fid, name, mode, in p9_client_mknod_dotl()
2180 err = p9pdu_readf(&req->rc, clnt->proto_version, "Q", qid); in p9_client_mknod_dotl()
2182 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_mknod_dotl()
2186 qid->type, qid->path, qid->version); in p9_client_mknod_dotl()
2201 clnt = fid->clnt; in p9_client_mkdir_dotl()
2203 fid->fid, name, mode, from_kgid(&init_user_ns, gid)); in p9_client_mkdir_dotl()
2205 fid->fid, name, mode, gid); in p9_client_mkdir_dotl()
2209 err = p9pdu_readf(&req->rc, clnt->proto_version, "Q", qid); in p9_client_mkdir_dotl()
2211 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_mkdir_dotl()
2214 p9_debug(P9_DEBUG_9P, "<<< RMKDIR qid %x.%llx.%x\n", qid->type, in p9_client_mkdir_dotl()
2215 qid->path, qid->version); in p9_client_mkdir_dotl()
2229 clnt = fid->clnt; in p9_client_lock_dotl()
2232 fid->fid, flock->type, flock->flags, flock->start, in p9_client_lock_dotl()
2233 flock->length, flock->proc_id, flock->client_id); in p9_client_lock_dotl()
2235 req = p9_client_rpc(clnt, P9_TLOCK, "dbdqqds", fid->fid, flock->type, in p9_client_lock_dotl()
2236 flock->flags, flock->start, flock->length, in p9_client_lock_dotl()
2237 flock->proc_id, flock->client_id); in p9_client_lock_dotl()
2242 err = p9pdu_readf(&req->rc, clnt->proto_version, "b", status); in p9_client_lock_dotl()
2244 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_lock_dotl()
2260 clnt = fid->clnt; in p9_client_getlock_dotl()
2263 fid->fid, glock->type, glock->start, glock->length, in p9_client_getlock_dotl()
2264 glock->proc_id, glock->client_id); in p9_client_getlock_dotl()
2266 req = p9_client_rpc(clnt, P9_TGETLOCK, "dbqqds", fid->fid, in p9_client_getlock_dotl()
2267 glock->type, glock->start, glock->length, in p9_client_getlock_dotl()
2268 glock->proc_id, glock->client_id); in p9_client_getlock_dotl()
2273 err = p9pdu_readf(&req->rc, clnt->proto_version, "bqqds", &glock->type, in p9_client_getlock_dotl()
2274 &glock->start, &glock->length, &glock->proc_id, in p9_client_getlock_dotl()
2275 &glock->client_id); in p9_client_getlock_dotl()
2277 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_getlock_dotl()
2282 glock->type, glock->start, glock->length, in p9_client_getlock_dotl()
2283 glock->proc_id, glock->client_id); in p9_client_getlock_dotl()
2296 clnt = fid->clnt; in p9_client_readlink()
2297 p9_debug(P9_DEBUG_9P, ">>> TREADLINK fid %d\n", fid->fid); in p9_client_readlink()
2299 req = p9_client_rpc(clnt, P9_TREADLINK, "d", fid->fid); in p9_client_readlink()
2303 err = p9pdu_readf(&req->rc, clnt->proto_version, "s", target); in p9_client_readlink()
2305 trace_9p_protocol_dump(clnt, &req->rc); in p9_client_readlink()
2318 return p9_req_cache ? 0 : -ENOMEM; in p9_client_init()