Commit 8789f13d authored by Valdis Klētnieks's avatar Valdis Klētnieks Committed by Greg Kroah-Hartman

staging: exfat: fix fs_sync() calls.

The majority of them were totally backwards.  Change the logic
so that if DELAYED_SYNC *isn't* in the config, we actually flush to disk
before flagging the file system as clean.

That leaves two calls in the DELAYED_SYNC case.  More detailed
analysis is needed to make sure that's what's really needed, or if other
call sites also need a fs_sync() call.  This patch is at least "less wrong"
than the code was, but further changes should be another patch.
Signed-off-by: default avatarValdis Kletnieks <valdis.kletnieks@vt.edu>

Link: https://lore.kernel.org/r/11092.1570043784@turing-policeSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7e6af677
...@@ -458,7 +458,7 @@ static int ffsUmountVol(struct super_block *sb) ...@@ -458,7 +458,7 @@ static int ffsUmountVol(struct super_block *sb)
/* acquire the lock for file system critical section */ /* acquire the lock for file system critical section */
down(&p_fs->v_sem); down(&p_fs->v_sem);
fs_sync(sb, false); fs_sync(sb, true);
fs_set_vol_flags(sb, VOL_CLEAN); fs_set_vol_flags(sb, VOL_CLEAN);
if (p_fs->vol_type == EXFAT) { if (p_fs->vol_type == EXFAT) {
...@@ -666,8 +666,8 @@ static int ffsCreateFile(struct inode *inode, char *path, u8 mode, ...@@ -666,8 +666,8 @@ static int ffsCreateFile(struct inode *inode, char *path, u8 mode,
/* create a new file */ /* create a new file */
ret = create_file(inode, &dir, &uni_name, mode, fid); ret = create_file(inode, &dir, &uni_name, mode, fid);
#ifdef CONFIG_EXFAT_DELAYED_SYNC #ifndef CONFIG_EXFAT_DELAYED_SYNC
fs_sync(sb, false); fs_sync(sb, true);
fs_set_vol_flags(sb, VOL_CLEAN); fs_set_vol_flags(sb, VOL_CLEAN);
#endif #endif
...@@ -1039,8 +1039,8 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, ...@@ -1039,8 +1039,8 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid,
release_entry_set(es); release_entry_set(es);
} }
#ifdef CONFIG_EXFAT_DELAYED_SYNC #ifndef CONFIG_EXFAT_DELAYED_SYNC
fs_sync(sb, false); fs_sync(sb, true);
fs_set_vol_flags(sb, VOL_CLEAN); fs_set_vol_flags(sb, VOL_CLEAN);
#endif #endif
...@@ -1179,8 +1179,8 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) ...@@ -1179,8 +1179,8 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size)
if (fid->rwoffset > fid->size) if (fid->rwoffset > fid->size)
fid->rwoffset = fid->size; fid->rwoffset = fid->size;
#ifdef CONFIG_EXFAT_DELAYED_SYNC #ifndef CONFIG_EXFAT_DELAYED_SYNC
fs_sync(sb, false); fs_sync(sb, true);
fs_set_vol_flags(sb, VOL_CLEAN); fs_set_vol_flags(sb, VOL_CLEAN);
#endif #endif
...@@ -1327,8 +1327,8 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, ...@@ -1327,8 +1327,8 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
num_entries + 1); num_entries + 1);
} }
out: out:
#ifdef CONFIG_EXFAT_DELAYED_SYNC #ifndef CONFIG_EXFAT_DELAYED_SYNC
fs_sync(sb, false); fs_sync(sb, true);
fs_set_vol_flags(sb, VOL_CLEAN); fs_set_vol_flags(sb, VOL_CLEAN);
#endif #endif
...@@ -1389,8 +1389,8 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid) ...@@ -1389,8 +1389,8 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid)
fid->start_clu = CLUSTER_32(~0); fid->start_clu = CLUSTER_32(~0);
fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01; fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01;
#ifdef CONFIG_EXFAT_DELAYED_SYNC #ifndef CONFIG_EXFAT_DELAYED_SYNC
fs_sync(sb, false); fs_sync(sb, true);
fs_set_vol_flags(sb, VOL_CLEAN); fs_set_vol_flags(sb, VOL_CLEAN);
#endif #endif
...@@ -1478,8 +1478,8 @@ static int ffsSetAttr(struct inode *inode, u32 attr) ...@@ -1478,8 +1478,8 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
release_entry_set(es); release_entry_set(es);
} }
#ifdef CONFIG_EXFAT_DELAYED_SYNC #ifndef CONFIG_EXFAT_DELAYED_SYNC
fs_sync(sb, false); fs_sync(sb, true);
fs_set_vol_flags(sb, VOL_CLEAN); fs_set_vol_flags(sb, VOL_CLEAN);
#endif #endif
...@@ -1916,8 +1916,8 @@ static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid) ...@@ -1916,8 +1916,8 @@ static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid)
ret = create_dir(inode, &dir, &uni_name, fid); ret = create_dir(inode, &dir, &uni_name, fid);
#ifdef CONFIG_EXFAT_DELAYED_SYNC #ifndef CONFIG_EXFAT_DELAYED_SYNC
fs_sync(sb, false); fs_sync(sb, true);
fs_set_vol_flags(sb, VOL_CLEAN); fs_set_vol_flags(sb, VOL_CLEAN);
#endif #endif
...@@ -2177,8 +2177,8 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) ...@@ -2177,8 +2177,8 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid)
fid->start_clu = CLUSTER_32(~0); fid->start_clu = CLUSTER_32(~0);
fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01; fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01;
#ifdef CONFIG_EXFAT_DELAYED_SYNC #ifndef CONFIG_EXFAT_DELAYED_SYNC
fs_sync(sb, false); fs_sync(sb, true);
fs_set_vol_flags(sb, VOL_CLEAN); fs_set_vol_flags(sb, VOL_CLEAN);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment