aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/sync.c')
-rw-r--r--fs/sync.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/sync.c b/fs/sync.c
index 192340930bb4..d104591b066b 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -27,6 +27,13 @@
27 */ 27 */
28static int __sync_filesystem(struct super_block *sb, int wait) 28static int __sync_filesystem(struct super_block *sb, int wait)
29{ 29{
30 /*
31 * This should be safe, as we require bdi backing to actually
32 * write out data in the first place
33 */
34 if (!sb->s_bdi)
35 return 0;
36
30 /* Avoid doing twice syncing and cache pruning for quota sync */ 37 /* Avoid doing twice syncing and cache pruning for quota sync */
31 if (!wait) { 38 if (!wait) {
32 writeout_quota_sb(sb, -1); 39 writeout_quota_sb(sb, -1);
@@ -101,7 +108,7 @@ restart:
101 spin_unlock(&sb_lock); 108 spin_unlock(&sb_lock);
102 109
103 down_read(&sb->s_umount); 110 down_read(&sb->s_umount);
104 if (!(sb->s_flags & MS_RDONLY) && sb->s_root) 111 if (!(sb->s_flags & MS_RDONLY) && sb->s_root && sb->s_bdi)
105 __sync_filesystem(sb, wait); 112 __sync_filesystem(sb, wait);
106 up_read(&sb->s_umount); 113 up_read(&sb->s_umount);
107 114
@@ -176,6 +183,7 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
176 ret = err; 183 ret = err;
177 return ret; 184 return ret;
178} 185}
186EXPORT_SYMBOL(file_fsync);
179 187
180/** 188/**
181 * vfs_fsync_range - helper to sync a range of data & metadata to disk 189 * vfs_fsync_range - helper to sync a range of data & metadata to disk