Changes in uspace/srv/vfs/vfs_ops.c [b72efe8:25bef0ff] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
rb72efe8 r25bef0ff 78 78 size_t rsize; 79 79 unsigned rlnkcnt; 80 async_exch_t *exch;81 80 sysarg_t rc; 81 int phone; 82 82 aid_t msg; 83 83 ipc_call_t answer; … … 123 123 124 124 /* Tell the mountee that it is being mounted. */ 125 exch = vfs_exchange_grab(fs_handle);126 msg = async_send_1( exch, VFS_OUT_MOUNTED,125 phone = vfs_grab_phone(fs_handle); 126 msg = async_send_1(phone, VFS_OUT_MOUNTED, 127 127 (sysarg_t) devmap_handle, &answer); 128 /* Send the mount options */129 rc = async_data_write_start( exch, (void *)opts,128 /* send the mount options */ 129 rc = async_data_write_start(phone, (void *)opts, 130 130 str_size(opts)); 131 vfs_exchange_release(exch);132 133 131 if (rc != EOK) { 134 132 async_wait_for(msg, NULL); 133 vfs_release_phone(fs_handle, phone); 135 134 fibril_rwlock_write_unlock(&namespace_rwlock); 136 135 async_answer_0(rid, rc); … … 138 137 } 139 138 async_wait_for(msg, &rc); 139 vfs_release_phone(fs_handle, phone); 140 140 141 141 if (rc != EOK) { … … 182 182 */ 183 183 184 async_exch_t *mountee_exch = vfs_exchange_grab(fs_handle);185 assert(mountee_ exch);186 187 exch = vfs_exchange_grab(mp_res.triplet.fs_handle);188 msg = async_send_4( exch, VFS_OUT_MOUNT,184 int mountee_phone = vfs_grab_phone(fs_handle); 185 assert(mountee_phone >= 0); 186 187 phone = vfs_grab_phone(mp_res.triplet.fs_handle); 188 msg = async_send_4(phone, VFS_OUT_MOUNT, 189 189 (sysarg_t) mp_res.triplet.devmap_handle, 190 190 (sysarg_t) mp_res.triplet.index, … … 192 192 (sysarg_t) devmap_handle, &answer); 193 193 194 /* Send connection */ 195 rc = async_exchange_clone(exch, mountee_exch); 196 vfs_exchange_release(mountee_exch); 197 198 if (rc != EOK) { 199 vfs_exchange_release(exch); 194 /* send connection */ 195 rc = async_req_1_0(phone, IPC_M_CONNECTION_CLONE, mountee_phone); 196 if (rc != EOK) { 200 197 async_wait_for(msg, NULL); 201 198 vfs_release_phone(fs_handle, mountee_phone); 199 vfs_release_phone(mp_res.triplet.fs_handle, phone); 202 200 /* Mount failed, drop reference to mp_node. */ 203 201 if (mp_node) 204 202 vfs_node_put(mp_node); 205 206 async_answer_0(rid, rc); 207 fibril_rwlock_write_unlock(&namespace_rwlock); 208 return; 209 } 203 async_answer_0(rid, rc); 204 fibril_rwlock_write_unlock(&namespace_rwlock); 205 return; 206 } 207 208 vfs_release_phone(fs_handle, mountee_phone); 210 209 211 210 /* send the mount options */ 212 rc = async_data_write_start(exch, (void *) opts, str_size(opts)); 213 if (rc != EOK) { 214 vfs_exchange_release(exch); 211 rc = async_data_write_start(phone, (void *)opts, str_size(opts)); 212 if (rc != EOK) { 215 213 async_wait_for(msg, NULL); 216 214 vfs_release_phone(mp_res.triplet.fs_handle, phone); 217 215 /* Mount failed, drop reference to mp_node. */ 218 216 if (mp_node) 219 217 vfs_node_put(mp_node); 220 221 fibril_rwlock_write_unlock(&namespace_rwlock); 222 async_answer_0(rid, rc); 223 return; 224 } 225 226 vfs_exchange_release(exch); 218 fibril_rwlock_write_unlock(&namespace_rwlock); 219 async_answer_0(rid, rc); 220 return; 221 } 227 222 async_wait_for(msg, &rc); 223 vfs_release_phone(mp_res.triplet.fs_handle, phone); 228 224 229 225 if (rc == EOK) { … … 231 227 rsize = (size_t) IPC_GET_ARG2(answer); 232 228 rlnkcnt = (unsigned) IPC_GET_ARG3(answer); 233 229 234 230 mr_res.triplet.fs_handle = fs_handle; 235 231 mr_res.triplet.devmap_handle = devmap_handle; … … 238 234 mr_res.lnkcnt = rlnkcnt; 239 235 mr_res.type = VFS_NODE_DIRECTORY; 240 236 241 237 /* Add reference to the mounted root. */ 242 238 mr_node = vfs_node_get(&mr_res); … … 247 243 vfs_node_put(mp_node); 248 244 } 249 245 250 246 async_answer_0(rid, rc); 251 247 fibril_rwlock_write_unlock(&namespace_rwlock); … … 307 303 308 304 /* 309 * Wait for VFS_IN_PING so that we can return an error if we don't know305 * Wait for IPC_M_PING so that we can return an error if we don't know 310 306 * fs_name. 311 307 */ 312 308 ipc_call_t data; 313 309 ipc_callid_t callid = async_get_call(&data); 314 if (IPC_GET_IMETHOD(data) != VFS_IN_PING) {310 if (IPC_GET_IMETHOD(data) != IPC_M_PING) { 315 311 async_answer_0(callid, ENOTSUP); 316 312 async_answer_0(rid, ENOTSUP); … … 325 321 * This will also give us its file system handle. 326 322 */ 327 fibril_mutex_lock(&fs_ list_lock);323 fibril_mutex_lock(&fs_head_lock); 328 324 fs_handle_t fs_handle; 329 325 recheck: … … 331 327 if (!fs_handle) { 332 328 if (flags & IPC_FLAG_BLOCKING) { 333 fibril_condvar_wait(&fs_ list_cv, &fs_list_lock);329 fibril_condvar_wait(&fs_head_cv, &fs_head_lock); 334 330 goto recheck; 335 331 } 336 332 337 fibril_mutex_unlock(&fs_ list_lock);333 fibril_mutex_unlock(&fs_head_lock); 338 334 async_answer_0(callid, ENOENT); 339 335 async_answer_0(rid, ENOENT); … … 343 339 return; 344 340 } 345 fibril_mutex_unlock(&fs_ list_lock);341 fibril_mutex_unlock(&fs_head_lock); 346 342 347 343 /* Acknowledge that we know fs_name. */ … … 362 358 vfs_lookup_res_t mr_res; 363 359 vfs_node_t *mr_node; 364 async_exch_t *exch;365 360 int phone; 361 366 362 /* 367 363 * Receive the mount point path. … … 371 367 if (rc != EOK) 372 368 async_answer_0(rid, rc); 373 369 374 370 /* 375 371 * Taking the namespace lock will do two things for us. First, it will … … 399 395 return; 400 396 } 401 397 402 398 /* 403 399 * Count the total number of references for the mounted file system. We … … 415 411 return; 416 412 } 417 413 418 414 if (str_cmp(mp, "/") == 0) { 419 415 420 416 /* 421 417 * Unmounting the root file system. … … 424 420 * VFS_OUT_UNMOUNTED directly to the mounted file system. 425 421 */ 426 422 427 423 free(mp); 428 429 exch = vfs_exchange_grab(mr_node->fs_handle); 430 rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED, 424 phone = vfs_grab_phone(mr_node->fs_handle); 425 rc = async_req_1_0(phone, VFS_OUT_UNMOUNTED, 431 426 mr_node->devmap_handle); 432 vfs_exchange_release(exch); 433 427 vfs_release_phone(mr_node->fs_handle, phone); 434 428 if (rc != EOK) { 435 429 fibril_rwlock_write_unlock(&namespace_rwlock); … … 438 432 return; 439 433 } 440 441 434 rootfs.fs_handle = 0; 442 435 rootfs.devmap_handle = 0; 443 436 } else { 444 437 445 438 /* 446 439 * Unmounting a non-root file system. … … 449 442 * file system, so we delegate the operation to it. 450 443 */ 451 444 452 445 rc = vfs_lookup_internal(mp, L_MP, &mp_res, NULL); 453 446 free(mp); … … 458 451 return; 459 452 } 460 461 453 vfs_node_t *mp_node = vfs_node_get(&mp_res); 462 454 if (!mp_node) { … … 466 458 return; 467 459 } 468 469 exch = vfs_exchange_grab(mp_node->fs_handle);470 rc = async_req_2_0( exch, VFS_OUT_UNMOUNT,460 461 phone = vfs_grab_phone(mp_node->fs_handle); 462 rc = async_req_2_0(phone, VFS_OUT_UNMOUNT, 471 463 mp_node->devmap_handle, mp_node->index); 472 vfs_exchange_release(exch); 473 464 vfs_release_phone(mp_node->fs_handle, phone); 474 465 if (rc != EOK) { 475 466 fibril_rwlock_write_unlock(&namespace_rwlock); … … 479 470 return; 480 471 } 481 472 482 473 /* Drop the reference we got above. */ 483 474 vfs_node_put(mp_node); … … 485 476 vfs_node_put(mp_node); 486 477 } 487 478 479 488 480 /* 489 481 * All went well, the mounted file system was successfully unmounted. … … 491 483 */ 492 484 vfs_node_forget(mr_node); 493 485 494 486 fibril_rwlock_write_unlock(&namespace_rwlock); 495 487 async_answer_0(rid, EOK); … … 706 698 */ 707 699 fibril_mutex_lock(&file->lock); 708 async_exch_t *fs_exch = vfs_exchange_grab(file->node->fs_handle);700 int fs_phone = vfs_grab_phone(file->node->fs_handle); 709 701 710 702 /* Make a VFS_OUT_SYMC request at the destination FS server. */ 711 703 aid_t msg; 712 704 ipc_call_t answer; 713 msg = async_send_2(fs_ exch, VFS_OUT_SYNC, file->node->devmap_handle,705 msg = async_send_2(fs_phone, VFS_OUT_SYNC, file->node->devmap_handle, 714 706 file->node->index, &answer); 715 716 vfs_exchange_release(fs_exch); 717 707 718 708 /* Wait for reply from the FS server. */ 719 709 sysarg_t rc; 720 710 async_wait_for(msg, &rc); 721 711 712 vfs_release_phone(file->node->fs_handle, fs_phone); 722 713 fibril_mutex_unlock(&file->lock); 723 714 724 715 vfs_file_put(file); 725 716 async_answer_0(rid, rc); … … 729 720 { 730 721 int fd = IPC_GET_ARG1(*request); 731 int ret = vfs_fd_free(fd); 722 int ret; 723 724 ret = vfs_fd_free(fd); 732 725 async_answer_0(rid, ret); 733 726 } … … 735 728 static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read) 736 729 { 730 vfs_info_t *vi; 731 737 732 /* 738 733 * The following code strongly depends on the fact that the files data … … 744 739 * open files supports parallel access! 745 740 */ 746 741 747 742 int fd = IPC_GET_ARG1(*request); 748 743 … … 759 754 */ 760 755 fibril_mutex_lock(&file->lock); 761 762 v fs_info_t *fs_info= fs_handle_to_info(file->node->fs_handle);763 assert( fs_info);764 756 757 vi = fs_handle_to_info(file->node->fs_handle); 758 assert(vi); 759 765 760 /* 766 761 * Lock the file's node so that no other client can read/write to it at … … 768 763 * write implementation does not modify the file size. 769 764 */ 770 if ((read) || 771 ((fs_info->concurrent_read_write) && (fs_info->write_retains_size))) 765 if (read || (vi->concurrent_read_write && vi->write_retains_size)) 772 766 fibril_rwlock_read_lock(&file->node->contents_rwlock); 773 767 else 774 768 fibril_rwlock_write_lock(&file->node->contents_rwlock); 775 769 776 770 if (file->node->type == VFS_NODE_DIRECTORY) { 777 771 /* … … 783 777 } 784 778 785 async_exch_t *fs_exch = vfs_exchange_grab(file->node->fs_handle);779 int fs_phone = vfs_grab_phone(file->node->fs_handle); 786 780 787 781 /* … … 795 789 ipc_call_t answer; 796 790 if (read) { 797 rc = async_data_read_forward_3_1(fs_ exch, VFS_OUT_READ,791 rc = async_data_read_forward_3_1(fs_phone, VFS_OUT_READ, 798 792 file->node->devmap_handle, file->node->index, file->pos, 799 793 &answer); … … 802 796 file->pos = file->node->size; 803 797 804 rc = async_data_write_forward_3_1(fs_ exch, VFS_OUT_WRITE,798 rc = async_data_write_forward_3_1(fs_phone, VFS_OUT_WRITE, 805 799 file->node->devmap_handle, file->node->index, file->pos, 806 800 &answer); 807 801 } 808 802 809 vfs_ exchange_release(fs_exch);803 vfs_release_phone(file->node->fs_handle, fs_phone); 810 804 811 805 size_t bytes = IPC_GET_ARG1(answer); … … 815 809 816 810 /* Unlock the VFS node. */ 817 if ((read) || 818 ((fs_info->concurrent_read_write) && (fs_info->write_retains_size))) 811 if (read || (vi->concurrent_read_write && vi->write_retains_size)) 819 812 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 820 813 else { … … 936 929 fs_index_t index, aoff64_t size) 937 930 { 938 async_exch_t *exch = vfs_exchange_grab(fs_handle); 939 sysarg_t rc = async_req_4_0(exch, VFS_OUT_TRUNCATE, 940 (sysarg_t) devmap_handle, (sysarg_t) index, LOWER32(size), 941 UPPER32(size)); 942 vfs_exchange_release(exch); 943 944 return (int) rc; 931 sysarg_t rc; 932 int fs_phone; 933 934 fs_phone = vfs_grab_phone(fs_handle); 935 rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (sysarg_t) devmap_handle, 936 (sysarg_t) index, LOWER32(size), UPPER32(size)); 937 vfs_release_phone(fs_handle, fs_phone); 938 return (int)rc; 945 939 } 946 940 … … 992 986 fibril_mutex_lock(&file->lock); 993 987 994 async_exch_t *exch = vfs_exchange_grab(file->node->fs_handle);988 int fs_phone = vfs_grab_phone(file->node->fs_handle); 995 989 996 990 aid_t msg; 997 msg = async_send_3( exch, VFS_OUT_STAT, file->node->devmap_handle,991 msg = async_send_3(fs_phone, VFS_OUT_STAT, file->node->devmap_handle, 998 992 file->node->index, true, NULL); 999 async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 1000 1001 vfs_exchange_release(exch); 1002 993 async_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 1003 994 async_wait_for(msg, &rc); 1004 995 vfs_release_phone(file->node->fs_handle, fs_phone); 996 1005 997 fibril_mutex_unlock(&file->lock); 1006 998 vfs_file_put(file); … … 1045 1037 fibril_rwlock_read_unlock(&namespace_rwlock); 1046 1038 1047 async_exch_t *exch = vfs_exchange_grab(node->fs_handle); 1048 1039 int fs_phone = vfs_grab_phone(node->fs_handle); 1049 1040 aid_t msg; 1050 msg = async_send_3( exch, VFS_OUT_STAT, node->devmap_handle,1041 msg = async_send_3(fs_phone, VFS_OUT_STAT, node->devmap_handle, 1051 1042 node->index, false, NULL); 1052 async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 1053 1054 vfs_exchange_release(exch); 1043 async_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 1055 1044 1056 1045 sysarg_t rv; 1057 1046 async_wait_for(msg, &rv); 1047 vfs_release_phone(node->fs_handle, fs_phone); 1058 1048 1059 1049 async_answer_0(rid, rv);
Note:
See TracChangeset
for help on using the changeset viewer.