linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix transaction leak during fsync call
@ 2014-05-29 19:33 Filipe David Borba Manana
  2014-05-29 22:31 ` [PATCH v2] " Filipe David Borba Manana
  0 siblings, 1 reply; 2+ messages in thread
From: Filipe David Borba Manana @ 2014-05-29 19:33 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Filipe David Borba Manana

If btrfs_log_dentry_safe() returns an error, we set ret to 1 and
fall through with the goal of committing the transaction. However,
in the case where the inode doesn't need a full sync, we would call
btrfs_wait_ordered_range() against the target range for our inode,
and if it returned an error, we would return without commiting or
ending the transaction, leaving the transaction open forever.

Since when btrfs_wait_ordered_range() doesn't return an error we
commit the transaction, it doesn't make sense to make a call to
btrfs_wait_ordered_range() because committing the transaction will
wait for all ordered extents to complete anyway.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---
 fs/btrfs/file.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 8accf94..e0be468 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2022,12 +2022,6 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 				goto out;
 			}
 		}
-		if (!full_sync) {
-			ret = btrfs_wait_ordered_range(inode, start,
-						       end - start + 1);
-			if (ret)
-				goto out;
-		}
 		ret = btrfs_commit_transaction(trans, root);
 	} else {
 		ret = btrfs_end_transaction(trans, root);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2] Btrfs: fix transaction leak during fsync call
  2014-05-29 19:33 [PATCH] Btrfs: fix transaction leak during fsync call Filipe David Borba Manana
@ 2014-05-29 22:31 ` Filipe David Borba Manana
  0 siblings, 0 replies; 2+ messages in thread
From: Filipe David Borba Manana @ 2014-05-29 22:31 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Filipe David Borba Manana

If btrfs_log_dentry_safe() returns an error, we set ret to 1 and
fall through with the goal of committing the transaction. However,
in the case where the inode doesn't need a full sync, we would call
btrfs_wait_ordered_range() against the target range for our inode,
and if it returned an error, we would return without commiting or
ending the transaction.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---

V2: Leave the call to btrfs_wait_ordered_range(), it's needed if
    the fs is mounted with -o no_flushoncommit.

 fs/btrfs/file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index e46bfaf..5a00597 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2025,8 +2025,10 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		if (!full_sync) {
 			ret = btrfs_wait_ordered_range(inode, start,
 						       end - start + 1);
-			if (ret)
+			if (ret) {
+				btrfs_end_transaction(trans, root);
 				goto out;
+			}
 		}
 		ret = btrfs_commit_transaction(trans, root);
 	} else {
-- 
1.9.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-29 21:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-29 19:33 [PATCH] Btrfs: fix transaction leak during fsync call Filipe David Borba Manana
2014-05-29 22:31 ` [PATCH v2] " Filipe David Borba Manana

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).