aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 90268334145e..872f104576e5 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -29,7 +29,6 @@
29#include <linux/writeback.h> 29#include <linux/writeback.h>
30#include <linux/statfs.h> 30#include <linux/statfs.h>
31#include <linux/compat.h> 31#include <linux/compat.h>
32#include <linux/version.h>
33#include "ctree.h" 32#include "ctree.h"
34#include "disk-io.h" 33#include "disk-io.h"
35#include "transaction.h" 34#include "transaction.h"
@@ -1215,15 +1214,15 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync)
1215 } 1214 }
1216 mutex_unlock(&root->fs_info->trans_mutex); 1215 mutex_unlock(&root->fs_info->trans_mutex);
1217 1216
1218 root->fs_info->tree_log_batch++; 1217 root->log_batch++;
1219 filemap_fdatawrite(inode->i_mapping); 1218 filemap_fdatawrite(inode->i_mapping);
1220 btrfs_wait_ordered_range(inode, 0, (u64)-1); 1219 btrfs_wait_ordered_range(inode, 0, (u64)-1);
1221 root->fs_info->tree_log_batch++; 1220 root->log_batch++;
1222 1221
1223 /* 1222 /*
1224 * ok we haven't committed the transaction yet, lets do a commit 1223 * ok we haven't committed the transaction yet, lets do a commit
1225 */ 1224 */
1226 if (file->private_data) 1225 if (file && file->private_data)
1227 btrfs_ioctl_trans_end(file); 1226 btrfs_ioctl_trans_end(file);
1228 1227
1229 trans = btrfs_start_transaction(root, 1); 1228 trans = btrfs_start_transaction(root, 1);
@@ -1232,7 +1231,7 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync)
1232 goto out; 1231 goto out;
1233 } 1232 }
1234 1233
1235 ret = btrfs_log_dentry_safe(trans, root, file->f_dentry); 1234 ret = btrfs_log_dentry_safe(trans, root, dentry);
1236 if (ret < 0) 1235 if (ret < 0)
1237 goto out; 1236 goto out;
1238 1237
@@ -1246,7 +1245,7 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync)
1246 * file again, but that will end up using the synchronization 1245 * file again, but that will end up using the synchronization
1247 * inside btrfs_sync_log to keep things safe. 1246 * inside btrfs_sync_log to keep things safe.
1248 */ 1247 */
1249 mutex_unlock(&file->f_dentry->d_inode->i_mutex); 1248 mutex_unlock(&dentry->d_inode->i_mutex);
1250 1249
1251 if (ret > 0) { 1250 if (ret > 0) {
1252 ret = btrfs_commit_transaction(trans, root); 1251 ret = btrfs_commit_transaction(trans, root);
@@ -1254,7 +1253,7 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync)
1254 btrfs_sync_log(trans, root); 1253 btrfs_sync_log(trans, root);
1255 ret = btrfs_end_transaction(trans, root); 1254 ret = btrfs_end_transaction(trans, root);
1256 } 1255 }
1257 mutex_lock(&file->f_dentry->d_inode->i_mutex); 1256 mutex_lock(&dentry->d_inode->i_mutex);
1258out: 1257out:
1259 return ret > 0 ? EIO : ret; 1258 return ret > 0 ? EIO : ret;
1260} 1259}