lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210923130814.140814-10-cgxu519@mykernel.net>
Date:   Thu, 23 Sep 2021 21:08:13 +0800
From:   Chengguang Xu <cgxu519@...ernel.net>
To:     miklos@...redi.hu, jack@...e.cz, amir73il@...il.com
Cc:     linux-fsdevel@...r.kernel.org, linux-unionfs@...r.kernel.org,
        linux-kernel@...r.kernel.org, Chengguang Xu <cgxu519@...ernel.net>
Subject: [RFC PATCH v5 09/10] fs: introduce new helper sync_fs_and_blockdev()

Overlayfs needs to call upper layer's ->sync_fs
and __sync_blockdev() to sync metadata during syncfs(2).

Currently, __sync_blockdev() does not export to module
so introduce new helper sync_fs_and_blockdev() to wrap
those operations.

Signed-off-by: Chengguang Xu <cgxu519@...ernel.net>
---
 fs/sync.c          | 14 ++++++++++----
 include/linux/fs.h |  1 +
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/sync.c b/fs/sync.c
index 1373a610dc78..36c755e6568a 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -21,6 +21,15 @@
 #define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \
 			SYNC_FILE_RANGE_WAIT_AFTER)
 
+
+int sync_fs_and_blockdev(struct super_block *sb, int wait)
+{
+	if (sb->s_op->sync_fs)
+		sb->s_op->sync_fs(sb, wait);
+	return __sync_blockdev(sb->s_bdev, wait);
+}
+EXPORT_SYMBOL(sync_fs_and_blockdev);
+
 /*
  * Do the filesystem syncing work. For simple filesystems
  * writeback_inodes_sb(sb) just dirties buffers with inodes so we have to
@@ -34,10 +43,7 @@ static int __sync_filesystem(struct super_block *sb, int wait)
 		sync_inodes_sb(sb);
 	else
 		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);
+	return sync_fs_and_blockdev(sb, wait);
 }
 
 /*
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e7a633353fd2..e5ebf126281c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2777,6 +2777,7 @@ static inline bool sb_is_blkdev_sb(struct super_block *sb)
 
 void emergency_thaw_all(void);
 extern int sync_filesystem(struct super_block *);
+extern int sync_fs_and_blockdev(struct super_block *sb, int wait);
 extern const struct file_operations def_blk_fops;
 extern const struct file_operations def_chr_fops;
 
-- 
2.27.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ