summaryrefslogtreecommitdiff
path: root/fs/ext4
diff options
context:
space:
mode:
authorSuparna Bhattacharya <suparna@in.ibm.com>2006-10-11 01:21:06 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-11 11:14:16 -0700
commit471d4011a9862efff02094388b8fe8cd67683c38 (patch)
tree7ec2cdd632cf4076517d3c81044643ac65528b9b /fs/ext4
parentf65e6fba163dfd0f962efb7d8f5528b6872e2b15 (diff)
downloadlinux-3.10-471d4011a9862efff02094388b8fe8cd67683c38.tar.gz
linux-3.10-471d4011a9862efff02094388b8fe8cd67683c38.tar.bz2
linux-3.10-471d4011a9862efff02094388b8fe8cd67683c38.zip
[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: Suparna Bhattacharya <suparna@in.ibm.com> Signed-off-by: Mingming Cao <cmm@us.ibm.com> Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/extents.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 4a13b56e154..32526061a17 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -1082,6 +1082,13 @@ ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
!= le32_to_cpu(ex2->ee_block))
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
if (le16_to_cpu(ex1->ee_len) >= 4)
return 0;
@@ -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);
ext4_fsblk_t ee_start = ext_pblock(ex);
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 (iblock >= ee_block && iblock < ee_block + ee_len) {
newblock = iblock - ee_block + ee_start;