Commit 471d4011 authored by Suparna Bhattacharya's avatar Suparna Bhattacharya Committed by Linus Torvalds

[PATCH] ext4: uninitialised extent handling

Make it possible to add file preallocation support in future as an RO_COMPAT
feature by recognizing uninitialized extents as holes and limiting extent
length to keep the top bit of ee_len free for marking uninitialized extents.
Signed-off-by: default avatarSuparna Bhattacharya <suparna@in.ibm.com>
Signed-off-by: default avatarMingming Cao <cmm@us.ibm.com>
Signed-off-by: default avatarDave Kleikamp <shaggy@austin.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f65e6fba
...@@ -1082,6 +1082,13 @@ ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1, ...@@ -1082,6 +1082,13 @@ ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
!= le32_to_cpu(ex2->ee_block)) != le32_to_cpu(ex2->ee_block))
return 0; return 0;
/*
* To allow future support for preallocated extents to be added
* as an RO_COMPAT feature, refuse to merge to extents if
* can result in the top bit of ee_len being set
*/
if (le16_to_cpu(ex1->ee_len) + le16_to_cpu(ex2->ee_len) > EXT_MAX_LEN)
return 0;
#ifdef AGRESSIVE_TEST #ifdef AGRESSIVE_TEST
if (le16_to_cpu(ex1->ee_len) >= 4) if (le16_to_cpu(ex1->ee_len) >= 4)
return 0; return 0;
...@@ -1944,6 +1951,15 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, ...@@ -1944,6 +1951,15 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
unsigned long ee_block = le32_to_cpu(ex->ee_block); unsigned long ee_block = le32_to_cpu(ex->ee_block);
ext4_fsblk_t ee_start = ext_pblock(ex); ext4_fsblk_t ee_start = ext_pblock(ex);
unsigned short ee_len = le16_to_cpu(ex->ee_len); unsigned short ee_len = le16_to_cpu(ex->ee_len);
/*
* Allow future support for preallocated extents to be added
* as an RO_COMPAT feature:
* Uninitialized extents are treated as holes, except that
* we avoid (fail) allocating new blocks during a write.
*/
if (ee_len > EXT_MAX_LEN)
goto out2;
/* if found exent covers block, simple return it */ /* if found exent covers block, simple return it */
if (iblock >= ee_block && iblock < ee_block + ee_len) { if (iblock >= ee_block && iblock < ee_block + ee_len) {
newblock = iblock - ee_block + ee_start; newblock = iblock - ee_block + ee_start;
......
...@@ -141,6 +141,8 @@ typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *, ...@@ -141,6 +141,8 @@ typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *,
#define EXT_MAX_BLOCK 0xffffffff #define EXT_MAX_BLOCK 0xffffffff
#define EXT_MAX_LEN ((1UL << 15) - 1)
#define EXT_FIRST_EXTENT(__hdr__) \ #define EXT_FIRST_EXTENT(__hdr__) \
((struct ext4_extent *) (((char *) (__hdr__)) + \ ((struct ext4_extent *) (((char *) (__hdr__)) + \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment