Re: [RFC PATCH 4/5] md: introduce MAX_RAID_DISKS macro to replace magic number
Zheng Qixing <[email protected]>
| Newsgroups | gmane.linux.raid,gmane.linux.kernel |
|---|---|
| Message-ID | <[email protected]> |
在 2026/1/1 2:00, John Stoffel 写道:
>> #define MaxSector (~(sector_t)0)
>> +#define MAX_RAID_DISKS ((4096-256)/2)
> Looks fine to me, except there's no explanation for the magic numbers
> here. Sure, it's 1916 devices max, but WHY? Other than that nit,
> looks fine.
>
In include/uapi/linux/raid/md_p.h :
/*
* The version-1 superblock :
* All numeric fields are little-endian.
*
* total size: 256 bytes plus 2 per device.
* 1K allows 384 devices.
*/
struct mdp_superblock_1 {
1.x superblock:
Per-device state is stored as a __u16 dev_roles[] array (2 bytes per
device) plus a fixed 256-byte header, still within a 4 KiB superblock.
Therefore the theoretical maximum is (4096 - 256) / 2 = 1920 entries.
0.90 superblock (27 devices):
The superblock is fixed at 4 KiB (1024 32-bit words). It must store
several fixed sections (generic + personality) and also reserves space
for one “this_disk” descriptor in addition to the per-member disks[]
table. Each member descriptor consumes 32 words = 128 bytes. After
accounting for the fixed sections and the extra descriptor, the
remaining space fits exactly 27 member descriptors.
Best regards,
Qixing