From patchwork Mon Apr 23 15:00:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 902985 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="t/O0S3Vw"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40V8jl4PHgz9rx7 for ; Tue, 24 Apr 2018 00:58:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755448AbeDWO6u (ORCPT ); Mon, 23 Apr 2018 10:58:50 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:44200 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755419AbeDWO6s (ORCPT ); Mon, 23 Apr 2018 10:58:48 -0400 Received: by mail-pg0-f65.google.com with SMTP id l12so8575505pgp.11 for ; Mon, 23 Apr 2018 07:58:47 -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:in-reply-to:references; bh=8+by8V5EyT6gpCTBZlaZaSiFahBZOO3uBFnFsl19Ab0=; b=t/O0S3Vw1mhTDro0s/NQ6Ttinw0F6mS2HOUkzne6qiG+kyUnhR8Jogxcnj5eD5aapL bsHmKUHZp4GG5lN2fzPetmR6iN07elrvW+z2OMcJwwLkHRW2l6/wO5j2WSvB7zLQ8LII MhUjFN3Ena56Y0//PMZXI1KpIQkimEMgib9fOVyLymcESRjDmA5o+H7ZHjzgmIrw9vNJ eu9brpkqSF1PBzLzu4qumK399M6cSs+gtemRejhKuQwtK2G6J6TYHOiDMvgMs+vSuabg XCstFV+/EFUxvRoizHPeXQdnMkWLVjMazWHnGesERrnqkLXGNtzb7JvUpaOt1VMyYqGj vEuw== 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:in-reply-to :references; bh=8+by8V5EyT6gpCTBZlaZaSiFahBZOO3uBFnFsl19Ab0=; b=selK6RCZIVNnyNGGxwg5wjYnoRfHJYMGVj+XSzZBQM6Bt7/xU6oVy2ldZRajArRzZb UcKG7uL2LytuWSgrXYb4k4ywp1rZwEUpsBccuqmE7lr0oC7U78K+OgCLX25+rnihl4Id BpAUhKuMbqcTSAK5sf4DgsRb1hU5Rs8JEuHCoNrkNYE/YZSgvmluRslP2y0PCKU8y/TA A4BZ57/it+GQag7nH5Yo7G3hD9Es+1ivMYZBmKaWCxm1gXe7n5DvVOhHLCMcc3GZSyFi LTaHCSwGbkUQZYjYKyxP9rW+NaH/v+F0whmBppvxQzS0N90nTxaAuLZcC8g7BXRQ7q9H MCvA== X-Gm-Message-State: ALQs6tBfLzs9ogpkn3zRvfWozL1YB/oCh/fGQsuI+ojH8bMAOTsHJMsc Jtv9FgpkJ6ior194la44oqU= X-Google-Smtp-Source: AIpwx49TYswxlmCwLkgy4/brZwOhPJHemycX2FHzLT9jPMQiNQOjaxMjrYJ1kBBeMygMbmEkyVepXw== X-Received: by 2002:a17:902:b105:: with SMTP id q5-v6mr21678144plr.173.1524495527506; Mon, 23 Apr 2018 07:58:47 -0700 (PDT) Received: from amir-VirtualBox.event.rightround.com ([198.233.165.212]) by smtp.gmail.com with ESMTPSA id o66sm23873923pfg.90.2018.04.23.07.58.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Apr 2018 07:58:46 -0700 (PDT) From: Amir Goldstein To: Theodore Tso Cc: Jan Kara , linux-ext4@vger.kernel.org Subject: [PATCH v3 3/3] ext4: do not update s_last_mounted of a frozen fs Date: Mon, 23 Apr 2018 09:00:08 -0600 Message-Id: <1524495608-14086-4-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524495608-14086-1-git-send-email-amir73il@gmail.com> References: <1524495608-14086-1-git-send-email-amir73il@gmail.com> 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 If fs is frozen, skip s_last_mounted update. [backport hint: to apply to stable tree, need to apply also patches vfs: add the sb_start_intwrite_trylock() helper ext4: factor out helper ext4_sample_last_mounted()] Fixes: bc0b0d6d69ee ("ext4: update the s_last_mounted field in the superblock") Cc: Reviewed-by: Jan Kara Signed-off-by: Amir Goldstein --- fs/ext4/file.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 065e95bb7186..918a59b6bc1a 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -392,7 +392,7 @@ static int ext4_sample_last_mounted(struct super_block *sb, if (likely(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED)) return 0; - if (sb_rdonly(sb)) + if (sb_rdonly(sb) || !sb_start_intwrite_trylock(sb)) return 0; sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED; @@ -406,21 +406,25 @@ static int ext4_sample_last_mounted(struct super_block *sb, path.mnt = mnt; path.dentry = mnt->mnt_root; cp = d_path(&path, buf, sizeof(buf)); + err = 0; if (IS_ERR(cp)) - return 0; + goto out; handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1); + err = PTR_ERR(handle); if (IS_ERR(handle)) - return PTR_ERR(handle); + goto out; BUFFER_TRACE(sbi->s_sbh, "get_write_access"); err = ext4_journal_get_write_access(handle, sbi->s_sbh); if (err) - goto out; + goto out_journal; strlcpy(sbi->s_es->s_last_mounted, cp, sizeof(sbi->s_es->s_last_mounted)); ext4_handle_dirty_super(handle, sb); -out: +out_journal: ext4_journal_stop(handle); +out: + sb_end_intwrite(sb); return err; }