^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) dm-stripe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) Device-Mapper's "striped" target is used to create a striped (i.e. RAID-0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) device across one or more underlying devices. Data is written in "chunks",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) with consecutive chunks rotating among the underlying devices. This can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) potentially provide improved I/O throughput by utilizing several physical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) devices in parallel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) Parameters: <num devs> <chunk size> [<dev path> <offset>]+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) <num devs>:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) Number of underlying devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) <chunk size>:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Size of each chunk of data. Must be at least as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) large as the system's PAGE_SIZE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) <dev path>:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) Full pathname to the underlying block-device, or a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) "major:minor" device-number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) <offset>:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) Starting sector within the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) One or more underlying devices can be specified. The striped device size must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) be a multiple of the chunk size multiplied by the number of underlying devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) Example scripts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #!/usr/bin/perl -w
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) # Create a striped device across any number of underlying devices. The device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) # will be called "stripe_dev" and have a chunk-size of 128k.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) my $chunk_size = 128 * 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) my $dev_name = "stripe_dev";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) my $num_devs = @ARGV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) my @devs = @ARGV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) my ($min_dev_size, $stripe_dev_size, $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) if (!$num_devs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) die("Specify at least one device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) $min_dev_size = `blockdev --getsz $devs[0]`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) for ($i = 1; $i < $num_devs; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) my $this_size = `blockdev --getsz $devs[$i]`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) $min_dev_size = ($min_dev_size < $this_size) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) $min_dev_size : $this_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) $stripe_dev_size = $min_dev_size * $num_devs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) $stripe_dev_size -= $stripe_dev_size % ($chunk_size * $num_devs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) $table = "0 $stripe_dev_size striped $num_devs $chunk_size";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) for ($i = 0; $i < $num_devs; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) $table .= " $devs[$i] 0";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) `echo $table | dmsetup create $dev_name`;