From patchwork Thu Aug 22 19:10:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 11109833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2E87174A for ; Thu, 22 Aug 2019 19:11:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1B1E233FD for ; Thu, 22 Aug 2019 19:11:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="Ybh4hbKN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388238AbfHVTLK (ORCPT ); Thu, 22 Aug 2019 15:11:10 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:37699 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731701AbfHVTLJ (ORCPT ); Thu, 22 Aug 2019 15:11:09 -0400 Received: by mail-yw1-f65.google.com with SMTP id u141so2850716ywe.4 for ; Thu, 22 Aug 2019 12:11:09 -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:mime-version :content-transfer-encoding; bh=ew4qcK4M0DxS6E8NTsrjj5KHfKdh869Q49UUyA+3JWw=; b=Ybh4hbKNQdb9DrpV6fg8yjTaGiTq7FH1priJmCZwH2G3crWet/hlhFoWH1mFPqDbDx /iMmbzcMLyZ4f6av9Zh8kYfzMsjU73H5Pr4WbJv2AQ8WsXHve0nuwxuv6CdiLd1i2fge XbnjSmB+3ajupbMnBDanvrFDUTRr6T5S0yPxIZjppL4pLCc9LdTByuMeHvgpaj3TyHF1 fyW9At4omTB8GnuLmcOFw8CXHBlV5hRWu6iOyerAA+51bH/nPTcLScC71TlFj8OAe6ua FS3CmyH+6FbUziKnWK03gh1bbrtzD889Y+GlDp4yuOnDPU4ZMOaAUxsJ2CZ/cBQOq1q9 S0yA== 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:mime-version:content-transfer-encoding; bh=ew4qcK4M0DxS6E8NTsrjj5KHfKdh869Q49UUyA+3JWw=; b=mKG7bx8WBfAM6Qg82dKPNJIPudt5/2BGlG0BnhffcR/3luIU+pn5P3IOoUAsh6GDqm sX+1AHe98pQPsdTtiT3f1P2CaeaHtDM83E/XLJ2CoyMgeG7Bu3jwidi0zaOSoy3dJn7C ps78H2924Jv5LsB8RomMfwKAluwoT4kjUNHcH1qVdCovK0Pb9a/g9fGZ5Y23Wi4uZ97y q+zVVYXBcgBAUZZdlbV9OPDKzgsBKKz3mstfyHqAEgpt4UtYiLs1y3LHcdMVX6ufxUyw npoFQ//Tbv/USASGGfcgHrJf995heCIe0PDowbLei8qWKnkiGTgwcNkxo9npEAE/DuDJ g4Ig== X-Gm-Message-State: APjAAAVWSKA3HH7KGs6NEsGD26dhQtKw23GkEva248V9/2NPUUMvf4D3 WIh7Ts721fw/CWuX+jARxcVv0w== X-Google-Smtp-Source: APXvYqw9JLXD+QVG4bciN9T1ldEtPG2fpxHBA08hqV6SC5SDfkxXala60ps9BXZQHXPuQd3SQ/T44g== X-Received: by 2002:a81:67d5:: with SMTP id b204mr675938ywc.416.1566501067518; Thu, 22 Aug 2019 12:11:07 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id k67sm126136ywb.68.2019.08.22.12.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 12:11:06 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH 1/9] btrfs: do not allow reservations if we have pending tickets Date: Thu, 22 Aug 2019 15:10:54 -0400 Message-Id: <20190822191102.13732-2-josef@toxicpanda.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190822191102.13732-1-josef@toxicpanda.com> References: <20190822191102.13732-1-josef@toxicpanda.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org If we already have tickets on the list we don't want to steal their reservations. This is a preparation patch for upcoming changes, technically this shouldn't happen today because of the way we add bytes to tickets before adding them to the space_info in most cases. This does not change the FIFO nature of reserve tickets, it simply allows us to enforce it in a different way. Previously it was enforced because any new space would be added to the first ticket on the list, which would result in new reservations getting a reserve ticket. This replaces that mechanism by simply checking to see if we have outstanding reserve tickets and skipping straight to adding a ticket for our reservation. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/space-info.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index 5f8f65599de1..33fa0ba49759 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -993,6 +993,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, struct reserve_ticket ticket; u64 used; int ret = 0; + bool pending_tickets; ASSERT(orig_bytes); ASSERT(!current->journal_info || flush != BTRFS_RESERVE_FLUSH_ALL); @@ -1000,14 +1001,17 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, spin_lock(&space_info->lock); ret = -ENOSPC; used = btrfs_space_info_used(space_info, true); + pending_tickets = !list_empty(&space_info->tickets) || + !list_empty(&space_info->priority_tickets); /* * Carry on if we have enough space (short-circuit) OR call * can_overcommit() to ensure we can overcommit to continue. */ - if ((used + orig_bytes <= space_info->total_bytes) || - can_overcommit(fs_info, space_info, orig_bytes, flush, - system_chunk)) { + if (!pending_tickets && + ((used + orig_bytes <= space_info->total_bytes) || + can_overcommit(fs_info, space_info, orig_bytes, flush, + system_chunk))) { btrfs_space_info_update_bytes_may_use(fs_info, space_info, orig_bytes); trace_btrfs_space_reservation(fs_info, "space_info", From patchwork Thu Aug 22 19:10:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 11109835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE29A174A for ; Thu, 22 Aug 2019 19:11:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A3FB523400 for ; Thu, 22 Aug 2019 19:11:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="YqzJX+Am" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390214AbfHVTLK (ORCPT ); Thu, 22 Aug 2019 15:11:10 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:40268 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387990AbfHVTLK (ORCPT ); Thu, 22 Aug 2019 15:11:10 -0400 Received: by mail-yb1-f194.google.com with SMTP id g7so2952031ybd.7 for ; Thu, 22 Aug 2019 12:11:09 -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:mime-version :content-transfer-encoding; bh=v1pSaaDbSqj2cZfBASQp5Ma0F6NJ1GGvihHWqIN/iu4=; b=YqzJX+AmKD4sn2ylNCPAeoBSxvk7j4VzzHPA7OeUL2VdS+jMt7M3wO7ULMpx/R5Pxm TO65UNh2d0JYK88gbSByi4lFm9pl71JIcSiGHW2FB0cNj1GDXvYtRGBJvZBTsVctDH2i Arg2a+Di8XUnYL1i7WMu2CMOI/mya3XHUBIxR2aK9KJPpT9EWcnjPuPGYuwxcysDCV/a ziO9WjBKhFi4Rqn5fgQK43kMnFOUQ8sbuYE5sTng9LJNBrbecM6IwuBoXcxTZrgD3nuA 4sN6Ygn15rEMd8OxzL8QTWDYCgryt88l9qbcJXSQ5ND4H1DB/usiP09nB9qMZifuYfHS bjuw== 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:mime-version:content-transfer-encoding; bh=v1pSaaDbSqj2cZfBASQp5Ma0F6NJ1GGvihHWqIN/iu4=; b=EY1VT6LZz1IRxYIr9o8wUZuV+kioDp4Pq4c5RFuq6HxwQunGv7aIunHHOdjER3Q7MH KlEgDFZZZ0TBIIge6DQ81oLuU9aI0MAM7uXSkK3h6eTGgqQHfhERg57c/MdpZJjNkiDy 9kViGyfem9BoYCMk+LGsPBFLk8M0iwMrn0e2WRO5veSRdgiwHM6BbjN9UnV0nmeChDSn UJ6q+6TzzWyFjAxG64u7c7ke+U9eQJfVDhgQcuOsYicVuS79g52BLkzuaAUdITFtAyk4 csNliw5zG4B6IIeOOeAmyF0tXnnzK1bTpkUK6RKEzBUojb2OpUC3XF0mXBIyKIoIQAkl tG+Q== X-Gm-Message-State: APjAAAUcEcuVKOeyo+7Qot90vC3PGuf1fiLpKseodaurRBetVHEBUCKw xcNkmPeam2YzVwsaO6WSC+oMVQDOuFM4pQ== X-Google-Smtp-Source: APXvYqy699hgn8kL+K/KLCvJ7LQQvuIJhiiM/5oWN//jaHVgWbLmBMSHZDzT2NLRNsdXzw4iVtUibg== X-Received: by 2002:a25:aa23:: with SMTP id s32mr377645ybi.198.1566501069209; Thu, 22 Aug 2019 12:11:09 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id d191sm267851ywh.12.2019.08.22.12.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 12:11:08 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH 2/9] btrfs: roll tracepoint into btrfs_space_info_update helper Date: Thu, 22 Aug 2019 15:10:55 -0400 Message-Id: <20190822191102.13732-3-josef@toxicpanda.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190822191102.13732-1-josef@toxicpanda.com> References: <20190822191102.13732-1-josef@toxicpanda.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We duplicate this tracepoint everywhere we call these helpers, so update the helper to have the tracepoint as well. Signed-off-by: Josef Bacik Reviewed-by: David Sterba --- fs/btrfs/block-group.c | 3 --- fs/btrfs/block-rsv.c | 5 ----- fs/btrfs/delalloc-space.c | 4 ---- fs/btrfs/extent-tree.c | 9 --------- fs/btrfs/space-info.c | 10 ---------- fs/btrfs/space-info.h | 10 +++++++--- 6 files changed, 7 insertions(+), 34 deletions(-) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 262e62ef52a5..9867c5d98650 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -2696,9 +2696,6 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans, spin_unlock(&cache->lock); spin_unlock(&cache->space_info->lock); - trace_btrfs_space_reservation(info, "pinned", - cache->space_info->flags, - num_bytes, 1); percpu_counter_add_batch( &cache->space_info->total_bytes_pinned, num_bytes, diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c index 698470b9f32d..c64b460a4301 100644 --- a/fs/btrfs/block-rsv.c +++ b/fs/btrfs/block-rsv.c @@ -283,16 +283,11 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info) block_rsv->reserved += num_bytes; btrfs_space_info_update_bytes_may_use(fs_info, sinfo, num_bytes); - trace_btrfs_space_reservation(fs_info, "space_info", - sinfo->flags, num_bytes, - 1); } } else if (block_rsv->reserved > block_rsv->size) { num_bytes = block_rsv->reserved - block_rsv->size; btrfs_space_info_update_bytes_may_use(fs_info, sinfo, -num_bytes); - trace_btrfs_space_reservation(fs_info, "space_info", - sinfo->flags, num_bytes, 0); block_rsv->reserved = block_rsv->size; } diff --git a/fs/btrfs/delalloc-space.c b/fs/btrfs/delalloc-space.c index d2dfc201b2e1..1fc6bef3ccdf 100644 --- a/fs/btrfs/delalloc-space.c +++ b/fs/btrfs/delalloc-space.c @@ -130,8 +130,6 @@ int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes) return -ENOSPC; } btrfs_space_info_update_bytes_may_use(fs_info, data_sinfo, bytes); - trace_btrfs_space_reservation(fs_info, "space_info", - data_sinfo->flags, bytes, 1); spin_unlock(&data_sinfo->lock); return 0; @@ -183,8 +181,6 @@ void btrfs_free_reserved_data_space_noquota(struct inode *inode, u64 start, data_sinfo = fs_info->data_sinfo; spin_lock(&data_sinfo->lock); btrfs_space_info_update_bytes_may_use(fs_info, data_sinfo, -len); - trace_btrfs_space_reservation(fs_info, "space_info", - data_sinfo->flags, len, 0); spin_unlock(&data_sinfo->lock); } diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 444844b431f7..8c3e8fdbf2c1 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2583,8 +2583,6 @@ static int pin_down_extent(struct btrfs_block_group_cache *cache, spin_unlock(&cache->lock); spin_unlock(&cache->space_info->lock); - trace_btrfs_space_reservation(fs_info, "pinned", - cache->space_info->flags, num_bytes, 1); percpu_counter_add_batch(&cache->space_info->total_bytes_pinned, num_bytes, BTRFS_TOTAL_BYTES_PINNED_BATCH); set_extent_dirty(fs_info->pinned_extents, bytenr, @@ -2842,9 +2840,6 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info, spin_lock(&cache->lock); cache->pinned -= len; btrfs_space_info_update_bytes_pinned(fs_info, space_info, -len); - - trace_btrfs_space_reservation(fs_info, "pinned", - space_info->flags, len, 0); space_info->max_extent_size = 0; percpu_counter_add_batch(&space_info->total_bytes_pinned, -len, BTRFS_TOTAL_BYTES_PINNED_BATCH); @@ -2866,10 +2861,6 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info, space_info, to_add); if (global_rsv->reserved >= global_rsv->size) global_rsv->full = 1; - trace_btrfs_space_reservation(fs_info, - "space_info", - space_info->flags, - to_add, 1); len -= to_add; } spin_unlock(&global_rsv->lock); diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index 33fa0ba49759..a0a36d5768e1 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -279,8 +279,6 @@ void btrfs_space_info_add_old_bytes(struct btrfs_fs_info *fs_info, goto again; } btrfs_space_info_update_bytes_may_use(fs_info, space_info, -num_bytes); - trace_btrfs_space_reservation(fs_info, "space_info", - space_info->flags, num_bytes, 0); spin_unlock(&space_info->lock); } @@ -301,9 +299,6 @@ void btrfs_space_info_add_new_bytes(struct btrfs_fs_info *fs_info, ticket = list_first_entry(head, struct reserve_ticket, list); if (num_bytes >= ticket->bytes) { - trace_btrfs_space_reservation(fs_info, "space_info", - space_info->flags, - ticket->bytes, 1); list_del_init(&ticket->list); num_bytes -= ticket->bytes; btrfs_space_info_update_bytes_may_use(fs_info, @@ -313,9 +308,6 @@ void btrfs_space_info_add_new_bytes(struct btrfs_fs_info *fs_info, space_info->tickets_id++; wake_up(&ticket->wait); } else { - trace_btrfs_space_reservation(fs_info, "space_info", - space_info->flags, - num_bytes, 1); btrfs_space_info_update_bytes_may_use(fs_info, space_info, num_bytes); @@ -1014,8 +1006,6 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, system_chunk))) { btrfs_space_info_update_bytes_may_use(fs_info, space_info, orig_bytes); - trace_btrfs_space_reservation(fs_info, "space_info", - space_info->flags, orig_bytes, 1); ret = 0; } diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h index c2b54b8e1a14..025f7ce2c9b1 100644 --- a/fs/btrfs/space-info.h +++ b/fs/btrfs/space-info.h @@ -87,14 +87,18 @@ static inline bool btrfs_mixed_space_info(struct btrfs_space_info *space_info) * * Declare a helper function to detect underflow of various space info members */ -#define DECLARE_SPACE_INFO_UPDATE(name) \ +#define DECLARE_SPACE_INFO_UPDATE(name, trace_name) \ static inline void \ btrfs_space_info_update_##name(struct btrfs_fs_info *fs_info, \ struct btrfs_space_info *sinfo, \ s64 bytes) \ { \ + u64 abs_bytes = (bytes < 0) ? -bytes : bytes; \ lockdep_assert_held(&sinfo->lock); \ trace_update_##name(fs_info, sinfo, sinfo->name, bytes); \ + trace_btrfs_space_reservation(fs_info, trace_name, \ + sinfo->flags, abs_bytes, \ + bytes > 0); \ if (bytes < 0 && sinfo->name < -bytes) { \ WARN_ON(1); \ sinfo->name = 0; \ @@ -103,8 +107,8 @@ btrfs_space_info_update_##name(struct btrfs_fs_info *fs_info, \ sinfo->name += bytes; \ } -DECLARE_SPACE_INFO_UPDATE(bytes_may_use); -DECLARE_SPACE_INFO_UPDATE(bytes_pinned); +DECLARE_SPACE_INFO_UPDATE(bytes_may_use, "space_info"); +DECLARE_SPACE_INFO_UPDATE(bytes_pinned, "pinned"); void btrfs_space_info_add_new_bytes(struct btrfs_fs_info *fs_info, struct btrfs_space_info *space_info, From patchwork Thu Aug 22 19:10:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 11109837 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 719371399 for ; Thu, 22 Aug 2019 19:11:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51AAE23400 for ; Thu, 22 Aug 2019 19:11:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="MW6SxWJE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391536AbfHVTLM (ORCPT ); Thu, 22 Aug 2019 15:11:12 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:37701 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387990AbfHVTLM (ORCPT ); Thu, 22 Aug 2019 15:11:12 -0400 Received: by mail-yw1-f66.google.com with SMTP id u141so2850743ywe.4 for ; Thu, 22 Aug 2019 12:11:11 -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:mime-version :content-transfer-encoding; bh=9CkSd9BE74+W51JiHMD0MEGF+qCN+/eIQz3CH+6fCG4=; b=MW6SxWJE7T0gbebkLEQCTmvnqNp2FF7ksqISSnR86yFmyRjxNNpwXJhKL6/pzjf8pp CvTByBVZyXs6fKXHsh5WIqSXItWrxvwAS69UNcP+kqGG8a+4LkUygZnN2l6lQsOvquT5 H3yBgVuB8ccyhefH0CjjarxeIqLOydok7ea2cZhSJSCVxkmeSvid6zxK8zX2i74rdfc7 qnHm918lY6uQLxtSXQCeUx2wyT8Ixh3u8imPqQTLEh67Ezztw6Bz4/8PAWI/bRmuyqMe 6SfK2U9petHyDqvJKojwzEPEYITdG4ZSJBqVK9kZkmOLa6kkM+OAaLNepcJdjdX3URDR 5uUA== 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:mime-version:content-transfer-encoding; bh=9CkSd9BE74+W51JiHMD0MEGF+qCN+/eIQz3CH+6fCG4=; b=PT85/9rqH05l0tEpd4MoacGbRQW6mt/kFQ5znn7mtJTIMJVsFUZhwOziRCDZuH3scR en1BlM3KT0JF5loG4qPEqzLUF2H15Tx/oW69XlcJzxGlLH9GmpCBgSPiSN0pIZ5UQFIW dKPcMAv1OZFI9x0dLQpchCe/z+l9EOeSCkzEgHFFVuR7/YuzZM8NBvYCW+/rzAdbIill Xkxm3Xlhf1j9B83Zti/8jYaUMbLFUPTAFnOmzmdN78Dat1Q3h4vhEoB/Lzo/hniQaICn 7LLmWkBc76EO618yOrTf2xHOt+J0bPAtjPjxsX6SWzLM7YNH7pnsUnFX47AGuUD7ZguG 42ZA== X-Gm-Message-State: APjAAAXykgivGIw2NaA2mm8Yr5V64kqHY7S9yy05nDMn45JukHBFJtdQ 5626b/z2bjcvgNyS+ALO28CdPv+OYBnttQ== X-Google-Smtp-Source: APXvYqzttA9zp9dRhpk68KROHW6MrFVv1MbPRT2pLRDlvgEP4xKcVjZNnnQI9UPvCqB+Tb5znraq+w== X-Received: by 2002:a81:94c7:: with SMTP id l190mr660132ywg.55.1566501070897; Thu, 22 Aug 2019 12:11:10 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id t186sm108524ywt.20.2019.08.22.12.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 12:11:10 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH 3/9] btrfs: add space reservation tracepoint for reserved bytes Date: Thu, 22 Aug 2019 15:10:56 -0400 Message-Id: <20190822191102.13732-4-josef@toxicpanda.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190822191102.13732-1-josef@toxicpanda.com> References: <20190822191102.13732-1-josef@toxicpanda.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org I noticed when folding the trace_btrfs_space_reservation() tracepoint into the btrfs_space_info_update_* helpers that we didn't emit a tracepoint when doing btrfs_add_reserved_bytes(). I know this is because we were swapping bytes_may_use for bytes_reserved, so in my mind there was no reason to have the tracepoint there. But now there is because we always emit the unreserve for the bytes_may_use side, and this would have broken if compression was on anyway. Add a tracepoint to cover the bytes_reserved counter so the math still comes out right. Signed-off-by: Josef Bacik Reviewed-by: David Sterba --- fs/btrfs/block-group.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 9867c5d98650..afae5c731904 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -2758,6 +2758,8 @@ int btrfs_add_reserved_bytes(struct btrfs_block_group_cache *cache, } else { cache->reserved += num_bytes; space_info->bytes_reserved += num_bytes; + trace_btrfs_space_reservation(cache->fs_info, "space_info", + space_info->flags, num_bytes, 1); btrfs_space_info_update_bytes_may_use(cache->fs_info, space_info, -ram_bytes); if (delalloc) From patchwork Thu Aug 22 19:10:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 11109839 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C438D1399 for ; Thu, 22 Aug 2019 19:11:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A3A7823400 for ; Thu, 22 Aug 2019 19:11:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="npXwjyyS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391554AbfHVTLO (ORCPT ); Thu, 22 Aug 2019 15:11:14 -0400 Received: from mail-yw1-f49.google.com ([209.85.161.49]:34545 "EHLO mail-yw1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387990AbfHVTLN (ORCPT ); Thu, 22 Aug 2019 15:11:13 -0400 Received: by mail-yw1-f49.google.com with SMTP id n126so2854499ywf.1 for ; Thu, 22 Aug 2019 12:11:13 -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:mime-version :content-transfer-encoding; bh=1TohfY64odoKuSpukVPpVWeT8cyz97ORIcTqA6NHK4M=; b=npXwjyySxH5tXY6phD6V92l80v/ZdllLL2sO25zQCX2Rl4QdzwssusizaddTOD3YT9 3ie8OFju7/1MsoAVEY/qVI9PJx0M+Puse9IkuhnvvPfMZNRpI/KSRlDo2BgTFIs4u7yU s4RudqxGThFp2m6QsWQWFaFD87e3etYDm15vZcoJkAVxL2WdUiY3zMPtZTbqR8c9Qoff 938rPoXsgSfuH74MdcwA227hoNbzYOejqijql7GRCVfiNXjTFu3GmWCmuneVquwRIPqe 2EEPupKQHkFmP+eclYfCchA9bVWvtAJ4qQHlNSHkh0rs1rEyPduYL0zgMiN582chkPVe WhEA== 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:mime-version:content-transfer-encoding; bh=1TohfY64odoKuSpukVPpVWeT8cyz97ORIcTqA6NHK4M=; b=Eg26oZA/mszbFW4rbpKd+y7yzjFr8fezBx1/JevNlK/KGUuLPeQfjFyKusvDZ6SozB 1NHNDEr0Y1kiCsXdpfjmGufMSceq05UFFQovSNQUDjl5adRbDx5536IpWl+eE+qttent 69qYRuJ/Knb12hI+njqJmJNe71L/u69loxIgrojcpVDh+tJzyToK9RwcloXYIs/AfEl9 cYbaDxkFMM/PL5H+0QMbEP301D0/vsG5OLRsma6PlKzDPoPTrvzXR5MEtoUK6yC20V5Y xwJgS6W7Z9PyZMV60Tdog9G8OeQwWCLQ3tcXFZ2QCey2KzSGZs9WCS/gtDS+kjDC4SRQ 4ZsQ== X-Gm-Message-State: APjAAAU3tz8dF3aJOdFdBQtKGX+uHforzpHduzUakRkWDRUSSK7+Fj9z kLnSY48diTC1/6dZdxMSO/TxRA== X-Google-Smtp-Source: APXvYqzmtZvSTkDZQBB2kcA3VL/E9w69syEd1QXyQ5FxDNrNn0RMGE4XyG08r94AYjRXOlI4hT1qyQ== X-Received: by 2002:a81:b308:: with SMTP id r8mr646481ywh.45.1566501072481; Thu, 22 Aug 2019 12:11:12 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id m40sm100187ywh.2.2019.08.22.12.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 12:11:11 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH 4/9] btrfs: rework btrfs_space_info_add_old_bytes Date: Thu, 22 Aug 2019 15:10:57 -0400 Message-Id: <20190822191102.13732-5-josef@toxicpanda.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190822191102.13732-1-josef@toxicpanda.com> References: <20190822191102.13732-1-josef@toxicpanda.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org If there are pending tickets and we are overcommitted we will simply return free'd reservations to space_info->bytes_may_use if we cannot overcommit any more. This is problematic because we assume any free space would have been added to the tickets, and so if we go from an overcommitted state to not overcommitted we could have plenty of space in our space_info but be unable to make progress on our tickets because we only refill tickets from previous reservations. Consider the following example. We were allowed to overcommit to space_info->total_bytes + 2mib. Now we've allocated all of our chunks and are no longer allowed to overcommit those extra 2mib. Assume there is a 3mib reservation we are now freeing. Because we can no longer overcommit we do not partially refill the ticket with the 3mib, instead we subtract it from space_info->bytes_may_use. Now the total reserved space is 1mib less than total_bytes, meaning we have 1mib of space we could reserve. Now assume that our ticket is 2mib, and we only have 1mib of space to reclaim, so we have a partial refilling to 1mib. We keep trying to flush and eventually give up and ENOSPC the ticket, when there was the remaining 1mib left in the space_info for usage. Instead of doing this partial filling of tickets dance we need to simply add our space to the space_info, and then do the normal check to see if we can satisfy the whole reservation. If we can then we wake up the ticket and carry on. This solves the above problem and makes it much more straightforward to understand how the tickets are satisfied. Signed-off-by: Josef Bacik --- fs/btrfs/space-info.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index a0a36d5768e1..357fe7548e07 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -233,52 +233,41 @@ void btrfs_space_info_add_old_bytes(struct btrfs_fs_info *fs_info, struct btrfs_space_info *space_info, u64 num_bytes) { - struct reserve_ticket *ticket; struct list_head *head; - u64 used; enum btrfs_reserve_flush_enum flush = BTRFS_RESERVE_NO_FLUSH; - bool check_overcommit = false; spin_lock(&space_info->lock); head = &space_info->priority_tickets; + btrfs_space_info_update_bytes_may_use(fs_info, space_info, -num_bytes); - /* - * If we are over our limit then we need to check and see if we can - * overcommit, and if we can't then we just need to free up our space - * and not satisfy any requests. - */ - used = btrfs_space_info_used(space_info, true); - if (used - num_bytes >= space_info->total_bytes) - check_overcommit = true; again: - while (!list_empty(head) && num_bytes) { - ticket = list_first_entry(head, struct reserve_ticket, - list); - /* - * We use 0 bytes because this space is already reserved, so - * adding the ticket space would be a double count. - */ - if (check_overcommit && - !can_overcommit(fs_info, space_info, 0, flush, false)) - break; - if (num_bytes >= ticket->bytes) { + while (!list_empty(head)) { + struct reserve_ticket *ticket; + u64 used = btrfs_space_info_used(space_info, true); + + ticket = list_first_entry(head, struct reserve_ticket, list); + + /* Check and see if our ticket can be satisified now. */ + if ((used + ticket->bytes <= space_info->total_bytes) || + can_overcommit(fs_info, space_info, ticket->bytes, flush, + false)) { + btrfs_space_info_update_bytes_may_use(fs_info, + space_info, + ticket->bytes); list_del_init(&ticket->list); - num_bytes -= ticket->bytes; ticket->bytes = 0; space_info->tickets_id++; wake_up(&ticket->wait); } else { - ticket->bytes -= num_bytes; - num_bytes = 0; + break; } } - if (num_bytes && head == &space_info->priority_tickets) { + if (head == &space_info->priority_tickets) { head = &space_info->tickets; flush = BTRFS_RESERVE_FLUSH_ALL; goto again; } - btrfs_space_info_update_bytes_may_use(fs_info, space_info, -num_bytes); spin_unlock(&space_info->lock); } From patchwork Thu Aug 22 19:10:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 11109841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 492A3174A for ; Thu, 22 Aug 2019 19:11:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1FD7823400 for ; Thu, 22 Aug 2019 19:11:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="qPgGcMNd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391556AbfHVTLP (ORCPT ); Thu, 22 Aug 2019 15:11:15 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:45807 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387990AbfHVTLP (ORCPT ); Thu, 22 Aug 2019 15:11:15 -0400 Received: by mail-qk1-f195.google.com with SMTP id m2so6112420qki.12 for ; Thu, 22 Aug 2019 12:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jo6UDQHALNv+EwzXafLqFqVdzqvJ+aDClaqqQOQU604=; b=qPgGcMNdVOT4HI4lMGOnYCw+m+e0OylmONBWOmWe9FqPd2nTzrn2kI5ANizpOrZp6k n6ArzDHgIXtj3cQh4QBZkSh0Xu37qR2VVZrEAWeWd3DAzszDvnyksckKGpniw8CCC92e Vq1KEtz0Efadou61Hc1aJhzJWVH8jKM8xMsoJv7UrMumOf9a039aExDYHIW2bpd7lS6o +8xBmypQEtARMdY5wZ/VNYplHCEeQryvBw/qqzmykw6mKBSj247BkvZ1i4t2DT+KvOtI rStYO9HTGQ08PRxlvxm7CyA44cU4LDWkiA5es9Y0y+R6dOUZb8kLoho0c9punM3spZHC v4qw== 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:mime-version:content-transfer-encoding; bh=jo6UDQHALNv+EwzXafLqFqVdzqvJ+aDClaqqQOQU604=; b=aVuxmLOnxd3GlZ92k5Me7lhE39Bzf3xj24Hw4OBVWcvZYsXToXBynSK2qkIgM+wCRC 3r5iQ8c6/Sx+4V7yyMCzjVdKRzxZfOgoJmNhRtPHq9SeExHw9CAUNm2z1W6lFNibRT7j s+mtZX+xQ2WULrMwAofbYf+4x0GK1JTg/DUqkrdDmhAsP2OxqMvzb4DBrRYUd7EF7uiN dVk1ieC1Cl2kJZVdRdG0iVyMagAHvc9smztuHxPQU1nmGnRzGtlPDR7l4zt5uigrOSnH VvofzxyqTXJh0m+Nwio/sJ/5Gn8I4HBDqKP12K+j+SqQrVBoqs+seAN6hFCEITEeUYTI naPA== X-Gm-Message-State: APjAAAUdV6XU3dRaZ/Xp/XUoizoa5CH+xVo/2dxYROUR+AvDBiN+rPbV YvU32RC5qaxdLT2TcCZUpbOgmA== X-Google-Smtp-Source: APXvYqzz5xXwqtxIUg7te0DQHCD8TZC20OnZWFx0/7DfydbABDI1v6u4IV14Gv4civzJoIwE7iJoRA== X-Received: by 2002:a37:4c4e:: with SMTP id z75mr512208qka.195.1566501074148; Thu, 22 Aug 2019 12:11:14 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id q28sm298260qtk.34.2019.08.22.12.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 12:11:13 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 5/9] btrfs: refactor the ticket wakeup code Date: Thu, 22 Aug 2019 15:10:58 -0400 Message-Id: <20190822191102.13732-6-josef@toxicpanda.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190822191102.13732-1-josef@toxicpanda.com> References: <20190822191102.13732-1-josef@toxicpanda.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that btrfs_space_info_add_old_bytes simply checks if we can make the reservation and updates bytes_may_use, there's no reason to have both helpers in place. Factor out the ticket wakeup logic into it's own helper, make btrfs_space_info_add_old_bytes() update bytes_may_use and then call the wakeup helper, and replace all calls to btrfs_space_info_add_new_bytes() with the wakeup helper. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/extent-tree.c | 4 +-- fs/btrfs/space-info.c | 55 ++++-------------------------------------- fs/btrfs/space-info.h | 19 ++++++++++----- 3 files changed, 20 insertions(+), 58 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 8c3e8fdbf2c1..2a56232309a3 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2866,8 +2866,8 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info, spin_unlock(&global_rsv->lock); /* Add to any tickets we may have */ if (len) - btrfs_space_info_add_new_bytes(fs_info, - space_info, len); + btrfs_try_granting_tickets(fs_info, + space_info); } spin_unlock(&space_info->lock); } diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index 357fe7548e07..c2143ddb7f4a 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -131,9 +131,7 @@ void btrfs_update_space_info(struct btrfs_fs_info *info, u64 flags, found->bytes_readonly += bytes_readonly; if (total_bytes > 0) found->full = 0; - btrfs_space_info_add_new_bytes(info, found, - total_bytes - bytes_used - - bytes_readonly); + btrfs_try_granting_tickets(info, found); spin_unlock(&found->lock); *space_info = found; } @@ -229,17 +227,15 @@ static int can_overcommit(struct btrfs_fs_info *fs_info, * This is for space we already have accounted in space_info->bytes_may_use, so * basically when we're returning space from block_rsv's. */ -void btrfs_space_info_add_old_bytes(struct btrfs_fs_info *fs_info, - struct btrfs_space_info *space_info, - u64 num_bytes) +void btrfs_try_granting_tickets(struct btrfs_fs_info *fs_info, + struct btrfs_space_info *space_info) { struct list_head *head; enum btrfs_reserve_flush_enum flush = BTRFS_RESERVE_NO_FLUSH; - spin_lock(&space_info->lock); - head = &space_info->priority_tickets; - btrfs_space_info_update_bytes_may_use(fs_info, space_info, -num_bytes); + lockdep_assert_held(&space_info->lock); + head = &space_info->priority_tickets; again: while (!list_empty(head)) { struct reserve_ticket *ticket; @@ -268,47 +264,6 @@ void btrfs_space_info_add_old_bytes(struct btrfs_fs_info *fs_info, flush = BTRFS_RESERVE_FLUSH_ALL; goto again; } - spin_unlock(&space_info->lock); -} - -/* - * This is for newly allocated space that isn't accounted in - * space_info->bytes_may_use yet. So if we allocate a chunk or unpin an extent - * we use this helper. - */ -void btrfs_space_info_add_new_bytes(struct btrfs_fs_info *fs_info, - struct btrfs_space_info *space_info, - u64 num_bytes) -{ - struct reserve_ticket *ticket; - struct list_head *head = &space_info->priority_tickets; - -again: - while (!list_empty(head) && num_bytes) { - ticket = list_first_entry(head, struct reserve_ticket, - list); - if (num_bytes >= ticket->bytes) { - list_del_init(&ticket->list); - num_bytes -= ticket->bytes; - btrfs_space_info_update_bytes_may_use(fs_info, - space_info, - ticket->bytes); - ticket->bytes = 0; - space_info->tickets_id++; - wake_up(&ticket->wait); - } else { - btrfs_space_info_update_bytes_may_use(fs_info, - space_info, - num_bytes); - ticket->bytes -= num_bytes; - num_bytes = 0; - } - } - - if (num_bytes && head == &space_info->priority_tickets) { - head = &space_info->tickets; - goto again; - } } #define DUMP_BLOCK_RSV(fs_info, rsv_name) \ diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h index 025f7ce2c9b1..0e805b5b1fca 100644 --- a/fs/btrfs/space-info.h +++ b/fs/btrfs/space-info.h @@ -110,12 +110,6 @@ btrfs_space_info_update_##name(struct btrfs_fs_info *fs_info, \ DECLARE_SPACE_INFO_UPDATE(bytes_may_use, "space_info"); DECLARE_SPACE_INFO_UPDATE(bytes_pinned, "pinned"); -void btrfs_space_info_add_new_bytes(struct btrfs_fs_info *fs_info, - struct btrfs_space_info *space_info, - u64 num_bytes); -void btrfs_space_info_add_old_bytes(struct btrfs_fs_info *fs_info, - struct btrfs_space_info *space_info, - u64 num_bytes); int btrfs_init_space_info(struct btrfs_fs_info *fs_info); void btrfs_update_space_info(struct btrfs_fs_info *info, u64 flags, u64 total_bytes, u64 bytes_used, @@ -133,5 +127,18 @@ int btrfs_reserve_metadata_bytes(struct btrfs_root *root, struct btrfs_block_rsv *block_rsv, u64 orig_bytes, enum btrfs_reserve_flush_enum flush); +void btrfs_try_granting_tickets(struct btrfs_fs_info *fs_info, + struct btrfs_space_info *space_info); + +static inline void +btrfs_space_info_add_old_bytes(struct btrfs_fs_info *fs_info, + struct btrfs_space_info *space_info, + u64 num_bytes) +{ + spin_lock(&space_info->lock); + btrfs_space_info_update_bytes_may_use(fs_info, space_info, -num_bytes); + btrfs_try_granting_tickets(fs_info, space_info); + spin_unlock(&space_info->lock); +} #endif /* BTRFS_SPACE_INFO_H */ From patchwork Thu Aug 22 19:10:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 11109843 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27F67174A for ; Thu, 22 Aug 2019 19:11:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0712D233FD for ; Thu, 22 Aug 2019 19:11:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="JhXGPGy2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391577AbfHVTLR (ORCPT ); Thu, 22 Aug 2019 15:11:17 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:36371 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387990AbfHVTLR (ORCPT ); Thu, 22 Aug 2019 15:11:17 -0400 Received: by mail-yw1-f66.google.com with SMTP id m11so2850845ywh.3 for ; Thu, 22 Aug 2019 12:11:16 -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:mime-version :content-transfer-encoding; bh=DFUWkxxV8j4WIwdU4nZnpBxKbZnkig1x1ot7uIbwXlI=; b=JhXGPGy2ajDskg3rYTXBan7ubsHQS3FckmC/tt9/h2SkqPKXiOCchphb7Y2dZV8GZC MHd0bsj3jtOgNWROWC5N+y7+c1S+eEKJdhewsNEeDHW3bzZHPiS9U/h3/im4GtAGgyn4 nxEBp4znixL/pAB7Y6IXWzDTu7CwJNf3cwUmNl7REVFPO44vws7RX85s9BstjTDEOwEW cmEJX4t5QKhjrHIcpjNj4PMk1ApwShl/Z7hcXESTEZ4WEvk4r3IpsiPNPzN73BAiwrOU 8d08CG2lvGb7Qb+pXqdXCDVolLAEzi26i3jkvHk3pJkIocQA/VCdxcOqiVjQw4maqO9x w2Bg== 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:mime-version:content-transfer-encoding; bh=DFUWkxxV8j4WIwdU4nZnpBxKbZnkig1x1ot7uIbwXlI=; b=bJi+4ODn3X6sYjDzrhGvzAIsCDm5fp58PkJbwbP2vmUabvH1j0KmYpTccaDqzj2ALj 7vnJblxJJ+LXZpSeokS5Evb5MMuYO+XHlrzPBnVZam0qBV7xfT6T6rhHqww1bgjkMfw9 FEQQl1VNxD62PjLOIZrMjizW+tJwbdBXczv63nyHkXB8vJSIEX+3BdAC/r0wO4PADJBu rpRumkTclQXB1JKww/LHKtp9z0gXPBuIL8Wz9glxzq5oNGNOdPQIhgiGrWs0zXKg1fv3 mmz4hWoPJqC2T7B8Rg7fWMZHUipxFfJriZ/GgAsSpSm+dnpT/k36JyfV3OBtilbd+tdo yH6w== X-Gm-Message-State: APjAAAV9Czx68xiIKQd4YJTAS70njeMCxLRLN4a6AcUTLD8uN3qJndHk 34RDT7qTZ2QcYP88HDPtYnYtpQ== X-Google-Smtp-Source: APXvYqxs4BUWegopHiRM4atVIZAS7i0zRvWCWcuxSu+Dxz6oUEKEhSgXiIEIxJD5N1t8R/52uoJy7w== X-Received: by 2002:a0d:d84c:: with SMTP id a73mr648425ywe.97.1566501075917; Thu, 22 Aug 2019 12:11:15 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id l4sm111529ywa.58.2019.08.22.12.11.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 12:11:15 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH 6/9] btrfs: rework wake_all_tickets Date: Thu, 22 Aug 2019 15:10:59 -0400 Message-Id: <20190822191102.13732-7-josef@toxicpanda.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190822191102.13732-1-josef@toxicpanda.com> References: <20190822191102.13732-1-josef@toxicpanda.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that we no longer partially fill tickets we need to rework wake_all_tickets to call btrfs_try_to_wakeup_tickets() in order to see if any subsequent tickets are able to be satisfied. If our tickets_id changes we know something happened and we can keep flushing. Also if we find a ticket that is smaller than the first ticket in our queue then we want to retry the flushing loop again in case may_commit_transaction() decides we could satisfy the ticket by committing the transaction. Rename this to maybe_fail_all_tickets() while we're at it, to better reflect what the function is actually doing. Signed-off-by: Josef Bacik --- fs/btrfs/space-info.c | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index c2143ddb7f4a..dd4adfa75a71 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -679,19 +679,46 @@ static inline int need_do_async_reclaim(struct btrfs_fs_info *fs_info, !test_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state)); } -static bool wake_all_tickets(struct list_head *head) +static bool maybe_fail_all_tickets(struct btrfs_fs_info *fs_info, + struct btrfs_space_info *space_info) { struct reserve_ticket *ticket; + u64 tickets_id = space_info->tickets_id; + u64 first_ticket_bytes = 0; + + while (!list_empty(&space_info->tickets) && + tickets_id == space_info->tickets_id) { + ticket = list_first_entry(&space_info->tickets, + struct reserve_ticket, list); + + /* + * may_commit_transaction will avoid committing the transaction + * if it doesn't feel like the space reclaimed by the commit + * would result in the ticket succeeding. However if we have a + * smaller ticket in the queue it may be small enough to be + * satisified by committing the transaction, so if any + * subsequent ticket is smaller than the first ticket go ahead + * and send us back for another loop through the enospc flushing + * code. + */ + if (first_ticket_bytes == 0) + first_ticket_bytes = ticket->bytes; + else if (first_ticket_bytes > ticket->bytes) + return true; - while (!list_empty(head)) { - ticket = list_first_entry(head, struct reserve_ticket, list); list_del_init(&ticket->list); ticket->error = -ENOSPC; wake_up(&ticket->wait); - if (ticket->bytes != ticket->orig_bytes) - return true; + + /* + * We're just throwing tickets away, so more flushing may not + * trip over btrfs_try_granting_tickets, so we need to call it + * here to see if we can make progress with the next ticket in + * the list. + */ + btrfs_try_granting_tickets(fs_info, space_info); } - return false; + return (tickets_id != space_info->tickets_id); } /* @@ -759,7 +786,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) if (flush_state > COMMIT_TRANS) { commit_cycles++; if (commit_cycles > 2) { - if (wake_all_tickets(&space_info->tickets)) { + if (maybe_fail_all_tickets(fs_info, space_info)) { flush_state = FLUSH_DELAYED_ITEMS_NR; commit_cycles--; } else { From patchwork Thu Aug 22 19:11:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 11109845 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B04581399 for ; Thu, 22 Aug 2019 19:11:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8EE20233FD for ; Thu, 22 Aug 2019 19:11:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="WCyZcyQ3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391595AbfHVTLS (ORCPT ); Thu, 22 Aug 2019 15:11:18 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:40984 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387990AbfHVTLS (ORCPT ); Thu, 22 Aug 2019 15:11:18 -0400 Received: by mail-yw1-f67.google.com with SMTP id i138so2837183ywg.8 for ; Thu, 22 Aug 2019 12:11:18 -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:mime-version :content-transfer-encoding; bh=we0y7S/ey++sSClxrOeO9dikgeZ30O9XVlCVkiwhijY=; b=WCyZcyQ3NP/CXCsfzkJU/BPR2aidTHEDjblgN8Qv10/tdEja93OEArD5UUvOEjyjjc RvCqW6kC+pTDjMHLcMVTpJKoqT1X3VwdCG5wGJg3M+56uIYqr227C+xNu4FkiyZhm+th ALnvHJY2RQJUTB2M6DLJX8Ol9Bl6EMcwjw6ueV5slk6HE0ELyX8qaUCk0EIozAcvmv4C eDA7VMfmyrXhav8Z2E6Xru47YNp00ZJAQ2fy28XBWb+ZZuzPWKHg7EUKMQTTG32xjTYp jmjgzX8A1FA5htyQ3LJ3md5N9STwDTjtBMrxAdfARu1OsrowfnLEm5NTAcN2zBU1dEYd RZCA== 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:mime-version:content-transfer-encoding; bh=we0y7S/ey++sSClxrOeO9dikgeZ30O9XVlCVkiwhijY=; b=ZXTne9Cn1BJ3KpgrghJCLgtpdSWq6OupxZgiYC5OwPiL3LmPY56/yMzle/EU9czh6n mUUva361RihKHDlNKRjKOIAIti+Ocgg56b7u9ZVmRYqLipBPRdAOBDi472jrWX64BXNO mWZl7H5bnf0vHBV1HhTgFyJxV8hbRk5tPLvigLPEdKhzB3/RLkg4hsG5P1FMWB4MuXHu ZErWRyLi2l+u6Nk4n+ErkbAUbZ3/6rmMHhKK9/O71vW3ozqqg8DjPPxJIfMMvttC6cc1 KT0ZN5Afj2HStcP30CXkoqWQChTDftdxE+wOeqPDTCl1ATrJzoWfaJlrXabUFJPpQmDk 9aTQ== X-Gm-Message-State: APjAAAUitZo7zDT2uX+uEk+bR/3EVRr/+0lFNZwqhNt0kN3TKM2UFp4i X1IT12+TZisS6XMpip8vyiIZXBGmm/mvUQ== X-Google-Smtp-Source: APXvYqyzjY5SvO4iQVYwpM/rRzF5iFnRQ/ZgYixW1YJnavnnOpXLabZv+VSzXGp2u3+V9QrNmKF1Ng== X-Received: by 2002:a81:3785:: with SMTP id e127mr683049ywa.242.1566501077640; Thu, 22 Aug 2019 12:11:17 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id 205sm111237ywd.26.2019.08.22.12.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 12:11:16 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH 7/9] btrfs: fix may_commit_transaction to deal with no partial filling Date: Thu, 22 Aug 2019 15:11:00 -0400 Message-Id: <20190822191102.13732-8-josef@toxicpanda.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190822191102.13732-1-josef@toxicpanda.com> References: <20190822191102.13732-1-josef@toxicpanda.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that we aren't partially filling tickets we may have some slack space left in the space_info. We need to account for this in may_commit_transaction, otherwise we may choose to not commit the transaction despite it actually having enough space to satisfy our ticket. Calculate the free space we have in the space_info, if any, and subtract this from the ticket we have and use that amount to determine if we will need to commit to reclaim enough space. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/space-info.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index dd4adfa75a71..cec6db0c41cc 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -473,12 +473,19 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, struct btrfs_trans_handle *trans; u64 bytes_needed; u64 reclaim_bytes = 0; + u64 cur_free_bytes = 0; trans = (struct btrfs_trans_handle *)current->journal_info; if (trans) return -EAGAIN; spin_lock(&space_info->lock); + cur_free_bytes = btrfs_space_info_used(space_info, true); + if (cur_free_bytes < space_info->total_bytes) + cur_free_bytes = space_info->total_bytes - cur_free_bytes; + else + cur_free_bytes = 0; + if (!list_empty(&space_info->priority_tickets)) ticket = list_first_entry(&space_info->priority_tickets, struct reserve_ticket, list); @@ -486,6 +493,11 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, ticket = list_first_entry(&space_info->tickets, struct reserve_ticket, list); bytes_needed = (ticket) ? ticket->bytes : 0; + + if (bytes_needed > cur_free_bytes) + bytes_needed -= cur_free_bytes; + else + bytes_needed = 0; spin_unlock(&space_info->lock); if (!bytes_needed) From patchwork Thu Aug 22 19:11:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 11109849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D8FE1399 for ; Thu, 22 Aug 2019 19:11:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B889233FD for ; Thu, 22 Aug 2019 19:11:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="nhvr64WN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391674AbfHVTLX (ORCPT ); Thu, 22 Aug 2019 15:11:23 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:41243 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387990AbfHVTLU (ORCPT ); Thu, 22 Aug 2019 15:11:20 -0400 Received: by mail-qk1-f193.google.com with SMTP id g17so6117874qkk.8 for ; Thu, 22 Aug 2019 12:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CWqO91MBMGp6m7eBB6gcnYr0fxdUY3GsTNytSY+/aqk=; b=nhvr64WNwQqzRExqlxK6d+cdlAKpEMQtJTqU1chyox55GGXDP7/ad0mbM7QUqkTb9+ Dkrq8Vy+D00uXD6/awsLDMbMQW7LmOnCyNp2SazVTvAA+6glNTn6YsZqFooQvsxojN1f HxDHpq1nA1yd2+kplaS2sProe/925uCj0eA5HGaMUWfmmoF+54eagdiosoRs6xIbJchE B5Ajv/d1+K1AI44uUrMpQ/55eHoJMmVlPVOUETLBHk5wqF/M9UjlZ6WXUxqIC28L0lPM r9QCkpZdWtz3MD5xqb618uj/qEU6X1PWoZ9HIep8AslPZHGJYd4Uqnwek3Im7neBla7h 2N/A== 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:mime-version:content-transfer-encoding; bh=CWqO91MBMGp6m7eBB6gcnYr0fxdUY3GsTNytSY+/aqk=; b=KQJFfg4qs7WUIFqESE69MXVVQ7jrgtTLLtkL/SzWbLbVvoXnNQ6FU5H4lcPRpa6SMD uXMF/o+y60FWmFHWVB4ya+82aCV+FQP9PWLt2+QVlYQKdMNGaSZKPb2EnADFbKAXTGy/ FWGJkkd4qQai1kr4RJdgni73vFW3KRwAeHVaz8qUX+RnOhRTcI5uxLsKylFkLXrigqv9 JO0kCdmu2VTQpamEIsiIENE4F4OcCOvKxLw4cD1cBYJhFyTWujcjSHsA8M5pcoiLbWAB h18JpKRawACJEOA6t1F5GRnJJhnhmwLJiJ0tP5e6GYxFXEtnMF/wEqi7djOBQo/Huujw Nzsg== X-Gm-Message-State: APjAAAV1ZeV9yCx7EWkF3mINOvmEgsa/IxURdftJz96RbKA9lzZrT4cT /bWK4trW7gMrdqpKhCoe6C8MxkttRQBv1A== X-Google-Smtp-Source: APXvYqzX8BjeyqCsTfMejaWziOY8ZWGNqvnKscrwOOJJo/K2+hfO5/pCA4D9qvAxJZ+rgq62/eRu1A== X-Received: by 2002:a37:a6cf:: with SMTP id p198mr523477qke.259.1566501079215; Thu, 22 Aug 2019 12:11:19 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id o18sm259940qtt.4.2019.08.22.12.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 12:11:18 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 8/9] btrfs: remove orig_bytes from reserve_ticket Date: Thu, 22 Aug 2019 15:11:01 -0400 Message-Id: <20190822191102.13732-9-josef@toxicpanda.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190822191102.13732-1-josef@toxicpanda.com> References: <20190822191102.13732-1-josef@toxicpanda.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that we do not do partial filling of tickets simply remove orig_bytes, it is no longer needed. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/space-info.c | 8 -------- fs/btrfs/space-info.h | 1 - 2 files changed, 9 deletions(-) diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index cec6db0c41cc..c5939c24c963 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -905,7 +905,6 @@ static int handle_reserve_ticket(struct btrfs_fs_info *fs_info, struct reserve_ticket *ticket, enum btrfs_reserve_flush_enum flush) { - u64 reclaim_bytes = 0; int ret; switch (flush) { @@ -930,17 +929,11 @@ static int handle_reserve_ticket(struct btrfs_fs_info *fs_info, spin_lock(&space_info->lock); ret = ticket->error; if (ticket->bytes || ticket->error) { - if (ticket->bytes < ticket->orig_bytes) - reclaim_bytes = ticket->orig_bytes - ticket->bytes; list_del_init(&ticket->list); if (!ret) ret = -ENOSPC; } spin_unlock(&space_info->lock); - - if (reclaim_bytes) - btrfs_space_info_add_old_bytes(fs_info, space_info, - reclaim_bytes); ASSERT(list_empty(&ticket->list)); return ret; } @@ -1000,7 +993,6 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, * the list and we will do our own flushing further down. */ if (ret && flush != BTRFS_RESERVE_NO_FLUSH) { - ticket.orig_bytes = orig_bytes; ticket.bytes = orig_bytes; ticket.error = 0; init_waitqueue_head(&ticket.wait); diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h index 0e805b5b1fca..d61550f06c94 100644 --- a/fs/btrfs/space-info.h +++ b/fs/btrfs/space-info.h @@ -70,7 +70,6 @@ struct btrfs_space_info { }; struct reserve_ticket { - u64 orig_bytes; u64 bytes; int error; struct list_head list; From patchwork Thu Aug 22 19:11:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 11109847 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A7DB174A for ; Thu, 22 Aug 2019 19:11:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4996C233FD for ; Thu, 22 Aug 2019 19:11:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="HBWnAYr4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391671AbfHVTLW (ORCPT ); Thu, 22 Aug 2019 15:11:22 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:42282 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391583AbfHVTLW (ORCPT ); Thu, 22 Aug 2019 15:11:22 -0400 Received: by mail-qt1-f193.google.com with SMTP id t12so8948055qtp.9 for ; Thu, 22 Aug 2019 12:11:21 -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:mime-version :content-transfer-encoding; bh=REZjaWdYz4cAnlPWw0OHqoelYEM3w54t+UYa94PyMJU=; b=HBWnAYr4IV/3krFvnBBw81RULBqkT2SvQ+8BNiH34+USmH1bOx9qLozhZe86gZHWwx v/8MvJLYM7Rlg5wJQZfQLUmhQgXtW+O3UDoUI4Zv8GsTTxJj2cYmo91QB7FbqS28qdS7 csinF4uLduCfbv/8y6/50c+LuPQC2zBtSBTyqPSNgKQg+THeieXtGeY3Gy+1AO4o1tuu 6jYs5c0OnUctvnfsfs+m+I7kq8QRlMdRPhGC6oZQ2Q9KaAkfvS4kU2kXdFzvJIzNaivh 56pLr908nvl8D4/kcHCUA00jZmAqLbKvc+vYTGZQ8oPTS7lv7Ba4zw5BpN6fw0U1Aehr /Kvg== 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:mime-version:content-transfer-encoding; bh=REZjaWdYz4cAnlPWw0OHqoelYEM3w54t+UYa94PyMJU=; b=tNnYSrZoJkz5kkCL1toOTJpwUkca24LOpRJzBqjeUEq5ySN3p8seUNCwPd7muKABf+ 9PZb/8H5W2MKL36d37tHGbpTnMdRMDFBLR2fVpjz4zSmL0JG44amCZ0jgFomwy3LXfIg W2h/ZXDB14xIx9EXT09kQ7aJN+Rndcpv0vVWhH/0yCo+VZNXv5Z341icjfPwDBByPXDW D5+yh2HIujAG6MrCg9nR1Mo+5M3C9N73Qar85sjOKUrhOALMe9imqyOUGeX473mtkTpp GRHs3tKOSwGccSn/Z3B0x2FgOOmKbCLxLRDNTFwAxYxWtY9hmvBpJrROOnvN38eA0QKq e3Jg== X-Gm-Message-State: APjAAAUQgGIdb3sX6FGElywX6yfpWmA2bbeqNBLr18jUXV9AM3+xmAfn 1lOR76yPfuxh2Q3iPpB26x8/ZA== X-Google-Smtp-Source: APXvYqyAs2FxLMExcQ08YfmuYyTKuyPhGIzvHBStgesb3Bxd0ZGNyWHYfV+4nu30YH2FhUpKqPzYTg== X-Received: by 2002:ad4:41c2:: with SMTP id a2mr852442qvq.224.1566501080856; Thu, 22 Aug 2019 12:11:20 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id z1sm338160qkg.103.2019.08.22.12.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 12:11:20 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH 9/9] btrfs: rename btrfs_space_info_add_old_bytes Date: Thu, 22 Aug 2019 15:11:02 -0400 Message-Id: <20190822191102.13732-10-josef@toxicpanda.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190822191102.13732-1-josef@toxicpanda.com> References: <20190822191102.13732-1-josef@toxicpanda.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This name doesn't really fit with how the space reservation stuff works now, rename it to btrfs_space_info_free_bytes_may_use so it's clear what the function is doing. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/block-rsv.c | 5 +++-- fs/btrfs/delayed-ref.c | 2 +- fs/btrfs/space-info.h | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c index c64b460a4301..60f313888a7d 100644 --- a/fs/btrfs/block-rsv.c +++ b/fs/btrfs/block-rsv.c @@ -54,8 +54,9 @@ static u64 block_rsv_release_bytes(struct btrfs_fs_info *fs_info, spin_unlock(&dest->lock); } if (num_bytes) - btrfs_space_info_add_old_bytes(fs_info, space_info, - num_bytes); + btrfs_space_info_free_bytes_may_use(fs_info, + space_info, + num_bytes); } if (qgroup_to_release_ret) *qgroup_to_release_ret = qgroup_to_release; diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 9a91d1eb0af4..3822edbf54a7 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -158,7 +158,7 @@ void btrfs_migrate_to_delayed_refs_rsv(struct btrfs_fs_info *fs_info, trace_btrfs_space_reservation(fs_info, "delayed_refs_rsv", 0, num_bytes, 1); if (to_free) - btrfs_space_info_add_old_bytes(fs_info, + btrfs_space_info_free_bytes_may_use(fs_info, delayed_refs_rsv->space_info, to_free); } diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h index d61550f06c94..c93fe9808dc0 100644 --- a/fs/btrfs/space-info.h +++ b/fs/btrfs/space-info.h @@ -130,9 +130,9 @@ void btrfs_try_granting_tickets(struct btrfs_fs_info *fs_info, struct btrfs_space_info *space_info); static inline void -btrfs_space_info_add_old_bytes(struct btrfs_fs_info *fs_info, - struct btrfs_space_info *space_info, - u64 num_bytes) +btrfs_space_info_free_bytes_may_use(struct btrfs_fs_info *fs_info, + struct btrfs_space_info *space_info, + u64 num_bytes) { spin_lock(&space_info->lock); btrfs_space_info_update_bytes_may_use(fs_info, space_info, -num_bytes);