From patchwork Wed Jul 20 23:11:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Gong X-Patchwork-Id: 9240657 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 1B5CC600CB for ; Wed, 20 Jul 2016 23:11:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0310D27569 for ; Wed, 20 Jul 2016 23:11:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EABFC27BF7; Wed, 20 Jul 2016 23:11:33 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 6C78C27569 for ; Wed, 20 Jul 2016 23:11:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755559AbcGTXLb (ORCPT ); Wed, 20 Jul 2016 19:11:31 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:13734 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755259AbcGTXLb (ORCPT ); Wed, 20 Jul 2016 19:11:31 -0400 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6KNAdM8006290 for ; Wed, 20 Jul 2016 16:11:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=LWzHM/pwsv5oTvzyszZV13FLT6KTd1/fGUGMTcYE7rY=; b=DTAbNYcv1mHhTiEtjL+vrnHV7veKgX6Z5Rar9sKBmu9Y9B13xDeJH394PW+xHm8aKXq8 SfS3xCvL43SQTpsbg/XSaP6Re11WmbuFfTWVTb9OW16vjQSEdL0KmKKnT7pnEhYQEqqA RhfKc/BBB1zvLRSOlS2AJhtnkkFhbb+XnJY= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 249wj9watp-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 20 Jul 2016 16:11:30 -0700 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB06.TheFacebook.com (192.168.16.16) with Microsoft SMTP Server (TLS) id 14.3.294.0; Wed, 20 Jul 2016 16:11:28 -0700 Received: from facebook.com (2401:db00:11:d0a6:face:0:17:0) by mx-out.facebook.com (10.223.100.97) with ESMTP id 496c9e004ecf11e6965a24be0593f280-490ceaf0 for ; Wed, 20 Jul 2016 16:11:28 -0700 Received: by devbig604.prn1.facebook.com (Postfix, from userid 117469) id 4D6DE1EC017A; Wed, 20 Jul 2016 16:11:27 -0700 (PDT) From: Charles Gong To: Alexander Viro CC: , , , Christoph Hellwig , Charles Gong Subject: [PATCH] Fix sysrq emergency thaw Date: Wed, 20 Jul 2016 16:11:16 -0700 Message-ID: <5823da614460b8c40809e6e0a6de172a9c4f4611.1468965479.git.cggong@fb.com> X-Mailer: git-send-email 2.8.0.rc2 X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-20_13:, , signatures=0 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 "SYSRQ + J" triggers a call to emergency_thaw_all(). Currently, this is an infinite loop. Once we trigger it, we'll need to do a hard power-cycle. There are users reporting this bug from 2012 to 2016, for example, at https://bugzilla.kernel.org/show_bug.cgi?id=47741. This happens because thaw_bdev() fails to return -EINVAL in the non-frozen case, so fix it so that do_one_thaw() can recognize this case and quit from looping. I checked that none of the other thaw_bdev() callers check the return value. The regression was introduced in commit 4504230a7156 ("freeze_bdev: grab active reference to frozen superblocks"). Reviewed-by: Chris Mason Signed-off-by: Charles Gong Acked-by: Pavel Machek --- fs/block_dev.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 71ccab1..14f015e 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -301,14 +301,12 @@ int thaw_bdev(struct block_device *bdev, struct super_block *sb) error = sb->s_op->thaw_super(sb); else error = thaw_super(sb); - if (error) { + if (error) bdev->bd_fsfreeze_count++; - mutex_unlock(&bdev->bd_fsfreeze_mutex); - return error; - } + out: mutex_unlock(&bdev->bd_fsfreeze_mutex); - return 0; + return error; } EXPORT_SYMBOL(thaw_bdev);