Changeset f164ae75 in rtems


Ignore:
Timestamp:
May 30, 2012, 11:41:31 AM (8 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
53f2ca3, e308b3a7
Parents:
73c09b3b
git-author:
Sebastian Huber <sebastian.huber@…> (05/30/12 11:41:31)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/31/12 09:05:48)
Message:

libblock: Move rtems_bdbuf_get_media_block() call

Move rtems_bdbuf_get_media_block() call inside the bdbuf lock.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libblock/src/bdbuf.c

    r73c09b3b rf164ae75  
    17811781  rtems_status_code   sc = RTEMS_SUCCESSFUL;
    17821782  rtems_bdbuf_buffer *bd = NULL;
    1783   rtems_blkdev_bnum   media_block = 0;
     1783  rtems_blkdev_bnum   media_block;
     1784
     1785  rtems_bdbuf_lock_cache ();
    17841786
    17851787  sc = rtems_bdbuf_get_media_block (dd, block, &media_block);
    1786   if (sc != RTEMS_SUCCESSFUL)
    1787     return sc;
    1788 
    1789   rtems_bdbuf_lock_cache ();
    1790 
    1791   /*
    1792    * Print the block index relative to the physical disk.
    1793    */
    1794   if (rtems_bdbuf_tracer)
    1795     printf ("bdbuf:get: %" PRIu32 " (%" PRIu32 ") (dev = %08x)\n",
    1796             media_block, block, (unsigned) dd->dev);
    1797 
    1798   bd = rtems_bdbuf_get_buffer_for_access (dd, media_block);
    1799 
    1800   switch (bd->state)
    1801   {
    1802     case RTEMS_BDBUF_STATE_CACHED:
    1803       rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_CACHED);
    1804       break;
    1805     case RTEMS_BDBUF_STATE_EMPTY:
    1806       rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_EMPTY);
    1807       break;
    1808     case RTEMS_BDBUF_STATE_MODIFIED:
    1809       /*
    1810        * To get a modified buffer could be considered a bug in the caller
    1811        * because you should not be getting an already modified buffer but user
    1812        * may have modified a byte in a block then decided to seek the start and
    1813        * write the whole block and the file system will have no record of this
    1814        * so just gets the block to fill.
    1815        */
    1816       rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_MODIFIED);
    1817       break;
    1818     default:
    1819       rtems_bdbuf_fatal (bd->state, RTEMS_BLKDEV_FATAL_BDBUF_STATE_2);
    1820       break;
    1821   }
    1822 
    1823   if (rtems_bdbuf_tracer)
    1824   {
    1825     rtems_bdbuf_show_users ("get", bd);
    1826     rtems_bdbuf_show_usage ();
     1788  if (sc == RTEMS_SUCCESSFUL)
     1789  {
     1790    /*
     1791     * Print the block index relative to the physical disk.
     1792     */
     1793    if (rtems_bdbuf_tracer)
     1794      printf ("bdbuf:get: %" PRIu32 " (%" PRIu32 ") (dev = %08x)\n",
     1795              media_block, block, (unsigned) dd->dev);
     1796
     1797    bd = rtems_bdbuf_get_buffer_for_access (dd, media_block);
     1798
     1799    switch (bd->state)
     1800    {
     1801      case RTEMS_BDBUF_STATE_CACHED:
     1802        rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_CACHED);
     1803        break;
     1804      case RTEMS_BDBUF_STATE_EMPTY:
     1805        rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_EMPTY);
     1806        break;
     1807      case RTEMS_BDBUF_STATE_MODIFIED:
     1808        /*
     1809         * To get a modified buffer could be considered a bug in the caller
     1810         * because you should not be getting an already modified buffer but
     1811         * user may have modified a byte in a block then decided to seek the
     1812         * start and write the whole block and the file system will have no
     1813         * record of this so just gets the block to fill.
     1814         */
     1815        rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_MODIFIED);
     1816        break;
     1817      default:
     1818        rtems_bdbuf_fatal (bd->state, RTEMS_BLKDEV_FATAL_BDBUF_STATE_2);
     1819        break;
     1820    }
     1821
     1822    if (rtems_bdbuf_tracer)
     1823    {
     1824      rtems_bdbuf_show_users ("get", bd);
     1825      rtems_bdbuf_show_usage ();
     1826    }
    18271827  }
    18281828
     
    18311831  *bd_ptr = bd;
    18321832
    1833   return RTEMS_SUCCESSFUL;
     1833  return sc;
    18341834}
    18351835
     
    19981998  rtems_blkdev_request *req = NULL;
    19991999  rtems_bdbuf_buffer   *bd = NULL;
    2000   rtems_blkdev_bnum     media_block = 0;
    2001 
    2002   sc = rtems_bdbuf_get_media_block (dd, block, &media_block);
    2003   if (sc != RTEMS_SUCCESSFUL)
    2004     return sc;
     2000  rtems_blkdev_bnum     media_block;
    20052001
    20062002  /*
     
    20132009                      (bdbuf_config.max_read_ahead_blocks + 1));
    20142010
    2015   if (rtems_bdbuf_tracer)
    2016     printf ("bdbuf:read: %" PRIu32 " (%" PRIu32 ") (dev = %08x)\n",
    2017             media_block + dd->start, block, (unsigned) dd->dev);
    2018 
    20192011  rtems_bdbuf_lock_cache ();
    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);
     2012
     2013  sc = rtems_bdbuf_get_media_block (dd, block, &media_block);
     2014  if (sc == RTEMS_SUCCESSFUL)
     2015  {
     2016    if (rtems_bdbuf_tracer)
     2017      printf ("bdbuf:read: %" PRIu32 " (%" PRIu32 ") (dev = %08x)\n",
     2018              media_block + dd->start, block, (unsigned) dd->dev);
     2019
     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
    20252032    if (sc == RTEMS_SUCCESSFUL)
    20262033    {
    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:
    2037         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     *bd_ptr = bd;
    2054   }
    2055   else
    2056     *bd_ptr = NULL;
     2034      switch (bd->state)
     2035      {
     2036        case RTEMS_BDBUF_STATE_CACHED:
     2037          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;
     2056    }
     2057  }
    20572058
    20582059  rtems_bdbuf_unlock_cache ();
     2060
     2061  *bd_ptr = bd;
    20592062
    20602063  return sc;
Note: See TracChangeset for help on using the changeset viewer.