Changeset 493853ec in mainline


Ignore:
Timestamp:
2009-05-23T16:25:58Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ac23b9d3
Parents:
4ef6645
Message:

Hold the namespace rwlock during the entire operation of vfs_mount_internal().
Get rid of rootfs futex, which is not needed anymore.
Do not instantiate VFS node for the mounted root if the mount failed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_ops.c

    r4ef6645 r493853ec  
    7575RWLOCK_INITIALIZE(namespace_rwlock);
    7676
    77 futex_t rootfs_futex = FUTEX_INITIALIZER;
    7877vfs_pair_t rootfs = {
    7978        .fs_handle = 0,
     
    9695        ipc_call_t answer;
    9796                       
    98 
    9997        /* Resolve the path to the mountpoint. */
    100         futex_down(&rootfs_futex);
     98        rwlock_write_lock(&namespace_rwlock);
    10199        if (rootfs.fs_handle) {
    102100                /* We already have the root FS. */
    103                 rwlock_write_lock(&namespace_rwlock);
    104101                if (str_cmp(mp, "/") == 0) {
    105102                        /* Trying to mount root FS over root FS */
     103                        ipc_answer_0(rid, EBUSY);
    106104                        rwlock_write_unlock(&namespace_rwlock);
    107                         futex_up(&rootfs_futex);
    108                         ipc_answer_0(rid, EBUSY);
    109105                        return;
    110106                }
     
    113109                if (rc != EOK) {
    114110                        /* The lookup failed for some reason. */
     111                        ipc_answer_0(rid, rc);
    115112                        rwlock_write_unlock(&namespace_rwlock);
    116                         futex_up(&rootfs_futex);
    117                         ipc_answer_0(rid, rc);
    118113                        return;
    119114                }
     
    121116                mp_node = vfs_node_get(&mp_res);
    122117                if (!mp_node) {
     118                        ipc_answer_0(rid, ENOMEM);
    123119                        rwlock_write_unlock(&namespace_rwlock);
    124                         futex_up(&rootfs_futex);
    125                         ipc_answer_0(rid, ENOMEM);
    126120                        return;
    127121                }
     
    132126                 * This prevents the mount point from being deleted.
    133127                 */
    134                 rwlock_write_unlock(&namespace_rwlock);
    135128        } else {
    136129                /* We still don't have the root file system mounted. */
     
    151144                                async_wait_for(msg, NULL);
    152145                                vfs_release_phone(phone);
    153                                 futex_up(&rootfs_futex);
    154146                                ipc_answer_0(rid, rc);
     147                                rwlock_write_unlock(&namespace_rwlock);
    155148                                return;
    156149                        }
     
    159152                       
    160153                        if (rc != EOK) {
    161                                 futex_up(&rootfs_futex);
    162154                                ipc_answer_0(rid, rc);
     155                                rwlock_write_unlock(&namespace_rwlock);
    163156                                return;
    164157                        }
     
    177170                        rootfs.fs_handle = fs_handle;
    178171                        rootfs.dev_handle = dev_handle;
    179                         futex_up(&rootfs_futex);
    180172                       
    181173                        /* Add reference to the mounted root. */
     
    184176                       
    185177                        ipc_answer_0(rid, rc);
     178                        rwlock_write_unlock(&namespace_rwlock);
    186179                        return;
    187180                } else {
     
    190183                         * being mounted first.
    191184                         */
    192                         futex_up(&rootfs_futex);
    193185                        ipc_answer_0(rid, ENOENT);
     186                        rwlock_write_unlock(&namespace_rwlock);
    194187                        return;
    195188                }
    196189        }
    197         futex_up(&rootfs_futex);
    198190       
    199191        /*
     
    222214                        vfs_node_put(mp_node);
    223215                ipc_answer_0(rid, rc);
     216                rwlock_write_unlock(&namespace_rwlock);
    224217                return;
    225218        }
     
    234227                        vfs_node_put(mp_node);
    235228                ipc_answer_0(rid, rc);
     229                rwlock_write_unlock(&namespace_rwlock);
    236230                return;
    237231        }
     
    239233        vfs_release_phone(phone);
    240234       
    241         if (rc != EOK) {
     235        if (rc == EOK) {
     236                rindex = (fs_index_t) IPC_GET_ARG1(answer);
     237                rsize = (size_t) IPC_GET_ARG2(answer);
     238                rlnkcnt = (unsigned) IPC_GET_ARG3(answer);
     239       
     240                mr_res.triplet.fs_handle = fs_handle;
     241                mr_res.triplet.dev_handle = dev_handle;
     242                mr_res.triplet.index = rindex;
     243                mr_res.size = rsize;
     244                mr_res.lnkcnt = rlnkcnt;
     245                mr_res.type = VFS_NODE_DIRECTORY;
     246       
     247                /* Add reference to the mounted root. */
     248                mr_node = vfs_node_get(&mr_res);
     249                assert(mr_node);
     250        } else {
    242251                /* Mount failed, drop reference to mp_node. */
    243252                if (mp_node)
    244253                        vfs_node_put(mp_node);
    245254        }
    246        
    247         rindex = (fs_index_t) IPC_GET_ARG1(answer);
    248         rsize = (size_t) IPC_GET_ARG2(answer);
    249         rlnkcnt = (unsigned) IPC_GET_ARG3(answer);
    250        
    251         mr_res.triplet.fs_handle = fs_handle;
    252         mr_res.triplet.dev_handle = dev_handle;
    253         mr_res.triplet.index = rindex;
    254         mr_res.size = rsize;
    255         mr_res.lnkcnt = rlnkcnt;
    256         mr_res.type = VFS_NODE_DIRECTORY;
    257        
    258         /* Add reference to the mounted root. */
    259         mr_node = vfs_node_get(&mr_res);
    260         assert(mr_node);
    261255
    262256        ipc_answer_0(rid, rc);
     257        rwlock_write_unlock(&namespace_rwlock);
    263258}
    264259
Note: See TracChangeset for help on using the changeset viewer.