From patchwork Thu Sep 23 13:08:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 12512929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68D6CC4332F for ; Thu, 23 Sep 2021 13:24:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F58F6124E for ; Thu, 23 Sep 2021 13:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241375AbhIWNZu (ORCPT ); Thu, 23 Sep 2021 09:25:50 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17279 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241320AbhIWNZo (ORCPT ); Thu, 23 Sep 2021 09:25:44 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1632402523; cv=none; d=zoho.com.cn; s=zohoarc; b=DRn4vGd96dGD8cKVzzWUjNJKFPgjfCYBK0l1Frw9AqTe7+7FinjJ8MrKMKiydWBaeUP3MpTuKud+dPmMcHEzShsMq7FpAfoaCP7Udy2l2iyVCsWKAe3s4vPu4LCYrDMXkWrPfyVyL4eZBRICJUhXFHoGbSsEpguwMzTvmNaHVuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1632402523; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=THw0YvMlxjX1i71lpc4CHFA+3w1dXqVfXs694rHAFw0=; b=MIAWSmelOd6p6i+AbbwfXjUZH1yPjBxaL/6JELlFuwbzO6KAylw3IljmmdRK7oIrRglfaEv5KUU41xDDHf9+oRBjq/IUbk3LSNdJY1WF6pSucd8apH1Cwniy3l62wAxjcwee2Oir1jRfsgoCe+cP5d6C9M3c/XnhpSXSmWLt8+I= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1632402523; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=THw0YvMlxjX1i71lpc4CHFA+3w1dXqVfXs694rHAFw0=; b=XWkTWpTIMjshz23RcCmTbnXDGGJxrJC4OAeiH5+AHTLm2qjREUfJsWJ3AGcWkBQn FRJyHnNlgBqolSkPsFGEoIh/7icBqaemuIu4uRm+Bub0i5FCFqlfnJfwa/0eYE0frot Q8E9qR0ldZNehaayd1aQSNTWqqn+HRu9BEeWvFuA= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 1632402522263998.249844109196; Thu, 23 Sep 2021 21:08:42 +0800 (CST) From: Chengguang Xu To: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20210923130814.140814-10-cgxu519@mykernel.net> Subject: [RFC PATCH v5 09/10] fs: introduce new helper sync_fs_and_blockdev() Date: Thu, 23 Sep 2021 21:08:13 +0800 X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210923130814.140814-1-cgxu519@mykernel.net> References: <20210923130814.140814-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 --- 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;