From patchwork Thu Feb 9 08:24:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takafumi Kubota X-Patchwork-Id: 9564177 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 8B905601C3 for ; Thu, 9 Feb 2017 08:31:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4771F26E94 for ; Thu, 9 Feb 2017 08:31:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C1F326E98; Thu, 9 Feb 2017 08:31:12 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 CD6762850F for ; Thu, 9 Feb 2017 08:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751969AbdBIIbD (ORCPT ); Thu, 9 Feb 2017 03:31:03 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35264 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807AbdBIIbC (ORCPT ); Thu, 9 Feb 2017 03:31:02 -0500 Received: by mail-pg0-f65.google.com with SMTP id 204so17335491pge.2 for ; Thu, 09 Feb 2017 00:30:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sslab.ics.keio.ac.jp; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pvLgoT/7r3y13t7jfZQTNMWhesPNAFbSYadRM/qzirE=; b=Yw/GfcGS2mWjVGqkLisfx8pyZXFe/7POiCrsiFExb7KNKtClEHRxrwJOP1RzXsg61g QO/vdcMr7Ggzyr7wTcGQkUIyh8wNciJ0yed3EgJNZMl5InLLqG1Rh+6Ahvu+mx6ISdNl SQ0pp2dzqPpzEJJK1JJk14sIyqk8VW82rOqwo= 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=pvLgoT/7r3y13t7jfZQTNMWhesPNAFbSYadRM/qzirE=; b=gKQZ6GAU66Zvc2aS8dUYnuDiHz3blOHTUj0lVe3gM3G8uKc9PKP20RROeFyEEU1k1+ SRnGXp332W8OLg1/ivF18C3wGeFs/8JVttJJBu5tKK8SU7thEGPDJ4T/hSDCYRIDMvMj 3P1bGrV+ESooYqaFY01gQnfvUiyX6J9B0EeHi98eLsSBniL4W4HbyS1D7rf8NNpvjZu9 UmfbiHDmc8JZb2hU0iYYrhSichpZRTErXa8miOYzlR1tI4vtpy0czMFM3xSKiH9kHMgg int8QlakDyPcroE0gTYL5r3gV7WcOCuLvUOZ5Sc3Eu8X4YWVn9T37CYnH0BeYa2b8oHv JrEQ== X-Gm-Message-State: AMke39kT5be6cJw0Z1eHzq7aZOucxtwCVA+ibEmxbtKzyRJ0/U8sx5EsDslSAjQPgjNPRX/9 X-Received: by 10.98.42.151 with SMTP id q145mr2261278pfq.175.1486628685447; Thu, 09 Feb 2017 00:24:45 -0800 (PST) Received: from localhost.jp (sslab-relay.ics.keio.ac.jp. [131.113.126.173]) by smtp.gmail.com with ESMTPSA id d63sm20436575pfg.65.2017.02.09.00.24.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 00:24:44 -0800 (PST) From: Takafumi Kubota To: linux-btrfs@vger.kernel.org Cc: clm@fb.com, jbacik@fb.com, dsterba@suse.com, linux-kernel@vger.kernel.org, bo.li.liu@oracle.com, naota@elisp.net, Takafumi Kubota , David Sterba Subject: [PATCH v2] Btrfs: add another missing end_page_writeback on submit_extent_page failure Date: Thu, 9 Feb 2017 17:24:33 +0900 Message-Id: <1486628673-30631-1-git-send-email-takafumi.kubota1012@sslab.ics.keio.ac.jp> X-Mailer: git-send-email 1.9.3 In-Reply-To: <20170208183013.GC16928@twin.jikos.cz> References: <20170208183013.GC16928@twin.jikos.cz> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If btrfs_bio_alloc fails in submit_extent_page, submit_extent_page returns without clearing the writeback bit of the failed page. __extent_writepage_io, that is a caller of submit_extent_page, does not clear the remaining writeback bit anywhere. As a result, this will cause the hang at filemap_fdatawait_range, because it waits the writeback bit to be cleared from the failed page. So, we have to call end_page_writeback to clear the writeback bit. For reproducing the hang, we inject a fault like if (should_failtest()) { // I define should_failtest() bio = NULL; } else { bio = btrfs_bio_alloc(...); } in submit_extent_page. We should also check whether page has the bit before end_page_writeback, to avoid the conflict against the other end_page_writeback in bio_endio. Thus, we add PageWriteback checks not only in __extent_writepage_io, but also in write_one_eb too, because it misses the check. Signed-off-by: Takafumi Kubota Reviewed-by: Liu Bo Cc: David Sterba --- fs/btrfs/extent_io.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 4ac383a..aa1908a 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3445,8 +3445,11 @@ static noinline_for_stack int __extent_writepage_io(struct inode *inode, bdev, &epd->bio, max_nr, end_bio_extent_writepage, 0, 0, 0, false); - if (ret) + if (ret) { SetPageError(page); + if (PageWriteback(page)) + end_page_writeback(page); + } cur = cur + iosize; pg_offset += iosize; @@ -3767,7 +3770,8 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb, epd->bio_flags = bio_flags; if (ret) { set_btree_ioerr(p); - end_page_writeback(p); + if (PageWriteback(p)) + end_page_writeback(p); if (atomic_sub_and_test(num_pages - i, &eb->io_pages)) end_extent_buffer_writeback(eb); ret = -EIO;