Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4413718imc; Mon, 25 Feb 2019 04:38:03 -0800 (PST) X-Google-Smtp-Source: AHgI3IYOA8jOtRzy2GHYBg+7mp2dOPnNK5gT1zVU4UL2tmh8wm6yRTWDrMzkDyExK+QVClgEFmXF X-Received: by 2002:a17:902:503:: with SMTP id 3mr20387621plf.233.1551098283625; Mon, 25 Feb 2019 04:38:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551098283; cv=none; d=google.com; s=arc-20160816; b=l0xdyLg3sb/GoVfWBuPS/8XQqhfwNe8st/RG/MTsSCYxkPq50/kBWR3O4yWXK0Po+7 KyFG7wRxE7mLxAUZ0Rp6oEPeV0Pd4WGQrx3JAUBNpJ+ZeXDIkP4bWNrcWjiAkTN9Q6g+ ewn+hZMjYnn9PEO23CrAyZxpHvEzfwXWrjrmiEMPAwXeTDdiK3XCF/OGSsBk0nu9b41o dbpRU/cR58+ZUIwJDOG6pnBXkTW6rahhMnBLlf+8Qy7BuabiKOcpI5LaogkuU6HQy6DJ 8hy2fgcLRZmjwj0JNDcpnrc0+sggvSE5CmXoobJBhfqhyaY/RL3DxWAZo+XTpg31SNZz wUtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=hlWl6hE47ItFKl9WAX/DZJI339w4w5TtS6vEDWmmnqU=; b=L7gRSMhDfnQkW6CbFydk5F+QJnuQUZJ5gqC9QTV60yPyyxTOA0uDWVxGTwXuRMv7mK 6vTx83rzr3HfHvPSOajijOHFSFr+a3vXHDWlHUpB5bjFH8s0Kvdk9TCuR3uxxVqgR9Zq taSvxDXCwG3YcN8lDaCB45WSi8sNbvWJsq5jEV/tMXApUhaTIbaHElM0HhmM9JSvg1fH p+JVm6wqd57vAG9Mmjgt289UaSRmKB4ks4g7OfVW6Hv6o2VQtwoKeFg+9B+IPDRyxzNC oipTiwSTHeFDgBocCZXuhje9Tm8iK17C+S3vAODLO5hpbqPYixSC1Z0d1AbM1CT6iRqm k8Dg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5si9614510pgo.229.2019.02.25.04.37.47; Mon, 25 Feb 2019 04:38:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbfBYMhF (ORCPT + 99 others); Mon, 25 Feb 2019 07:37:05 -0500 Received: from 61-228-43-219.dynamic-ip.hinet.net ([61.228.43.219]:38772 "EHLO E6440.gar.corp.intel.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726475AbfBYMhF (ORCPT ); Mon, 25 Feb 2019 07:37:05 -0500 X-Greylist: delayed 3768 seconds by postgrey-1.27 at vger.kernel.org; Mon, 25 Feb 2019 07:37:04 EST Received: from E6440.gar.corp.intel.com (localhost [127.0.0.1]) by E6440.gar.corp.intel.com (Postfix) with ESMTP id CBE30C0BE5; Mon, 25 Feb 2019 20:37:03 +0800 (CST) From: Harry Pan To: LKML Cc: harry.pan@intel.com, gs0622@gmail.com, rjw@rjwysocki.net, pavel@ucw.cz, len.brown@intel.com, linux-pm@vger.kernel.org Subject: [PATCH v7 1/2] PM / sleep: refactor the filesystems sync to reduce duplication Date: Mon, 25 Feb 2019 20:36:41 +0800 Message-Id: <20190225123642.17111-1-harry.pan@intel.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190224061753.17638-2-harry.pan@intel.com> References: <20190224061753.17638-2-harry.pan@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch creates a common helper to sync filesystems and shares to the suspend, hibernate, and snapshot. Signed-off-by: Harry Pan --- include/linux/suspend.h | 3 +++ kernel/power/hibernate.c | 5 +---- kernel/power/main.c | 9 +++++++++ kernel/power/suspend.c | 13 +++++-------- kernel/power/user.c | 5 +---- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 3f529ad9a9d2..6b3ea9ea6a9e 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -425,6 +425,7 @@ void restore_processor_state(void); /* kernel/power/main.c */ extern int register_pm_notifier(struct notifier_block *nb); extern int unregister_pm_notifier(struct notifier_block *nb); +extern void ksys_sync_helper(void); #define pm_notifier(fn, pri) { \ static struct notifier_block fn##_nb = \ @@ -462,6 +463,8 @@ static inline int unregister_pm_notifier(struct notifier_block *nb) return 0; } +static inline void ksys_sync_helper(void) {} + #define pm_notifier(fn, pri) do { (void)(fn); } while (0) static inline bool pm_wakeup_pending(void) { return false; } diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index abef759de7c8..cc105ecd9c07 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -14,7 +14,6 @@ #include #include -#include #include #include #include @@ -709,9 +708,7 @@ int hibernate(void) goto Exit; } - pr_info("Syncing filesystems ... \n"); - ksys_sync(); - pr_info("done.\n"); + ksys_sync_helper(); error = freeze_processes(); if (error) diff --git a/kernel/power/main.c b/kernel/power/main.c index 35b50823d83b..a8a8e6ec57e6 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "power.h" @@ -51,6 +52,14 @@ void unlock_system_sleep(void) } EXPORT_SYMBOL_GPL(unlock_system_sleep); +void ksys_sync_helper(void) +{ + pr_info("Syncing filesystems ... "); + ksys_sync(); + pr_cont("done.\n"); +} +EXPORT_SYMBOL_GPL(ksys_sync_helper); + /* Routines for PM-transition notifications */ static BLOCKING_NOTIFIER_HEAD(pm_chain_head); diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 0bd595a0b610..e39059dea38b 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -568,13 +567,11 @@ static int enter_state(suspend_state_t state) if (state == PM_SUSPEND_TO_IDLE) s2idle_begin(); -#ifndef CONFIG_SUSPEND_SKIP_SYNC - trace_suspend_resume(TPS("sync_filesystems"), 0, true); - pr_info("Syncing filesystems ... "); - ksys_sync(); - pr_cont("done.\n"); - trace_suspend_resume(TPS("sync_filesystems"), 0, false); -#endif + if (!IS_ENABLED(CONFIG_SUSPEND_SKIP_SYNC)) { + trace_suspend_resume(TPS("sync_filesystems"), 0, true); + ksys_sync_helper(); + trace_suspend_resume(TPS("sync_filesystems"), 0, false); + } pm_pr_dbg("Preparing system for sleep (%s)\n", mem_sleep_labels[state]); pm_suspend_clear_flags(); diff --git a/kernel/power/user.c b/kernel/power/user.c index 2d8b60a3c86b..cb24e840a3e6 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c @@ -10,7 +10,6 @@ */ #include -#include #include #include #include @@ -228,9 +227,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, if (data->frozen) break; - printk("Syncing filesystems ... "); - ksys_sync(); - printk("done.\n"); + ksys_sync_helper(); error = freeze_processes(); if (error) -- 2.18.1