From patchwork Sun Apr 22 16:12:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 902659 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nLCyWC8y"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40TZMq3Rhyz9ry1 for ; Mon, 23 Apr 2018 02:11:19 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753641AbeDVQLS (ORCPT ); Sun, 22 Apr 2018 12:11:18 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:45287 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753865AbeDVQKs (ORCPT ); Sun, 22 Apr 2018 12:10:48 -0400 Received: by mail-pg0-f66.google.com with SMTP id i29so5169293pgn.12 for ; Sun, 22 Apr 2018 09:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Uxr0giViiOBmcOcXAvpTVMrnhCUE+AIrxJD2uznuxj4=; b=nLCyWC8y/5iBbiG9WzFuK+3O5P+4lmZfEXO/6q/bXbbkEH8/hPnNBDf9ftGPO6IEbD M/hATra8jyyAnRhxTFoWMgpMk69WLLuE3nQNCogcRmSFHV54cG2SimUFDJn0yQIQtAJf qk7TwS85FoUQyEpmkfodeKJRPabMzVg0nLlLB8R+8QmHBl4P+NAmpOotxfnrVYaRyq9L 8Y3l1JIKeTxM6/3U/ZUSvFBUKkRAn2CXyRj2XSGt1HhlZo9llIM5+oFeDiNEQoazFY4k X+hSqjRV2waFRvRyPHcVvf/Z8ynzxDXObXE+GxgOeJbrL5R2EgJiAqZP8RIomzqqUzc9 goqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Uxr0giViiOBmcOcXAvpTVMrnhCUE+AIrxJD2uznuxj4=; b=R861mpWGzXIvWZIHSVH6gv4CVn6Ae7H7m9KMhd/FTmFsgfsOfaZrSQkuV8DcoX5rS2 l6BrvM2zRBBBdQV5zaRPfv4sLAsbFR1u4VWgmY9JY1NZr6awDkLc0yOlB4giFt8d6oJk A/y9cpXoq1iPiIdG0ceuWDUX7FqJZ6GtO94ln3QFUtz/8XsMOKfjYPUQbyyndiCw03ef XEsm2k+oUuynoaN9hE+B65HtA4B/4iJ0W554c1Batv1FabeAgVmRZV2WLzt8+AaD4lFH V03YjFRmsNmKhWAacQnb9b3QVZLtzvlKsmJktCuvp270cXebDfqseeWrNsZaaxkKvEHO tfjQ== X-Gm-Message-State: ALQs6tA1qs4/pkdbCA3bfftDClVK2EnCBrvOiCYGMdHqiDOYUB+rFVrW A08XU+BS3lzqNhwlYoAhpE1kgw== X-Google-Smtp-Source: AIpwx4/Q///ij4i7TRDSKM4Lmj53HxInc0EegbDisgkfzhaxxeFkSqVF36Xi2fSo3ThctwUr0lsgww== X-Received: by 10.99.116.76 with SMTP id e12mr14479758pgn.270.1524413448140; Sun, 22 Apr 2018 09:10:48 -0700 (PDT) Received: from amir-VirtualBox.localdomain (c-24-5-85-70.hsd1.ca.comcast.net. [24.5.85.70]) by smtp.gmail.com with ESMTPSA id p86sm18948957pfi.148.2018.04.22.09.10.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Apr 2018 09:10:47 -0700 (PDT) From: Amir Goldstein To: Theodore Tso Cc: Jan Kara , linux-ext4@vger.kernel.org Subject: [PATCH] ext4: do not update s_last_mounted of a frozen fs Date: Sun, 22 Apr 2018 09:12:10 -0700 Message-Id: <1524413530-23808-1-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If fs is frozen after mount and before the first file open, the update of s_last_mounted bypasses freeze protection and prints out a WARNING splat: $ mount /vdf $ fsfreeze -f /vdf $ cat /vdf/foo [ 31.578555] WARNING: CPU: 1 PID: 1415 at fs/ext4/ext4_jbd2.c:53 ext4_journal_check_start+0x48/0x82 [ 31.614016] Call Trace: [ 31.614997] __ext4_journal_start_sb+0xe4/0x1a4 [ 31.616771] ? ext4_file_open+0xb6/0x189 [ 31.618094] ext4_file_open+0xb6/0x189 This fix might not be free of open vs. freeze race, but it closes a big hole. [backport hint: to apply to stable tree, just need to repace sb_rdonly(sb) with (sb->s_flags & MS_RDONLY)] Fixes: bc0b0d6d69ee ("ext4: update the s_last_mounted field in the superblock") Cc: Signed-off-by: Amir Goldstein --- fs/ext4/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index fb6f023622fe..b78e5e6c0e51 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -392,8 +392,8 @@ static int ext4_file_open(struct inode * inode, struct file * filp) if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) return -EIO; - if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED) && - !sb_rdonly(sb))) { + if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED)) && + !sb_rdonly(sb) && sb->s_writers.frozen == SB_UNFROZEN) { sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED; /* * Sample where the filesystem has been mounted and