[Devel] [PATCH RHEL9 COMMIT] ve/fs/sync: introduce argument struct for helper routines

Konstantin Khorenko khorenko at virtuozzo.com
Thu Dec 9 11:23:22 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.10.34
------>
commit 093872bc6b5bdb34590bb94c8351e2f7d98aec35
Author: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
Date:   Thu Dec 9 11:23:22 2021 +0300

    ve/fs/sync: introduce argument struct for helper routines
    
    In this commit, this replaces passing an integer flag by pointer.
    
    With implementation of per-VE sync, this will be also used to pass
    VE where sync happens.
    
    https://jira.sw.ru/browse/PSBM-44684
    Feature: fs: per-CT sync behavior management
    
    Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 fs/sync.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/fs/sync.c b/fs/sync.c
index cca10ec7a90f..91a764988f41 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -69,6 +69,10 @@ int sync_filesystem(struct super_block *sb)
 }
 EXPORT_SYMBOL(sync_filesystem);
 
+struct sync_arg {
+	int wait;
+};
+
 static void sync_inodes_one_sb(struct super_block *sb, void *arg)
 {
 	if (!sb_rdonly(sb))
@@ -77,9 +81,11 @@ static void sync_inodes_one_sb(struct super_block *sb, void *arg)
 
 static void sync_fs_one_sb(struct super_block *sb, void *arg)
 {
+	struct sync_arg *sarg = arg;
+
 	if (!sb_rdonly(sb) && !(sb->s_iflags & SB_I_SKIP_SYNC) &&
 	    sb->s_op->sync_fs)
-		sb->s_op->sync_fs(sb, *(int *)arg);
+		sb->s_op->sync_fs(sb, sarg->wait);
 }
 
 static void fdatawrite_one_bdev(struct block_device *bdev, void *arg)
@@ -120,15 +126,17 @@ int ve_fsync_behavior(void)
  */
 void ksys_sync(void)
 {
-	int nowait = 0, wait = 1;
+	struct sync_arg sarg;
 
 	if (ve_fsync_behavior() == FSYNC_NEVER)
 		return;
 
 	wakeup_flusher_threads(WB_REASON_SYNC);
 	iterate_supers(sync_inodes_one_sb, NULL);
-	iterate_supers(sync_fs_one_sb, &nowait);
-	iterate_supers(sync_fs_one_sb, &wait);
+	sarg.wait = 0;
+	iterate_supers(sync_fs_one_sb, &sarg);
+	sarg.wait = 1;
+	iterate_supers(sync_fs_one_sb, &sarg);
 	iterate_bdevs(fdatawrite_one_bdev, NULL);
 	iterate_bdevs(fdatawait_one_bdev, NULL);
 	if (unlikely(laptop_mode))
@@ -143,17 +151,19 @@ SYSCALL_DEFINE0(sync)
 
 static void do_sync_work(struct work_struct *work)
 {
-	int nowait = 0;
+	struct sync_arg sarg;
+
+	sarg.wait = 0;
 
 	/*
 	 * Sync twice to reduce the possibility we skipped some inodes / pages
 	 * because they were temporarily locked
 	 */
-	iterate_supers(sync_inodes_one_sb, &nowait);
-	iterate_supers(sync_fs_one_sb, &nowait);
+	iterate_supers(sync_inodes_one_sb, &sarg);
+	iterate_supers(sync_fs_one_sb, &sarg);
 	iterate_bdevs(fdatawrite_one_bdev, NULL);
-	iterate_supers(sync_inodes_one_sb, &nowait);
-	iterate_supers(sync_fs_one_sb, &nowait);
+	iterate_supers(sync_inodes_one_sb, &sarg);
+	iterate_supers(sync_fs_one_sb, &sarg);
 	iterate_bdevs(fdatawrite_one_bdev, NULL);
 	printk("Emergency Sync complete\n");
 	kfree(work);


More information about the Devel mailing list