Skip to content

Commit

Permalink
[PATCH] hfs: don't dirty unchanged inode
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Roman Zippel authored and Linus Torvalds committed Aug 2, 2005
1 parent 0072b13 commit f76d28d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion fs/hfs/extent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion fs/hfsplus/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f76d28d

Please sign in to comment.