Advertisement
Guest User

Untitled

a guest
Aug 24th, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. From b71fc079b5d8f42b2a52743c8d2f1d35d655b1c5 Mon Sep 17 00:00:00 2001
  2. From: Jan Kara <jack@suse.cz>
  3. Date: Wed, 26 Sep 2012 21:52:20 -0400
  4. Subject: ext4: fix fdatasync() for files with only i_size changes
  5.  
  6. Code tracking when transaction needs to be committed on fdatasync(2) forgets
  7. to handle a situation when only inode's i_size is changed. Thus in such
  8. situations fdatasync(2) doesn't force transaction with new i_size to disk
  9. and that can result in wrong i_size after a crash.
  10.  
  11. Fix the issue by updating inode's i_datasync_tid whenever its size is
  12. updated.
  13.  
  14. CC: <stable@vger.kernel.org> # >= 2.6.32
  15. Reported-by: Kristian Nielsen <knielsen@knielsen-hq.org>
  16. Signed-off-by: Jan Kara <jack@suse.cz>
  17.  
  18. diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
  19. index 0a31197..4df5e95 100644
  20. --- a/fs/ext4/inode.c
  21. +++ b/fs/ext4/inode.c
  22. @@ -4054,6 +4054,7 @@ static int ext4_do_update_inode(handle_t *handle,
  23. struct ext4_inode_info *ei = EXT4_I(inode);
  24. struct buffer_head *bh = iloc->bh;
  25. int err = 0, rc, block;
  26. + int need_datasync = 0;
  27. uid_t i_uid;
  28. gid_t i_gid;
  29.  
  30. @@ -4104,7 +4105,10 @@ static int ext4_do_update_inode(handle_t *handle,
  31. raw_inode->i_file_acl_high =
  32. cpu_to_le16(ei->i_file_acl >> 32);
  33. raw_inode->i_file_acl_lo = cpu_to_le32(ei->i_file_acl);
  34. - ext4_isize_set(raw_inode, ei->i_disksize);
  35. + if (ei->i_disksize != ext4_isize(raw_inode)) {
  36. + ext4_isize_set(raw_inode, ei->i_disksize);
  37. + need_datasync = 1;
  38. + }
  39. if (ei->i_disksize > 0x7fffffffULL) {
  40. struct super_block *sb = inode->i_sb;
  41. if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
  42. @@ -4157,7 +4161,7 @@ static int ext4_do_update_inode(handle_t *handle,
  43. err = rc;
  44. ext4_clear_inode_state(inode, EXT4_STATE_NEW);
  45.  
  46. - ext4_update_inode_fsync_trans(handle, inode, 0);
  47. + ext4_update_inode_fsync_trans(handle, inode, need_datasync);
  48. out_brelse:
  49. brelse(bh);
  50. ext4_std_error(inode->i_sb, err);
  51. --
  52. cgit v0.10.2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement