From patchwork Wed Apr 17 14:20:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 2453941 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 857BE3FD8C for ; Wed, 17 Apr 2013 14:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966515Ab3DQOU7 (ORCPT ); Wed, 17 Apr 2013 10:20:59 -0400 Received: from dkim1.fusionio.com ([66.114.96.53]:49837 "EHLO dkim1.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966435Ab3DQOU5 (ORCPT ); Wed, 17 Apr 2013 10:20:57 -0400 Received: from mx2.fusionio.com (unknown [10.101.1.160]) by dkim1.fusionio.com (Postfix) with ESMTP id 41E437C068F for ; Wed, 17 Apr 2013 08:20:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com; s=default; t=1366208457; bh=Em3LV6s45Uav3AkZiSvjPEYz6qYm5t5U/pM7Z3sebXQ=; h=From:To:Subject:Date; b=S4FF9CYxXhM1ZMQCX01D71AyCqJNLoeNj7moiqx58QJJKtiGZtzC51hCBZWVr2U7E sREX2U4lyiINskROztlUH4DZWvWoziAkJtgzB/NKd0VHFg0nlIHPDrzQFo7bYXrwDz qck02f6fyzdgiayyfRwktcnYAlfN6mYtS3EsVqq8= X-ASG-Debug-ID: 1366208456-0421b537ab6af00001-6jHSXT Received: from mail1.int.fusionio.com (mail1.int.fusionio.com [10.101.1.21]) by mx2.fusionio.com with ESMTP id o5AkCRxUGskWQon7 (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO) for ; Wed, 17 Apr 2013 08:20:56 -0600 (MDT) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (76.182.72.146) by mail.fusionio.com (10.101.1.19) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 17 Apr 2013 08:20:56 -0600 From: Josef Bacik To: Subject: [PATCH] Btrfs: don't force pages under writeback to finish when aborting Date: Wed, 17 Apr 2013 10:20:54 -0400 X-ASG-Orig-Subj: [PATCH] Btrfs: don't force pages under writeback to finish when aborting Message-ID: <1366208454-5893-1-git-send-email-jbacik@fusionio.com> X-Mailer: git-send-email 1.7.7.6 MIME-Version: 1.0 X-Barracuda-Connect: mail1.int.fusionio.com[10.101.1.21] X-Barracuda-Start-Time: 1366208456 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.181:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.128387 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Dave reported a BUG_ON() that happened in end_page_writeback() after an abort. This happened because we unconditionally call end_page_writeback() in the endio case, which is right. However when we abort the transaction we will call end_page_writeback() on any writeback pages we find, which is wrong. We need to lock the page and wait on page writeback to complete if it is. There is nothing unsafe about this since we are discarding the transaction anyway. Thanks, Reported-by: David Sterba Signed-off-by: Josef Bacik --- fs/btrfs/disk-io.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 66d036b..fa8438f 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3815,10 +3815,9 @@ static int btrfs_destroy_marked_extents(struct btrfs_root *root, if (eb) ret = test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags); - if (PageWriteback(page)) - end_page_writeback(page); - lock_page(page); + + wait_on_page_writeback(page); if (PageDirty(page)) { clear_page_dirty_for_io(page); spin_lock_irq(&page->mapping->tree_lock);