Skip to contentSkip to conversation

add ext3_fileblk_t for file relative offset

PATCH New [email protected] 1 participant 1 message Jun 29, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add ext3_fileblk_t for file relative offset

Hi all,

Quoted 7 lines · On June 28, 2006, I wrote:
Quoted 6 lines · On May 26, 2006, I wrote:
Quoted 5 lines · Mingming

As we have discussed before, it's saner to define ext3 fs blocks type and group block type and then fix the kernel ext3 block variable type bugs....So above patches from me are going to be replaced by a new set of ext3 filesystem blocks patches, I have sent out a RFC to the ext2-devel list in the last few weeks:

Quoted 8 lines
Quoted 6 lines

I agree. But the aim of this fix is to keep as much compatibility as possible by making only >2TB file incompatible(RO). So I didn't add typedef for ext3 block type.

Now I'm working on changing the type of variables related to block, including ext3_fileblk_t. I'll send the update patches later.

I've finished this work finally.

I rewrite this patch comment to describe ext3_fileblk_t more clearly. Nothing changed about my patch itself.

There are two new types in Mingming's patches. One is "ext3_fsblk_t" for filesystem relative block and the other is "ext3_grpblk_t" for blockgroup relative offset. But they have no type for file relative offset. Moreover variables for file relative offset are used as various types(int, long and unsigned long) in current kernel.

Therefore I added "ext3_fileblk_t" for file relative offset. It gives unity, which makes maintenance easier and code clearer. ext3_fileblk_t is unsigned long which is the maximum size of current type for file relative offset.

For example:
static unsigned long blocks_for_truncate(struct inode *inode) {
unsigned long needed; <- for file relative offset

This patch applies on top of Mingming's patches which were posted at:
http://marc.theaimsgroup.com/?l=ext2-devel&m=114981607414944&w=2

---

fs/ext3/dir.c renamed from ../linux-2.6.17.org/fs/ext3/dir.c +1 -1
diff -Nurp -x CVS ../../linux-2.6.17.org/fs/ext3/dir.c linux-2.6.17-rc6-48bitext3/fs/ext3/dir.c
@@ -126,7 +126,7 @@ static int ext3_readdir(struct file * fi
 	offset = filp->f_pos & (sb->s_blocksize - 1);
 
 	while (!error && !stored && filp->f_pos < inode->i_size) {
-		unsigned long blk = filp->f_pos >> EXT3_BLOCK_SIZE_BITS(sb);
+		ext3_fileblk_t blk = filp->f_pos >> EXT3_BLOCK_SIZE_BITS(sb);
 		struct buffer_head map_bh;
 		struct buffer_head *bh = NULL;
 
fs/ext3/inode.c renamed from ../linux-2.6.17.org/fs/ext3/inode.c +10 -9
diff -Nurp -x CVS ../../linux-2.6.17.org/fs/ext3/inode.c linux-2.6.17-rc6-48bitext3/fs/ext3/inode.c
@@ -105,7 +105,7 @@ int ext3_forget(handle_t *handle, int is
  */
 static unsigned long blocks_for_truncate(struct inode *inode) 
 {
-	unsigned long needed;
+	ext3_fileblk_t needed;
 
 	needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9);
 
@@ -282,7 +282,7 @@ static int verify_chain(Indirect *from, 
  */
 
 static int ext3_block_to_path(struct inode *inode,
-			long i_block, int offsets[4], int *boundary)
+			ext3_fileblk_t i_block, int offsets[4], int *boundary)
 {
 	int ptrs = EXT3_ADDR_PER_BLOCK(inode->i_sb);
 	int ptrs_bits = EXT3_ADDR_PER_BLOCK_BITS(inode->i_sb);
@@ -445,7 +445,7 @@ static ext3_fsblk_t ext3_find_near(struc
  *	stores it in *@goal and returns zero.
  */
 
-static ext3_fsblk_t ext3_find_goal(struct inode *inode, long block,
+static ext3_fsblk_t ext3_find_goal(struct inode *inode, ext3_fileblk_t block,
 		Indirect chain[4], Indirect *partial)
 {
 	struct ext3_block_alloc_info *block_i;
@@ -680,7 +680,7 @@ failed:
  * chain to new block and return 0.
  */
 static int ext3_splice_branch(handle_t *handle, struct inode *inode,
-			long block, Indirect *where, int num, int blks)
+			ext3_fileblk_t block, Indirect *where, int num, int blks)
 {
 	int i;
 	int err = 0;
@@ -784,7 +784,7 @@ err_out:
  * return < 0, error case.
  */
 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
-		sector_t iblock, unsigned long maxblocks,
+		ext3_fileblk_t iblock, unsigned long maxblocks,
 		struct buffer_head *bh_result,
 		int create, int extend_disksize)
 {
@@ -996,7 +996,7 @@ get_block:
  * `handle' can be NULL if create is zero
  */
 struct buffer_head *ext3_getblk(handle_t *handle, struct inode *inode,
-				long block, int create, int *errp)
+				ext3_fileblk_t block, int create, int *errp)
 {
 	struct buffer_head dummy;
 	int fatal = 0, err;
@@ -1060,7 +1060,7 @@ err:
 }
 
 struct buffer_head *ext3_bread(handle_t *handle, struct inode *inode,
-			       int block, int create, int *err)
+			       ext3_fileblk_t block, int create, int *err)
 {
 	struct buffer_head * bh;
 
@@ -1759,7 +1759,8 @@ int ext3_block_truncate_page(handle_t *h
 {
 	ext3_fsblk_t index = from >> PAGE_CACHE_SHIFT;
 	unsigned offset = from & (PAGE_CACHE_SIZE-1);
-	unsigned blocksize, iblock, length, pos;
+	unsigned blocksize, length, pos;
+	ext3_fileblk_t iblock;
 	struct inode *inode = mapping->host;
 	struct buffer_head *bh;
 	int err = 0;
@@ -2232,7 +2233,7 @@ void ext3_truncate(struct inode *inode)
 	Indirect *partial;
 	__le32 nr = 0;
 	int n;
-	long last_block;
+	ext3_fileblk_t last_block;
 	unsigned blocksize = inode->i_sb->s_blocksize;
 	struct page *page;
 
fs/ext3/namei.c renamed from ../linux-2.6.17.org/fs/ext3/namei.c +22 -20

153 lines not on this page · raw message

fs/ext3/super.c renamed from ../linux-2.6.17.org/fs/ext3/super.c +2 -2
diff -Nurp -x CVS ../../linux-2.6.17.org/fs/ext3/super.c linux-2.6.17-rc6-48bitext3/fs/ext3/super.c
@@ -2577,7 +2577,7 @@ static ssize_t ext3_quota_read(struct su
 			       size_t len, loff_t off)
 {
 	struct inode *inode = sb_dqopt(sb)->files[type];
-	sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb);
+	ext3_fileblk_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb);
 	int err = 0;
 	int offset = off & (sb->s_blocksize - 1);
 	int tocopy;
@@ -2615,7 +2615,7 @@ static ssize_t ext3_quota_write(struct s
 				const char *data, size_t len, loff_t off)
 {
 	struct inode *inode = sb_dqopt(sb)->files[type];
-	sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb);
+	ext3_fileblk_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb);
 	int err = 0;
 	int offset = off & (sb->s_blocksize - 1);
 	int tocopy;
include/linux/ext3_fs.h renamed from ../linux-2.6.17.org/include/linux/ext3_fs.h +3 -3
diff -Nurp -x CVS ../../linux-2.6.17.org/include/linux/ext3_fs.h linux-2.6.17-rc6-48bitext3/include/linux/ext3_fs.h
@@ -897,10 +897,10 @@ extern unsigned long ext3_count_free (st
 /* inode.c */
 int ext3_forget(handle_t *handle, int is_metadata, struct inode *inode,
 		struct buffer_head *bh, ext3_fsblk_t blocknr);
-struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
-struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
+struct buffer_head * ext3_getblk (handle_t *, struct inode *, ext3_fileblk_t, int, int *);
+struct buffer_head * ext3_bread (handle_t *, struct inode *, ext3_fileblk_t, int, int *);
 int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
-	sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
+	ext3_fileblk_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
 	int create, int extend_disksize);
 
 extern void ext3_read_inode (struct inode *);
include/linux/ext3_fs_i.h renamed from ../linux-2.6.17.org/include/linux/ext3_fs_i.h +5 -2
diff -Nurp -x CVS ../../linux-2.6.17.org/include/linux/ext3_fs_i.h linux-2.6.17-rc6-48bitext3/include/linux/ext3_fs_i.h
@@ -27,6 +27,9 @@ typedef int ext3_grpblk_t;
 /* data type for filesystem-wide blocks number */
 typedef sector_t ext3_fsblk_t;
 
+/* data type for block offset of file */
+typedef unsigned long ext3_fileblk_t;
+
 #define E3FSBLK SECTOR_FMT
 
 struct ext3_reserve_window {
@@ -50,7 +53,7 @@ struct ext3_block_alloc_info {
 	 * most-recently-allocated block in this file.
 	 * We use this for detecting linearly ascending allocation requests.
 	 */
-	__u32                   last_alloc_logical_block;
+	ext3_fileblk_t                   last_alloc_logical_block;
 	/*
 	 * Was i_next_alloc_goal in ext3_inode_info
 	 * is the *physical* companion to i_next_alloc_block.
@@ -102,7 +105,7 @@ struct ext3_inode_info {
 	/* block reservation info */
 	struct ext3_block_alloc_info *i_block_alloc_info;
 
-	__u32	i_dir_start_lookup;
+	ext3_fileblk_t	i_dir_start_lookup;
 #ifdef CONFIG_EXT3_FS_XATTR
 	/*
 	 * Extended attributes can be read independently of the main file

Cheers, sho