subutai-attic / pars

https://subutai.io/projects/pars/
28 stars 15 forks source link

RAID0 metadata modification #40

Closed AzamatBeksadaev closed 7 years ago

AzamatBeksadaev commented 7 years ago

While identification process is running storage device sends data contained in the control registers. One of that register is "extended CSD" (Device-Specific Data). It is 512 bytes long. The most significant 320 bytes are the Properties segment, that defines the Device capabilities and cannot be modified by the host. The lower 192 bytes are the Modes segment, that defines the configuration the Device is working in. The purpose of this issue is doubled the storage size by modification of certain fields of ext. CSD. Host driver will suppose that storage has a large space, but actually RAID will break large space into two smaller storage spaces.

AzamatBeksadaev commented 7 years ago

There is a good tool to get parsed extended CSD information from existing /dev/mmcblk$ devices. Repository of that tool http://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc-utils.git/ Storage device size calculate as: Device density = SEC_COUNT x 512B, where _SECCOUNT [215:212] field is the addressable sector range for the device will be from Sector 0 to Sector (SEC_COUNT-1). In our case we have:

root@linaro-developer:/home/linaro/git/mmc-utils# ./mmc extcsd read /dev/mmcblk1 | grep SEC_COUNT
Sector Count [SEC_COUNT: 0x01d5a000]

01d5a000 = 30777344 sectors 30777344 * 512bytes = 15758000128 bytes 15758000128 byte / 1024 /1024 /1024= 14.67 Gbytes

AzamatBeksadaev commented 7 years ago

eMMC card with 14.7G disk space determined by system as 29.4G. Comit - 786e4e644c791507a0f01e389103cc9b4a6c51de

mmcblk1      179:16   0  29.4G  0 disk 
└─mmcblk1p1  179:17   0  14.7G  0 part