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 <[email protected]>
Signed-off-by: Mingming Cao <[email protected]>
---
linux-2.6.17-ming/fs/ext3/extents.c | 16 ++++++++++++++++
linux-2.6.17-ming/include/linux/ext3_fs_extents.h | 2 ++
2 files changed, 18 insertions(+)
diff -puN fs/ext3/extents.c~ext3-unitialized-extent-handling fs/ext3/extents.c
--- linux-2.6.17/fs/ext3/extents.c~ext3-unitialized-extent-handling 2006-06-28 16:46:49.657758078 -0700
+++ linux-2.6.17-ming/fs/ext3/extents.c 2006-06-28 16:46:49.667756930 -0700
@@ -1082,6 +1082,13 @@ ext3_can_extents_be_merged(struct inode
!= 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;
@@ -1943,6 +1950,15 @@ int ext3_ext_get_blocks(handle_t *handle
unsigned long ee_block = le32_to_cpu(ex->ee_block);
ext3_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;
diff -puN include/linux/ext3_fs_extents.h~ext3-unitialized-extent-handling include/linux/ext3_fs_extents.h
--- linux-2.6.17/include/linux/ext3_fs_extents.h~ext3-unitialized-extent-handling 2006-06-28 16:46:49.661757619 -0700
+++ linux-2.6.17-ming/include/linux/ext3_fs_extents.h 2006-06-28 16:46:49.668756816 -0700
@@ -141,6 +141,8 @@ typedef int (*ext_prepare_callback)(stru
#define EXT_MAX_BLOCK 0xffffffff
+#define EXT_MAX_LEN ((1UL << 15) - 1)
+
#define EXT_FIRST_EXTENT(__hdr__) \
((struct ext3_extent *) (((char *) (__hdr__)) + \
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]