当设备大小不同时,RAID0 在底层如何工作?

hbo*_*ert 17 software-raid mdadm raid0

令我惊讶的是,CentOS 7 安装程序允许我创建一个 RAID0 设备,其中包含大约 17 GB 磁盘和 26 GB 磁盘。我预计即使允许,逻辑大小也将是2 * min(17 GB, 26 GB) ~= 34 GB. 但我确实可以在文件系统级别看到 44 GB 的可用大小:

$ cat /sys/block/md127/md/dev*/size
16955392
26195968
$ df -h |grep md
/dev/md127   44G 1.9G 40G 5% /
Run Code Online (Sandbox Code Playgroud)

与磁盘相同的情况相比,md 子系统的性能表现如何?因为不可能在 2 个磁盘上进行简单的平衡条带化。

ilk*_*chu 26

raid.wiki.kernel.org说:

\n
\n

RAID0/条带模式:设备应该(但不必)具有相同的大小。[...] 如果一个设备比其他设备大得多,则 RAID 设备中仍会利用额外的空间,但在 RAID 设备的高端写入期间,您将单独访问这个较大的磁盘。这当然会损害性能。

\n
\n

这是一个有点尴尬的措辞,但mdadm 的维基百科页面是这样说的:

\n
\n

RAID 0 \xe2\x80\x93 块级条带化。MD可以处理不同长度的设备,较大设备上的额外空间不会被条带化。

\n
\n

因此,对于大小分别为 4 和 2 个“块”的两个磁盘的简化情况,您得到的可能如下所示:

\n
disk0  disk1\n00     01\n02     03\n04\n05\n
Run Code Online (Sandbox Code Playgroud)\n

读取“块”04-05 必须仅从 disk0 完成,因此那里没有条带化优势。md设备应该是可分区的,因此您可以在设备的开头和结尾处进行分区测试,看看速度差异是否变得明显。

\n


avi*_*iro 11

从手册页md(4)

   The RAID0 driver assigns the first chunk of the array to the
   first device, the second chunk to the second device, and so on
   until all drives have been assigned one chunk.  This collection
   of chunks forms a stripe.  Further chunks are gathered into
   stripes in the same way, and are assigned to the remaining space
   in the drives.

   If devices in the array are not all the same size, then once the
   smallest device has been exhausted, the RAID0 driver starts
   collecting chunks into smaller stripes that only span the drives
   which still have remaining space.
Run Code Online (Sandbox Code Playgroud)