summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2014-09-11 21:22:14 +0100
committerChris Mason <clm@fb.com>2014-09-16 16:12:19 -0700
commit125c4cf9f37c98fed2c08229b31358cfec63dcf6 (patch)
treea5aaaa434b9be066a0b236a5acfe4406c35dfd21 /fs/btrfs/tree-log.c
parentb0d5d10f41a0f1cd839408dd94427f2db3553bca (diff)
downloadlinux-125c4cf9f37c98fed2c08229b31358cfec63dcf6.tar.gz
linux-125c4cf9f37c98fed2c08229b31358cfec63dcf6.tar.bz2
linux-125c4cf9f37c98fed2c08229b31358cfec63dcf6.zip
Btrfs: set inode's logged_trans/last_log_commit after ranged fsync
When a ranged fsync finishes if there are still extent maps in the modified list, still set the inode's logged_trans and last_log_commit. This is important in case an inode is fsync'ed and unlinked in the same transaction, to ensure its inode ref gets deleted from the log and the respective dentries in its parent are deleted too from the log (if the parent directory was fsync'ed in the same transaction). Instead make btrfs_inode_in_log() return false if the list of modified extent maps isn't empty. This is an incremental on top of the v4 version of the patch: "Btrfs: fix fsync data loss after a ranged fsync" which was added to its v5, but didn't make it on time. Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index d296efe2d3e7..1d1ba083ca6e 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -4093,18 +4093,8 @@ log_extents:
}
}
- write_lock(&em_tree->lock);
- /*
- * If we're doing a ranged fsync and there are still modified extents
- * in the list, we must run on the next fsync call as it might cover
- * those extents (a full fsync or an fsync for other range).
- */
- if (list_empty(&em_tree->modified_extents)) {
- BTRFS_I(inode)->logged_trans = trans->transid;
- BTRFS_I(inode)->last_log_commit =
- BTRFS_I(inode)->last_sub_trans;
- }
- write_unlock(&em_tree->lock);
+ BTRFS_I(inode)->logged_trans = trans->transid;
+ BTRFS_I(inode)->last_log_commit = BTRFS_I(inode)->last_sub_trans;
out_unlock:
if (unlikely(err))
btrfs_put_logged_extents(&logged_list);