Skip to content

btrfs: reduce the width of devices counter

Qu Wenruo linux-btrfs 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2btrfs: reject a superblock with over 65536 devicesfs/btrfs/disk-io.c+2 -10 replies
2/2btrfs: reduce the width of device countersfs/btrfs/dev-replace.c fs/btrfs/volumes.c fs/btrfs/volumes.h+25 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] btrfs: reduce the width of devices counter

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(-)
Signature · 1 line
2.42.0