linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 0/2] btrfs: reduce the width of devices counter
Date: Tue, 19 Sep 2023 11:51:21 +0930	[thread overview]
Message-ID: <cover.1695089790.git.wqu@suse.com> (raw)

Currently btrfs_super_block::num_devices is u64, thus all of our
internal devices counters are also u64.

But the truth is, it's really impractical to have that many devices, one
of two dozens of devices may be the upper limit in the real world.

In fact we already have a sanity check for
btrfs_super_block::num_devices, if the value is beyond 1<<31, we would
consider it insane and reject the superblock.

Now let's go a step further, by reducing the limit to U16_MAX (65536),
and with that change, we can also reduce the width from 64 to 16 for all
our internal devices counters.
(superblock num_devices still stay u64 though).

Such reduce would slightly reduce the memory usage per-btrfs.

Also with the new device number limit, the 2nd patch would do extra
device number check to avoid overflow u16.

Qu Wenruo (2):
  btrfs: reject a superblock with over 65536 devices
  btrfs: reduce the width of device counters

 fs/btrfs/dev-replace.c |  9 +++++++++
 fs/btrfs/disk-io.c     |  3 ++-
 fs/btrfs/volumes.c     | 11 ++++++++++-
 fs/btrfs/volumes.h     | 12 ++++++------
 4 files changed, 27 insertions(+), 8 deletions(-)

-- 
2.42.0


             reply	other threads:[~2023-09-19  2:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19  2:21 Qu Wenruo [this message]
2023-09-19  2:21 ` [PATCH 1/2] btrfs: reject a superblock with over 65536 devices Qu Wenruo
2023-09-19  2:21 ` [PATCH 2/2] btrfs: reduce the width of device counters Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1695089790.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).