|
@@ -993,9 +993,17 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
|
|
|
trans = btrfs_attach_transaction_barrier(root);
|
|
|
if (IS_ERR(trans)) {
|
|
|
/* no transaction, don't bother */
|
|
|
- if (PTR_ERR(trans) == -ENOENT)
|
|
|
- return 0;
|
|
|
- return PTR_ERR(trans);
|
|
|
+ if (PTR_ERR(trans) == -ENOENT) {
|
|
|
+ /*
|
|
|
+ * Exit unless we have some pending changes
|
|
|
+ * that need to go through commit
|
|
|
+ */
|
|
|
+ if (fs_info->pending_changes == 0)
|
|
|
+ return 0;
|
|
|
+ trans = btrfs_start_transaction(root, 0);
|
|
|
+ } else {
|
|
|
+ return PTR_ERR(trans);
|
|
|
+ }
|
|
|
}
|
|
|
return btrfs_commit_transaction(trans, root);
|
|
|
}
|