[PATCH] hfs: don't dirty unchanged inode
authorRoman Zippel <zippel@linux-m68k.org>
Tue, 2 Aug 2005 04:11:40 +0000 (21:11 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 2 Aug 2005 04:38:00 +0000 (21:38 -0700)
If inode size hasn't changed, don't do anything further in truncate, which
also prevents a dirty inode, what might upset some readonly devices quite
badly.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/hfs/extent.c
fs/hfsplus/extents.c

index cbc8510ad22212a58f7dfab2ce1a34f36d599064..5ea6b3d45eaa608f9ab38887de18ccb8477dacc2 100644 (file)
@@ -482,7 +482,8 @@ void hfs_file_truncate(struct inode *inode)
                page_cache_release(page);
                mark_inode_dirty(inode);
                return;
-       }
+       } else if (inode->i_size == HFS_I(inode)->phys_size)
+               return;
        size = inode->i_size + HFS_SB(sb)->alloc_blksz - 1;
        blk_cnt = size / HFS_SB(sb)->alloc_blksz;
        alloc_cnt = HFS_I(inode)->alloc_blocks;
index 376498cc64fddb5b54df6d8f249df43570d38c5e..e7235ca79a95285a1ddb0cdb79e2cadaa9895705 100644 (file)
@@ -461,7 +461,9 @@ void hfsplus_file_truncate(struct inode *inode)
                page_cache_release(page);
                mark_inode_dirty(inode);
                return;
-       }
+       } else if (inode->i_size == HFSPLUS_I(inode).phys_size)
+               return;
+
        blk_cnt = (inode->i_size + HFSPLUS_SB(sb).alloc_blksz - 1) >> HFSPLUS_SB(sb).alloc_blksz_shift;
        alloc_cnt = HFSPLUS_I(inode).alloc_blocks;
        if (blk_cnt == alloc_cnt)