diff options
author | Theodore Ts'o <tytso@mit.edu> | 2010-05-16 19:00:00 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2010-05-16 19:00:00 -0400 |
commit | e35fd6609b2fee54484d520deccb8f18bf7d38f3 (patch) | |
tree | 9b786445602819074f599c282b31bead166e8c03 /fs/ext4/ext4.h | |
parent | 8e48dcfbd7c0892b4cfd064d682cc4c95a29df32 (diff) |
ext4: Add new abstraction ext4_map_blocks() underneath ext4_get_blocks()
Jack up ext4_get_blocks() and add a new function, ext4_map_blocks()
which uses a much smaller structure, struct ext4_map_blocks which is
20 bytes, as opposed to a struct buffer_head, which nearly 5 times
bigger on an x86_64 machine. By switching things to use
ext4_map_blocks(), we can save stack space by using ext4_map_blocks()
since we can avoid allocating a struct buffer_head on the stack.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r-- | fs/ext4/ext4.h | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index d266003cac3e..57fc0e5c0918 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -126,6 +126,29 @@ struct ext4_allocation_request { | |||
126 | }; | 126 | }; |
127 | 127 | ||
128 | /* | 128 | /* |
129 | * Logical to physical block mapping, used by ext4_map_blocks() | ||
130 | * | ||
131 | * This structure is used to pass requests into ext4_map_blocks() as | ||
132 | * well as to store the information returned by ext4_map_blocks(). It | ||
133 | * takes less room on the stack than a struct buffer_head. | ||
134 | */ | ||
135 | #define EXT4_MAP_NEW (1 << BH_New) | ||
136 | #define EXT4_MAP_MAPPED (1 << BH_Mapped) | ||
137 | #define EXT4_MAP_UNWRITTEN (1 << BH_Unwritten) | ||
138 | #define EXT4_MAP_BOUNDARY (1 << BH_Boundary) | ||
139 | #define EXT4_MAP_UNINIT (1 << BH_Uninit) | ||
140 | #define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\ | ||
141 | EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY |\ | ||
142 | EXT4_MAP_UNINIT) | ||
143 | |||
144 | struct ext4_map_blocks { | ||
145 | ext4_fsblk_t m_pblk; | ||
146 | ext4_lblk_t m_lblk; | ||
147 | unsigned int m_len; | ||
148 | unsigned int m_flags; | ||
149 | }; | ||
150 | |||
151 | /* | ||
129 | * For delayed allocation tracking | 152 | * For delayed allocation tracking |
130 | */ | 153 | */ |
131 | struct mpage_da_data { | 154 | struct mpage_da_data { |
@@ -1773,9 +1796,8 @@ extern int ext4_ext_tree_init(handle_t *handle, struct inode *); | |||
1773 | extern int ext4_ext_writepage_trans_blocks(struct inode *, int); | 1796 | extern int ext4_ext_writepage_trans_blocks(struct inode *, int); |
1774 | extern int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks, | 1797 | extern int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks, |
1775 | int chunk); | 1798 | int chunk); |
1776 | extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | 1799 | extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, |
1777 | ext4_lblk_t iblock, unsigned int max_blocks, | 1800 | struct ext4_map_blocks *map, int flags); |
1778 | struct buffer_head *bh_result, int flags); | ||
1779 | extern void ext4_ext_truncate(struct inode *); | 1801 | extern void ext4_ext_truncate(struct inode *); |
1780 | extern void ext4_ext_init(struct super_block *); | 1802 | extern void ext4_ext_init(struct super_block *); |
1781 | extern void ext4_ext_release(struct super_block *); | 1803 | extern void ext4_ext_release(struct super_block *); |
@@ -1783,6 +1805,8 @@ extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset, | |||
1783 | loff_t len); | 1805 | loff_t len); |
1784 | extern int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset, | 1806 | extern int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset, |
1785 | ssize_t len); | 1807 | ssize_t len); |
1808 | extern int ext4_map_blocks(handle_t *handle, struct inode *inode, | ||
1809 | struct ext4_map_blocks *map, int flags); | ||
1786 | extern int ext4_get_blocks(handle_t *handle, struct inode *inode, | 1810 | extern int ext4_get_blocks(handle_t *handle, struct inode *inode, |
1787 | sector_t block, unsigned int max_blocks, | 1811 | sector_t block, unsigned int max_blocks, |
1788 | struct buffer_head *bh, int flags); | 1812 | struct buffer_head *bh, int flags); |