*/
int pd;
+ /* layout is not relevant for raid0 and raid4 */
+ if ((level == 0) ||
+ (level == 4))
+ layout = 0;
+
switch(level*100 + layout) {
case 000:
case 400:
int data_disks = raid_disks - (level == 0 ? 0 : level <= 5 ? 1 : 2);
- posix_memalign((void**)&stripe_buf, 4096, raid_disks * chunk_size);
+ if (posix_memalign((void**)&stripe_buf, 4096, raid_disks * chunk_size))
+ stripe_buf = NULL;
if (zero == NULL) {
zero = malloc(chunk_size);
if (zero)
for (i=0; i<raid_disks; i++)
stripes[i] = stripe_buf + i * chunk_size;
while (length > 0) {
- int len = data_disks * chunk_size;
+ unsigned int len = data_disks * chunk_size;
unsigned long long offset;
int disk, qdisk;
int syndrome_disks;
for (i=0; i < data_disks; i++) {
int disk = geo_map(i, start/chunk_size/data_disks,
raid_disks, level, layout);
- if (lseek64(source, read_offset, 0) != read_offset)
+ if ((unsigned long long)lseek64(source, read_offset, 0)
+ != read_offset)
return -1;
- if (read(source, stripes[disk], chunk_size) != chunk_size)
+ if (read(source, stripes[disk],
+ chunk_size) != chunk_size)
return -1;
read_offset += chunk_size;
}