archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfs, syncfs: Do not ignore return code from ->sync_fs()
@ 2020-12-16 14:38 Vivek Goyal
  2020-12-16 14:57 ` Jeff Layton
  0 siblings, 1 reply; 6+ messages in thread
From: Vivek Goyal @ 2020-12-16 14:38 UTC (permalink / raw)
  To: Linux fsdevel mailing list, linux-unionfs, linux-kernel
  Cc: viro, miklos, jlayton, amir73il, willy, jack, sargun

I see that current implementation of __sync_filesystem() ignores the
return code from ->sync_fs(). I am not sure why that's the case.

Ignoring ->sync_fs() return code is problematic for overlayfs where
it can return error if sync_filesystem() on upper super block failed.
That error will simply be lost and sycnfs(overlay_fd), will get
success (despite the fact it failed).

I am assuming that we want to continue to call __sync_blockdev()
despite the fact that there have been errors reported from
->sync_fs(). So I wrote this simple patch which captures the
error from ->sync_fs() but continues to call __sync_blockdev()
and returns error from sync_fs() if there is one.

There might be some very good reasons to not capture ->sync_fs()
return code, I don't know. Hence thought of proposing this patch.
Atleast I will get to know the reason. I still need to figure
a way out how to propagate overlay sync_fs() errors to user

Signed-off-by: Vivek Goyal <>
 fs/sync.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Index: redhat-linux/fs/sync.c
--- redhat-linux.orig/fs/sync.c	2020-12-16 09:15:49.831565653 -0500
+++ redhat-linux/fs/sync.c	2020-12-16 09:23:42.499853207 -0500
@@ -30,14 +30,18 @@
 static int __sync_filesystem(struct super_block *sb, int wait)
+	int ret, ret2;
 	if (wait)
 		writeback_inodes_sb(sb, WB_REASON_SYNC);
 	if (sb->s_op->sync_fs)
-		sb->s_op->sync_fs(sb, wait);
-	return __sync_blockdev(sb->s_bdev, wait);
+		ret = sb->s_op->sync_fs(sb, wait);
+	ret2 = __sync_blockdev(sb->s_bdev, wait);
+	return ret ? ret : ret2;

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

end of thread, other threads:[~2020-12-16 17:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 14:38 [PATCH] vfs, syncfs: Do not ignore return code from ->sync_fs() Vivek Goyal
2020-12-16 14:57 ` Jeff Layton
2020-12-16 15:14   ` Vivek Goyal
2020-12-16 15:44     ` Jeff Layton
2020-12-16 15:53       ` Jeff Layton
2020-12-16 17:16         ` Vivek Goyal

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).