From patchwork Wed Nov 21 19:05:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10693071 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 7D12B5A4 for ; Wed, 21 Nov 2018 19:05:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69F1C2B64D for ; Wed, 21 Nov 2018 19:05:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E11F2B694; Wed, 21 Nov 2018 19:05:52 +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 037182B64D for ; Wed, 21 Nov 2018 19:05:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732101AbeKVFlW (ORCPT ); Thu, 22 Nov 2018 00:41:22 -0500 Received: from mail-yb1-f196.google.com ([209.85.219.196]:34343 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730172AbeKVFlW (ORCPT ); Thu, 22 Nov 2018 00:41:22 -0500 Received: by mail-yb1-f196.google.com with SMTP id a67-v6so1092020ybg.1 for ; Wed, 21 Nov 2018 11:05:50 -0800 (PST) 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=MGS24WHfpQTuQ+5v8FcOJLX4g4kfm56cdKOc1o1JYb8=; b=DOB7v93H/16lTdX9XQL3nxNvFv+YZyRPPwTvNV+0necMVqOmnjqMlLQBu/wcteD+0/ 36kmNNASLc3qBu8Q7U/GeBHJabSPRXqRwMio4amTOIWRfKKyNn0Ey+l5ZjtzLucaOnCd gyHAK0CAove215oAnSvk3XH7Vp8BBviZ1FO3BXz0a5sY7BXG4fpuRmtvmXHWLuA6qKYf pvJ+6kt81aooWoIw33iBN/sFsGCgbtTkzbIopidqESVApcqTA4BwaXfZYSozrEV4yFtp 2Iy9JjGnGUOsmPV41kRiyYHeEcfLPsjTBylGSZ3TN+uQ7PPDsIAAz0njg7Edqe43Agpx y1Eg== 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=MGS24WHfpQTuQ+5v8FcOJLX4g4kfm56cdKOc1o1JYb8=; b=h80yxfUrAIyOr+Tly/3CN1VBZUAyBkpacQCH95dJI7XQPb24C3YAl7Lmc0lcY7uOh+ jPz4ahOCoFdoiOK0koUf3/HcqOlU6TyJsKPwwkSaW9PkJu3gD9pF2A2NdhfqSEiJuCBF oMdnYIDsWY6c4177mj1noCGrayhWv2p75RTn5RvNNI+u4jXFhcqhAOgZZbW1eg8moak8 ne24+Yeee/FhJ1Y72SweQDRqi92VSmK1BP3PySjMG+OjxLZWEmHK5Z9nI8PRQ6iOwGf7 GpSHZcqM8fWM5fQHkiitiAeDzjxNTWTjxQnOr1HV/3jWobbj8y8t/qysh20i0WL0+Sbq XLtA== X-Gm-Message-State: AA+aEWZi/yzMnKPWw9xl456PclGJMtoMix0nq0A4Cefn4augxgF8fsNh N79SWeIUXNyRaB9ZwczG3OP6qT2NeBk= X-Google-Smtp-Source: AFSGD/Xs/vMOXpHh/Bv4WVEdcRIsjslBZIDUpKYHDJ9b2yeQg5c4EWqV974eAQPaoEktiUAXHhJbmA== X-Received: by 2002:a25:7e46:: with SMTP id z67-v6mr7528122ybc.90.1542827149466; Wed, 21 Nov 2018 11:05:49 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id s189-v6sm9242422ywg.69.2018.11.21.11.05.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 11:05:48 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 1/7] btrfs: make btrfs_destroy_delayed_refs use btrfs_delayed_ref_lock Date: Wed, 21 Nov 2018 14:05:39 -0500 Message-Id: <20181121190545.24798-2-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181121190545.24798-1-josef@toxicpanda.com> References: <20181121190545.24798-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 We have this open coded in btrfs_destroy_delayed_refs, use the helper instead. Reviewed-by: Nikolay Borisov Signed-off-by: Josef Bacik --- fs/btrfs/disk-io.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index beaa58e742b5..f062fb0487cd 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4197,16 +4197,9 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, head = rb_entry(node, struct btrfs_delayed_ref_head, href_node); - if (!mutex_trylock(&head->mutex)) { - refcount_inc(&head->refs); - spin_unlock(&delayed_refs->lock); - - mutex_lock(&head->mutex); - mutex_unlock(&head->mutex); - btrfs_put_delayed_ref_head(head); - spin_lock(&delayed_refs->lock); + if (btrfs_delayed_ref_lock(delayed_refs, head)) continue; - } + spin_lock(&head->lock); while ((n = rb_first_cached(&head->ref_tree)) != NULL) { ref = rb_entry(n, struct btrfs_delayed_ref_node, From patchwork Wed Nov 21 19:05:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10693073 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 3EE4213BF for ; Wed, 21 Nov 2018 19:05:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CA552B64D for ; Wed, 21 Nov 2018 19:05:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20E2A2B694; Wed, 21 Nov 2018 19:05:54 +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 C822B2B64D for ; Wed, 21 Nov 2018 19:05:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732108AbeKVFlY (ORCPT ); Thu, 22 Nov 2018 00:41:24 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:39205 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730172AbeKVFlY (ORCPT ); Thu, 22 Nov 2018 00:41:24 -0500 Received: by mail-yw1-f67.google.com with SMTP id v8-v6so2679928ywh.6 for ; Wed, 21 Nov 2018 11:05:51 -0800 (PST) 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=xMNYjYZWLpf7m1COoaNSNiw8vw9MswDKLqZGSLeZQig=; b=EV+q0NxW1ZGbtiCbJzkuEZUNTI9t0gRMYo266x27S4eLEpF5O5EEqkeSBjhXTZNTpf 9RFEwHJmuuP4iJmY81Lt5opsVpmPH9YJVu2ZOb4reY5RYxyAjkD8dKqyl0F32Yc3zdSL W5ummRX7mRsFvQMoYoIGe5r3IzpGk/+LceuBLqVh0V1SQou7rXCR5pqEOCsBJMWcIBEd 3Dz7a6yfIJrlQfIekAGBJybZ1T5+T2OQ+JG0gsRJX3Cr+e5b0WupxKh2CFoWY6kPTkEV Wy26Yztxs58cajx4gH376bVC7JM61gGlu/iNvp4EormSNOv0gaPiKB+0KGtNgYNnsH6C hRQg== 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=xMNYjYZWLpf7m1COoaNSNiw8vw9MswDKLqZGSLeZQig=; b=J5kA/lt9GVYd2us80vhv8OeHCCEozq1U6NINBB0JoC/jml0B8L0t0OmzxXQGSdIMxb LWU8V44n7YyYFLC2zB58LjsECS7hDidXyBBpf+uSMglezs6yW8v3JmjFavDgBwNzciHC CJhnqUbESMRFvhvl/mQoErZwfUToOv428fFY1I8Whr7SLhwgUE1wSRXnTHRznwpQ9gYu XF6w0WyWsEfGprfaYpKV+IQhS57NsNr8SMNZPWGlJuAFJqVF0GBztrlj8KCTvuRMYHXx n8yJiqKPGNuXiV9Ft5O7QCJmLqBYCpz0I6Q+XDtBPg3AN82+vkJ9/zer35pnwEHxWySC hG9Q== X-Gm-Message-State: AA+aEWYf/po1kjwS+S6Oa+fecZo5Qf2w7wulCnR0sPxljtlnz87TYXkK StlyqAz3tZZ/Mix8JYTW1OiD49L14Yk= X-Google-Smtp-Source: AFSGD/UfWWT7fF1F+jIMeLby+fb62YFlZgUTz6ZAu5DGOnr3znq0kk17iEOWmL2F/dyRqBcjI16abw== X-Received: by 2002:a81:b54f:: with SMTP id c15mr6181576ywk.274.1542827151195; Wed, 21 Nov 2018 11:05:51 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id 131sm12377908ywn.88.2018.11.21.11.05.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 11:05:50 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 2/7] btrfs: make btrfs_destroy_delayed_refs use btrfs_delete_ref_head Date: Wed, 21 Nov 2018 14:05:40 -0500 Message-Id: <20181121190545.24798-3-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181121190545.24798-1-josef@toxicpanda.com> References: <20181121190545.24798-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 Instead of open coding this stuff use the helper instead. Reviewed-by: Nikolay Borisov Signed-off-by: Josef Bacik --- fs/btrfs/disk-io.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index f062fb0487cd..7d02748cf3f6 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4215,12 +4215,7 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, if (head->must_insert_reserved) pin_bytes = true; btrfs_free_delayed_extent_op(head->extent_op); - delayed_refs->num_heads--; - if (head->processing == 0) - delayed_refs->num_heads_ready--; - atomic_dec(&delayed_refs->num_entries); - rb_erase_cached(&head->href_node, &delayed_refs->href_root); - RB_CLEAR_NODE(&head->href_node); + btrfs_delete_ref_head(delayed_refs, head); spin_unlock(&head->lock); spin_unlock(&delayed_refs->lock); mutex_unlock(&head->mutex); From patchwork Wed Nov 21 19:05:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10693075 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 725CD13BF for ; Wed, 21 Nov 2018 19:05:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6078D2B64D for ; Wed, 21 Nov 2018 19:05:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 548692B694; Wed, 21 Nov 2018 19:05:56 +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 E21872B64D for ; Wed, 21 Nov 2018 19:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732114AbeKVFl0 (ORCPT ); Thu, 22 Nov 2018 00:41:26 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:42447 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730172AbeKVFl0 (ORCPT ); Thu, 22 Nov 2018 00:41:26 -0500 Received: by mail-yw1-f65.google.com with SMTP id x2so2671524ywc.9 for ; Wed, 21 Nov 2018 11:05:53 -0800 (PST) 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=cjyVjbBoG7sKEOd6P0V8B1uoPTV5nrc874hF4EtA1tc=; b=onMnJ7zRoi7uPV07Z54fN3N/de/88LHBSO8+xVcpkBaFkvkqcmbjiihHR9XPZlgKL4 To4Kyjb+DWMk5hFsv8ROXNsawKY2TmWmPK+almMEfGGzrq7y8ffRxyZbNUEutEQfVXHz a/1KqeKC6CsFm5sMPLV+VUyGnIm6uLMvL3qF6pzzMJszea2/e4ijB6bY05yzVCZQd2hS uCeIru6a/F/ARL1l0A8ROZnWaSBsiNcgxdDczEb8Fnp6Fo0R/BO8J0rywfNFAS7Jp1LK D2kt9Zp+j2raw+awLjzKUQli+SZwO3YTHlsxwR0Q1z3m2pj7ahwf4TTTyjTQ5ddNidq6 gAVw== 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=cjyVjbBoG7sKEOd6P0V8B1uoPTV5nrc874hF4EtA1tc=; b=Xg6KngpYyd7lIojtOMOuJbXBLHM8iOUjU47MciZGA6ZDreK2jMPmC9FuzE8g/KPkls 0UwtFBpwIr22Y1pjh6eV06yV5lxuod+O6cLMPHrvrEYRo4S5Y2/XItBw2pG6P74NYPq6 2KVlbNGXvP0jAoH9+IXC30HCPMys2NSW1DCHsEzoEPzJAPR3yfgLj5p7mv89+rNYDKWs l0qJ3kN6KRY4Cjs23mxPmeGQQWPLjlaH2aL03eBIe/pBMMAUDPFUS9ScJ5NPbpn33+oA DlIcv40D6Rba2AmQxcbuJbOYzCEyckACiCmZdil6M3t7gsqPlke6e0OcGslkOAW1eQfi pHGQ== X-Gm-Message-State: AGRZ1gLyBSRD/TYo+0uJHXfOzojSZgJ9qsFh4jR8YDLHYbnZYFPFqj/l PmYC3x9j9JAaUjztdS1KzmQhesJxj4s= X-Google-Smtp-Source: AJdET5d08M5de16pZGj0yCHrhr14MscpQKvEY3XFNmUqcxavaMv3itoajZmIAwVOQ1oGQc0L0vaDqA== X-Received: by 2002:a81:2b04:: with SMTP id r4mr7957844ywr.511.1542827153028; Wed, 21 Nov 2018 11:05:53 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id u130-v6sm11395418ywa.71.2018.11.21.11.05.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 11:05:52 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 3/7] btrfs: handle delayed ref head accounting cleanup in abort Date: Wed, 21 Nov 2018 14:05:41 -0500 Message-Id: <20181121190545.24798-4-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181121190545.24798-1-josef@toxicpanda.com> References: <20181121190545.24798-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 We weren't doing any of the accounting cleanup when we aborted transactions. Fix this by making cleanup_ref_head_accounting global and calling it from the abort code, this fixes the issue where our accounting was all wrong after the fs aborts. Signed-off-by: Josef Bacik --- fs/btrfs/ctree.h | 5 +++++ fs/btrfs/disk-io.c | 1 + fs/btrfs/extent-tree.c | 13 ++++++------- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 8ccc5019172b..709de7471d86 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -35,6 +35,7 @@ struct btrfs_trans_handle; struct btrfs_transaction; struct btrfs_pending_snapshot; +struct btrfs_delayed_ref_root; extern struct kmem_cache *btrfs_trans_handle_cachep; extern struct kmem_cache *btrfs_bit_radix_cachep; extern struct kmem_cache *btrfs_path_cachep; @@ -2643,6 +2644,10 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, unsigned long count); int btrfs_async_run_delayed_refs(struct btrfs_fs_info *fs_info, unsigned long count, u64 transid, int wait); +void +btrfs_cleanup_ref_head_accounting(struct btrfs_fs_info *fs_info, + struct btrfs_delayed_ref_root *delayed_refs, + struct btrfs_delayed_ref_head *head); int btrfs_lookup_data_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len); int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info, u64 bytenr, diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 7d02748cf3f6..8e7926c91e35 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4223,6 +4223,7 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, if (pin_bytes) btrfs_pin_extent(fs_info, head->bytenr, head->num_bytes, 1); + btrfs_cleanup_ref_head_accounting(fs_info, delayed_refs, head); btrfs_put_delayed_ref_head(head); cond_resched(); spin_lock(&delayed_refs->lock); diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e31980d451c2..a0f8880ee5dd 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2457,12 +2457,11 @@ static int run_and_cleanup_extent_op(struct btrfs_trans_handle *trans, return ret ? ret : 1; } -static void cleanup_ref_head_accounting(struct btrfs_trans_handle *trans, - struct btrfs_delayed_ref_head *head) +void +btrfs_cleanup_ref_head_accounting(struct btrfs_fs_info *fs_info, + struct btrfs_delayed_ref_root *delayed_refs, + struct btrfs_delayed_ref_head *head) { - struct btrfs_fs_info *fs_info = trans->fs_info; - struct btrfs_delayed_ref_root *delayed_refs = - &trans->transaction->delayed_refs; int nr_items = 1; if (head->total_ref_mod < 0) { @@ -2540,7 +2539,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, } } - cleanup_ref_head_accounting(trans, head); + btrfs_cleanup_ref_head_accounting(fs_info, delayed_refs, head); trace_run_delayed_ref_head(fs_info, head, 0); btrfs_delayed_ref_unlock(head); @@ -7218,7 +7217,7 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans, if (head->must_insert_reserved) ret = 1; - cleanup_ref_head_accounting(trans, head); + btrfs_cleanup_ref_head_accounting(trans->fs_info, delayed_refs, head); mutex_unlock(&head->mutex); btrfs_put_delayed_ref_head(head); return ret; From patchwork Wed Nov 21 19:05:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10693077 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 1841C5A4 for ; Wed, 21 Nov 2018 19:05:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05DB32B64D for ; Wed, 21 Nov 2018 19:05:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE3052B694; Wed, 21 Nov 2018 19:05:57 +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 9ABFB2B64D for ; Wed, 21 Nov 2018 19:05:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732118AbeKVFl2 (ORCPT ); Thu, 22 Nov 2018 00:41:28 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:45576 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730172AbeKVFl2 (ORCPT ); Thu, 22 Nov 2018 00:41:28 -0500 Received: by mail-yw1-f65.google.com with SMTP id d190so2668596ywd.12 for ; Wed, 21 Nov 2018 11:05:55 -0800 (PST) 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=cR41VZhNf/30aNDR9wwgeVsNkTnsAPanvCYJGlZyjvA=; b=p4uaYaD8J+cVPVxl16RuncQFeoQffwJRpXqFkpkbi58USjW3g+OdTPsagssSbfwisx tKc3GQGhUW7d1M9uVI2DAG+XxRdoZcCoNShs3/HwF6iCeGSLstNJTF/CYwDgumUsgUGY QbepuRzaxh8yOKS8RwnPLOVyvaXLSdNMZIzRLqxnYNQoY6YE+bTIbviLA78ohDertudr PIGc+J0N353A244nvnZgq/Bu0xORoKl4PkHW2SE1+SY7AfaXBfPAcDMocsBziTj4Ctyr RnsEx53YqzLY7srQqUHmsR4sxMUb7R0vaOaRfdY2NSbYfqRJFKyUNqIUeQA7RxgTguxR YWCA== 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=cR41VZhNf/30aNDR9wwgeVsNkTnsAPanvCYJGlZyjvA=; b=LZCPoo/KMrs1aGeezIkQtFpG3NOalvGN8zi4u0Z1041E8eQ3rBrHG3cVCxdmC3uiQI GnBud7J0rfeScC0Yn4oz282EbD7VKxYNsW+FTZgy5sshyHNaBdxjbjjwI+r+4ch+xLEQ 5LrFrdDlPHBA2MQBICpT1mOzT+0ESY2MKDoHcOcWWiw+I5CIlJ5SByqhzSj+6orSp53k GJnZDNKxJYx6jRbUeozyVONZat41h0f+ZgbOoKE0g3BU+7kZ9sY4zdHWvgwJSRx25aqb eSTy8bRveymlbN87S44VERFn1fFQT5jVqMGOSFufj8fOW8JekH5Q2IWwvyXxdTQrGYYN zjMQ== X-Gm-Message-State: AGRZ1gLRGt7ky9R6Hk0KonEZ40pHMvkbCINJTch5Ti/Oxw3m7MydgyCX u+01MC3v8gdl/27xE3djtdJ3jJfDy5w= X-Google-Smtp-Source: AJdET5dcF9iE5rkbqHdBquJBwAnpOegzxdM4nQ7r1BNRGWA9hUkO1/gig66rZAcuN1cd6HcKhb47tw== X-Received: by 2002:a81:a4d1:: with SMTP id b200mr7454109ywh.316.1542827154717; Wed, 21 Nov 2018 11:05:54 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id g70sm670457ywe.105.2018.11.21.11.05.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 11:05:54 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 4/7] btrfs: call btrfs_create_pending_block_groups unconditionally Date: Wed, 21 Nov 2018 14:05:42 -0500 Message-Id: <20181121190545.24798-5-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181121190545.24798-1-josef@toxicpanda.com> References: <20181121190545.24798-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 The first thing we do is loop through the list, this if (!list_empty()) btrfs_create_pending_block_groups(); thing is just wasted space. Reviewed-by: Nikolay Borisov Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 3 +-- fs/btrfs/transaction.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a0f8880ee5dd..b9b829c8825c 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3004,8 +3004,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, } if (run_all) { - if (!list_empty(&trans->new_bgs)) - btrfs_create_pending_block_groups(trans); + btrfs_create_pending_block_groups(trans); spin_lock(&delayed_refs->lock); node = rb_first_cached(&delayed_refs->href_root); diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index a4682a696fb6..826a15a07fce 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -845,8 +845,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, btrfs_trans_release_metadata(trans); trans->block_rsv = NULL; - if (!list_empty(&trans->new_bgs)) - btrfs_create_pending_block_groups(trans); + btrfs_create_pending_block_groups(trans); btrfs_trans_release_chunk_metadata(trans); @@ -1937,8 +1936,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) cur_trans->delayed_refs.flushing = 1; smp_wmb(); - if (!list_empty(&trans->new_bgs)) - btrfs_create_pending_block_groups(trans); + btrfs_create_pending_block_groups(trans); ret = btrfs_run_delayed_refs(trans, 0); if (ret) { From patchwork Wed Nov 21 19:05:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10693079 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 4637B5A4 for ; Wed, 21 Nov 2018 19:05:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34C1F2B64D for ; Wed, 21 Nov 2018 19:05:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 291592B694; Wed, 21 Nov 2018 19:05:59 +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 CE2E52B64D for ; Wed, 21 Nov 2018 19:05:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732165AbeKVFl3 (ORCPT ); Thu, 22 Nov 2018 00:41:29 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:46439 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730172AbeKVFl3 (ORCPT ); Thu, 22 Nov 2018 00:41:29 -0500 Received: by mail-yb1-f195.google.com with SMTP id i17-v6so2627726ybp.13 for ; Wed, 21 Nov 2018 11:05:57 -0800 (PST) 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=JdbY4jZtPIPda37F1AntqT6ZzucRQu0I7FkAGpehVsk=; b=EqPxyamXCEYpua7E8JurGtYst4ELgAK5nxglIsPtSfkUP2inw/iEBJ/mt/kXFMFK5F OtYgwXaXfgOpMwiFgDQUUxXreTdnoKxH6m+UENIn6rExFfJAoY5Q/YMB2nE07f06uwor mLRW5WFJuoLzTU5pzr2PFS0wuKwmi0x9RhWYaKf5hVkQ7eVn8+WfztWCxYFKL9lZqtJl T5ITblnNU7AFiN3qikfdrvW06rs51IyipjHWRBa27qZxQTbfGhxCyHL5lVZdS5OKPcRS NqQLrmG3076wB0TKQDx1vvoFOBikS4Z7PpxO0mlG6KVnNOtyji/oRPsNngIGUoLoQGsi cHUw== 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=JdbY4jZtPIPda37F1AntqT6ZzucRQu0I7FkAGpehVsk=; b=HLDOrAxSAEoT3PX8CoDjGOxTYSLQ9UcvHBuTrAqNyUegk+/KAzpwvq/5oYkpUJRo8K 2iPowj1m1+Hb6Xf2aUHzy687FSPR5QZSR23rSfL/HUdtowqMzBLyq5uhI64DEGpP4sTU tqc691F8CZs+MVZeUAHj4TEsW8AmSPkkCzI4sXh9L3p7bdD3DrmBVXsRfs3iJrP7fFBh S8c5LcRdhCS9x30QRhMq6TOHzzDG2f/zqsiVljJPihamocksTkbjKx41LeGZre7hVtXw HO0wf9lgeiXyU0Vzh6exYENpmhryAtlgGmCS3Km4rBR2WVBEYQVLo2/NcDatU8obpw5x Jgvg== X-Gm-Message-State: AA+aEWYh9fnRk+g357OllqcGJDugB0YsQRllWTsjh1uFQpn55JdJAcV6 jT2q0GxPHXnYz2wNWcJc6PnB/8ybBjY= X-Google-Smtp-Source: AFSGD/Vp/qFIVGpI+4/KGPYnbCzklNDALmedrUAgtMycbFKEm7cbAW3d6B9hy9m85UhkQ4FmwZ3CWg== X-Received: by 2002:a5b:708:: with SMTP id g8-v6mr7593807ybq.331.1542827156373; Wed, 21 Nov 2018 11:05:56 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id l35sm13351690ywh.48.2018.11.21.11.05.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 11:05:55 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 5/7] btrfs: just delete pending bgs if we are aborted Date: Wed, 21 Nov 2018 14:05:43 -0500 Message-Id: <20181121190545.24798-6-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181121190545.24798-1-josef@toxicpanda.com> References: <20181121190545.24798-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 We still need to do all of the accounting cleanup for pending block groups if we abort. So set the ret to trans->aborted so if we aborted the cleanup happens and everybody is happy. Reviewed-by: Omar Sandoval Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index b9b829c8825c..90423b6749b7 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -10500,11 +10500,17 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans) struct btrfs_root *extent_root = fs_info->extent_root; struct btrfs_block_group_item item; struct btrfs_key key; - int ret = 0; + int ret; if (!trans->can_flush_pending_bgs) return; + /* + * If we aborted the transaction with pending bg's we need to just + * cleanup the list and carry on. + */ + ret = trans->aborted; + while (!list_empty(&trans->new_bgs)) { block_group = list_first_entry(&trans->new_bgs, struct btrfs_block_group_cache, From patchwork Wed Nov 21 19:05:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10693081 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 2D95D13BF for ; Wed, 21 Nov 2018 19:06:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BB632B64D for ; Wed, 21 Nov 2018 19:06:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1008B2B694; Wed, 21 Nov 2018 19:06:01 +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 AA8152B64D for ; Wed, 21 Nov 2018 19:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732222AbeKVFlb (ORCPT ); Thu, 22 Nov 2018 00:41:31 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:38768 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730172AbeKVFlb (ORCPT ); Thu, 22 Nov 2018 00:41:31 -0500 Received: by mail-yw1-f66.google.com with SMTP id i20so2677947ywc.5 for ; Wed, 21 Nov 2018 11:05:59 -0800 (PST) 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=DTDAD38vSYBkub9gfA4jndGSFn3T+R5a7UQKxBBUTEY=; b=pnm3x3FPGZ/7XQNGpCh4H6P78YO1XJ0ZW5XB0DZ1JzDp3GLFQhuxEORhS6BGXacr5Y G9eZSHhKVgCkYkk+YK8YLj/nYn0iBy/VRc+CX8LcRmVA8aUc1uHkH3R2boP9u+6LOazX 9d/Rv2c9mXdBihSZ9hFU4SvpF23UDAYCaC/jqRwlxQ4Z9XYKoaDOkXcJNyKFynkmPCId lfiCebhMgSAcUpTzWFevFVIo8Mb33QeSAdoKtaHf/4YMf8xSHWOe+6UVabFsbpb+Dm3f Z8ephzGZLgdWpXx9TrmSJMsODSj0LpCH7x5EnkZhZluRuqQR5wTSqsJWU2aw0l8hix7K 8deQ== 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=DTDAD38vSYBkub9gfA4jndGSFn3T+R5a7UQKxBBUTEY=; b=kOC0PxDFYpehW7hDT46smrfE3CUtFLclbJDWKAjRNUnM/R02gI1/jeR+WslPt13L93 xF0CMzeqlQG822Ah1yPxTPJmtxW3hsNa7jD8uhZQ3GzbErFfMiysmIVm1BazzDxaGabD ZZF9+Q7S1R/XnpLGTJmbsNNvQ29B8eoztrx7O+uRdpI4FPJmDI6KAki3BDakv6WHOLM3 eJELLAJfHC1EAkQAl/0tLrJiqJuvLKMFoN2zIDm0dPkSpykSjKzfsHRaWtZ0bCzS8xXO f55vBRK8N1JmbKkIPghy3XdkmZxiyJaJgb3LzN4zzu440KXaflt4CCQ9FlE/w9ArN0Ys hKMg== X-Gm-Message-State: AGRZ1gIDp23nHUkQUpodlzkpsNOUf+0e3myVnGP3+ESZp7d2fBe8hxFG Qk3FvtpCNekf6UVrkEmCUrKT6Du7Cds= X-Google-Smtp-Source: AJdET5dkOdFj1CILR0ehTJbWQp8vneHfUz5cudnP3iUKl9L2PiVS6BM7vZpkwI4QThJeoJ/vYgENAA== X-Received: by 2002:a81:3358:: with SMTP id z85mr7788872ywz.398.1542827158041; Wed, 21 Nov 2018 11:05:58 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id k206sm1602455ywa.16.2018.11.21.11.05.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 11:05:57 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 6/7] btrfs: cleanup pending bgs on transaction abort Date: Wed, 21 Nov 2018 14:05:44 -0500 Message-Id: <20181121190545.24798-7-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181121190545.24798-1-josef@toxicpanda.com> References: <20181121190545.24798-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 We may abort the transaction during a commit and not have a chance to run the pending bgs stuff, which will leave block groups on our list and cause us accounting issues and leaked memory. Fix this by running the pending bgs when we cleanup a transaction. Reviewed-by: Omar Sandoval Signed-off-by: Josef Bacik --- fs/btrfs/transaction.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 826a15a07fce..3c1be9db897c 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -2269,6 +2269,10 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) btrfs_scrub_continue(fs_info); cleanup_transaction: btrfs_trans_release_metadata(trans); + /* This cleans up the pending block groups list properly. */ + if (!trans->aborted) + trans->aborted = ret; + btrfs_create_pending_block_groups(trans); btrfs_trans_release_chunk_metadata(trans); trans->block_rsv = NULL; btrfs_warn(fs_info, "Skipping commit of aborted transaction."); From patchwork Wed Nov 21 19:05:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10693083 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 A297313BF for ; Wed, 21 Nov 2018 19:06:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9047A2B64D for ; Wed, 21 Nov 2018 19:06:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84AD22B694; Wed, 21 Nov 2018 19:06:02 +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 3236B2B64D for ; Wed, 21 Nov 2018 19:06:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732250AbeKVFlc (ORCPT ); Thu, 22 Nov 2018 00:41:32 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:42733 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730172AbeKVFlc (ORCPT ); Thu, 22 Nov 2018 00:41:32 -0500 Received: by mail-yb1-f195.google.com with SMTP id o204-v6so2631975yba.9 for ; Wed, 21 Nov 2018 11:06:00 -0800 (PST) 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=ChDhmHleKb4VZu9DLBBdualiLEzB3kbTWeFT8Vil964=; b=v5hoo/Hd9i8mxyHynQcrpKJc59+79guNfS/aXoUkOk3bsFK4EiPcSqcQ/9mbMtTKaP 4v8LQRz+Zp1ACfkXob7ZFgBqyHXiKBhO5bzMN0PdxlMG7UY6dbmchNF9ODxI9c8l56TT CUvV6Tj/5CN4+9fPN/eONx6oSsKrqbk0aeKhg4LqABALDKI5dTbNVIu5zhbxlXWp2Rn/ I7y4Ho/3xVQcWHC4lWqMV1Oi6unYUN+d3zDecj574/T0Th54Ls6oZrkQOCSwpLwsDikW Lh8A+SWxF61+5vSn8wRAFurwD9v20iyxoX2oKh6MRT9xH6Cz7t0KkHTQupyK0ZLxLOcm PBWQ== 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=ChDhmHleKb4VZu9DLBBdualiLEzB3kbTWeFT8Vil964=; b=jbs/PFRACMHesx773aIrrfpz0Ch/QMs+Ga7x/WrxqAbH1tkLCWTgUkD9T6MqIRru0z Yjzi2rdmb0+EwohWzUNC3Zhy6Y77QUovnV9i9cpC0ayzXmvFCKuxOBPb9OpwX0uTmX4z OEvwNEuiaxiOJy+zO9YScomAKXmHosz3BoDfbcrUsZE9oyl+/FkY8osAJJNEJINTOI3T zXoGiG4av4v4Zq8W8uYFLc5PY+Ggcu5puGcH5+tHoVHaxpOUxtvXimxVhTepPpzqd3sf 4qUvKoootyUKbLfQafQzMQw0OybVFdjqlBuDqCC83BAs+3fKN4VrKwbhaOx3DRsYkxRr jZaw== X-Gm-Message-State: AA+aEWZta9gpCx/x1EV8M4t3B+RQwWdENmzPLiPCLJu/MkwaDzI1cmwM mpO38ibYII35t6GG2AqrdIFlddOZSww= X-Google-Smtp-Source: AFSGD/VnYaf3h7bFfu5iBNIxutxtI10wQAxh/YLf0a3j93puqjkL4ZUKt6aFyNcM9o4A06qnbbp6DA== X-Received: by 2002:a25:aae2:: with SMTP id t89-v6mr7530049ybi.200.1542827159701; Wed, 21 Nov 2018 11:05:59 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id d138sm9746967ywb.44.2018.11.21.11.05.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 11:05:59 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 7/7] btrfs: wait on ordered extents on abort cleanup Date: Wed, 21 Nov 2018 14:05:45 -0500 Message-Id: <20181121190545.24798-8-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181121190545.24798-1-josef@toxicpanda.com> References: <20181121190545.24798-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 8e7926c91e35..c5918ff8241b 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4171,6 +4171,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,