Changeset c544c5d in mainline


Ignore:
Timestamp:
2008-08-08T14:31:05Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
12fc042
Parents:
a61d1fc3
Message:

Stop using fixed size BLOCK_SIZE in the ramdisk task and allow each client to negotiate its own
maximum block size. Allow the individual transfers to use block sizes smaller and equal to the
negotiated maximum block size.

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libfs/libfs.c

    ra61d1fc3 rc544c5d  
    3737#include "libfs.h"
    3838#include "../../srv/vfs/vfs.h"
     39#include "../../srv/rd/rd.h"
    3940#include <errno.h>
    4041#include <async.h>
     
    331332}
    332333
    333 #define RD_BASE         1024    // FIXME
    334 #define RD_READ_BLOCK   (RD_BASE + 1)
    335 
    336334/** Read data from a block device.
    337335 *
  • uspace/srv/rd/rd.c

    ra61d1fc3 rc544c5d  
    8282        int retval;
    8383        void *fs_va = NULL;
    84         ipcarg_t offset;
     84        off_t offset;
     85        size_t block_size;
     86        size_t maxblock_size;
    8587
    8688        /*
    87          * We allocate VA for communication per connection.
    88          * This allows us to potentionally have more clients and work
    89          * concurrently.
     89         * Answer the first IPC_M_CONNECT_ME_TO call.
    9090         */
    91         fs_va = as_get_mappable_page(ALIGN_UP(BLOCK_SIZE, PAGE_SIZE));
    92         if (!fs_va) {
    93                 /*
    94                  * Hang up the phone if we cannot proceed any further.
    95                  * This is the answer to the call that opened the connection.
    96                  */
    97                 ipc_answer_0(iid, EHANGUP);
    98                 return;
    99         } else {
    100                 /*
    101                  * Answer the first IPC_M_CONNECT_ME_TO call.
    102                  * Return supported block size as ARG1.
    103                  */
    104                 ipc_answer_1(iid, EOK, BLOCK_SIZE);
    105         }
     91        ipc_answer_0(iid, EOK);
    10692
    10793        /*
    10894         * Now we wait for the client to send us its communication as_area.
    10995         */
    110         size_t size;
    11196        int flags;
    112         if (ipc_share_out_receive(&callid, &size, &flags)) {
    113                 if (size >= BLOCK_SIZE) {
    114                         /*
    115                          * The client sends an as_area that can absorb the whole
    116                          * block.
    117                          */
     97        if (ipc_share_out_receive(&callid, &maxblock_size, &flags)) {
     98                fs_va = as_get_mappable_page(maxblock_size);
     99                if (fs_va) {
    118100                        (void) ipc_share_out_finalize(callid, fs_va);
    119101                } else {
    120                         /*
    121                          * The client offered as_area too small.
    122                          * Close the connection.
    123                          */
    124102                        ipc_answer_0(callid, EHANGUP);
    125103                        return;         
     
    147125                case RD_READ_BLOCK:
    148126                        offset = IPC_GET_ARG1(call);
    149                         if (offset * BLOCK_SIZE > rd_size - BLOCK_SIZE) {
     127                        block_size = IPC_GET_ARG2(call);
     128                        if (block_size > maxblock_size) {
     129                                /*
     130                                 * Maximum block size exceeded.
     131                                 */
     132                                retval = ELIMIT;
     133                                break;
     134                        }
     135                        if (offset * block_size > rd_size - block_size) {
    150136                                /*
    151137                                 * Reading past the end of the device.
     
    155141                        }
    156142                        futex_down(&rd_futex);
    157                         memcpy(fs_va, rd_addr + offset * BLOCK_SIZE, BLOCK_SIZE);
     143                        memcpy(fs_va, rd_addr + offset * block_size, block_size);
    158144                        futex_up(&rd_futex);
    159145                        retval = EOK;
     
    161147                case RD_WRITE_BLOCK:
    162148                        offset = IPC_GET_ARG1(call);
    163                         if (offset * BLOCK_SIZE > rd_size - BLOCK_SIZE) {
     149                        block_size = IPC_GET_ARG2(call);
     150                        if (block_size > maxblock_size) {
     151                                /*
     152                                 * Maximum block size exceeded.
     153                                 */
     154                                retval = ELIMIT;
     155                                break;
     156                        }
     157                        if (offset * block_size > rd_size - block_size) {
    164158                                /*
    165159                                 * Writing past the end of the device.
     
    169163                        }
    170164                        futex_up(&rd_futex);
    171                         memcpy(rd_addr + offset * BLOCK_SIZE, fs_va, BLOCK_SIZE);
     165                        memcpy(rd_addr + offset * block_size, fs_va, block_size);
    172166                        futex_down(&rd_futex);
    173167                        retval = EOK;
  • uspace/srv/rd/rd.h

    ra61d1fc3 rc544c5d  
    4444#define RD_RD_H_
    4545
    46 #define BLOCK_SIZE      1024    /**< Working block size */
    47 
    4846#define RD_BASE         1024
    4947#define RD_READ_BLOCK   (RD_BASE + 1)   /**< Method for reading block. */
Note: See TracChangeset for help on using the changeset viewer.