diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2013-03-19 13:16:45 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2013-03-22 20:13:59 -0400 |
commit | 68e41a43f18b681f83329c8ad83123571bb8db0d (patch) | |
tree | 0e421f7124c5884d171f40492c3cadf0e9984726 /drivers/block/drbd/drbd_int.h | |
parent | 3a4d4eb3cb03fbc66696fc8cd472701d56f3aee7 (diff) |
drbd: use the cached meta_dev_idx
Now we have the cached meta_dev_idx member,
we can get rid of a few rcu_read_lock() sections and rcu_dereference().
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/drbd/drbd_int.h')
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index ee19ba28b59a..6eecdec9da2b 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -1777,9 +1777,9 @@ static inline void drbd_chk_io_error_(struct drbd_conf *mdev, | |||
1777 | * BTW, for internal meta data, this happens to be the maximum capacity | 1777 | * BTW, for internal meta data, this happens to be the maximum capacity |
1778 | * we could agree upon with our peer node. | 1778 | * we could agree upon with our peer node. |
1779 | */ | 1779 | */ |
1780 | static inline sector_t _drbd_md_first_sector(int meta_dev_idx, struct drbd_backing_dev *bdev) | 1780 | static inline sector_t drbd_md_first_sector(struct drbd_backing_dev *bdev) |
1781 | { | 1781 | { |
1782 | switch (meta_dev_idx) { | 1782 | switch (bdev->md.meta_dev_idx) { |
1783 | case DRBD_MD_INDEX_INTERNAL: | 1783 | case DRBD_MD_INDEX_INTERNAL: |
1784 | case DRBD_MD_INDEX_FLEX_INT: | 1784 | case DRBD_MD_INDEX_FLEX_INT: |
1785 | return bdev->md.md_offset + bdev->md.bm_offset; | 1785 | return bdev->md.md_offset + bdev->md.bm_offset; |
@@ -1789,30 +1789,13 @@ static inline sector_t _drbd_md_first_sector(int meta_dev_idx, struct drbd_backi | |||
1789 | } | 1789 | } |
1790 | } | 1790 | } |
1791 | 1791 | ||
1792 | static inline sector_t drbd_md_first_sector(struct drbd_backing_dev *bdev) | ||
1793 | { | ||
1794 | int meta_dev_idx; | ||
1795 | |||
1796 | rcu_read_lock(); | ||
1797 | meta_dev_idx = rcu_dereference(bdev->disk_conf)->meta_dev_idx; | ||
1798 | rcu_read_unlock(); | ||
1799 | |||
1800 | return _drbd_md_first_sector(meta_dev_idx, bdev); | ||
1801 | } | ||
1802 | |||
1803 | /** | 1792 | /** |
1804 | * drbd_md_last_sector() - Return the last sector number of the meta data area | 1793 | * drbd_md_last_sector() - Return the last sector number of the meta data area |
1805 | * @bdev: Meta data block device. | 1794 | * @bdev: Meta data block device. |
1806 | */ | 1795 | */ |
1807 | static inline sector_t drbd_md_last_sector(struct drbd_backing_dev *bdev) | 1796 | static inline sector_t drbd_md_last_sector(struct drbd_backing_dev *bdev) |
1808 | { | 1797 | { |
1809 | int meta_dev_idx; | 1798 | switch (bdev->md.meta_dev_idx) { |
1810 | |||
1811 | rcu_read_lock(); | ||
1812 | meta_dev_idx = rcu_dereference(bdev->disk_conf)->meta_dev_idx; | ||
1813 | rcu_read_unlock(); | ||
1814 | |||
1815 | switch (meta_dev_idx) { | ||
1816 | case DRBD_MD_INDEX_INTERNAL: | 1799 | case DRBD_MD_INDEX_INTERNAL: |
1817 | case DRBD_MD_INDEX_FLEX_INT: | 1800 | case DRBD_MD_INDEX_FLEX_INT: |
1818 | return bdev->md.md_offset + MD_4kB_SECT -1; | 1801 | return bdev->md.md_offset + MD_4kB_SECT -1; |
@@ -1840,18 +1823,13 @@ static inline sector_t drbd_get_capacity(struct block_device *bdev) | |||
1840 | static inline sector_t drbd_get_max_capacity(struct drbd_backing_dev *bdev) | 1823 | static inline sector_t drbd_get_max_capacity(struct drbd_backing_dev *bdev) |
1841 | { | 1824 | { |
1842 | sector_t s; | 1825 | sector_t s; |
1843 | int meta_dev_idx; | ||
1844 | |||
1845 | rcu_read_lock(); | ||
1846 | meta_dev_idx = rcu_dereference(bdev->disk_conf)->meta_dev_idx; | ||
1847 | rcu_read_unlock(); | ||
1848 | 1826 | ||
1849 | switch (meta_dev_idx) { | 1827 | switch (bdev->md.meta_dev_idx) { |
1850 | case DRBD_MD_INDEX_INTERNAL: | 1828 | case DRBD_MD_INDEX_INTERNAL: |
1851 | case DRBD_MD_INDEX_FLEX_INT: | 1829 | case DRBD_MD_INDEX_FLEX_INT: |
1852 | s = drbd_get_capacity(bdev->backing_bdev) | 1830 | s = drbd_get_capacity(bdev->backing_bdev) |
1853 | ? min_t(sector_t, DRBD_MAX_SECTORS_FLEX, | 1831 | ? min_t(sector_t, DRBD_MAX_SECTORS_FLEX, |
1854 | _drbd_md_first_sector(meta_dev_idx, bdev)) | 1832 | drbd_md_first_sector(bdev)) |
1855 | : 0; | 1833 | : 0; |
1856 | break; | 1834 | break; |
1857 | case DRBD_MD_INDEX_FLEX_EXT: | 1835 | case DRBD_MD_INDEX_FLEX_EXT: |