Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1114719imm; Wed, 1 Aug 2018 10:25:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcvp0rBNONNVZiPMCEWKGXxYSGSQTt27NJSQHl3WBPRwJ9vyybIB/H2X8IxGRP4EhxzEDOf X-Received: by 2002:a17:902:529:: with SMTP id 38-v6mr25915669plf.145.1533144316102; Wed, 01 Aug 2018 10:25:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533144316; cv=none; d=google.com; s=arc-20160816; b=JGrmNfDWlNWnmoUbjVO0+Q1d/GhzNNy9QlFwkjSqgHGzGQceUDdyrXyGAJnjNVhdmr ImV8HNXFpkVKP591BfpP4ypnzOPLgY0E6X62qTvfIRXJahzWK4n11/STRXYzGQU9KH5n uyNg8oFSPUAjT5HLDLU/+G/yQ7mJx7x+mFDWZ8A1eD268Jq6Jzi+XWZpTNucoyIGEqXa wIUg+yIcfNIj5AwyAdzHePF2dW8OFR3E3GI67J8bnKW4K/Ai30/zMsYgZ2/MsjVGcNq3 9mrzaTJw9rcj8i1YRFZTi0xWgcLp09no7UkRSqbf3L2aAJon8di5G3PVjFRdGnny3/oQ LpPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nFiD3UMsfNxWhvZHdSh372p473MkSUU67/cujvIPCbM=; b=sfJ2m0BhLErPguX2uyfybFAat5/+Z8Rg9kFCrUwa1pnMvvv4jCJljBYeJva2wZxST8 hD7escbX2XJxfpNCOSFs+XOeZDXfFNgvz/K5PcRJ+BOcOlkkmiE7RvsnhqC2o0J0CCDJ QsKqzuefl5Xz9Q7/UubA29jESTxT/BxLHjF3sqeSGs2jaSB/R7uS/5irLhtuFDCgzlMn U9yr6GLfLcuEGFay5zSdW/DWS8yCHk4lKwdBbJwvWi3Y21amAjx/vOwEXKVMjm+TAuGy VHz462Uljj2xIC9ro/lg4TVVYx7zZd9vX/LkYzpHwjK/11IE/m7obEtcDLAhZJtTRfDk M/xw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f89-v6si2713456pfj.97.2018.08.01.10.25.01; Wed, 01 Aug 2018 10:25:16 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406374AbeHATJy (ORCPT + 99 others); Wed, 1 Aug 2018 15:09:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50868 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405274AbeHATJx (ORCPT ); Wed, 1 Aug 2018 15:09:53 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 41262CC9; Wed, 1 Aug 2018 17:23:11 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chengguang Xu , Miklos Szeredi , Sudip Mukherjee Subject: [PATCH 4.14 225/246] ovl: Sync upper dirty data when syncing overlayfs Date: Wed, 1 Aug 2018 18:52:15 +0200 Message-Id: <20180801165022.470509225@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chengguang Xu commit e8d4bfe3a71537284a90561f77c85dea6c154369 upstream. When executing filesystem sync or umount on overlayfs, dirty data does not get synced as expected on upper filesystem. This patch fixes sync filesystem method to keep data consistency for overlayfs. Signed-off-by: Chengguang Xu Fixes: e593b2bf513d ("ovl: properly implement sync_filesystem()") Cc: #4.11 Signed-off-by: Miklos Szeredi Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/super.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -232,6 +232,7 @@ static void ovl_put_super(struct super_b kfree(ufs); } +/* Sync real dirty inodes in upper filesystem (if it exists) */ static int ovl_sync_fs(struct super_block *sb, int wait) { struct ovl_fs *ufs = sb->s_fs_info; @@ -240,14 +241,24 @@ static int ovl_sync_fs(struct super_bloc if (!ufs->upper_mnt) return 0; - upper_sb = ufs->upper_mnt->mnt_sb; - if (!upper_sb->s_op->sync_fs) + + /* + * If this is a sync(2) call or an emergency sync, all the super blocks + * will be iterated, including upper_sb, so no need to do anything. + * + * If this is a syncfs(2) call, then we do need to call + * sync_filesystem() on upper_sb, but enough if we do it when being + * called with wait == 1. + */ + if (!wait) return 0; - /* real inodes have already been synced by sync_filesystem(ovl_sb) */ + upper_sb = ufs->upper_mnt->mnt_sb; + down_read(&upper_sb->s_umount); - ret = upper_sb->s_op->sync_fs(upper_sb, wait); + ret = sync_filesystem(upper_sb); up_read(&upper_sb->s_umount); + return ret; }