Lines 3092-3098
static int read_imsm_migr_rec(int fd, struct intel_super *super)
Link Here
|
3092 |
unsigned long long dsize; |
3092 |
unsigned long long dsize; |
3093 |
|
3093 |
|
3094 |
get_dev_size(fd, NULL, &dsize); |
3094 |
get_dev_size(fd, NULL, &dsize); |
3095 |
if (lseek64(fd, dsize - (sector_size*MIGR_REC_SECTOR_POSITION), |
3095 |
if (lseek(fd, dsize - (sector_size*MIGR_REC_SECTOR_POSITION), |
3096 |
SEEK_SET) < 0) { |
3096 |
SEEK_SET) < 0) { |
3097 |
pr_err("Cannot seek to anchor block: %s\n", |
3097 |
pr_err("Cannot seek to anchor block: %s\n", |
3098 |
strerror(errno)); |
3098 |
strerror(errno)); |
Lines 3283-3289
static int write_imsm_migr_rec(struct supertype *st)
Link Here
|
3283 |
continue; |
3283 |
continue; |
3284 |
|
3284 |
|
3285 |
get_dev_size(sd->fd, NULL, &dsize); |
3285 |
get_dev_size(sd->fd, NULL, &dsize); |
3286 |
if (lseek64(sd->fd, dsize - (MIGR_REC_SECTOR_POSITION * |
3286 |
if (lseek(sd->fd, dsize - (MIGR_REC_SECTOR_POSITION * |
3287 |
sector_size), |
3287 |
sector_size), |
3288 |
SEEK_SET) < 0) { |
3288 |
SEEK_SET) < 0) { |
3289 |
pr_err("Cannot seek to anchor block: %s\n", |
3289 |
pr_err("Cannot seek to anchor block: %s\n", |
Lines 4404-4410
static int load_imsm_mpb(int fd, struct intel_super *super, char *devname)
Link Here
|
4404 |
return 1; |
4404 |
return 1; |
4405 |
} |
4405 |
} |
4406 |
|
4406 |
|
4407 |
if (lseek64(fd, dsize - (sector_size * 2), SEEK_SET) < 0) { |
4407 |
if (lseek(fd, dsize - (sector_size * 2), SEEK_SET) < 0) { |
4408 |
if (devname) |
4408 |
if (devname) |
4409 |
pr_err("Cannot seek to anchor block on %s: %s\n", |
4409 |
pr_err("Cannot seek to anchor block on %s: %s\n", |
4410 |
devname, strerror(errno)); |
4410 |
devname, strerror(errno)); |
Lines 4472-4478
static int load_imsm_mpb(int fd, struct intel_super *super, char *devname)
Link Here
|
4472 |
} |
4472 |
} |
4473 |
|
4473 |
|
4474 |
/* read the extended mpb */ |
4474 |
/* read the extended mpb */ |
4475 |
if (lseek64(fd, dsize - (sector_size * (2 + sectors)), SEEK_SET) < 0) { |
4475 |
if (lseek(fd, dsize - (sector_size * (2 + sectors)), SEEK_SET) < 0) { |
4476 |
if (devname) |
4476 |
if (devname) |
4477 |
pr_err("Cannot seek to extended mpb on %s: %s\n", |
4477 |
pr_err("Cannot seek to extended mpb on %s: %s\n", |
4478 |
devname, strerror(errno)); |
4478 |
devname, strerror(errno)); |
Lines 5994-6000
static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
Link Here
|
5994 |
|
5994 |
|
5995 |
/* clear migr_rec when adding disk to container */ |
5995 |
/* clear migr_rec when adding disk to container */ |
5996 |
memset(super->migr_rec_buf, 0, MIGR_REC_BUF_SECTORS*MAX_SECTOR_SIZE); |
5996 |
memset(super->migr_rec_buf, 0, MIGR_REC_BUF_SECTORS*MAX_SECTOR_SIZE); |
5997 |
if (lseek64(fd, size - MIGR_REC_SECTOR_POSITION*member_sector_size, |
5997 |
if (lseek(fd, size - MIGR_REC_SECTOR_POSITION*member_sector_size, |
5998 |
SEEK_SET) >= 0) { |
5998 |
SEEK_SET) >= 0) { |
5999 |
if ((unsigned int)write(fd, super->migr_rec_buf, |
5999 |
if ((unsigned int)write(fd, super->migr_rec_buf, |
6000 |
MIGR_REC_BUF_SECTORS*member_sector_size) != |
6000 |
MIGR_REC_BUF_SECTORS*member_sector_size) != |
Lines 6219-6225
static int write_super_imsm(struct supertype *st, int doclose)
Link Here
|
6219 |
unsigned long long dsize; |
6219 |
unsigned long long dsize; |
6220 |
|
6220 |
|
6221 |
get_dev_size(d->fd, NULL, &dsize); |
6221 |
get_dev_size(d->fd, NULL, &dsize); |
6222 |
if (lseek64(d->fd, dsize - sector_size, |
6222 |
if (lseek(d->fd, dsize - sector_size, |
6223 |
SEEK_SET) >= 0) { |
6223 |
SEEK_SET) >= 0) { |
6224 |
if ((unsigned int)write(d->fd, |
6224 |
if ((unsigned int)write(d->fd, |
6225 |
super->migr_rec_buf, |
6225 |
super->migr_rec_buf, |
Lines 6302-6308
static int write_ppl_header(unsigned long long ppl_sector, int fd, void *buf)
Link Here
|
6302 |
|
6302 |
|
6303 |
ppl_hdr->checksum = __cpu_to_le32(~crc32c_le(~0, buf, PPL_HEADER_SIZE)); |
6303 |
ppl_hdr->checksum = __cpu_to_le32(~crc32c_le(~0, buf, PPL_HEADER_SIZE)); |
6304 |
|
6304 |
|
6305 |
if (lseek64(fd, ppl_sector * 512, SEEK_SET) < 0) { |
6305 |
if (lseek(fd, ppl_sector * 512, SEEK_SET) < 0) { |
6306 |
ret = -errno; |
6306 |
ret = -errno; |
6307 |
perror("Failed to seek to PPL header location"); |
6307 |
perror("Failed to seek to PPL header location"); |
6308 |
return ret; |
6308 |
return ret; |
Lines 6396-6402
static int validate_ppl_imsm(struct supertype *st, struct mdinfo *info,
Link Here
|
6396 |
|
6396 |
|
6397 |
dprintf("Checking potential PPL at offset: %llu\n", ppl_offset); |
6397 |
dprintf("Checking potential PPL at offset: %llu\n", ppl_offset); |
6398 |
|
6398 |
|
6399 |
if (lseek64(d->fd, info->ppl_sector * 512 + ppl_offset, |
6399 |
if (lseek(d->fd, info->ppl_sector * 512 + ppl_offset, |
6400 |
SEEK_SET) < 0) { |
6400 |
SEEK_SET) < 0) { |
6401 |
perror("Failed to seek to PPL header location"); |
6401 |
perror("Failed to seek to PPL header location"); |
6402 |
ret = -1; |
6402 |
ret = -1; |
Lines 8858-8864
static int store_imsm_mpb(int fd, struct imsm_super *mpb)
Link Here
|
8858 |
sectors = mpb_sectors(mpb, sector_size) - 1; |
8858 |
sectors = mpb_sectors(mpb, sector_size) - 1; |
8859 |
|
8859 |
|
8860 |
/* write the extended mpb to the sectors preceeding the anchor */ |
8860 |
/* write the extended mpb to the sectors preceeding the anchor */ |
8861 |
if (lseek64(fd, dsize - (sector_size * (2 + sectors)), |
8861 |
if (lseek(fd, dsize - (sector_size * (2 + sectors)), |
8862 |
SEEK_SET) < 0) |
8862 |
SEEK_SET) < 0) |
8863 |
return 1; |
8863 |
return 1; |
8864 |
|
8864 |
|
Lines 8868-8874
static int store_imsm_mpb(int fd, struct imsm_super *mpb)
Link Here
|
8868 |
} |
8868 |
} |
8869 |
|
8869 |
|
8870 |
/* first block is stored on second to last sector of the disk */ |
8870 |
/* first block is stored on second to last sector of the disk */ |
8871 |
if (lseek64(fd, dsize - (sector_size * 2), SEEK_SET) < 0) |
8871 |
if (lseek(fd, dsize - (sector_size * 2), SEEK_SET) < 0) |
8872 |
return 1; |
8872 |
return 1; |
8873 |
|
8873 |
|
8874 |
if ((unsigned int)write(fd, buf, sector_size) != sector_size) |
8874 |
if ((unsigned int)write(fd, buf, sector_size) != sector_size) |
Lines 11058-11064
int recover_backup_imsm(struct supertype *st, struct mdinfo *info)
Link Here
|
11058 |
skipped_disks++; |
11058 |
skipped_disks++; |
11059 |
continue; |
11059 |
continue; |
11060 |
} |
11060 |
} |
11061 |
if (lseek64(dl_disk->fd, read_offset, SEEK_SET) < 0) { |
11061 |
if (lseek(dl_disk->fd, read_offset, SEEK_SET) < 0) { |
11062 |
pr_err("Cannot seek to block: %s\n", |
11062 |
pr_err("Cannot seek to block: %s\n", |
11063 |
strerror(errno)); |
11063 |
strerror(errno)); |
11064 |
skipped_disks++; |
11064 |
skipped_disks++; |
Lines 11070-11076
int recover_backup_imsm(struct supertype *st, struct mdinfo *info)
Link Here
|
11070 |
skipped_disks++; |
11070 |
skipped_disks++; |
11071 |
continue; |
11071 |
continue; |
11072 |
} |
11072 |
} |
11073 |
if (lseek64(dl_disk->fd, write_offset, SEEK_SET) < 0) { |
11073 |
if (lseek(dl_disk->fd, write_offset, SEEK_SET) < 0) { |
11074 |
pr_err("Cannot seek to block: %s\n", |
11074 |
pr_err("Cannot seek to block: %s\n", |
11075 |
strerror(errno)); |
11075 |
strerror(errno)); |
11076 |
skipped_disks++; |
11076 |
skipped_disks++; |
Lines 12320-12326
static int imsm_manage_reshape(
Link Here
|
12320 |
unsigned long long dsize; |
12320 |
unsigned long long dsize; |
12321 |
|
12321 |
|
12322 |
get_dev_size(d->fd, NULL, &dsize); |
12322 |
get_dev_size(d->fd, NULL, &dsize); |
12323 |
if (lseek64(d->fd, dsize - MIGR_REC_SECTOR_POSITION*sector_size, |
12323 |
if (lseek(d->fd, dsize - MIGR_REC_SECTOR_POSITION*sector_size, |
12324 |
SEEK_SET) >= 0) { |
12324 |
SEEK_SET) >= 0) { |
12325 |
if ((unsigned int)write(d->fd, super->migr_rec_buf, |
12325 |
if ((unsigned int)write(d->fd, super->migr_rec_buf, |
12326 |
MIGR_REC_BUF_SECTORS*sector_size) != |
12326 |
MIGR_REC_BUF_SECTORS*sector_size) != |
Lines 12476-12482
static int validate_internal_bitmap_for_drive(struct supertype *st,
Link Here
|
12476 |
} |
12476 |
} |
12477 |
} |
12477 |
} |
12478 |
|
12478 |
|
12479 |
if (lseek64(fd, offset * super->sector_size, SEEK_SET) < 0) |
12479 |
if (lseek(fd, offset * super->sector_size, SEEK_SET) < 0) |
12480 |
goto abort; |
12480 |
goto abort; |
12481 |
if (read(fd, read_buf, IMSM_BITMAP_HEADER_SIZE) != |
12481 |
if (read(fd, read_buf, IMSM_BITMAP_HEADER_SIZE) != |
12482 |
IMSM_BITMAP_HEADER_SIZE) |
12482 |
IMSM_BITMAP_HEADER_SIZE) |
Lines 12605-12611
static int locate_bitmap_imsm(struct supertype *st, int fd, int node_num)
Link Here
|
12605 |
offset = get_bitmap_header_sector(super, super->current_vol); |
12605 |
offset = get_bitmap_header_sector(super, super->current_vol); |
12606 |
dprintf("bitmap header offset is %llu\n", offset); |
12606 |
dprintf("bitmap header offset is %llu\n", offset); |
12607 |
|
12607 |
|
12608 |
lseek64(fd, offset << 9, 0); |
12608 |
lseek(fd, offset << 9, 0); |
12609 |
|
12609 |
|
12610 |
return 0; |
12610 |
return 0; |
12611 |
} |
12611 |
} |
Lines 12659-12665
static int write_init_bitmap_imsm(struct supertype *st, int fd,
Link Here
|
12659 |
return -1; |
12659 |
return -1; |
12660 |
memset(buf, 0xFF, MAX_SECTOR_SIZE); |
12660 |
memset(buf, 0xFF, MAX_SECTOR_SIZE); |
12661 |
offset = get_bitmap_sector(super, vol_idx); |
12661 |
offset = get_bitmap_sector(super, vol_idx); |
12662 |
lseek64(fd, offset << 9, 0); |
12662 |
lseek(fd, offset << 9, 0); |
12663 |
while (written < IMSM_BITMAP_AREA_SIZE) { |
12663 |
while (written < IMSM_BITMAP_AREA_SIZE) { |
12664 |
to_write = IMSM_BITMAP_AREA_SIZE - written; |
12664 |
to_write = IMSM_BITMAP_AREA_SIZE - written; |
12665 |
if (to_write > MAX_SECTOR_SIZE) |
12665 |
if (to_write > MAX_SECTOR_SIZE) |