From patchwork Wed Sep 27 17:46:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13401466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE697E82CBC for ; Wed, 27 Sep 2023 17:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229608AbjI0RrP (ORCPT ); Wed, 27 Sep 2023 13:47:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjI0RrO (ORCPT ); Wed, 27 Sep 2023 13:47:14 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA8EAA1 for ; Wed, 27 Sep 2023 10:47:11 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-77432add7caso439875585a.2 for ; Wed, 27 Sep 2023 10:47:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1695836830; x=1696441630; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vxznYvzA02PDJe2TFNGF+HSeHbWxqcrgvzF+MJ0KmRk=; b=mS0a8MCchNj3T8TPYRy4BYhaHsvyzGZVaR80upwrYuDrg+q4y3juTs1XoKu56IafMs ao3QhIEwm8Kjn8de/kKQpOJwN02sQ/7P9wMg8ii2irblzk1CB3QdUwP0t86LVonDVL9O rvNNABVltP6rLzZy/c+36tcr9NpD8yHh7DZVyKeURn8eivF4qqEFwXZ+WECLfTG1aruw RjqnKp7AIvTReepljMdshjUKOZKk6LBTzYhiajTTYeINUxWLmF6gLmUiphwnh0RF21nV 1ewI3QUWZ11FITt1zQHCWjM1soGsV/MmOM52DnfnFS4/P0ASVGUOxO57Bc5rNkA8F90o x/tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695836830; x=1696441630; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vxznYvzA02PDJe2TFNGF+HSeHbWxqcrgvzF+MJ0KmRk=; b=r2xsQ8KAZsn5+34teLn8fltbxph9qtnBTlOWBdxETLzDIs7x5slrtWFxmuIVMPAjeY /vpLUYt1Nk4WlJ3kTRRt6lf0NYzsyhg8PCjzY29/NheiOteWhuFpntdfeCjUIuwr6GSs 5mUGfXkkeLdTM1h7AB7b0Ie20/86UEyhB09yJyvrCqyC3eNbzZmpgbeqDCjmMNdL5PiY TM+5quzEzXME2G/4KI52PheVKb2Yuy0EJBFyzewkVfWXHElxqDq0omYoRvq7EO+lCW6y r7xkSFF7RM2Z2LAcf+mVTTJ/ebs4TH5O8jFyN0OCCMiOx37QaW7Iv7Q3y81a63hqvQJA 0fKg== X-Gm-Message-State: AOJu0Yzlda7+tlCFeqd8ep5H9pS8kNkS2+u8/ec/QKO0okb1aEFSCteu P+SgB/vBgapOMbyL9OYlBGHD87L9pZfeFvkYUEK4lg== X-Google-Smtp-Source: AGHT+IE8kJ3E1I6liSMwfBsZFq5HHqYjHeFmlh17n8LgocnT12oRQBUXQ1dZuEOw2fHQ+df/gjCvRQ== X-Received: by 2002:a0c:f30a:0:b0:65b:259f:d6a9 with SMTP id j10-20020a0cf30a000000b0065b259fd6a9mr2924787qvl.7.1695836830574; Wed, 27 Sep 2023 10:47:10 -0700 (PDT) Received: from localhost (cpe-76-182-20-124.nc.res.rr.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id m17-20020a0cdb91000000b0065d04135014sm358443qvk.13.2023.09.27.10.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:47:10 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 1/3] btrfs: fix ->free_chunk_space math in btrfs_shrink_device Date: Wed, 27 Sep 2023 13:46:59 -0400 Message-ID: <1c153ebd18861caaac06d1b30b41483f33b360b7.1695836511.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org There's two bugs in how we adjust ->free_chunk_space in btrfs_shrink_device. First we're removing the entire diff between new_size and old_size from ->free_chunk_space. This only works if we're reducing the free area, which we could potentially not be. So adjust the math to only subtract the diff in the free space from ->free_chunk_space. Additionally in the error case we're unconditionally adding the diff back into ->free_chunk_space, which we need to only do if this device is writeable. Signed-off-by: Josef Bacik --- fs/btrfs/volumes.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 733842136163..907ea775f4e4 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4841,6 +4841,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size) u64 old_size = btrfs_device_get_total_bytes(device); u64 diff; u64 start; + u64 free_diff = 0; new_size = round_down(new_size, fs_info->sectorsize); start = new_size; @@ -4866,7 +4867,19 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size) btrfs_device_set_total_bytes(device, new_size); if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) { device->fs_devices->total_rw_bytes -= diff; - atomic64_sub(diff, &fs_info->free_chunk_space); + + /* + * The new free_chunk_space is new_size - used, so we have to + * subtract the delta of the old free_chunk_space which included + * old_size - used. If used > new_size then just subtract this + * entire device's free space. + */ + if (device->bytes_used < new_size) + free_diff = (old_size - device->bytes_used) - + (new_size - device->bytes_used); + else + free_diff = old_size - device->bytes_used; + atomic64_sub(free_diff, &fs_info->free_chunk_space); } /* @@ -5001,9 +5014,10 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size) if (ret) { mutex_lock(&fs_info->chunk_mutex); btrfs_device_set_total_bytes(device, old_size); - if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) + if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) { device->fs_devices->total_rw_bytes += diff; - atomic64_add(diff, &fs_info->free_chunk_space); + atomic64_add(free_diff, &fs_info->free_chunk_space); + } mutex_unlock(&fs_info->chunk_mutex); } return ret; From patchwork Wed Sep 27 17:47:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13401465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4096DE82CA1 for ; Wed, 27 Sep 2023 17:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbjI0RrO (ORCPT ); Wed, 27 Sep 2023 13:47:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229593AbjI0RrN (ORCPT ); Wed, 27 Sep 2023 13:47:13 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD30FEB for ; Wed, 27 Sep 2023 10:47:12 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-7740c8509c8so699808585a.3 for ; Wed, 27 Sep 2023 10:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1695836832; x=1696441632; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=x/vuMoLckYaeutabTNUQ3SzvUz8X85Zc7zWQhmqXj8k=; b=gdjyqRB9P82jdOhCbPQOWZlwANwzP4WNgcsEg4al+pWc9eb6KWfsA92754s8oS9IM2 kdWW8VW7OeXwWcpzSgmoiTD1HahfXyNB0QvnlODhUmGipspiNiGg3EMaiEylmM/Y7ZtT mT0Fu7pv3EqDop+s3xSgcABu4+PRJ6gaXIWl792/349YSwrmwxqTk3u1ucA8hZ8tLYaK PW9A25CCUhlsbt9Ob7ReUR1GjFPPfaOYqj++AeZ5ikcUzgqzyGnHzsjbYV+065bsPULl SdYMChv5bFdZTv2mIXg22gTxQnEm3VY3taV9p3LHk989CTUacS+00g70DRm7dNDZUpjt s55w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695836832; x=1696441632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x/vuMoLckYaeutabTNUQ3SzvUz8X85Zc7zWQhmqXj8k=; b=NifjoNMfvGopMlnnklrDlBy5acEWZMp4PNJnF2iG73/e9pEYZlKHQR7OHcxoDP/ybe rQe3WyVfp+QvCQp4++bkELmNAnZBCaaEQ4y2w0fQ0pO5mogXgNdVKtgvZLM2FZktFB34 nCpSOFejCOwMUgNtlGQHoXrGFvB5bVq7c3BZQhXC5AWN5gHe76K781vLhz4j/IK5Glv1 jAzShjx1GVixTFityzkcxI0VErvqKbD6pBFiQZaAURXNbKyUwOLCiqJC1OS7EJcRBj1I pveYwZsRCR/Tgky1iXYzkc/cW3J0GZ85d276LY3lgTxviCid11x+q3iqVy58zK5iD9gp fh1Q== X-Gm-Message-State: AOJu0YxHTyHvih/Nw0PBS3jj3zPsdNNMohTGMIdwgV2K5OM5cxFaNDss G/3TF7TPFJKM9QROgtx06k+A11t5G1hcD1PJd/olcw== X-Google-Smtp-Source: AGHT+IFy8zPIntKD4PPb5uR9p+IikxxXZ/rGi0AqZqSQQKYqcK/7nPC//tB6dC89huVduar7hWHxNQ== X-Received: by 2002:a05:620a:7f0:b0:774:15ea:55f with SMTP id k16-20020a05620a07f000b0077415ea055fmr2150817qkk.77.1695836831737; Wed, 27 Sep 2023 10:47:11 -0700 (PDT) Received: from localhost (cpe-76-182-20-124.nc.res.rr.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id m14-20020ae9e00e000000b007742ad3047asm3304264qkk.54.2023.09.27.10.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:47:11 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 2/3] btrfs: increase ->free_chunk_space in btrfs_grow_device Date: Wed, 27 Sep 2023 13:47:00 -0400 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org My overcommit patch exposed a bug with btrfs/177. The problem here is that when we grow the device we're not adding to ->free_chunk_space, so subsequent allocations can cause ->free_chunk_space to wrap, which causes problems in can_overcommit because we add this to ->total_bytes, which causes the counter to wrap and gives us an unexpected ENOSPC. Fix this by properly updating ->free_chunk_space with the new available space in btrfs_grow_device. Signed-off-by: Josef Bacik --- fs/btrfs/volumes.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 907ea775f4e4..1aedd15d1db7 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2932,6 +2932,7 @@ int btrfs_grow_device(struct btrfs_trans_handle *trans, btrfs_set_super_total_bytes(super_copy, round_down(old_total + diff, fs_info->sectorsize)); device->fs_devices->total_rw_bytes += diff; + atomic64_add(diff, &fs_info->free_chunk_space); btrfs_device_set_total_bytes(device, new_size); btrfs_device_set_disk_total_bytes(device, new_size); From patchwork Wed Sep 27 17:47:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13401467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1170AE82CBB for ; Wed, 27 Sep 2023 17:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbjI0RrQ (ORCPT ); Wed, 27 Sep 2023 13:47:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjI0RrP (ORCPT ); Wed, 27 Sep 2023 13:47:15 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42960A1 for ; Wed, 27 Sep 2023 10:47:14 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-418148607c2so38188801cf.3 for ; Wed, 27 Sep 2023 10:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1695836833; x=1696441633; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9XawQw8pM4FCGlnKBQnr/sTgSHhTznWGJtzSsWCZMhc=; b=S9GstarF2MLP240iCW0nYnj8IbkdmIFjqFqXgNAdMwGJAEYtQkOU0Q16pEaBOuhz5S fFsqfOTuRUauwQhZccHxxtx5WaNy56F+1eI77sR0aaGIPZXIaRq8QlbovzWg/hYEYxLc NbpfeoAEn/pAih8bzZl7BsxqYAntN+8Oot0nrtoeMv2CjxeX2V5jn6iI92x/k4KUKasb 21cNwReytvAx5TKoEAZDQYdw9RZ6W5/SJnJlnamFMABZPAHX+3anj1IqztkwCP3ocbz0 naAytKvvUgjkpURJ9MuhsInNtKuPJo6PjaN8VHRv65pW2/izuUCJpBPZD6ud4ILuTeQh byRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695836833; x=1696441633; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9XawQw8pM4FCGlnKBQnr/sTgSHhTznWGJtzSsWCZMhc=; b=euvOpUGigzc3B/W187Ntu1gmJS7Ti0HmVricroLAXA4l9phCMUb1Rw2z8i+EGdO7YJ fkTuScLL1JtPT0Gex6aisCXylNFCCOrdYA3wZBgDZkiI/6fDj3MgIUsDDFXYRkhZ5hHb aJtDv67YN0vreRYIt/HxkgF2xTzNc6E+ojhP4aUBxcPmr/c+IRjXYPot75tVqwbjc1Yz uA9AAgmcTwGQ8AZ43vgv+kiRDbvNA78Fk9BYFJWin5yB0blFQirk6s5mzkDFnAfVEwMR ngTtkJeCz8bJ1UtD18DqMGu8glWGweYawwAPwjI+xxuiEftBJ2RGY70IViPQ6PEyejb0 IBPg== X-Gm-Message-State: AOJu0YzDO8eIbpUFqn/5QrXQVlkcU6QZSodMPvj5Jq78Vxo0Xp3Z/GmO gCxICI9LeJ04LwpUjK4jJG2acHYc6WLkTHUfzv0Pgw== X-Google-Smtp-Source: AGHT+IH5w6EdHJsA9DN6GTm2XcI8RVpVJC86QkrorSORMBBp6/1SdTA99XjKGjyBWrV46Zi9HoTEeA== X-Received: by 2002:a05:622a:551:b0:417:d600:115d with SMTP id m17-20020a05622a055100b00417d600115dmr3000060qtx.66.1695836833120; Wed, 27 Sep 2023 10:47:13 -0700 (PDT) Received: from localhost (cpe-76-182-20-124.nc.res.rr.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id j4-20020ac84c84000000b004195b8554efsm705650qtv.24.2023.09.27.10.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:47:12 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 3/3] btrfs: adjust overcommit logic when very close to full Date: Wed, 27 Sep 2023 13:47:01 -0400 Message-ID: <4f76978ee26b73ecadd24a6cc7aab6187f35adf4.1695836511.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org A user reported some unpleasant behavior with very small file systems. The reproducer is this mkfs.btrfs -f -m single -b 8g /dev/vdb mount /dev/vdb /mnt/test dd if=/dev/zero of=/mnt/test/testfile bs=512M count=20 This will result in usage that looks like this Overall: Device size: 8.00GiB Device allocated: 8.00GiB Device unallocated: 1.00MiB Device missing: 0.00B Device slack: 2.00GiB Used: 5.47GiB Free (estimated): 2.52GiB (min: 2.52GiB) Free (statfs, df): 0.00B Data ratio: 1.00 Metadata ratio: 1.00 Global reserve: 5.50MiB (used: 0.00B) Multiple profiles: no Data,single: Size:7.99GiB, Used:5.46GiB (68.41%) /dev/vdb 7.99GiB Metadata,single: Size:8.00MiB, Used:5.77MiB (72.07%) /dev/vdb 8.00MiB System,single: Size:4.00MiB, Used:16.00KiB (0.39%) /dev/vdb 4.00MiB Unallocated: /dev/vdb 1.00MiB As you can see we've gotten ourselves quite full with metadata, with all of the disk being allocated for data. On smaller file systems there's not a lot of time before we get full, so our overcommit behavior bites us here. Generally speaking data reservations result in chunk allocations as we assume reservation == actual use for data. This means at any point we could end up with a chunk allocation for data, and if we're very close to full we could do this before we have a chance to figure out that we need another metadata chunk. Address this by adjusting the overcommit logic. Simply put we need to take away 1 chunk from the available chunk space in case of a data reservation. This will allow us to stop overcommitting before we potentially lose this space to a data allocation. With this fix in place we properly allocate a metadata chunk before we're completely full, allowing for enough slack space in metadata. Signed-off-by: Josef Bacik --- fs/btrfs/space-info.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index d7e8cd4f140c..f1cc3ea4553c 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -345,8 +345,10 @@ static u64 calc_available_free_space(struct btrfs_fs_info *fs_info, struct btrfs_space_info *space_info, enum btrfs_reserve_flush_enum flush) { + struct btrfs_space_info *data_sinfo; u64 profile; u64 avail; + u64 data_chunk_size; int factor; if (space_info->flags & BTRFS_BLOCK_GROUP_SYSTEM) @@ -364,6 +366,36 @@ static u64 calc_available_free_space(struct btrfs_fs_info *fs_info, */ factor = btrfs_bg_type_to_factor(profile); avail = div_u64(avail, factor); + if (avail == 0) + return 0; + + /* + * Calculate the data_chunk_size, space_info->chunk_size is the + * "optimal" chunk size based on the fs size. However when we actually + * allocate the chunk we will strip this down further, making it no more + * than 10% of the disk or 1G, whichever is smaller. + */ + data_sinfo = btrfs_find_space_info(fs_info, BTRFS_BLOCK_GROUP_DATA); + data_chunk_size = min(data_sinfo->chunk_size, + mult_perc(fs_info->fs_devices->total_rw_bytes, 10)); + data_chunk_size = min_t(u64, data_chunk_size, SZ_1G); + + /* + * Since data allocations immediately use block groups as part of the + * reservation, because we assume that data reservations will == actual + * usage, we could potentially overcommit and then immediately have that + * available space used by a data allocation, which could put us in a + * bind when we get close to filling the file system. + * + * To handle this simply remove the data_chunk_size from the available + * space. If we are relatively empty this won't affect our ability to + * overcommit much, and if we're very close to full it'll keep us from + * getting into a position where we've given ourselves very little + * metadata wiggle room. + */ + if (avail <= data_chunk_size) + return 0; + avail -= data_chunk_size; /* * If we aren't flushing all things, let us overcommit up to