From patchwork Sat Jul 2 21:42:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vegard Nossum X-Patchwork-Id: 9211041 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 817CB607D6 for ; Sat, 2 Jul 2016 21:42:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 605C627F9C for ; Sat, 2 Jul 2016 21:42:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E7B32859A; Sat, 2 Jul 2016 21:42:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9691827F9C for ; Sat, 2 Jul 2016 21:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751673AbcGBVmw (ORCPT ); Sat, 2 Jul 2016 17:42:52 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:31585 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751420AbcGBVmv (ORCPT ); Sat, 2 Jul 2016 17:42:51 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u62LgiJJ027839 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 2 Jul 2016 21:42:46 GMT Received: from lenuta.oracle.com (dhcp-ukc1-twvpn-2-vpnpool-10-175-220-93.vpn.oracle.com [10.175.220.93]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u62LghQS003100; Sat, 2 Jul 2016 21:42:43 GMT From: Vegard Nossum To: tytso@mit.edu Cc: Jan Kara , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH] ext4: don't call ext4_should_journal_data() on the journal inode Date: Sat, 2 Jul 2016 23:42:42 +0200 Message-Id: <1467495762-25353-1-git-send-email-vegard.nossum@oracle.com> X-Mailer: git-send-email 1.9.1 X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Certain combinations of mount options in the superblock will cause set_journal_csum_feature_set() in ext4_fill_super() to fail after the journal has been created. When iput() is called on the journal inode, we will hit the BUG() in ext4_should_journal_data(). We can prevent this by only calling ext4_should_journal_data() if we already know that it's not the journal inode. Fixes: 2d859db3e4 ("ext4: fix data corruption in inodes with journalled data") Fixes: 2b405bfa84 ("ext4: fix data=journal fast mount/umount hang") Cc: Jan Kara Cc: stable@vger.kernel.org Signed-off-by: Vegard Nossum Reviewed-by: Jan Kara --- fs/ext4/inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 91b66db..2591236 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -207,9 +207,9 @@ void ext4_evict_inode(struct inode *inode) * Note that directories do not have this problem because they * don't use page cache. */ - if (ext4_should_journal_data(inode) && - (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode)) && - inode->i_ino != EXT4_JOURNAL_INO) { + if (inode->i_ino != EXT4_JOURNAL_INO && + ext4_should_journal_data(inode) && + (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode))) { journal_t *journal = EXT4_SB(inode->i_sb)->s_journal; tid_t commit_tid = EXT4_I(inode)->i_datasync_tid;