Skip to contentSkip to conversation

ext4: reduce the size of inode.c

PATCH In review [email protected] 2 participants 10 messages Jun 21, 2011 – Jun 28, 2011 ext4 file system

lore
Share & tools
lore
#0 lore raw

cover ext4: reduce the size of inode.c

inode.c has grown to almost 6000 lines and contains code for a wide variety of functionalities.

This patch series reduces the file's size to under 4500 lines, by moving all indirect inode specific implementations to a new file called indirect.c. This convention is aligned with extent inode code being mostly in extents.c.

My own ulterior motive is that the snapshot patches were about to add another ~500 lines to inode.c, so now most of those lines will be added to indirect.c.

[PATCH 1/4] ext4: split ext4_ind_truncate from ext4_truncate [PATCH 2/4] ext4: rename ext4_indirect_* funcs to ext4_ind_* [PATCH 3/4] ext4: clone indirect.c file from inode.c
[PATCH 4/4] ext4: move ext4_ind_* functions from inode.c to indirect.c

#1 lore raw

PATCH 1/4 ext4: split ext4_ind_truncate from ext4_truncate

From: Amir Goldstein <[email protected]>

We are about to move all indirect inode functions to a new file. Before we do that, let's split ext4_ind_truncate() out of ext4_truncate() leaving only generic code in the latter, so we will be able to move ext4_ind_truncate() to the new file.

---
 fs/ext4/ext4.h  |    2 ++
 fs/ext4/inode.c |   36 ++++++++++++++++++++----------------
 2 files changed, 22 insertions(+), 16 deletions(-)
fs/ext4/ext4.h +2 -0
index 1921392..8532dd4 100644
@@ -1834,6 +1834,8 @@ extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
 extern qsize_t *ext4_get_reserved_space(struct inode *inode);
 extern void ext4_da_update_reserve_space(struct inode *inode,
 					int used, int quota_claim);
+extern void ext4_ind_truncate(struct inode *inode);
+
 /* ioctl.c */
 extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
 extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);
fs/ext4/inode.c +20 -15
index a5763e3..2bb7102 100644
@@ -4471,6 +4471,26 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
  */
 void ext4_truncate(struct inode *inode)
 {
+	trace_ext4_truncate_enter(inode);
+
+	if (!ext4_can_truncate(inode))
+		return;
+
+	ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
+
+	if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
+		ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
+
+	if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
+		ext4_ext_truncate(inode);
+	else
+		ext4_ind_truncate(inode);
+
+	trace_ext4_truncate_exit(inode);
+}
+
+void ext4_ind_truncate(struct inode *inode)
+{
 	handle_t *handle;
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	__le32 *i_data = ei->i_data;
@@ -4484,22 +4504,6 @@ void ext4_truncate(struct inode *inode)
 	ext4_lblk_t last_block, max_block;
 	unsigned blocksize = inode->i_sb->s_blocksize;
 
-	trace_ext4_truncate_enter(inode);
-
-	if (!ext4_can_truncate(inode))
-		return;
-
-	ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
-
-	if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
-		ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
-
-	if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
-		ext4_ext_truncate(inode);
-		trace_ext4_truncate_exit(inode);
-		return;
-	}
#2 lore raw

PATCH 2/4 ext4: rename ext4_indirect_* funcs to ext4_ind_*

In reply to [email protected]

From: Amir Goldstein <[email protected]>

We are going to move all ext4_ind_* functions to indirect.c. Before we do that, let's rename 2 functions called ext4_indirect_* to ext4_ind_*, to keep to the naming convention.

---
 fs/ext4/inode.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
fs/ext4/inode.c +4 -6
index 2bb7102..79af0cc 100644
@@ -1075,8 +1075,7 @@ qsize_t *ext4_get_reserved_space(struct inode *inode)
  * Calculate the number of metadata blocks need to reserve
  * to allocate a new block at @lblocks for non extent file based file
  */
-static int ext4_indirect_calc_metadata_amount(struct inode *inode,
-					      sector_t lblock)
+static int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock)
 {
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	sector_t dind_mask = ~((sector_t)EXT4_ADDR_PER_BLOCK(inode->i_sb) - 1);
@@ -1107,7 +1106,7 @@ static int ext4_calc_metadata_amount(struct inode *inode, ext4_lblk_t lblock)
 	if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
 		return ext4_ext_calc_metadata_amount(inode, lblock);
 
-	return ext4_indirect_calc_metadata_amount(inode, lblock);
+	return ext4_ind_calc_metadata_amount(inode, lblock);
 }
 
 /*
@@ -5456,8 +5455,7 @@ int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry,
 	return 0;
 }
 
-static int ext4_indirect_trans_blocks(struct inode *inode, int nrblocks,
-				      int chunk)
+static int ext4_ind_trans_blocks(struct inode *inode, int nrblocks, int chunk)
 {
 	int indirects;
 
@@ -5483,7 +5481,7 @@ static int ext4_indirect_trans_blocks(struct inode *inode, int nrblocks,
 static int ext4_index_trans_blocks(struct inode *inode, int nrblocks, int chunk)
 {
 	if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
-		return ext4_indirect_trans_blocks(inode, nrblocks, chunk);
+		return ext4_ind_trans_blocks(inode, nrblocks, chunk);
 	return ext4_ext_index_trans_blocks(inode, nrblocks, chunk);
 }
 
Signature · 1 line
1.7.4.1
#3 lore raw

PATCH 3/4 ext4: clone indirect.c file from inode.c

In reply to [email protected]

From: Amir Goldstein <[email protected]>

The next patch is going to move ext4_ind_ functions to indirect.c. First, we clone the file from inode.c and only leave code that is going to be duplicated in both files. This should keep the deleted lines count from inode.c in the next patch the same as the added lines count to indirect.c.

---
 fs/ext4/indirect.c |   92 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 92 insertions(+), 0 deletions(-)
 create mode 100644 fs/ext4/indirect.c
fs/ext4/indirect.c new file +92 -0
new file mode 100644
index 0000000..98cf221
@@ -0,0 +1,92 @@
+/*
+ *  linux/fs/ext4/indirect.c
+ *
+ *  from
+ *
+ *  linux/fs/ext4/inode.c
+ *
+ * Copyright (C) 1992, 1993, 1994, 1995
+ * Remy Card ([email protected])
+ * Laboratoire MASI - Institut Blaise Pascal
+ * Universite Pierre et Marie Curie (Paris VI)
+ *
+ *  from
+ *
+ *  linux/fs/minix/inode.c
+ *
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ *
+ *  Goal-directed block allocation by Stephen Tweedie
+ *	([email protected]), 1993, 1998
+ *  Big-endian to little-endian byte-swapping/bitmaps by
+ *        David S. Miller ([email protected]), 1995
+ *  64-bit file support on 64-bit platforms by Jakub Jelinek
+ *	([email protected])
+ *
+ *  Assorted race fixes, rewrite of ext4_get_block() by Al Viro, 2000
+ */
+
+#include <linux/module.h>
+#include "ext4_jbd2.h"
+
+#include <trace/events/ext4.h>
+
+static int __ext4_check_blockref(const char *function, unsigned int line,
+				 struct inode *inode,
+				 __le32 *p, unsigned int max)
+{
+	struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
+	__le32 *bref = p;
+	unsigned int blk;
+
+	while (bref < p+max) {
+		blk = le32_to_cpu(*bref++);
+		if (blk &&
+		    unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
+						    blk, 1))) {
+			es->s_last_error_block = cpu_to_le64(blk);
+			ext4_error_inode(inode, function, line, blk,
+					 "invalid block");
+			return -EIO;
+		}
+	}
+	return 0;
+}
+
+
+/*
+ * Truncate blocks that were not used by write. We have to truncate the
+ * pagecache as well so that corresponding buffers get properly unmapped.
+ */
+static void ext4_truncate_failed_write(struct inode *inode)
+{
+	truncate_inode_pages(inode->i_mapping, inode->i_size);
+	ext4_truncate(inode);
+}
+
+/*
+ * Work out how many blocks we need to proceed with the next chunk of a
+ * truncate transaction.
+ */
+static unsigned long blocks_for_truncate(struct inode *inode)
+{
+	ext4_lblk_t needed;
+
+	needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9);
+
+	/* Give ourselves just enough room to cope with inodes in which
+	 * i_blocks is corrupt: we've seen disk corruptions in the past
+	 * which resulted in random data in an inode which looked enough
+	 * like a regular file for ext4 to try to delete it.  Things
+	 * will go a bit crazy if that happens, but at least we should
+	 * try not to panic the whole kernel. */
+	if (needed < 2)
+		needed = 2;
+
+	/* But we need to bound the transaction so we don't overflow the
+	 * journal. */
+	if (needed > EXT4_MAX_TRANS_DATA)
+		needed = EXT4_MAX_TRANS_DATA;
+
+	return EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + needed;
+}
Signature · 1 line
1.7.4.1
#9 lore raw

PATCH 4/4 ext4: move ext4_ind_* functions from inode.c to indirect.c

In reply to [email protected]

From: Amir Goldstein <[email protected]>

This patch moves functions from inode.c to indirect.c.
The moved functions are ext4_ind_* functions and theier helpers. Functions called from inode.c are declared extern.
1487 lines are deleted from inode.c and 1486 lines are added to indirect.c. The missing line is the newline that was deleted from the end of indirect.c.

---
 fs/ext4/Makefile   |    2 +-
 fs/ext4/ext4.h     |    9 +
 fs/ext4/indirect.c | 1486 +++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext4/inode.c    | 1487 ----------------------------------------------------
 4 files changed, 1496 insertions(+), 1488 deletions(-)
fs/ext4/Makefile +1 -1
index 0410946..56fd8f86 100644
@@ -7,7 +7,7 @@ obj-$(CONFIG_EXT4_FS) += ext4.o
 ext4-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o page-io.o \
 		ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \
 		ext4_jbd2.o migrate.o mballoc.o block_validity.o move_extent.o \
-		mmp.o
+		mmp.o indirect.o
 
 ext4-$(CONFIG_EXT4_FS_XATTR)		+= xattr.o xattr_user.o xattr_trusted.o
 ext4-$(CONFIG_EXT4_FS_POSIX_ACL)	+= acl.o
fs/ext4/ext4.h +9 -0
index 8532dd4..fb86d4d 100644
@@ -1834,6 +1834,15 @@ extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
 extern qsize_t *ext4_get_reserved_space(struct inode *inode);
 extern void ext4_da_update_reserve_space(struct inode *inode,
 					int used, int quota_claim);
+
+/* indirect.c */
+extern int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
+				struct ext4_map_blocks *map, int flags);
+extern ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
+				const struct iovec *iov, loff_t offset,
+				unsigned long nr_segs);
+extern int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock);
+extern int ext4_ind_trans_blocks(struct inode *inode, int nrblocks, int chunk);
 extern void ext4_ind_truncate(struct inode *inode);
 
 /* ioctl.c */
fs/ext4/indirect.c +1486 -0

1,507 lines not on this page · raw message

fs/ext4/inode.c +0 -1486

1,470 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

maintainer
#4 lore raw

Re: [PATCH 3/4] ext4: clone indirect.c file from inode.c

In reply to [email protected]
Quoted 7 lines · On Tue, Jun 21, 2011 at 12:39:27PM +0300, [email protected] wrote:

From: Amir Goldstein <[email protected]>

The next patch is going to move ext4_ind_ functions to indirect.c. First, we clone the file from inode.c and only leave code that is going to be duplicated in both files. This should keep the deleted lines count from inode.c in the next patch the same as the added lines count to indirect.c.

I really dislike cloning functions. This becomes a maintenance headache, since bugs that get fixed in one file might not get propagated to another. Since I need to manually move all of the functions to verify nothing else changed in patches that do massive code movement, I used the first two patches in your patch series, but replaced the last two patches in the patch series, and replaced it with the following:

A) Move __ext4_check_blockref() to fs/ext4/block_validity.c and declare it extern.

B) Move ext4_truncate_failed_write() and blocks_for_truncate() to a new function, fs/ext4/truncate.h.

C) Movement of indirect-related code to fs/ext4/indirect.c.

- Ted

maintainer
#5 lore raw

PATCH 1/3 ext4: move __ext4_check_blockref to block_validity.c

In preparation for moving the indirect functions to a separate file, move __ext4_check_blockref() to block_validity.c and rename it to ext4_check_blockref() which is exported as globally visible function.

Also, rename the cpp macro ext4_check_inode_blockref() to ext4_ind_check_inode(), to make it clear that it is only valid for use with non-extent mapped inodes.

---
 fs/ext4/block_validity.c |   20 ++++++++++++++++++++
 fs/ext4/ext4.h           |   15 +++++++++++++++
 fs/ext4/inode.c          |   35 +----------------------------------
 3 files changed, 36 insertions(+), 34 deletions(-)
fs/ext4/block_validity.c +20 -0
index fac90f3..af103be 100644
@@ -246,3 +246,23 @@ int ext4_data_block_valid(struct ext4_sb_info *sbi, ext4_fsblk_t start_blk,
 	return 1;
 }
 
+int ext4_check_blockref(const char *function, unsigned int line,
+			struct inode *inode, __le32 *p, unsigned int max)
+{
+	struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
+	__le32 *bref = p;
+	unsigned int blk;
+
+	while (bref < p+max) {
+		blk = le32_to_cpu(*bref++);
+		if (blk &&
+		    unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
+						    blk, 1))) {
+			es->s_last_error_block = cpu_to_le64(blk);
+			ext4_error_inode(inode, function, line, blk,
+					 "invalid block");
+			return -EIO;
+		}
+	}
+	return 0;
+}
fs/ext4/ext4.h +15 -0
index 8532dd4..82ba7eb 100644
@@ -2125,6 +2125,19 @@ static inline void ext4_mark_super_dirty(struct super_block *sb)
 }
 
 /*
+ * Block validity checking
+ */
+#define ext4_check_indirect_blockref(inode, bh)				\
+	ext4_check_blockref(__func__, __LINE__, inode,			\
+			    (__le32 *)(bh)->b_data,			\
+			    EXT4_ADDR_PER_BLOCK((inode)->i_sb))
+
+#define ext4_ind_check_inode(inode)					\
+	ext4_check_blockref(__func__, __LINE__, inode,			\
+			    EXT4_I(inode)->i_data,			\
+			    EXT4_NDIR_BLOCKS)
+
+/*
  * Inodes and files operations
  */
 
@@ -2153,6 +2166,8 @@ extern void ext4_exit_system_zone(void);
 extern int ext4_data_block_valid(struct ext4_sb_info *sbi,
 				 ext4_fsblk_t start_blk,
 				 unsigned int count);
+extern int ext4_check_blockref(const char *, unsigned int,
+			       struct inode *, __le32 *, unsigned int);
 
 /* extents.c */
 extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
fs/ext4/inode.c +0 -32
index 6c1d28e..3dca526 100644
@@ -360,39 +360,6 @@ static int ext4_block_to_path(struct inode *inode,
 	return n;
 }
 
-static int __ext4_check_blockref(const char *function, unsigned int line,
-				 struct inode *inode,
-				 __le32 *p, unsigned int max)
-{
-	struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
-	__le32 *bref = p;
-	unsigned int blk;
-
-	while (bref < p+max) {
-		blk = le32_to_cpu(*bref++);
-		if (blk &&
-		    unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
-						    blk, 1))) {
-			es->s_last_error_block = cpu_to_le64(blk);
-			ext4_error_inode(inode, function, line, blk,
-					 "invalid block");
-			return -EIO;
-		}
-	}
-	return 0;
-}
-
-
-#define ext4_check_indirect_blockref(inode, bh)                         \
-	__ext4_check_blockref(__func__, __LINE__, inode,		\
-			      (__le32 *)(bh)->b_data,			\
-			      EXT4_ADDR_PER_BLOCK((inode)->i_sb))
-
-#define ext4_check_inode_blockref(inode)                                \
-	__ext4_check_blockref(__func__, __LINE__, inode,		\
-			      EXT4_I(inode)->i_data,			\
-			      EXT4_NDIR_BLOCKS)
maintainer
#6 lore raw

PATCH 2/3 ext4: move common truncate functions to header file

Move two functions that will be needed by the indirect functions to be moved to indirect.c as well as inode.c to truncate.h as inline functions, so that we can avoid having duplicate copies of the function (which can be a maintenance problem) without having to expose them as globally functions.

---
 fs/ext4/inode.c    |   48 ++++++------------------------------------------
 fs/ext4/truncate.h |   43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 42 deletions(-)
 create mode 100644 fs/ext4/truncate.h
fs/ext4/inode.c +6 -42
index 3dca526..9b82ac7 100644
@@ -47,6 +47,7 @@
 #include "xattr.h"
 #include "acl.h"
 #include "ext4_extents.h"
+#include "truncate.h"
 
 #include <trace/events/ext4.h>
 
@@ -89,33 +90,6 @@ static int ext4_inode_is_fast_symlink(struct inode *inode)
 }
 
 /*
- * Work out how many blocks we need to proceed with the next chunk of a
- * truncate transaction.
- */
-static unsigned long blocks_for_truncate(struct inode *inode)
-{
-	ext4_lblk_t needed;
-
-	needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9);
-
-	/* Give ourselves just enough room to cope with inodes in which
-	 * i_blocks is corrupt: we've seen disk corruptions in the past
-	 * which resulted in random data in an inode which looked enough
-	 * like a regular file for ext4 to try to delete it.  Things
-	 * will go a bit crazy if that happens, but at least we should
-	 * try not to panic the whole kernel. */
-	if (needed < 2)
-		needed = 2;
-
-	/* But we need to bound the transaction so we don't overflow the
-	 * journal. */
-	if (needed > EXT4_MAX_TRANS_DATA)
-		needed = EXT4_MAX_TRANS_DATA;
-
-	return EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + needed;
-}
-
-/*
  * Truncate transactions can be complex and absolutely huge.  So we need to
  * be able to restart the transaction at a conventient checkpoint to make
  * sure we don't overflow the journal.
@@ -129,7 +103,7 @@ static handle_t *start_transaction(struct inode *inode)
 {
 	handle_t *result;
 
-	result = ext4_journal_start(inode, blocks_for_truncate(inode));
+	result = ext4_journal_start(inode, ext4_blocks_for_truncate(inode));
 	if (!IS_ERR(result))
 		return result;
 
@@ -149,7 +123,7 @@ static int try_to_extend_transaction(handle_t *handle, struct inode *inode)
 		return 0;
 	if (ext4_handle_has_enough_credits(handle, EXT4_RESERVE_TRANS_BLOCKS+1))
 		return 0;
-	if (!ext4_journal_extend(handle, blocks_for_truncate(inode)))
+	if (!ext4_journal_extend(handle, ext4_blocks_for_truncate(inode)))
 		return 0;
 	return 1;
 }
@@ -204,7 +178,7 @@ void ext4_evict_inode(struct inode *inode)
 	if (is_bad_inode(inode))
 		goto no_delete;
 
-	handle = ext4_journal_start(inode, blocks_for_truncate(inode)+3);
+	handle = ext4_journal_start(inode, ext4_blocks_for_truncate(inode)+3);
 	if (IS_ERR(handle)) {
 		ext4_std_error(inode->i_sb, PTR_ERR(handle));
 		/*
@@ -1555,16 +1529,6 @@ static int do_journal_get_write_access(handle_t *handle,
 	return ret;
 }
 
-/*
- * Truncate blocks that were not used by write. We have to truncate the
- * pagecache as well so that corresponding buffers get properly unmapped.
- */
-static void ext4_truncate_failed_write(struct inode *inode)
-{
-	truncate_inode_pages(inode->i_mapping, inode->i_size);
-	ext4_truncate(inode);
-}
-
 static int ext4_get_block_write(struct inode *inode, sector_t iblock,
 		   struct buffer_head *bh_result, int create);
 static int ext4_write_begin(struct file *file, struct address_space *mapping,
@@ -4134,7 +4098,7 @@ static int ext4_clear_blocks(handle_t *handle, struct inode *inode,
 		if (unlikely(err))
 			goto out_err;
 		err = ext4_truncate_restart_trans(handle, inode,
-						  blocks_for_truncate(inode));
+					ext4_blocks_for_truncate(inode));
 		if (unlikely(err))
 			goto out_err;
 		if (bh) {
@@ -4329,7 +4293,7 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
 			if (try_to_extend_transaction(handle, inode)) {
 				ext4_mark_inode_dirty(handle, inode);
 				ext4_truncate_restart_trans(handle, inode,
-					    blocks_for_truncate(inode));
+					    ext4_blocks_for_truncate(inode));
 			}
 
 			/*
fs/ext4/truncate.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
1.7.4.1.22.gec8e1.dirty
maintainer
#7 lore raw

PATCH 3/3 ext4: move ext4_ind_* functions from inode.c to indirect.c

In reply to Theodore Ts'o

From: Amir Goldstein <[email protected]>

This patch moves functions from inode.c to indirect.c. The moved functions are ext4_ind_* functions and their helpers. Functions called from inode.c are declared extern.

---
 fs/ext4/Makefile         |    2 +-
 fs/ext4/block_validity.c |    1 +
 fs/ext4/ext4.h           |    9 +
 fs/ext4/indirect.c       | 1510 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext4/inode.c          | 1486 ---------------------------------------------
 5 files changed, 1521 insertions(+), 1487 deletions(-)
 create mode 100644 fs/ext4/indirect.c
fs/ext4/Makefile +1 -1
index 0410946..56fd8f86 100644
@@ -7,7 +7,7 @@ obj-$(CONFIG_EXT4_FS) += ext4.o
 ext4-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o page-io.o \
 		ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \
 		ext4_jbd2.o migrate.o mballoc.o block_validity.o move_extent.o \
-		mmp.o
+		mmp.o indirect.o
 
 ext4-$(CONFIG_EXT4_FS_XATTR)		+= xattr.o xattr_user.o xattr_trusted.o
 ext4-$(CONFIG_EXT4_FS_POSIX_ACL)	+= acl.o
fs/ext4/block_validity.c +1 -0
index af103be..8efb2f0 100644
@@ -266,3 +266,4 @@ int ext4_check_blockref(const char *function, unsigned int line,
 	}
 	return 0;
 }
+
fs/ext4/ext4.h +9 -0
index 82ba7eb..ddaf504 100644
@@ -1834,6 +1834,15 @@ extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
 extern qsize_t *ext4_get_reserved_space(struct inode *inode);
 extern void ext4_da_update_reserve_space(struct inode *inode,
 					int used, int quota_claim);
+
+/* indirect.c */
+extern int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
+				struct ext4_map_blocks *map, int flags);
+extern ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
+				const struct iovec *iov, loff_t offset,
+				unsigned long nr_segs);
+extern int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock);
+extern int ext4_ind_trans_blocks(struct inode *inode, int nrblocks, int chunk);
 extern void ext4_ind_truncate(struct inode *inode);
 
 /* ioctl.c */
fs/ext4/indirect.c new file +1510 -0

1,510 lines not on this page · raw message

fs/ext4/inode.c +0 -1485

1,463 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

author
#8 lore raw

Re: [PATCH 3/4] ext4: clone indirect.c file from inode.c

In reply to Ted Ts'o
Quoted 17 lines · Ted Ts'o
Quoted 7 lines · On Tue, Jun 21, 2011 at 12:39:27PM +0300, [email protected] wrote:

From: Amir Goldstein <[email protected]>

The next patch is going to move ext4_ind_ functions to indirect.c. First, we clone the file from inode.c and only leave code that is going to be duplicated in both files. This should keep the deleted lines count from inode.c in the next patch the same as the added lines count to indirect.c.

I really dislike cloning functions.  This becomes a maintenance headache, since bugs that get fixed in one file might not get propagated to another.  Since I need to manually move all of the functions to verify nothing else changed in patches that do massive code movement, I used the first two patches in your patch series, but replaced the last two patches in the patch series, and replaced it with the following:

Quoted 5 lines

A) Move __ext4_check_blockref() to fs/ext4/block_validity.c and declare it extern.

B) Move ext4_truncate_failed_write() and blocks_for_truncate() to a new function, fs/ext4/truncate.h.

Nice cleanups!

Quoted 3 lines

C) Movement of indirect-related code to fs/ext4/indirect.c.

Hmm.. in my patch the deleted lines from inode.c matched the added lines in indirect.c (-1 newline at end of file). Your patch has:

 fs/ext4/indirect.c       | 1510 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext4/inode.c          | 1486 ---------------------------------------------

This accounts for 28 lines added by header comment and includes in indirect.c -1 newline at end of file, so where did 3 more lines go?
I am guessing these are just deleted newlines, but have no way of knowing. Have you made other (maybe checkpatch) changes while moving or just removed 'static'
from function declarations?
I am asking just in case I get 'git blamed' for it some day ;-)

Cheers,
Amir.
--
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