linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: exfat: use bdev_sync function directly where needed
@ 2019-10-02 15:17 Saiyam Doshi
  2019-10-02 19:04 ` Valdis Klētnieks
  2019-10-03 11:13 ` Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: Saiyam Doshi @ 2019-10-02 15:17 UTC (permalink / raw)
  To: valdis.kletnieks, gregkh; +Cc: devel, linux-kernel

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.

Signed-off-by: Saiyam Doshi <saiyamdoshi.in@gmail.com>
---
 drivers/staging/exfat/exfat_super.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index 229ecabe7a93..3d3b0f0eebdc 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -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
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: exfat: use bdev_sync function directly where needed
  2019-10-02 15:17 [PATCH] staging: exfat: use bdev_sync function directly where needed Saiyam Doshi
@ 2019-10-02 19:04 ` Valdis Klētnieks
  2019-10-03 11:46   ` Dan Carpenter
  2019-10-03 11:13 ` Dan Carpenter
  1 sibling, 1 reply; 5+ messages in thread
From: Valdis Klētnieks @ 2019-10-02 19:04 UTC (permalink / raw)
  To: Saiyam Doshi; +Cc: gregkh, devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1046 bytes --]

On Wed, 02 Oct 2019 20:47:03 +0530, Saiyam Doshi said:
> 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.

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.



[-- Attachment #2: Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: exfat: use bdev_sync function directly where needed
  2019-10-02 15:17 [PATCH] staging: exfat: use bdev_sync function directly where needed Saiyam Doshi
  2019-10-02 19:04 ` Valdis Klētnieks
@ 2019-10-03 11:13 ` Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2019-10-03 11:13 UTC (permalink / raw)
  To: Saiyam Doshi; +Cc: valdis.kletnieks, gregkh, devel, linux-kernel

On Wed, Oct 02, 2019 at 08:47:03PM +0530, Saiyam Doshi wrote:
> 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.
> 
> Signed-off-by: Saiyam Doshi <saiyamdoshi.in@gmail.com>

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: exfat: use bdev_sync function directly where needed
  2019-10-02 19:04 ` Valdis Klētnieks
@ 2019-10-03 11:46   ` Dan Carpenter
  2019-10-03 11:48     ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-10-03 11:46 UTC (permalink / raw)
  To: Valdis Klētnieks; +Cc: Saiyam Doshi, devel, gregkh, linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: exfat: use bdev_sync function directly where needed
  2019-10-03 11:46   ` Dan Carpenter
@ 2019-10-03 11:48     ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2019-10-03 11:48 UTC (permalink / raw)
  To: Valdis Klētnieks; +Cc: Saiyam Doshi, devel, gregkh, linux-kernel

Or we could apply your other patch which trumps both this patch and the
patch to the TODO.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-03 11:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02 15:17 [PATCH] staging: exfat: use bdev_sync function directly where needed Saiyam Doshi
2019-10-02 19:04 ` Valdis Klētnieks
2019-10-03 11:46   ` Dan Carpenter
2019-10-03 11:48     ` Dan Carpenter
2019-10-03 11:13 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).