Changeset 39ee704e in rtems for cpukit/libblock


Ignore:
Timestamp:
May 31, 2012, 8:27:29 AM (8 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
96b1d7f
Parents:
6273201
git-author:
Sebastian Huber <sebastian.huber@…> (05/31/12 08:27:29)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/04/12 07:54:31)
Message:

libblock: Add read-ahead task

Read-ahead requests were previously executed in the context of the
reading task. This blocks the reading task until the complete read
with read-ahead transfer is finished. A read-ahead task is introduced
to off-load the read-ahead transfer. This allows the reading task to
work with the requested block more quickly. The read-ahead is triggered
after two misses of ascending consecutive blocks or a read hit of a
block read by the most-recent read-ahead transfer. The read-ahead
feature is configurable and can be disabled.

Location:
cpukit/libblock
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libblock/include/rtems/bdbuf.h

    r6273201 r39ee704e  
    4747 *
    4848 * The Block Device Buffer Management implements a cache between the disk
    49  * devices and file systems.  The code provides read ahead and write queuing to
     49 * devices and file systems.  The code provides read-ahead and write queuing to
    5050 * the drivers and fast cache look-up using an AVL tree.
    5151 *
     
    153153 *
    154154 * The code performs multiple block reads and writes.  Multiple block reads or
    155  * read ahead increases performance with hardware that supports it.  It also
     155 * read-ahead increases performance with hardware that supports it.  It also
    156156 * helps with a large cache as the disk head movement is reduced.  It however
    157157 * is a speculative operation so excessive use can remove valuable and needed
    158  * blocks from the cache.
     158 * blocks from the cache.  The read-ahead is triggered after two misses of
     159 * ascending consecutive blocks or a read hit of a block read by the
     160 * most-resent read-ahead transfer.  The read-ahead works per disk, but all
     161 * transfers are issued by the read-ahead task.
    159162 *
    160163 * The cache has the following lists of buffers:
     
    380383                                                * supported. It is also the
    381384                                                * allocation size. */
     385  rtems_task_priority read_ahead_priority;     /**< Priority of the read-ahead
     386                                                * task. */
    382387} rtems_bdbuf_config;
    383388
     
    390395
    391396/**
    392  * The max_read_ahead_blocks value is altered if there are fewer buffers
    393  * than this defined max. This stops thrashing in the cache.
     397 * The default value for the maximum read-ahead blocks disables the read-ahead
     398 * feature.
    394399 */
    395400#define RTEMS_BDBUF_MAX_READ_AHEAD_BLOCKS_DEFAULT    0
     
    425430#define RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT \
    426431                             RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT
     432
     433/**
     434 * Default read-ahead task priority.  The same as the swap-out task.
     435 */
     436#define RTEMS_BDBUF_READ_AHEAD_TASK_PRIORITY_DEFAULT \
     437  RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT
    427438
    428439/**
     
    622633 * @brief Purges all buffers corresponding to the disk device @a dd.
    623634 *
    624  * This may result in loss of data.
     635 * This may result in loss of data.  The read-ahead state of this device is reset.
    625636 *
    626637 * Before you can use this function, the rtems_bdbuf_init() routine must be
     
    636647 * @brief Sets the block size of a disk device.
    637648 *
    638  * This will set the block size derived fields of the disk device.
     649 * This will set the block size derived fields of the disk device.  The
     650 * read-ahead state of this device is reset.
    639651 *
    640652 * Before you can use this function, the rtems_bdbuf_init() routine must be
  • cpukit/libblock/include/rtems/diskdevs.h

    r6273201 r39ee704e  
    1717#include <rtems.h>
    1818#include <rtems/libio.h>
     19#include <rtems/chain.h>
    1920#include <stdlib.h>
    2021
     
    5657
    5758/**
     59 * @brief Trigger value to disable further read-ahead requests.
     60 */
     61#define RTEMS_DISK_READ_AHEAD_NO_TRIGGER ((rtems_blkdev_bnum) -1)
     62
     63/**
     64 * @brief Read-ahead control.
     65 */
     66typedef struct {
     67  /**
     68   * @brief Chain node for the read-ahead request queue of the read-ahead task.
     69   */
     70  rtems_chain_node node;
     71
     72  /**
     73   * @brief Block value to trigger the read-ahead request.
     74   *
     75   * A value of @ref RTEMS_DISK_READ_AHEAD_NO_TRIGGER will disable further
     76   * read-ahead requests since no valid block can have this value.
     77   */
     78  rtems_blkdev_bnum trigger;
     79
     80  /**
     81   * @brief Start block for the next read-ahead request.
     82   *
     83   * In case the trigger value is out of range of valid blocks, this value my
     84   * be arbitrary.
     85   */
     86  rtems_blkdev_bnum next;
     87} rtems_disk_read_ahread;
     88
     89/**
    5890 * @brief Description of a disk device (logical and physical disks).
    5991 *
     
    169201   */
    170202  bool deleted;
     203
     204  /**
     205   * @brief Read-ahead control for this disk.
     206   */
     207  rtems_disk_read_ahread read_ahead;
    171208};
    172209
  • cpukit/libblock/src/bdbuf.c

    r6273201 r39ee704e  
    135135  size_t              group_count;       /**< The number of groups. */
    136136  rtems_bdbuf_group*  groups;            /**< The groups. */
     137  rtems_id            read_ahead_task;   /**< Read-ahead task */
     138  rtems_chain_control read_ahead_chain;  /**< Read-ahead request chain */
     139  bool                read_ahead_enabled; /**< Read-ahead enabled */
    137140
    138141  bool                initialised;       /**< Initialised state. */
     
    181184#define RTEMS_BLKDEV_FATAL_BDBUF_STATE_1       RTEMS_BLKDEV_FATAL_ERROR(29)
    182185#define RTEMS_BLKDEV_FATAL_BDBUF_STATE_2       RTEMS_BLKDEV_FATAL_ERROR(30)
     186#define RTEMS_BLKDEV_FATAL_BDBUF_RA_WAKE_UP    RTEMS_BLKDEV_FATAL_ERROR(31)
    183187
    184188/**
     
    188192#define RTEMS_BDBUF_TRANSFER_SYNC  RTEMS_EVENT_1
    189193#define RTEMS_BDBUF_SWAPOUT_SYNC   RTEMS_EVENT_2
     194#define RTEMS_BDBUF_READ_AHEAD_WAKE_UP RTEMS_EVENT_1
    190195
    191196/**
     
    220225#endif
    221226
    222 /*
    223  * The swap out task.
    224  */
    225227static rtems_task rtems_bdbuf_swapout_task(rtems_task_argument arg);
     228
     229static rtems_task rtems_bdbuf_read_ahead_task(rtems_task_argument arg);
    226230
    227231/**
     
    13661370  rtems_chain_initialize_empty (&bdbuf_cache.modified);
    13671371  rtems_chain_initialize_empty (&bdbuf_cache.sync);
     1372  rtems_chain_initialize_empty (&bdbuf_cache.read_ahead_chain);
    13681373
    13691374  /*
     
    14871492    goto error;
    14881493
     1494  if (bdbuf_config.max_read_ahead_blocks > 0)
     1495  {
     1496    bdbuf_cache.read_ahead_enabled = true;
     1497    sc = rtems_bdbuf_create_task (rtems_build_name('B', 'R', 'D', 'A'),
     1498                                  bdbuf_config.read_ahead_priority,
     1499                                  RTEMS_BDBUF_READ_AHEAD_TASK_PRIORITY_DEFAULT,
     1500                                  rtems_bdbuf_read_ahead_task,
     1501                                  0,
     1502                                  &bdbuf_cache.read_ahead_task);
     1503    if (sc != RTEMS_SUCCESSFUL)
     1504      goto error;
     1505  }
     1506
    14891507  rtems_bdbuf_unlock_cache ();
    14901508
     
    14921510
    14931511error:
     1512
     1513  if (bdbuf_cache.read_ahead_task != 0)
     1514    rtems_task_delete (bdbuf_cache.read_ahead_task);
    14941515
    14951516  if (bdbuf_cache.swapout != 0)
     
    18531874}
    18541875
    1855 static void
    1856 rtems_bdbuf_create_read_request (const rtems_disk_device *dd,
    1857                                  rtems_blkdev_bnum        media_block,
    1858                                  rtems_blkdev_request    *req,
    1859                                  rtems_bdbuf_buffer     **bd_ptr)
    1860 {
    1861   rtems_bdbuf_buffer *bd = NULL;
    1862   rtems_blkdev_bnum   media_block_end = dd->start + dd->size;
    1863   rtems_blkdev_bnum   media_block_count = dd->block_to_media_block_shift >= 0 ?
    1864     1U << dd->block_to_media_block_shift
    1865       : dd->block_size / dd->media_block_size;
    1866   uint32_t            block_size = dd->block_size;
    1867   uint32_t            transfer_index = 1;
    1868   uint32_t            transfer_count = bdbuf_config.max_read_ahead_blocks + 1;
    1869 
    1870   if (media_block_end - media_block < transfer_count)
    1871     transfer_count = media_block_end - media_block;
     1876static rtems_status_code
     1877rtems_bdbuf_execute_transfer_request (const rtems_disk_device *dd,
     1878                                      rtems_blkdev_request    *req,
     1879                                      bool                     cache_locked)
     1880{
     1881  rtems_status_code sc = RTEMS_SUCCESSFUL;
     1882  int result = 0;
     1883  uint32_t transfer_index = 0;
     1884  bool wake_transfer_waiters = false;
     1885  bool wake_buffer_waiters = false;
     1886
     1887  if (cache_locked)
     1888    rtems_bdbuf_unlock_cache ();
     1889
     1890  result = dd->ioctl (dd->phys_dev, RTEMS_BLKIO_REQUEST, req);
     1891
     1892  if (result == 0)
     1893  {
     1894    rtems_bdbuf_wait_for_event (RTEMS_BDBUF_TRANSFER_SYNC);
     1895    sc = req->status;
     1896  }
     1897  else
     1898    sc = RTEMS_IO_ERROR;
     1899
     1900  rtems_bdbuf_lock_cache ();
     1901
     1902  for (transfer_index = 0; transfer_index < req->bufnum; ++transfer_index)
     1903  {
     1904    rtems_bdbuf_buffer *bd = req->bufs [transfer_index].user;
     1905    bool waiters = bd->waiters;
     1906
     1907    if (waiters)
     1908      wake_transfer_waiters = true;
     1909    else
     1910      wake_buffer_waiters = true;
     1911
     1912    rtems_bdbuf_group_release (bd);
     1913
     1914    if (sc == RTEMS_SUCCESSFUL && bd->state == RTEMS_BDBUF_STATE_TRANSFER)
     1915      rtems_bdbuf_make_cached_and_add_to_lru_list (bd);
     1916    else
     1917      rtems_bdbuf_discard_buffer (bd);
     1918
     1919    if (rtems_bdbuf_tracer)
     1920      rtems_bdbuf_show_users ("transfer", bd);
     1921  }
     1922
     1923  if (wake_transfer_waiters)
     1924    rtems_bdbuf_wake (&bdbuf_cache.transfer_waiters);
     1925
     1926  if (wake_buffer_waiters)
     1927    rtems_bdbuf_wake (&bdbuf_cache.buffer_waiters);
     1928
     1929  if (!cache_locked)
     1930    rtems_bdbuf_unlock_cache ();
     1931
     1932  if (sc == RTEMS_SUCCESSFUL || sc == RTEMS_UNSATISFIED)
     1933    return sc;
     1934  else
     1935    return RTEMS_IO_ERROR;
     1936}
     1937
     1938static rtems_status_code
     1939rtems_bdbuf_execute_read_request (const rtems_disk_device *dd,
     1940                                  rtems_bdbuf_buffer      *bd,
     1941                                  uint32_t                 transfer_count)
     1942{
     1943  rtems_blkdev_request *req = NULL;
     1944  rtems_blkdev_bnum media_block = bd->block;
     1945  uint32_t media_blocks_per_block = dd->media_blocks_per_block;
     1946  uint32_t block_size = dd->block_size;
     1947  uint32_t transfer_index = 1;
     1948
     1949  /*
     1950   * TODO: This type of request structure is wrong and should be removed.
     1951   */
     1952#define bdbuf_alloc(size) __builtin_alloca (size)
     1953
     1954  req = bdbuf_alloc (sizeof (rtems_blkdev_request) +
     1955                     sizeof (rtems_blkdev_sg_buffer) * transfer_count);
    18721956
    18731957  req->req = RTEMS_BLKDEV_REQ_READ;
     
    18781962  req->bufnum = 0;
    18791963
    1880   bd = rtems_bdbuf_get_buffer_for_access (dd, media_block);
    1881 
    1882   *bd_ptr = bd;
     1964  rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_TRANSFER);
    18831965
    18841966  req->bufs [0].user   = bd;
     
    18901972    rtems_bdbuf_show_users ("read", bd);
    18911973
    1892   switch (bd->state)
    1893   {
    1894     case RTEMS_BDBUF_STATE_CACHED:
    1895     case RTEMS_BDBUF_STATE_MODIFIED:
    1896       return;
    1897     case RTEMS_BDBUF_STATE_EMPTY:
    1898       rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_TRANSFER);
    1899       break;
    1900     default:
    1901       rtems_bdbuf_fatal (bd->state, RTEMS_BLKDEV_FATAL_BDBUF_STATE_1);
    1902       break;
    1903   }
    1904 
    19051974  while (transfer_index < transfer_count)
    19061975  {
    1907     media_block += media_block_count;
     1976    media_block += media_blocks_per_block;
    19081977
    19091978    bd = rtems_bdbuf_get_buffer_for_read_ahead (dd, media_block);
     
    19201989
    19211990    if (rtems_bdbuf_tracer)
    1922       rtems_bdbuf_show_users ("read-ahead", bd);
     1991      rtems_bdbuf_show_users ("read", bd);
    19231992
    19241993    ++transfer_index;
     
    19261995
    19271996  req->bufnum = transfer_index;
    1928 }
    1929 
    1930 static rtems_status_code
    1931 rtems_bdbuf_execute_transfer_request (const rtems_disk_device *dd,
    1932                                       rtems_blkdev_request    *req,
    1933                                       bool                     cache_locked)
    1934 {
    1935   rtems_status_code sc = RTEMS_SUCCESSFUL;
    1936   int result = 0;
    1937   uint32_t transfer_index = 0;
    1938   bool wake_transfer_waiters = false;
    1939   bool wake_buffer_waiters = false;
    1940 
    1941   if (cache_locked)
    1942     rtems_bdbuf_unlock_cache ();
    1943 
    1944   result = dd->ioctl (dd->phys_dev, RTEMS_BLKIO_REQUEST, req);
    1945 
    1946   if (result == 0)
    1947   {
    1948     rtems_bdbuf_wait_for_event (RTEMS_BDBUF_TRANSFER_SYNC);
    1949     sc = req->status;
    1950   }
    1951   else
    1952     sc = RTEMS_IO_ERROR;
    1953 
    1954   rtems_bdbuf_lock_cache ();
    1955 
    1956   for (transfer_index = 0; transfer_index < req->bufnum; ++transfer_index)
    1957   {
    1958     rtems_bdbuf_buffer *bd = req->bufs [transfer_index].user;
    1959     bool waiters = bd->waiters;
    1960 
    1961     if (waiters)
    1962       wake_transfer_waiters = true;
    1963     else
    1964       wake_buffer_waiters = true;
    1965 
    1966     rtems_bdbuf_group_release (bd);
    1967 
    1968     if (sc == RTEMS_SUCCESSFUL && bd->state == RTEMS_BDBUF_STATE_TRANSFER)
    1969       rtems_bdbuf_make_cached_and_add_to_lru_list (bd);
    1970     else
    1971       rtems_bdbuf_discard_buffer (bd);
    1972 
    1973     if (rtems_bdbuf_tracer)
    1974       rtems_bdbuf_show_users ("transfer", bd);
    1975   }
    1976 
    1977   if (wake_transfer_waiters)
    1978     rtems_bdbuf_wake (&bdbuf_cache.transfer_waiters);
    1979 
    1980   if (wake_buffer_waiters)
    1981     rtems_bdbuf_wake (&bdbuf_cache.buffer_waiters);
    1982 
    1983   if (!cache_locked)
    1984     rtems_bdbuf_unlock_cache ();
    1985 
    1986   if (sc == RTEMS_SUCCESSFUL || sc == RTEMS_UNSATISFIED)
    1987     return sc;
    1988   else
    1989     return RTEMS_IO_ERROR;
     1997
     1998  return rtems_bdbuf_execute_transfer_request (dd, req, true);
     1999}
     2000
     2001static bool
     2002rtems_bdbuf_is_read_ahead_active (const rtems_disk_device *dd)
     2003{
     2004  return !rtems_chain_is_node_off_chain (&dd->read_ahead.node);
     2005}
     2006
     2007static void
     2008rtems_bdbuf_read_ahead_cancel (rtems_disk_device *dd)
     2009{
     2010  if (rtems_bdbuf_is_read_ahead_active (dd))
     2011  {
     2012    rtems_chain_extract_unprotected (&dd->read_ahead.node);
     2013    rtems_chain_set_off_chain (&dd->read_ahead.node);
     2014  }
     2015}
     2016
     2017static void
     2018rtems_bdbuf_read_ahead_reset (rtems_disk_device *dd)
     2019{
     2020  rtems_bdbuf_read_ahead_cancel (dd);
     2021  dd->read_ahead.trigger = RTEMS_DISK_READ_AHEAD_NO_TRIGGER;
     2022}
     2023
     2024static void
     2025rtems_bdbuf_check_read_ahead_trigger (rtems_disk_device *dd,
     2026                                      rtems_blkdev_bnum  block)
     2027{
     2028  if (dd->read_ahead.trigger == block
     2029      && !rtems_bdbuf_is_read_ahead_active (dd))
     2030  {
     2031    rtems_status_code sc;
     2032    rtems_chain_control *chain = &bdbuf_cache.read_ahead_chain;
     2033
     2034    rtems_chain_append_unprotected (chain, &dd->read_ahead.node);
     2035    sc = rtems_event_send (bdbuf_cache.read_ahead_task,
     2036                           RTEMS_BDBUF_READ_AHEAD_WAKE_UP);
     2037    if (sc != RTEMS_SUCCESSFUL)
     2038      rtems_fatal_error_occurred (RTEMS_BLKDEV_FATAL_BDBUF_RA_WAKE_UP);
     2039  }
     2040}
     2041
     2042static void
     2043rtems_bdbuf_set_read_ahead_trigger (rtems_disk_device *dd,
     2044                                    rtems_blkdev_bnum  block)
     2045{
     2046  if (dd->read_ahead.trigger != block)
     2047  {
     2048    rtems_bdbuf_read_ahead_cancel (dd);
     2049    dd->read_ahead.trigger = block + 1;
     2050    dd->read_ahead.next = block + 2;
     2051  }
    19902052}
    19912053
     
    19962058{
    19972059  rtems_status_code     sc = RTEMS_SUCCESSFUL;
    1998   rtems_blkdev_request *req = NULL;
    19992060  rtems_bdbuf_buffer   *bd = NULL;
    20002061  rtems_blkdev_bnum     media_block;
    2001 
    2002   /*
    2003    * TODO: This type of request structure is wrong and should be removed.
    2004    */
    2005 #define bdbuf_alloc(size) __builtin_alloca (size)
    2006 
    2007   req = bdbuf_alloc (sizeof (rtems_blkdev_request) +
    2008                      sizeof (rtems_blkdev_sg_buffer) *
    2009                       (bdbuf_config.max_read_ahead_blocks + 1));
    20102062
    20112063  rtems_bdbuf_lock_cache ();
     
    20182070              media_block + dd->start, block, (unsigned) dd->dev);
    20192071
    2020     rtems_bdbuf_create_read_request (dd, media_block, req, &bd);
    2021 
    2022     if (req->bufnum > 0)
    2023     {
    2024       sc = rtems_bdbuf_execute_transfer_request (dd, req, true);
    2025       if (sc == RTEMS_SUCCESSFUL)
    2026       {
    2027         rtems_chain_extract_unprotected (&bd->link);
    2028         rtems_bdbuf_group_obtain (bd);
    2029       }
    2030     }
    2031 
    2032     if (sc == RTEMS_SUCCESSFUL)
    2033     {
    2034       switch (bd->state)
    2035       {
    2036         case RTEMS_BDBUF_STATE_CACHED:
     2072    rtems_bdbuf_check_read_ahead_trigger (dd, block);
     2073    bd = rtems_bdbuf_get_buffer_for_access (dd, media_block);
     2074    switch (bd->state)
     2075    {
     2076      case RTEMS_BDBUF_STATE_CACHED:
     2077        rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_CACHED);
     2078        break;
     2079      case RTEMS_BDBUF_STATE_MODIFIED:
     2080        rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_MODIFIED);
     2081        break;
     2082      case RTEMS_BDBUF_STATE_EMPTY:
     2083        rtems_bdbuf_set_read_ahead_trigger (dd, block);
     2084        sc = rtems_bdbuf_execute_read_request (dd, bd, 1);
     2085        if (sc == RTEMS_SUCCESSFUL)
     2086        {
    20372087          rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_CACHED);
    2038           break;
    2039         case RTEMS_BDBUF_STATE_MODIFIED:
    2040           rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_MODIFIED);
    2041           break;
    2042         default:
    2043           rtems_bdbuf_fatal (bd->state, RTEMS_BLKDEV_FATAL_BDBUF_STATE_4);
    2044           break;
    2045       }
    2046 
    2047       if (rtems_bdbuf_tracer)
    2048       {
    2049         rtems_bdbuf_show_users ("read", bd);
    2050         rtems_bdbuf_show_usage ();
    2051       }
    2052     }
    2053     else
    2054     {
    2055       bd = NULL;
     2088          rtems_chain_extract_unprotected (&bd->link);
     2089          rtems_bdbuf_group_obtain (bd);
     2090        }
     2091        else
     2092        {
     2093          bd = NULL;
     2094        }
     2095        break;
     2096      default:
     2097        rtems_bdbuf_fatal (bd->state, RTEMS_BLKDEV_FATAL_BDBUF_STATE_4);
     2098        break;
    20562099    }
    20572100  }
     
    28852928  rtems_chain_initialize_empty (&purge_list);
    28862929  rtems_bdbuf_lock_cache ();
     2930  rtems_bdbuf_read_ahead_reset (dd);
    28872931  rtems_bdbuf_gather_for_purge (&purge_list, dd);
    28882932  rtems_bdbuf_purge_list (&purge_list);
     
    29202964      dd->block_to_media_block_shift = block_to_media_block_shift;
    29212965      dd->bds_per_group = bds_per_group;
     2966
     2967      rtems_bdbuf_read_ahead_reset (dd);
    29222968    }
    29232969    else
     
    29352981  return sc;
    29362982}
     2983
     2984static rtems_task
     2985rtems_bdbuf_read_ahead_task (rtems_task_argument arg)
     2986{
     2987  rtems_chain_control *chain = &bdbuf_cache.read_ahead_chain;
     2988
     2989  while (bdbuf_cache.read_ahead_enabled)
     2990  {
     2991    rtems_chain_node *node;
     2992
     2993    rtems_bdbuf_wait_for_event (RTEMS_BDBUF_READ_AHEAD_WAKE_UP);
     2994    rtems_bdbuf_lock_cache ();
     2995
     2996    while ((node = rtems_chain_get_unprotected (chain)) != NULL)
     2997    {
     2998      rtems_disk_device *dd = (rtems_disk_device *)
     2999        ((char *) node - offsetof (rtems_disk_device, read_ahead.node));
     3000      rtems_blkdev_bnum block = dd->read_ahead.next;
     3001      rtems_blkdev_bnum media_block = 0;
     3002      rtems_status_code sc =
     3003        rtems_bdbuf_get_media_block (dd, block, &media_block);
     3004
     3005      rtems_chain_set_off_chain (&dd->read_ahead.node);
     3006
     3007      if (sc == RTEMS_SUCCESSFUL)
     3008      {
     3009        rtems_bdbuf_buffer *bd =
     3010          rtems_bdbuf_get_buffer_for_read_ahead (dd, media_block);
     3011
     3012        if (bd != NULL)
     3013        {
     3014          uint32_t transfer_count = dd->block_count - block;
     3015          uint32_t max_transfer_count = bdbuf_config.max_read_ahead_blocks;
     3016
     3017          if (transfer_count >= max_transfer_count)
     3018          {
     3019            transfer_count = max_transfer_count;
     3020            dd->read_ahead.trigger += max_transfer_count / 2 + 1;
     3021            dd->read_ahead.next += max_transfer_count;
     3022          }
     3023          else
     3024          {
     3025            dd->read_ahead.trigger = RTEMS_DISK_READ_AHEAD_NO_TRIGGER;
     3026          }
     3027
     3028          rtems_bdbuf_execute_read_request (dd, bd, transfer_count);
     3029        }
     3030      }
     3031      else
     3032      {
     3033        dd->read_ahead.trigger = RTEMS_DISK_READ_AHEAD_NO_TRIGGER;
     3034      }
     3035    }
     3036
     3037    rtems_bdbuf_unlock_cache ();
     3038  }
     3039
     3040  rtems_task_delete (RTEMS_SELF);
     3041}
  • cpukit/libblock/src/diskdevs-init.c

    r6273201 r39ee704e  
    3737  dd->ioctl = handler;
    3838  dd->driver_data = driver_data;
     39  dd->read_ahead.trigger = RTEMS_DISK_READ_AHEAD_NO_TRIGGER;
    3940
    4041  if (block_count > 0) {
     
    6869  dd->ioctl = phys_dd->ioctl;
    6970  dd->driver_data = phys_dd->driver_data;
     71  dd->read_ahead.trigger = RTEMS_DISK_READ_AHEAD_NO_TRIGGER;
    7072
    7173  if (phys_dd->phys_dev == phys_dd) {
Note: See TracChangeset for help on using the changeset viewer.