staging: exfat: use bdev_sync function directly where needed
PATCH 1/1 staging: exfat: use bdev_sync function directly where needed
fs_sync() is wrapper to bdev_sync(). When fs_sync is called with non-zero argument, bdev_sync gets called.
Most instances of fs_sync is called with false and very few with true. Refactor this and makes direct call to bdev_sync() where needed and removes fs_sync definition.
--- drivers/staging/exfat/exfat_super.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/staging/exfat/exfat_super.c +3 -16
@@ -285,12 +285,6 @@ static const struct dentry_operations exfat_dentry_ops = {static DEFINE_SEMAPHORE (z_sem); -static inline void fs_sync (struct super_block *sb,bool do_sync) -{ -if (do_sync) -bdev_sync (sb); -} -/* * If ->i_mode can't hold S_IWUGO (i.e. ATTR_RO), we use ->i_attrs to * save ATTR_RO instead of ->i_mode.
@@ -458,7 +452,6 @@ static int ffsUmountVol(struct super_block *sb)/* acquire the lock for file system critical section */ down (&p_fs->v_sem); -fs_sync (sb, false);fs_set_vol_flags (sb,VOL_CLEAN );if (p_fs->vol_type ==EXFAT ) {
@@ -527,7 +520,9 @@ static int ffsSyncVol(struct super_block *sb, bool do_sync)down (&p_fs->v_sem);/* synchronize the file system */ -fs_sync (sb, do_sync); +if (do_sync) +bdev_sync (sb); +fs_set_vol_flags (sb,VOL_CLEAN );if (p_fs->dev_ejected)
@@ -667,7 +662,6 @@ static int ffsCreateFile(struct inode *inode, char *path, u8 mode, ret =create_file (inode, &dir, &uni_name, mode, fid);#ifdef CONFIG_EXFAT_DELAYED_SYNC -fs_sync (sb, false);fs_set_vol_flags (sb,VOL_CLEAN );#endif
@@ -1040,7 +1034,6 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, }#ifdef CONFIG_EXFAT_DELAYED_SYNC -fs_sync (sb, false);fs_set_vol_flags (sb,VOL_CLEAN );#endif
@@ -1180,7 +1173,6 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) fid->rwoffset = fid->size;#ifdef CONFIG_EXFAT_DELAYED_SYNC -fs_sync (sb, false);fs_set_vol_flags (sb,VOL_CLEAN );#endif
@@ -1328,7 +1320,6 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, } out: #ifdef CONFIG_EXFAT_DELAYED_SYNC -fs_sync (sb ,false );fs_set_vol_flags (sb ,VOL_CLEAN );#endif
@@ -1390,7 +1381,6 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid) fid->flags = (p_fs->vol_type ==EXFAT ) ?0x03 :0x01 ;#ifdef CONFIG_EXFAT_DELAYED_SYNC -fs_sync (sb, false);fs_set_vol_flags (sb,VOL_CLEAN );#endif
@@ -1479,7 +1469,6 @@ static int ffsSetAttr(struct inode *inode, u32 attr) }#ifdef CONFIG_EXFAT_DELAYED_SYNC -fs_sync (sb, false);fs_set_vol_flags (sb,VOL_CLEAN );#endif
@@ -1917,7 +1906,6 @@ static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid) ret =create_dir (inode, &dir, &uni_name, fid);#ifdef CONFIG_EXFAT_DELAYED_SYNC -fs_sync (sb, false);fs_set_vol_flags (sb,VOL_CLEAN );#endif
@@ -2178,7 +2166,6 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) fid->flags = (p_fs->vol_type ==EXFAT ) ?0x03 :0x01 ;#ifdef CONFIG_EXFAT_DELAYED_SYNC -fs_sync (sb, false);fs_set_vol_flags (sb,VOL_CLEAN );#endif
Signature · 1 line
2.20.1
Quoted 6 lines · Saiyam Doshi
fs_sync()is wrapper tobdev_sync(). Whenfs_syncis called with non-zero argument,bdev_syncgets called.Most instances of
fs_syncis called with false and very few with true. Refactor this and makes direct call tobdev_sync()where needed and removesfs_syncdefinition.
Did you do an actual analysis of where bdev_sync() *should* be called?
The note in the TODO was intended to point out that many of the calls are called with 'false' and probably should not be.
#ifdef CONFIG_EXFAT_DELAYED_SYNC
- fs_sync(sb, false);
fs_set_vol_flags(sb, VOL_CLEAN);
#endif
Consider - with this patch, we are now setting the volume state to clean - but we've not actually flushed the filesystem to disk, which means it's almost guaranteed that the file system is *NOT* in fact clean.
Changing all the 'false' that happen before a VOL_CLEAN to 'true' is probably more correct - but still totally wrong if DELAYED_SYNC isn't defined because then we *aren't* syncing to disk at all.
I replied to your other thread and I added Saiyam Doshi to the CC list there. Just to be clear this patch is a good cleanup and doesn't affect runtime at all.
In the other thread, I suggested that we leave fs_sync() as a marker even though it's dead code. But looking at it now, I think that it's not really useful. Future auditors should look for places which call fs_set_vol_flags(sb, VOL_CLEAN); instead. That's exactly the places which call fs_sync().
regards,
dan carpenter
Or we could apply your other patch which trumps both this patch and the patch to the TODO.
regards,
dan carpenter
Quoted 8 lines · Saiyam Doshi
fs_sync()is wrapper tobdev_sync(). Whenfs_syncis called with non-zero argument,bdev_syncgets called.Most instances of
fs_syncis called with false and very few with true. Refactor this and makes direct call tobdev_sync()where needed and removesfs_syncdefinition.Signed-off-by Saiyam Doshi <[email protected]>
regards,
dan carpenter