Skip to content

Commit 127186c

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: reintroduce md-linear
THe md-linear is removed by commit 849d18e ("md: Remove deprecated CONFIG_MD_LINEAR") because it has been marked as deprecated for a long time. However, md-linear is used widely for underlying disks with different size, sadly we didn't know this until now, and it's true useful to create partitions and assemble multiple raid and then append one to the other. People have to use dm-linear in this case now, however, they will prefer to minimize the number of involved modules. Fixes: 849d18e ("md: Remove deprecated CONFIG_MD_LINEAR") Cc: stable@vger.kernel.org Signed-off-by: Yu Kuai <yukuai3@huawei.com> Acked-by: Coly Li <colyli@kernel.org> Acked-by: Mike Snitzer <snitzer@kernel.org> Link: https://lore.kernel.org/r/20250102112841.1227111-1-yukuai1@huaweicloud.com Signed-off-by: Song Liu <song@kernel.org>
1 parent e494e45 commit 127186c

File tree

7 files changed

+379
-4
lines changed

7 files changed

+379
-4
lines changed

drivers/md/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ config MD_BITMAP_FILE
6161
various kernel APIs and can only work with files on a file system not
6262
actually sitting on the MD device.
6363

64+
config MD_LINEAR
65+
tristate "Linear (append) mode"
66+
depends on BLK_DEV_MD
67+
help
68+
If you say Y here, then your multiple devices driver will be able to
69+
use the so-called linear mode, i.e. it will combine the hard disk
70+
partitions by simply appending one to the other.
71+
72+
To compile this as a module, choose M here: the module
73+
will be called linear.
74+
75+
If unsure, say Y.
76+
6477
config MD_RAID0
6578
tristate "RAID-0 (striping) mode"
6679
depends on BLK_DEV_MD

drivers/md/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ dm-zoned-y += dm-zoned-target.o dm-zoned-metadata.o dm-zoned-reclaim.o
2929

3030
md-mod-y += md.o md-bitmap.o
3131
raid456-y += raid5.o raid5-cache.o raid5-ppl.o
32+
linear-y += md-linear.o
3233

3334
# Note: link order is important. All raid personalities
3435
# and must come before md.o, as they each initialise
3536
# themselves, and md.o may use the personalities when it
3637
# auto-initialised.
3738

39+
obj-$(CONFIG_MD_LINEAR) += linear.o
3840
obj-$(CONFIG_MD_RAID0) += raid0.o
3941
obj-$(CONFIG_MD_RAID1) += raid1.o
4042
obj-$(CONFIG_MD_RAID10) += raid10.o

drivers/md/md-autodetect.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static int md_setup_ents __initdata;
4949
* instead of just one. -- KTK
5050
* 18May2000: Added support for persistent-superblock arrays:
5151
* md=n,0,factor,fault,device-list uses RAID0 for device n
52+
* md=n,-1,factor,fault,device-list uses LINEAR for device n
5253
* md=n,device-list reads a RAID superblock from the devices
5354
* elements in device-list are read by name_to_kdev_t so can be
5455
* a hex number or something like /dev/hda1 /dev/sdb
@@ -87,15 +88,18 @@ static int __init md_setup(char *str)
8788
md_setup_ents++;
8889
switch (get_option(&str, &level)) { /* RAID level */
8990
case 2: /* could be 0 or -1.. */
90-
if (level == 0) {
91+
if (level == 0 || level == LEVEL_LINEAR) {
9192
if (get_option(&str, &factor) != 2 || /* Chunk Size */
9293
get_option(&str, &fault) != 2) {
9394
printk(KERN_WARNING "md: Too few arguments supplied to md=.\n");
9495
return 0;
9596
}
9697
md_setup_args[ent].level = level;
9798
md_setup_args[ent].chunk = 1 << (factor+12);
98-
pername = "raid0";
99+
if (level == LEVEL_LINEAR)
100+
pername = "linear";
101+
else
102+
pername = "raid0";
99103
break;
100104
}
101105
fallthrough;

0 commit comments

Comments
 (0)