diff options
author | Amit Arora <aarora@in.ibm.com> | 2007-07-17 21:42:41 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2007-07-17 21:42:41 -0400 |
commit | a2df2a63407803a833f82e1fa6693826c8c9d584 (patch) | |
tree | db761e8d82dbbe53e166511a9f8af9162541a212 /include | |
parent | 97ac73506c0ba93f30239bb57b4cfc5d73e68a62 (diff) |
fallocate support in ext4
This patch implements ->fallocate() inode operation in ext4. With this
patch users of ext4 file systems will be able to use fallocate() system
call for persistent preallocation. Current implementation only supports
preallocation for regular files (directories not supported as of date)
with extent maps. This patch does not support block-mapped files currently.
Only FALLOC_ALLOCATE and FALLOC_RESV_SPACE modes are being supported as of
now.
Signed-off-by: Amit Arora <aarora@in.ibm.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/ext4_fs.h | 8 | ||||
-rw-r--r-- | include/linux/ext4_fs_extents.h | 15 |
2 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h index de1f9f78625a..87c2d7a05b01 100644 --- a/include/linux/ext4_fs.h +++ b/include/linux/ext4_fs.h | |||
@@ -102,6 +102,7 @@ | |||
102 | EXT4_GOOD_OLD_FIRST_INO : \ | 102 | EXT4_GOOD_OLD_FIRST_INO : \ |
103 | (s)->s_first_ino) | 103 | (s)->s_first_ino) |
104 | #endif | 104 | #endif |
105 | #define EXT4_BLOCK_ALIGN(size, blkbits) ALIGN((size), (1 << (blkbits))) | ||
105 | 106 | ||
106 | /* | 107 | /* |
107 | * Macro-instructions used to manage fragments | 108 | * Macro-instructions used to manage fragments |
@@ -225,6 +226,11 @@ struct ext4_new_group_data { | |||
225 | __u32 free_blocks_count; | 226 | __u32 free_blocks_count; |
226 | }; | 227 | }; |
227 | 228 | ||
229 | /* | ||
230 | * Following is used by preallocation code to tell get_blocks() that we | ||
231 | * want uninitialzed extents. | ||
232 | */ | ||
233 | #define EXT4_CREATE_UNINITIALIZED_EXT 2 | ||
228 | 234 | ||
229 | /* | 235 | /* |
230 | * ioctl commands | 236 | * ioctl commands |
@@ -983,6 +989,8 @@ extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | |||
983 | extern void ext4_ext_truncate(struct inode *, struct page *); | 989 | extern void ext4_ext_truncate(struct inode *, struct page *); |
984 | extern void ext4_ext_init(struct super_block *); | 990 | extern void ext4_ext_init(struct super_block *); |
985 | extern void ext4_ext_release(struct super_block *); | 991 | extern void ext4_ext_release(struct super_block *); |
992 | extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset, | ||
993 | loff_t len); | ||
986 | static inline int | 994 | static inline int |
987 | ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block, | 995 | ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block, |
988 | unsigned long max_blocks, struct buffer_head *bh, | 996 | unsigned long max_blocks, struct buffer_head *bh, |
diff --git a/include/linux/ext4_fs_extents.h b/include/linux/ext4_fs_extents.h index acfe59740b03..e3d5afc6f23e 100644 --- a/include/linux/ext4_fs_extents.h +++ b/include/linux/ext4_fs_extents.h | |||
@@ -188,6 +188,21 @@ ext4_ext_invalidate_cache(struct inode *inode) | |||
188 | EXT4_I(inode)->i_cached_extent.ec_type = EXT4_EXT_CACHE_NO; | 188 | EXT4_I(inode)->i_cached_extent.ec_type = EXT4_EXT_CACHE_NO; |
189 | } | 189 | } |
190 | 190 | ||
191 | static inline void ext4_ext_mark_uninitialized(struct ext4_extent *ext) | ||
192 | { | ||
193 | ext->ee_len |= cpu_to_le16(0x8000); | ||
194 | } | ||
195 | |||
196 | static inline int ext4_ext_is_uninitialized(struct ext4_extent *ext) | ||
197 | { | ||
198 | return (int)(le16_to_cpu((ext)->ee_len) & 0x8000); | ||
199 | } | ||
200 | |||
201 | static inline int ext4_ext_get_actual_len(struct ext4_extent *ext) | ||
202 | { | ||
203 | return (int)(le16_to_cpu((ext)->ee_len) & 0x7FFF); | ||
204 | } | ||
205 | |||
191 | extern int ext4_extent_tree_init(handle_t *, struct inode *); | 206 | extern int ext4_extent_tree_init(handle_t *, struct inode *); |
192 | extern int ext4_ext_calc_credits_for_insert(struct inode *, struct ext4_ext_path *); | 207 | extern int ext4_ext_calc_credits_for_insert(struct inode *, struct ext4_ext_path *); |
193 | extern unsigned int ext4_ext_check_overlap(struct inode *, struct ext4_extent *, struct ext4_ext_path *); | 208 | extern unsigned int ext4_ext_check_overlap(struct inode *, struct ext4_extent *, struct ext4_ext_path *); |