[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1332314639-22875-2-git-send-email-lczerner@redhat.com>
Date: Wed, 21 Mar 2012 08:23:55 +0100
From: Lukas Czerner <lczerner@...hat.com>
To: linux-ext4@...r.kernel.org
Cc: tytso@....edu, achender@...ux.vnet.ibm.com,
Lukas Czerner <lczerner@...hat.com>
Subject: [PATCH 2/5] ext4: Correctly handle EOFBLOCKS flag in ext4_ext_punch_hole
We have to clear the EOFBLOCK flag in the case that we just punched
out all blocks allocated past the i_size, so that e2fsck does not
compain about it. Even though we're going to remove EOFBLOCKS flag
in the future we still have to handle it correctly for now as there
are e2fsck versions out there which would complain about it. We can
remove this after the new e2fsck code ignoring the EOFBLOCKS flag
is common enough.
Signed-off-by: Lukas Czerner <lczerner@...hat.com>
---
fs/ext4/extents.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 06b0792..7b822c0 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4822,6 +4822,41 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length)
up_write(&EXT4_I(inode)->i_data_sem);
+ /*
+ * This is fugly, but even though we're going to get rid of the
+ * EOFBLOCKS_LF in the future, we have to handle it correctly now
+ * because there are still versions of e2fsck out there which
+ * would scream otherwise. Once the new e2fsck code ignoring
+ * this flag is common enough this can be removed entirely.
+ */
+ if (ext4_test_inode_flag(inode, EXT4_INODE_EOFBLOCKS)) {
+ struct ext4_ext_path *path;
+ ext4_lblk_t last_block;
+
+ mutex_lock(&inode->i_mutex);
+ down_read(&EXT4_I(inode)->i_data_sem);
+
+ last_block = inode->i_size >> EXT4_BLOCK_SIZE_BITS(sb);
+
+ /*
+ * We have to check whether there is any extent past the
+ * i_size. If not, we probably punched that out, so we need
+ * to clear the EOFBLOCKS flag
+ */
+ path = ext4_ext_find_extent(inode, last_block, NULL);
+ if (IS_ERR(path))
+ err = PTR_ERR(path);
+ else {
+ err = check_eofblocks_fl(handle, inode, last_block,
+ path, 1);
+ ext4_ext_drop_refs(path);
+ kfree(path);
+ }
+
+ up_read(&EXT4_I(inode)->i_data_sem);
+ mutex_unlock(&inode->i_mutex);
+ }
+
out:
ext4_orphan_del(handle, inode);
inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
--
1.7.4.4
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists