From patchwork Tue Sep 11 17:58:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10596121 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F91914BD for ; Tue, 11 Sep 2018 17:59:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF81529B9F for ; Tue, 11 Sep 2018 17:59:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E324E29BA1; Tue, 11 Sep 2018 17:59:16 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 8D43429B9F for ; Tue, 11 Sep 2018 17:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728379AbeIKW7l (ORCPT ); Tue, 11 Sep 2018 18:59:41 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:37295 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728113AbeIKW7k (ORCPT ); Tue, 11 Sep 2018 18:59:40 -0400 Received: by mail-qt0-f194.google.com with SMTP id n6-v6so29180945qtl.4 for ; Tue, 11 Sep 2018 10:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=o3aniGDG3zSjx1n1+LpysocBJ3oenkOpLCURB29A0Uc=; b=Oe/z8EILMhWXyrfi70RXZltFrR0ew+r5/s4abp2DcG8avStdBG0qnZ3K1k9KvQlLjs sZXFG9jzxy42bquUTGEeHKv/ZhRbX2kzjf33oHdTRpphDdQ87VFo2f2gvnmFn81QfZzr qqXraITckanOpOvpugq6X6YwKahsPX0ydMsbRaPplJb/gyp1dmpcjjgGZrVTGLxWZSDm caiIMXtuWrevDB/H09NYwcHQ+Nvm3dmJ22CNONVb24DaZVr3sVIAfxInPFMcdbqqPh3o knIhOYepm8Zqf9IVOQ2QRsigLOzYBFdzgEmnwKU0fomqgjjG/P43My5YEIv9POk9JBeJ 8KYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=o3aniGDG3zSjx1n1+LpysocBJ3oenkOpLCURB29A0Uc=; b=BFpXlnNPhYzx0v0bKnpobaU2/+u8PCTXEM/ywIvmfaJKHFkDBC7s3tDaTWwdMIGBaA hv9IHfM6nfl0an1d/0uCJHsNVMjaXoT/fVDMTAewF2KTz4c5sFpfx9gMIt4Hnjc3V8vE BaZggFUKMKikf8wFLnm3vMNkBiIP0gXbdwbGt6zdXPHjkxvoi/13f+5Om/v8Jhf/mSYj VaXcS7sXRFKGyVfACBxHet6DKMle43eKrCpCRaCp/k9JdeeIXe16NSH/hgQYT+CPg1sp naFENSm5TrcYTgeMMlBQMxe4Oyi9O7kMrhS9+ymj7qZm43tZzflDat5x4wV3M2gUqP7a AMKg== X-Gm-Message-State: APzg51Bsfox5J8zJr4cyd2ulTIes80Duy+Sw3DqbE8gLTVwchyCFHsn8 hE45wuWwimwLE+V9waWTmnj0yv32er0YYw== X-Google-Smtp-Source: ANB0Vdb8mLgzAYb/B95VY+CRJktmEWIKtfCYAvtqQaeTYA5x5dsMRSjMH+Y7JvzEbTIrP66Xyx+kFw== X-Received: by 2002:a0c:f987:: with SMTP id t7-v6mr19414539qvn.72.1536688754614; Tue, 11 Sep 2018 10:59:14 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id r20-v6sm12295042qtc.81.2018.09.11.10.59.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Sep 2018 10:59:13 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH 35/36] btrfs: wait on ordered extents on abort cleanup Date: Tue, 11 Sep 2018 13:58:06 -0400 Message-Id: <20180911175807.26181-36-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180911175807.26181-1-josef@toxicpanda.com> References: <20180911175807.26181-1-josef@toxicpanda.com> 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 we flip read-only before we initiate writeback on all dirty pages for ordered extents we've created then we'll have ordered extents left over on umount, which results in all sorts of bad things happening. Fix this by making sure we wait on ordered extents if we have to do the aborted transaction cleanup stuff. Reviewed-by: Nikolay Borisov Signed-off-by: Josef Bacik --- fs/btrfs/disk-io.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 54fbdc944a3f..51b2a5bf25e5 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4188,6 +4188,14 @@ static void btrfs_destroy_all_ordered_extents(struct btrfs_fs_info *fs_info) spin_lock(&fs_info->ordered_root_lock); } spin_unlock(&fs_info->ordered_root_lock); + + /* + * We need this here because if we've been flipped read-only we won't + * get sync() from the umount, so we need to make sure any ordered + * extents that haven't had their dirty pages IO start writeout yet + * actually get run and error out properly. + */ + btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); } static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,