Changeset 7fff5eab in mainline


Ignore:
Timestamp:
2008-01-08T20:38:59Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
67f63c4
Parents:
752ccee
Message:

Management of the cached VFS node size.

Location:
uspace/srv
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r752ccee r7fff5eab  
    275275        }
    276276
    277         ipc_answer_3(rid, EOK, tmpfs_reg.fs_handle, dev_handle, dcur->index);
     277        ipc_answer_4(rid, EOK, tmpfs_reg.fs_handle, dev_handle, dcur->index,
     278            dcur->size);
    278279}
    279280
     
    373374        dentry->data = newdata;
    374375        (void) ipc_data_write_finalize(callid, dentry->data + pos, len);
    375         ipc_answer_1(rid, EOK, len);
     376        ipc_answer_2(rid, EOK, len, dentry->size);
    376377}
    377378
  • uspace/srv/vfs/vfs.h

    r752ccee r7fff5eab  
    188188extern int fs_name_to_handle(char *, bool);
    189189
    190 extern int vfs_lookup_internal(char *, size_t, vfs_triplet_t *, vfs_pair_t *);
     190extern int vfs_lookup_internal(char *, size_t, vfs_triplet_t *, size_t *,
     191    vfs_pair_t *);
    191192
    192193extern bool vfs_nodes_init(void);
    193 extern vfs_node_t *vfs_node_get(vfs_triplet_t *);
     194extern vfs_node_t *vfs_node_get(vfs_triplet_t *, size_t);
    194195extern void vfs_node_put(vfs_node_t *);
    195196
  • uspace/srv/vfs/vfs_lookup.c

    r752ccee r7fff5eab  
    5757 * @param len           Number of path characters pointed by path.
    5858 * @param result        Empty node structure where the result will be stored.
     59 * @param size          Storage where the size of the node will be stored. Can
     60 *                      be NULL.
    5961 * @param altroot       If non-empty, will be used instead of rootfs as the root
    6062 *                      of the whole VFS tree.
     
    6365 */
    6466int vfs_lookup_internal(char *path, size_t len, vfs_triplet_t *result,
    65     vfs_pair_t *altroot)
     67    size_t *size, vfs_pair_t *altroot)
    6668{
    6769        vfs_pair_t *root;
     
    166168                result->dev_handle = (int) IPC_GET_ARG2(answer);
    167169                result->index = (int) IPC_GET_ARG3(answer);
     170                if (size)
     171                        *size = (size_t) IPC_GET_ARG4(answer);
    168172        }
    169173
  • uspace/srv/vfs/vfs_mount.c

    r752ccee r7fff5eab  
    5353};
    5454
    55 static int lookup_root(int fs_handle, int dev_handle, vfs_triplet_t *root)
     55static int lookup_root(int fs_handle, int dev_handle, vfs_triplet_t *root,
     56    size_t *size)
    5657{
    5758        vfs_pair_t altroot = {
     
    6061        };
    6162
    62         return vfs_lookup_internal("/", strlen("/"), root, &altroot);
     63        return vfs_lookup_internal("/", strlen("/"), root, size, &altroot);
    6364}
    6465
     
    161162        int rc;
    162163        vfs_triplet_t mounted_root;
    163         rc = lookup_root(fs_handle, dev_handle, &mounted_root);
     164        size_t mrsz;
     165        rc = lookup_root(fs_handle, dev_handle, &mounted_root, &mrsz);
    164166        if (rc != EOK) {
    165167                free(buf);
     
    167169                return;
    168170        }
    169         vfs_node_t *mr_node = vfs_node_get(&mounted_root);
     171        vfs_node_t *mr_node = vfs_node_get(&mounted_root, mrsz);
    170172        if (!mr_node) {
    171173                free(buf);
     
    178180         */
    179181        vfs_triplet_t mp;
     182        size_t mpsz;
    180183        futex_down(&rootfs_futex);
    181184        if (rootfs.fs_handle) {
     
    184187                 */
    185188                rwlock_writer_lock(&namespace_rwlock);
    186                 rc = vfs_lookup_internal(buf, size, &mp, NULL);
     189                rc = vfs_lookup_internal(buf, size, &mp, &mpsz, NULL);
    187190                if (rc != EOK) {
    188191                        /*
     
    196199                        return;
    197200                }
    198                 mp_node = vfs_node_get(&mp);
     201                mp_node = vfs_node_get(&mp, mpsz);
    199202                if (!mp_node) {
    200203                        rwlock_writer_unlock(&namespace_rwlock);
  • uspace/srv/vfs/vfs_node.c

    r752ccee r7fff5eab  
    4343#include <rwlock.h>
    4444#include <libadt/hash_table.h>
     45#include <assert.h>
    4546
    4647/** Futex protecting the VFS node hash table. */
     
    122123 *
    123124 * @param triplet       Triplet encoding the identity of the VFS node.
     125 * @param size          Size of the node as filled by vfs_lookup_internal().
    124126 *
    125127 * @return              VFS node corresponding to the given triplet.
    126128 */
    127 vfs_node_t *vfs_node_get(vfs_triplet_t *triplet)
     129vfs_node_t *vfs_node_get(vfs_triplet_t *triplet, size_t size)
    128130{
    129131        unsigned long key[] = {
     
    147149                node->dev_handle = triplet->fs_handle;
    148150                node->index = triplet->index;
     151                node->size = size;
    149152                link_initialize(&node->nh_link);
    150153                rwlock_initialize(&node->contents_rwlock);
     
    153156                node = hash_table_get_instance(tmp, vfs_node_t, nh_link);       
    154157        }
     158
     159        assert(node->size == size);
     160
    155161        _vfs_node_addref(node);
    156162        futex_up(&nodes_futex);
  • uspace/srv/vfs/vfs_open.c

    r752ccee r7fff5eab  
    5858        int flags = IPC_GET_ARG1(*request);
    5959        int mode = IPC_GET_ARG2(*request);
    60         size_t size;
     60        size_t len;
    6161
    6262        ipc_callid_t callid;
    6363
    64         if (!ipc_data_write_receive(&callid, &size)) {
     64        if (!ipc_data_write_receive(&callid, &len)) {
    6565                ipc_answer_0(callid, EINVAL);
    6666                ipc_answer_0(rid, EINVAL);
     
    7474         * directly into the PLB using some kind of a callback.
    7575         */
    76         char *path = malloc(size);
     76        char *path = malloc(len);
    7777       
    7878        if (!path) {
     
    8383
    8484        int rc;
    85         if ((rc = ipc_data_write_finalize(callid, path, size))) {
     85        if ((rc = ipc_data_write_finalize(callid, path, len))) {
    8686                ipc_answer_0(rid, rc);
    8787                free(path);
     
    100100         */
    101101        vfs_triplet_t triplet;
    102         rc = vfs_lookup_internal(path, size, &triplet, NULL);
     102        size_t size;
     103        rc = vfs_lookup_internal(path, len, &triplet, &size, NULL);
    103104        if (rc) {
    104105                rwlock_reader_unlock(&namespace_rwlock);
     
    113114        free(path);
    114115
    115         vfs_node_t *node = vfs_node_get(&triplet);
     116        vfs_node_t *node = vfs_node_get(&triplet, size);
    116117        rwlock_reader_unlock(&namespace_rwlock);
    117118
  • uspace/srv/vfs/vfs_rdwr.c

    r752ccee r7fff5eab  
    130130        if (read)
    131131                rwlock_reader_unlock(&file->node->contents_rwlock);
    132         else
     132        else {
     133                /* Update the cached version of node's size. */
     134                file->node->size = IPC_GET_ARG2(answer);
    133135                rwlock_writer_unlock(&file->node->contents_rwlock);
     136        }
    134137
    135138        /*
Note: See TracChangeset for help on using the changeset viewer.