Changeset 3d5515b in rtems for cpukit/libblock
- Timestamp:
- 10/30/09 10:57:39 (14 years ago)
- Branches:
- 4.10, 4.11, 5, master
- Children:
- 2960c42
- Parents:
- 3fd5ece0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libblock/src/bdbuf.c
r3fd5ece0 r3d5515b 1386 1386 } 1387 1387 1388 static inline void 1389 rtems_bdbuf_group_obtain (rtems_bdbuf_buffer *bd) 1390 { 1391 ++bd->group->users; 1392 } 1393 1394 static inline void 1395 rtems_bdbuf_group_release (rtems_bdbuf_buffer *bd) 1396 { 1397 --bd->group->users; 1398 } 1399 1388 1400 /** 1389 1401 * Get a buffer for this device and block. This function returns a buffer once … … 1433 1445 * different the buffer size for the block has changed. The buffer needs to be 1434 1446 * invalidated. 1447 * 1448 * The returned buffer will be a user its group. 1435 1449 * 1436 1450 * @param dd The disk device. Has the configured block size. … … 1588 1602 rtems_fatal_error_occurred (RTEMS_BLKDEV_FATAL_BDBUF_CONSISTENCY_5); 1589 1603 1604 rtems_bdbuf_group_obtain (bd); 1605 1590 1606 return bd; 1591 1607 } … … 1622 1638 1623 1639 /* 1640 * Before we wait for the buffer, we have to obtain its group. This prevents 1641 * a reallocation. 1642 */ 1643 rtems_bdbuf_group_obtain (bd); 1644 1645 /* 1624 1646 * Loop waiting for the buffer to enter the cached state. If the buffer is in 1625 1647 * the access or transfer state then wait until it is not. … … 1660 1682 rtems_chain_extract (&bd->link); 1661 1683 1684 /* 1685 * The modified list is no longer a user of the buffers group. 1686 */ 1687 if (bd->state == RTEMS_BDBUF_STATE_MODIFIED) 1688 rtems_bdbuf_group_release (bd); 1689 1662 1690 return bd; 1663 1691 } … … 1718 1746 1719 1747 /* 1720 * This could be considered a bug in the caller because you should not be 1721 * getting an already modified buffer but user may have modified a byte in a 1722 * block then decided to seek the start and write the whole block and the 1723 * file system will have no record of this so just gets the block to fill. 1724 */ 1725 if (bd->state == RTEMS_BDBUF_STATE_MODIFIED) 1748 * To get a modified buffer could be considered a bug in the caller because 1749 * you should not be getting an already modified buffer but user may have 1750 * modified a byte in a block then decided to seek the start and write the 1751 * whole block and the file system will have no record of this so just gets 1752 * the block to fill. 1753 */ 1754 if (bd->state != RTEMS_BDBUF_STATE_MODIFIED) 1755 bd->state = RTEMS_BDBUF_STATE_ACCESS; 1756 else 1726 1757 bd->state = RTEMS_BDBUF_STATE_ACCESS_MODIFIED; 1727 else1728 {1729 bd->state = RTEMS_BDBUF_STATE_ACCESS;1730 /*1731 * Indicate a buffer in this group is being used.1732 */1733 bd->group->users++;1734 }1735 1758 1736 1759 if (rtems_bdbuf_tracer) … … 1782 1805 rtems_blkdev_bnum media_block; 1783 1806 rtems_blkdev_bnum media_block_count; 1807 bool read_ahead = false; 1784 1808 1785 1809 if (!bdbuf_cache.initialised) … … 1860 1884 */ 1861 1885 bd = rtems_bdbuf_get_buffer (dd, bds_per_group, media_block + dd->start, 1862 re q->bufnum == 0 ? false : true);1886 read_ahead); 1863 1887 1864 1888 /* … … 1874 1898 if ((bd->state == RTEMS_BDBUF_STATE_CACHED) || 1875 1899 (bd->state == RTEMS_BDBUF_STATE_MODIFIED)) 1900 { 1901 if (read_ahead) 1902 rtems_bdbuf_group_release (bd); 1903 1876 1904 break; 1905 } 1877 1906 1878 1907 bd->state = RTEMS_BDBUF_STATE_TRANSFER; 1879 1908 bd->error = 0; 1880 1881 /*1882 * The buffer will be passed to the driver so this buffer has a user.1883 */1884 bd->group->users++;1885 1909 1886 1910 if (rtems_bdbuf_tracer) … … 1906 1930 */ 1907 1931 media_block += media_block_count; 1932 1933 /* 1934 * After the first buffer we have read ahead buffers. 1935 */ 1936 read_ahead = true; 1908 1937 } 1909 1938 … … 1979 2008 bd->error = req->error; 1980 2009 bd->state = RTEMS_BDBUF_STATE_READ_AHEAD; 1981 bd->group->users--; 2010 2011 rtems_bdbuf_group_release (bd); 1982 2012 1983 2013 if (rtems_bdbuf_tracer) … … 2009 2039 bd = req->bufs[0].user; 2010 2040 2011 /*2012 * One less user for the BD we return. The loop above is only for the read2013 * head buffers. We do this here then increment again so the case of the2014 * buffer in the cache or modified and no read leaves the user counts at2015 * the correct level.2016 */2017 bd->group->users--;2018 2019 2041 if (rtems_bdbuf_tracer) 2020 2042 rtems_bdbuf_show_users ("read-done", bd); 2021 2043 } 2022 2044 2023 /* 2024 * The data for this block is cached in the buffer. 2025 */ 2026 if (bd->state == RTEMS_BDBUF_STATE_MODIFIED) 2045 if (bd->state != RTEMS_BDBUF_STATE_MODIFIED) 2046 bd->state = RTEMS_BDBUF_STATE_ACCESS; 2047 else 2027 2048 bd->state = RTEMS_BDBUF_STATE_ACCESS_MODIFIED; 2028 else2029 {2030 /*2031 * The file system is a user of the buffer.2032 */2033 bd->group->users++;2034 bd->state = RTEMS_BDBUF_STATE_ACCESS;2035 }2036 2049 2037 2050 if (rtems_bdbuf_tracer) … … 2072 2085 rtems_chain_append (&bdbuf_cache.lru, &bd->link); 2073 2086 2074 /* 2075 * One less user for the group of bds. 2076 */ 2077 bd->group->users--; 2087 rtems_bdbuf_group_release (bd); 2078 2088 } 2079 2089 … … 2412 2422 bd->error = 0; 2413 2423 2414 /* 2415 * The buffer is now not modified so lower the user count for the group. 2416 */ 2417 bd->group->users--; 2424 rtems_bdbuf_group_release (bd); 2418 2425 2419 2426 if (rtems_bdbuf_tracer)
Note: See TracChangeset
for help on using the changeset viewer.