diff options
author | Christian Mauderer <christian.mauderer@embedded-brains.de> | 2021-01-19 15:33:35 +0100 |
---|---|---|
committer | Christian Mauderer <christian.mauderer@embedded-brains.de> | 2021-03-26 14:25:38 +0100 |
commit | 6ae79e6df6fbc89ffbd6badb3f84d6a2b513fe83 (patch) | |
tree | 370419dc3ec031519955f899069222fbd138b91b /cpukit/include | |
parent | gen_uuid.c: Revert previous patch (597e4f476568a225d14dfaff02074cf269ad62ac) (diff) | |
download | rtems-6ae79e6df6fbc89ffbd6badb3f84d6a2b513fe83.tar.bz2 |
libblock: Add rtems_bdbuf_peek()
Adds a peek function that allows (for example) a file system to suggest
the next blocks that should be used for read ahead. This can increase
the read speed of fragmented files.
Update #3689
Diffstat (limited to 'cpukit/include')
-rw-r--r-- | cpukit/include/rtems/bdbuf.h | 23 | ||||
-rw-r--r-- | cpukit/include/rtems/diskdevs.h | 24 |
2 files changed, 45 insertions, 2 deletions
diff --git a/cpukit/include/rtems/bdbuf.h b/cpukit/include/rtems/bdbuf.h index fbb4fc05e9..4d11a47619 100644 --- a/cpukit/include/rtems/bdbuf.h +++ b/cpukit/include/rtems/bdbuf.h @@ -540,6 +540,29 @@ rtems_bdbuf_read ( ); /** + * @brief Give a hint which blocks should be cached next. + * + * Provide a hint to the read ahead mechanism which blocks should be cached + * next. This overwrites the default linear pattern. You should use it in (for + * example) a file system to tell bdbuf where the next part of a fragmented file + * is. If you know the length of the file, you can provide that too. + * + * Before you can use this function, the rtems_bdbuf_init() routine must be + * called at least once to initialize everything. Otherwise you might get + * unexpected results. + * + * @param dd [in] The disk device. + * @param block [in] Linear media block number. + * @param nr_blocks [in] Number of consecutive blocks that can be pre-fetched. + */ +void +rtems_bdbuf_peek ( + rtems_disk_device *dd, + rtems_blkdev_bnum block, + uint32_t nr_blocks +); + +/** * Release the buffer obtained by a read call back to the cache. If the buffer * was obtained by a get call and was not already in the cache the release * modified call should be used. A buffer released with this call obtained by a diff --git a/cpukit/include/rtems/diskdevs.h b/cpukit/include/rtems/diskdevs.h index 85d157dcd5..527a8cc955 100644 --- a/cpukit/include/rtems/diskdevs.h +++ b/cpukit/include/rtems/diskdevs.h @@ -59,6 +59,11 @@ typedef int (*rtems_block_device_ioctl)( #define RTEMS_DISK_READ_AHEAD_NO_TRIGGER ((rtems_blkdev_bnum) -1) /** + * @brief Size value to set number of blocks based on config and disk size. + */ +#define RTEMS_DISK_READ_AHEAD_SIZE_AUTO (0) + +/** * @brief Block device read-ahead control. */ typedef struct { @@ -71,7 +76,8 @@ typedef struct { * @brief Block value to trigger the read-ahead request. * * A value of @ref RTEMS_DISK_READ_AHEAD_NO_TRIGGER will disable further - * read-ahead requests since no valid block can have this value. + * read-ahead requests (except the ones triggered by @a rtems_bdbuf_peek) + * since no valid block can have this value. */ rtems_blkdev_bnum trigger; @@ -82,6 +88,14 @@ typedef struct { * be arbitrary. */ rtems_blkdev_bnum next; + + /** + * @brief Size of the next read-ahead request in blocks. + * + * A value of @ref RTEMS_DISK_READ_AHEAD_SIZE_AUTO will try to read the rest + * of the disk but at most the configured max_read_ahead_blocks. + */ + uint32_t nr_blocks; } rtems_blkdev_read_ahead; /** @@ -110,11 +124,17 @@ typedef struct { /** * @brief Read-ahead transfer count. * - * Each read-ahead transfer may read multiple blocks. + * Each read-ahead transfer may read multiple blocks. This counts all + * transfers (including peeks). */ uint32_t read_ahead_transfers; /** + * @brief Read-ahead transfers caused by a peek. + */ + uint32_t read_ahead_peeks; + + /** * @brief Count of blocks transfered from the device. */ uint32_t read_blocks; |