From patchwork Thu Aug 30 17:42:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582491 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 4AEAB5A4 for ; Thu, 30 Aug 2018 17:43:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39E0E28676 for ; Thu, 30 Aug 2018 17:43:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E80D2C363; Thu, 30 Aug 2018 17:43:32 +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 D562128676 for ; Thu, 30 Aug 2018 17:43:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727753AbeH3Vqp (ORCPT ); Thu, 30 Aug 2018 17:46:45 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35945 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vqp (ORCPT ); Thu, 30 Aug 2018 17:46:45 -0400 Received: by mail-qt0-f193.google.com with SMTP id t5-v6so11321060qtn.3 for ; Thu, 30 Aug 2018 10:43:30 -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=Xb1Cr6yQ8rDat/54ctOxCRjwJqtEopvqWdESq9M76bo=; b=L1hIp/ShW6eUdn1bQFZ/FJYQcmU7+FOYGR+0ZPBdGACuTngX8uLB+wL6zXUVd32hWO 3MrxdQe3ZB4kjRQrH56ATZyRg7VYjdBi4+eO91R9cs8LvkbReVA99HCJwLd4xKzySSCS Sf5EwkjcID0ZNZqlS6twbucW/D2AwPZu/Bjj3L4J9T1uzqsOp3nVqge1FoqhphXMbyGH GNWjxOACJ2O7IOz+07j99EN0j+ELr9veK+QY5dcVMH4MosGKAeICTWnnqmLE8wK5Oull 5ZJ9EzMnV2x2h1Rxfn69PcFMC+vainF0yzDpWvi8c469yF09YMtQpPsCfJU25CyvyAe6 dQ2g== 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=Xb1Cr6yQ8rDat/54ctOxCRjwJqtEopvqWdESq9M76bo=; b=UIoNtVhlM7R23TqSmHT/gFBFn/8KnrzuCq222VNeThe5xFReyQJmdgheXsfojnp1H/ bvmwokzt5rgxOraE/K8JaUoZGK4JGiRSLArPEVtZ1S4cR3ERQTNExUbO/J6Yz2lHch03 YzK2xjN1Kes6ealKkTWl4ihocBDepGqjr0xqrdS080F6P79XUYMW7MohrHBwpUMVAd4V 9nGPoD25EUI5FU4UQuNzokhHDD90liOizF7YJt1FXtTTkdYJtSIFQixqn21YA1Tb7T/M HC4kf4wgJR8Hysfo06cAfm/2anCFCV0ZnMN46IrpfKqV3wtSiK4Hj7D7Jxm5wVODf9tJ Qx8A== X-Gm-Message-State: APzg51B2zpx1CqyJRnnUoHn3qxwPjPyhkRoeL4pGrC7weehdosjr3j2B xmWWpzzOmMO7PdyiVUU+9tH4uV3+pYjueQ== X-Google-Smtp-Source: ANB0VdZoF/EtovHDIIm4Xinh4wUsn7kgq7lpyXBtrqRxl8jDlHjwoU564n+zrDU8gHNZmGz5fn8ZUA== X-Received: by 2002:ac8:4691:: with SMTP id g17-v6mr13051456qto.137.1535651009473; Thu, 30 Aug 2018 10:43:29 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id 60-v6sm4294899qte.29.2018.08.30.10.43.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:28 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 34/35] btrfs: wait on ordered extents on abort cleanup Date: Thu, 30 Aug 2018 13:42:24 -0400 Message-Id: <20180830174225.2200-35-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180830174225.2200-1-josef@toxicpanda.com> References: <20180830174225.2200-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. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- 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,