Skip to contentSkip to conversation

EXT_MAX_BLOCK for >= 16TB fs

RFC In review Girish Shilamkar 2 participants 6 messages Jul 7, 2008 – Jul 8, 2008 ext4 file system

lore
Share & tools
lore
#0 lore raw

Hi,

	The magic constant EXT_MAX_BLOCK = 0xffffffff in extents code is used

in some places to return "invalid block number", and to set the extent length = "whole file" in other places.
So with >= 16 TB fs we would prefer to use it differently. We can have
EXT_UNSET_BLOCK = 1 to indicate "invalid block number" as it will never be valid block for allocation. And for "whole file" usecase we can continue using current EXT_MAX_BLOCK

Regards,
Girish

#1 lore raw

PATCH 1/1 EXT_MAX_BLOCK for >= 16TB fs

Hi,
Here is the patch for same.

Thanks,
Girish

Quoted 18 lines · Girish Shilamkar

Hi,

	The magic constant EXT_MAX_BLOCK = 0xffffffff in extents code is used

in some places to return "invalid block number", and to set the extent length = "whole file" in other places.
So with >= 16 TB fs we would prefer to use it differently. We can have
EXT_UNSET_BLOCK = 1 to indicate "invalid block number" as it will never be valid block for allocation. And for "whole file" usecase we can continue using current EXT_MAX_BLOCK

Regards,
Girish

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

Oops ...

Quoted 26 lines · Girish Shilamkar

Hi,
Here is the patch for same.

Thanks,
Girish

Quoted 14 lines · Girish Shilamkar

Hi,

	The magic constant EXT_MAX_BLOCK = 0xffffffff in extents code is used

in some places to return "invalid block number", and to set the extent length = "whole file" in other places.
So with >= 16 TB fs we would prefer to use it differently. We can have
EXT_UNSET_BLOCK = 1 to indicate "invalid block number" as it will never be valid block for allocation. And for "whole file" usecase we can continue using current EXT_MAX_BLOCK

Regards,
Girish

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

fs/ext3/dir.c +1 -2
Index: linux-stage/fs/ext3/dir.c
===================================================================
@@ -131,8 +131,7 @@ static int ext3_readdir(struct file * fi
 		struct buffer_head *bh = NULL;
 
 		map_bh.b_state = 0;
-		err = ext3_get_blocks_handle(NULL, inode, blk, 1,
-						&map_bh, 0, 0);
+		err = ext3_get_blocks_wrap(NULL, inode, blk, 1, &map_bh, 0, 0);
 		if (err > 0) {
 			page_cache_readahead(sb->s_bdev->bd_inode->i_mapping,
 				&filp->f_ra,
fs/ext3/extents.c new file +2278 -0

2,278 lines not on this page · raw message

fs/ext3/ialloc.c +11 -0
Index: linux-stage/fs/ext3/ialloc.c
===================================================================
@@ -651,6 +651,17 @@ got:
 		ext3_std_error(sb, err);
 		goto fail_free_drop;
 	}
+	if (test_opt(sb, EXTENTS) && S_ISREG(inode->i_mode)) {
+		EXT3_I(inode)->i_flags |= EXT3_EXTENTS_FL;
+		ext3_ext_tree_init(handle, inode);
+		if (!EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_EXTENTS)) {
+			err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
+			if (err) goto fail;
+			EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_EXTENTS);
+			BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "call ext3_journal_dirty_metadata");
+			err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
+		}
+	}
 
 	ext3_debug("allocating inode %lu\n", inode->i_ino);
 	goto really_out;
fs/ext3/inode.c +13 -10
Index: linux-stage/fs/ext3/inode.c
===================================================================
@@ -40,8 +40,6 @@
 #include "iopen.h"
 #include "acl.h"
 
-static int ext3_writepage_trans_blocks(struct inode *inode);
-
 /*
  * Test whether an inode is a fast symlink.
  */
@@ -804,6 +802,7 @@ int ext3_get_blocks_handle(handle_t *han
 	ext3_fsblk_t first_block = 0;
 
 
+	J_ASSERT(!(EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL));
 	J_ASSERT(handle != NULL || create == 0);
 	depth = ext3_block_to_path(inode,iblock,offsets,&blocks_to_boundary);
 
@@ -984,12 +983,10 @@ static int ext3_get_block(struct inode *
 
 get_block:
 	if (ret == 0) {
-		ret = ext3_get_blocks_handle(handle, inode, iblock,
+		ret = ext3_get_blocks_wrap(handle, inode, iblock,
 					max_blocks, bh_result, create, 0);
-		if (ret > 0) {
-			bh_result->b_size = (ret << inode->i_blkbits);
+		if (ret > 0)
 			ret = 0;
-		}
 	}
 	return ret;
 }
@@ -1008,7 +1005,7 @@ struct buffer_head *ext3_getblk(handle_t
 	dummy.b_state = 0;
 	dummy.b_blocknr = -1000;
 	buffer_trace_init(&dummy.b_history);
-	err = ext3_get_blocks_handle(handle, inode, block, 1,
+	err = ext3_get_blocks_wrap(handle, inode, block, 1,
 					&dummy, create, 1);
 	/*
 	 * ext3_get_blocks_handle() returns number of blocks
@@ -1759,7 +1756,7 @@ void ext3_set_aops(struct inode *inode)
  * This required during truncate. We need to physically zero the tail end
  * of that block so it doesn't yield old data if the file is later grown.
  */
-static int ext3_block_truncate_page(handle_t *handle, struct page *page,
+int ext3_block_truncate_page(handle_t *handle, struct page *page,
 		struct address_space *mapping, loff_t from)
 {
 	ext3_fsblk_t index = from >> PAGE_CACHE_SHIFT;
@@ -2263,6 +2260,9 @@ void ext3_truncate(struct inode *inode)
 			return;
 	}
 
+	if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL)
+		return ext3_ext_truncate(inode, page);
+
 	handle = start_transaction(inode);
 	if (IS_ERR(handle)) {
 		if (page) {
@@ -3005,12 +3005,15 @@ err_out:
  * block and work out the exact number of indirects which are touched.  Pah.
  */
 
-static int ext3_writepage_trans_blocks(struct inode *inode)
+int ext3_writepage_trans_blocks(struct inode *inode)
 {
 	int bpp = ext3_journal_blocks_per_page(inode);
 	int indirects = (EXT3_NDIR_BLOCKS % bpp) ? 5 : 3;
 	int ret;
 
+ 	if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL)
+ 		return ext3_ext_writepage_trans_blocks(inode, bpp);
+
 	if (ext3_should_journal_data(inode))
 		ret = 3 * (bpp + indirects) + 2;
 	else
@@ -3257,7 +3260,7 @@ int ext3_map_inode_page(struct inode *in
 		if (blocks[i] != 0)
 			continue;
 
-		rc = ext3_get_blocks_handle(handle, inode, iblock, 1, &dummy, 1, 1);
+		rc = ext3_get_blocks_wrap(handle, inode, iblock, 1, &dummy, 1, 1);
 		if (rc < 0) {
 			printk(KERN_INFO "ext3_map_inode_page: error reading "
 					"block %ld\n", iblock);
fs/ext3/Makefile +1 -1
Index: linux-stage/fs/ext3/Makefile
===================================================================
@@ -5,7 +5,7 @@
 obj-$(CONFIG_EXT3_FS) += ext3.o
 
 ext3-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
-	   ioctl.o namei.o super.o symlink.o hash.o resize.o
+	   ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o
 
 ext3-$(CONFIG_EXT3_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
 ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
fs/ext3/super.c +19 -1
Index: linux-stage/fs/ext3/super.c
===================================================================
@@ -391,6 +391,7 @@ static void ext3_put_super (struct super
 	struct ext3_super_block *es = sbi->s_es;
 	int i;
 
+	ext3_ext_release(sb);
 	ext3_xattr_put_super(sb);
 	journal_destroy(sbi->s_journal);
 	if (!(sb->s_flags & MS_RDONLY)) {
@@ -455,6 +456,8 @@ static struct inode *ext3_alloc_inode(st
 #endif
 	ei->i_block_alloc_info = NULL;
 	ei->vfs_inode.i_version = 1;
+
+	memset(&ei->i_cached_extent, 0, sizeof(ei->i_cached_extent));
 	return &ei->vfs_inode;
 }
 
@@ -680,7 +683,8 @@ enum {
 	Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
 	Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
 	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
-	Opt_grpquota
+	Opt_grpquota,
+	Opt_extents, Opt_noextents, Opt_extdebug,
 };
 
 static match_table_t tokens = {
@@ -733,6 +737,9 @@ static match_table_t tokens = {
 	{Opt_noiopen, "noiopen"},
 	{Opt_iopen_nopriv, "iopen_nopriv"},
 	{Opt_barrier, "barrier=%u"},
+	{Opt_extents, "extents"},
+	{Opt_noextents, "noextents"},
+	{Opt_extdebug, "extdebug"},
 	{Opt_err, NULL},
 	{Opt_resize, "resize"},
 };
@@ -1077,6 +1084,15 @@ clear_qf_name:
 		case Opt_bh:
 			clear_opt(sbi->s_mount_opt, NOBH);
 			break;
+		case Opt_extents:
+			set_opt (sbi->s_mount_opt, EXTENTS);
+			break;
+		case Opt_noextents:
+			clear_opt (sbi->s_mount_opt, EXTENTS);
+			break;
+		case Opt_extdebug:
+			set_opt (sbi->s_mount_opt, EXTDEBUG);
+			break;
 		default:
 			printk (KERN_ERR
 				"EXT3-fs: Unrecognized mount option \"%s\" "
@@ -1812,6 +1828,8 @@ static int ext3_fill_super (struct super
 		test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered":
 		"writeback");
 
+	ext3_ext_init(sb);
+
 	lock_kernel();
 	return 0;
 
include/linux/ext3_extents.h new file +232 -0

232 lines not on this page · raw message

include/linux/ext3_fs.h +34 -2
Index: linux-stage/include/linux/ext3_fs.h
===================================================================
@@ -182,8 +182,9 @@ struct ext3_group_desc
 #define EXT3_DIRSYNC_FL			0x00010000 /* dirsync behaviour (directories only) */
 #define EXT3_TOPDIR_FL			0x00020000 /* Top of directory hierarchies*/
 #define EXT3_RESERVED_FL		0x80000000 /* reserved for ext3 lib */
+#define EXT3_EXTENTS_FL			0x00080000 /* Inode uses extents */
 
-#define EXT3_FL_USER_VISIBLE		0x0003DFFF /* User visible flags */
+#define EXT3_FL_USER_VISIBLE		0x000BDFFF /* User visible flags */
 #define EXT3_FL_USER_MODIFIABLE		0x000380FF /* User modifiable flags */
 
 /*
@@ -373,6 +374,8 @@ struct ext3_inode {
 #define EXT3_MOUNT_GRPQUOTA		0x200000 /* "old" group quota */
 #define EXT3_MOUNT_IOPEN		0x400000	/* Allow access via iopen */
 #define EXT3_MOUNT_IOPEN_NOPRIV		0x800000/* Make iopen world-readable */
+#define EXT3_MOUNT_EXTENTS		0x2000000/* Extents support */
+#define EXT3_MOUNT_EXTDEBUG             0x4000000/* Extents debug */
 
 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
 #ifndef clear_opt
@@ -572,11 +575,13 @@ static inline int ext3_valid_inum(struct
 #define EXT3_FEATURE_INCOMPAT_RECOVER		0x0004 /* Needs recovery */
 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV	0x0008 /* Journal device */
 #define EXT3_FEATURE_INCOMPAT_META_BG		0x0010
+#define EXT3_FEATURE_INCOMPAT_EXTENTS		0x0040 /* extents support */
 
 #define EXT3_FEATURE_COMPAT_SUPP	EXT2_FEATURE_COMPAT_EXT_ATTR
 #define EXT3_FEATURE_INCOMPAT_SUPP	(EXT3_FEATURE_INCOMPAT_FILETYPE| \
 					 EXT3_FEATURE_INCOMPAT_RECOVER| \
-					 EXT3_FEATURE_INCOMPAT_META_BG)
+					 EXT3_FEATURE_INCOMPAT_META_BG| \
+					 EXT3_FEATURE_INCOMPAT_EXTENTS)
 #define EXT3_FEATURE_RO_COMPAT_SUPP	(EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
 					 EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
 					 EXT3_FEATURE_RO_COMPAT_BTREE_DIR)
@@ -816,6 +821,9 @@ extern int ext3_get_inode_loc(struct ino
 extern void ext3_truncate (struct inode *);
 extern void ext3_set_inode_flags(struct inode *);
 extern void ext3_set_aops(struct inode *inode);
+extern int ext3_writepage_trans_blocks(struct inode *);
+extern int ext3_block_truncate_page(handle_t *handle, struct page *page,
+		struct address_space *mapping, loff_t from);
 
 /* ioctl.c */
 extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
@@ -869,6 +877,30 @@ extern struct inode_operations ext3_spec
 extern struct inode_operations ext3_symlink_inode_operations;
 extern struct inode_operations ext3_fast_symlink_inode_operations;
 
+/* extents.c */
+extern int ext3_ext_tree_init(handle_t *handle, struct inode *);
+extern int ext3_ext_writepage_trans_blocks(struct inode *, int);
+extern int ext3_ext_get_blocks(handle_t *, struct inode *, sector_t,
+				unsigned long, struct buffer_head *, int, int);
+extern void ext3_ext_truncate(struct inode *, struct page *);
+extern void ext3_ext_init(struct super_block *);
+extern void ext3_ext_release(struct super_block *);
+static inline int
+ext3_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
+			unsigned long max_blocks, struct buffer_head *bh,
+			int create, int extend_disksize)
+{
+	int ret;
+	if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL)
+		return ext3_ext_get_blocks(handle, inode, block, max_blocks,
+					bh, create, extend_disksize);
+	ret = ext3_get_blocks_handle(handle, inode, block, max_blocks, bh, create,
+			             extend_disksize);
+	if (ret > 0)
+		bh->b_size = (ret << inode->i_blkbits);
+	return ret;
+}
+
 
 #endif	/* __KERNEL__ */
 
include/linux/ext3_fs_i.h +12 -0
Index: linux-stage/include/linux/ext3_fs_i.h
===================================================================
@@ -65,6 +65,16 @@ struct ext3_block_alloc_info {
 #define rsv_end rsv_window._rsv_end
 
 /*
+ * storage for cached extent
+ */
+struct ext3_ext_cache {
+	__u32	ec_start;
+	__u32	ec_block;
+	__u32	ec_len; /* must be 32bit to return holes */
+	__u32	ec_type;
+};
+
+/*
  * third extended file system inode data in memory
  */
 struct ext3_inode_info {
@@ -142,6 +152,8 @@ struct ext3_inode_info {
 	 */
 	struct mutex truncate_mutex;
 	struct inode vfs_inode;
+
+ 	struct ext3_ext_cache i_cached_extent;
 };
 
 #endif	/* _LINUX_EXT3_FS_I */
include/linux/ext3_fs_sb.h +10 -0
Index: linux-stage/include/linux/ext3_fs_sb.h
===================================================================
@@ -78,6 +78,16 @@ struct ext3_sb_info {
 	char *s_qf_names[MAXQUOTAS];		/* Names of quota files with journalled quota */
 	int s_jquota_fmt;			/* Format of quota to use */
 #endif
+
+#ifdef EXTENTS_STATS
+	/* ext3 extents stats */
+	unsigned long s_ext_min;
+	unsigned long s_ext_max;
+	unsigned long s_depth_max;
+	spinlock_t s_ext_stats_lock;
+	unsigned long s_ext_blocks;
+	unsigned long s_ext_extents;
+#endif
 };
 
 #endif	/* _LINUX_EXT3_FS_SB */
include/linux/ext3_jbd.h +14 -6
Index: linux-stage/include/linux/ext3_jbd.h
===================================================================
@@ -23,12 +23,20 @@
 
 /* Define the number of blocks we need to account to a transaction to
  * modify one block of data.
- * 
+ *
  * We may have to touch one inode, one bitmap buffer, up to three
  * indirection blocks, the group and superblock summaries, and the data
- * block to complete the transaction.  */
+ * block to complete the transaction.
+ *
+ * For extents-enabled fs we may have to allocate and modify upto
+ * 5 levels of tree + root which is stored in inode. */
+
+#define EXT3_SINGLEDATA_TRANS_BLOCKS(sb)				\
+	(EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_EXTENTS)	\
+		|| test_opt(sb, EXTENTS) ? 27U : 8U)
 
-#define EXT3_SINGLEDATA_TRANS_BLOCKS	8U
+/* Indicate that EXT3_SINGLEDATA_TRANS_BLOCKS takes the sb as argument */
+#define EXT3_SINGLEDATA_TRANS_BLOCKS_HAS_SB
 
 /* Extended attribute operations touch at most two data buffers,
  * two bitmap buffers, and two group summaries, in addition to the inode
@@ -42,7 +50,7 @@
  * superblock only gets updated once, of course, so don't bother
  * counting that again for the quota updates. */
 
-#define EXT3_DATA_TRANS_BLOCKS(sb)	(EXT3_SINGLEDATA_TRANS_BLOCKS + \
+#define EXT3_DATA_TRANS_BLOCKS(sb)	(EXT3_SINGLEDATA_TRANS_BLOCKS(sb) + \
 					 EXT3_XATTR_TRANS_BLOCKS - 2 + \
 					 2*EXT3_QUOTA_TRANS_BLOCKS(sb))
 
@@ -78,9 +86,9 @@
 /* Amount of blocks needed for quota insert/delete - we do some block writes
  * but inode, sb and group updates are done only once */
 #define EXT3_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
-		(EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_INIT_REWRITE) : 0)
+		(EXT3_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_INIT_REWRITE) : 0)
 #define EXT3_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\
-		(EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_DEL_REWRITE) : 0)
+		(EXT3_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_DEL_REWRITE) : 0)
 #else
 #define EXT3_QUOTA_TRANS_BLOCKS(sb) 0
 #define EXT3_QUOTA_INIT_BLOCKS(sb) 0
#3 lore raw

Hi,
Please disregard the last mail as it had incorrect patch, sorry for
that.
The correct patch is attached here.

Thanks,
Girish

Quoted 33 lines · Girish Shilamkar

Oops ...

Quoted 30 lines · Girish Shilamkar

Hi,
Here is the patch for same.

Thanks,
Girish

Quoted 14 lines · Girish Shilamkar

Hi,

	The magic constant EXT_MAX_BLOCK = 0xffffffff in extents code is used

in some places to return "invalid block number", and to set the extent length = "whole file" in other places.
So with >= 16 TB fs we would prefer to use it differently. We can have
EXT_UNSET_BLOCK = 1 to indicate "invalid block number" as it will never be valid block for allocation. And for "whole file" usecase we can continue using current EXT_MAX_BLOCK

Regards,
Girish

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

fs/ext4/ext4_extents.h +1 -0
Index: linux-2.6/fs/ext4/ext4_extents.h
===================================================================
@@ -139,6 +139,7 @@ typedef int (*ext_prepare_callback)(stru
 #define EXT_REPEAT     2
 
 #define EXT_MAX_BLOCK	0xffffffff
+#define EXT_UNSET_BLOCK 1
 
 /*
  * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
fs/ext4/extents.c +14 -12
Index: linux-2.6/fs/ext4/extents.c
===================================================================
@@ -1217,7 +1217,7 @@ ext4_ext_search_right(struct inode *inod
 
 /*
  * ext4_ext_next_allocated_block:
- * returns allocated block in subsequent extent or EXT_MAX_BLOCK.
+ * returns allocated block in subsequent extent or EXT_UNSET_BLOCK.
  * NOTE: it considers block number from index entry as
  * allocated block. Thus, index entries have to be consistent
  * with leaves.
@@ -1231,7 +1231,7 @@ ext4_ext_next_allocated_block(struct ext
 	depth = path->p_depth;
 
 	if (depth == 0 && path->p_ext == NULL)
-		return EXT_MAX_BLOCK;
+		return EXT_UNSET_BLOCK;
 
 	while (depth >= 0) {
 		if (depth == path->p_depth) {
@@ -1248,12 +1248,12 @@ ext4_ext_next_allocated_block(struct ext
 		depth--;
 	}
 
-	return EXT_MAX_BLOCK;
+	return EXT_UNSET_BLOCK;
 }
 
 /*
  * ext4_ext_next_leaf_block:
- * returns first allocated block from next leaf or EXT_MAX_BLOCK
+ * returns first allocated block from next leaf or EXT_UNSET_BLOCK
  */
 static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode,
 					struct ext4_ext_path *path)
@@ -1265,7 +1265,7 @@ static ext4_lblk_t ext4_ext_next_leaf_bl
 
 	/* zero-tree has no leaf blocks at all */
 	if (depth == 0)
-		return EXT_MAX_BLOCK;
+		return EXT_UNSET_BLOCK;
 
 	/* go to index block */
 	depth--;
@@ -1278,7 +1278,7 @@ static ext4_lblk_t ext4_ext_next_leaf_bl
 		depth--;
 	}
 
-	return EXT_MAX_BLOCK;
+	return EXT_UNSET_BLOCK;
 }
 
 /*
@@ -1458,7 +1458,7 @@ unsigned int ext4_ext_check_overlap(stru
 	 */
 	if (b2 < b1) {
 		b2 = ext4_ext_next_allocated_block(path);
-		if (b2 == EXT_MAX_BLOCK)
+		if (b2 == EXT_UNSET_BLOCK)
 			goto out;
 	}
 
@@ -1551,7 +1551,7 @@ repeat:
 	fex = EXT_LAST_EXTENT(eh);
 	next = ext4_ext_next_leaf_block(inode, path);
 	if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
-	    && next != EXT_MAX_BLOCK) {
+	    && next != EXT_UNSET_BLOCK) {
 		ext_debug("next leaf block - %d\n", next);
 		BUG_ON(npath != NULL);
 		npath = ext4_ext_find_extent(inode, next, NULL);
@@ -1671,7 +1671,7 @@ int ext4_ext_walk_space(struct inode *in
 	BUG_ON(func == NULL);
 	BUG_ON(inode == NULL);
 
-	while (block < last && block != EXT_MAX_BLOCK) {
+	while (block < last && block != EXT_UNSET_BLOCK) {
 		num = last - block;
 		/* find extent for this block */
 		path = ext4_ext_find_extent(inode, block, path);
@@ -1703,7 +1703,9 @@ int ext4_ext_walk_space(struct inode *in
 			/* need to allocate space after found extent */
 			start = block;
 			end = block + num;
-			if (end >= next)
+			if (next == EXT_UNSET_BLOCK)
+				end = EXT_MAX_BLOCK;
+			else if (end >= next)
 				end = next;
 		} else if (block >= le32_to_cpu(ex->ee_block)) {
 			/*
@@ -2021,8 +2023,8 @@ ext4_ext_rm_leaf(handle_t *handle, struc
 		path[depth].p_ext = ex;
 
 		a = ex_ee_block > start ? ex_ee_block : start;
-		b = ex_ee_block + ex_ee_len - 1 < EXT_MAX_BLOCK ?
-			ex_ee_block + ex_ee_len - 1 : EXT_MAX_BLOCK;
+		b = (unsigned long long)ex_ee_block + ex_ee_len - 1 <
+		    EXT_MAX_BLOCK ? ex_ee_block + ex_ee_len - 1 : EXT_MAX_BLOCK;
 
 		ext_debug("  border %u:%u\n", a, b);
 
#4 lore raw
In reply to Girish Shilamkar

Girish, thanks for sending out the patch. Looks like it's agains ext3, could you please port it to ext4?

Thanks,
Mingming

Quoted 33 lines · 在 2008-07-08二的 18:52 +0530,Girish Shilamkar写道:

Oops ...

Quoted 30 lines · Girish Shilamkar

Hi,
Here is the patch for same.

Thanks,
Girish

Quoted 14 lines · Girish Shilamkar

Hi,

	The magic constant EXT_MAX_BLOCK = 0xffffffff in extents code is used

in some places to return "invalid block number", and to set the extent length = "whole file" in other places.
So with >= 16 TB fs we would prefer to use it differently. We can have
EXT_UNSET_BLOCK = 1 to indicate "invalid block number" as it will never be valid block for allocation. And for "whole file" usecase we can continue using current EXT_MAX_BLOCK

Regards,
Girish

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

oops, I saw your updated patch, thanks

Quoted 39 lines · 在 2008-07-08二的 16:56 -0700,Mingming Cao写道:

Girish, thanks for sending out the patch. Looks like it's agains ext3, could you please port it to ext4?

Thanks,
Mingming

Quoted 33 lines · 在 2008-07-08二的 18:52 +0530,Girish Shilamkar写道:

Oops ...

Quoted 30 lines · Girish Shilamkar

Hi,
Here is the patch for same.

Thanks,
Girish

Quoted 14 lines · Girish Shilamkar

Hi,

	The magic constant EXT_MAX_BLOCK = 0xffffffff in extents code is used

in some places to return "invalid block number", and to set the extent length = "whole file" in other places.
So with >= 16 TB fs we would prefer to use it differently. We can have
EXT_UNSET_BLOCK = 1 to indicate "invalid block number" as it will never be valid block for allocation. And for "whole file" usecase we can continue using current EXT_MAX_BLOCK

Regards,
Girish

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html