1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-28 16:43:09 +00:00

Fix zpool_read_all_labels when vfs.aio.enable_unsafe=0

Previously, zpool_read_all_labels was trying to do 256KB reads, which are
greater than the default MAXPHYS and therefore must go through the slow,
unsafe AIO path.  Shrink these reads to 112KB so they can use the safe, fast
AIO path instead.

MFC after:	1 week
X-MFC-With:	324568
Sponsored by:	Spectra Logic Corp
This commit is contained in:
Alan Somers 2017-10-25 16:01:19 +00:00
parent 1170c2fecc
commit 63f8025d6a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=324991

View File

@ -930,7 +930,7 @@ zpool_read_all_labels(int fd, nvlist_t **config)
struct aiocb aiocbs[VDEV_LABELS];
struct aiocb *aiocbps[VDEV_LABELS];
int l;
vdev_label_t *labels;
vdev_phys_t *labels;
uint64_t state, txg, size;
int nlabels = 0;
@ -940,15 +940,15 @@ zpool_read_all_labels(int fd, nvlist_t **config)
return (0);
size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t);
if ((labels = calloc(VDEV_LABELS, sizeof (vdev_label_t))) == NULL)
if ((labels = calloc(VDEV_LABELS, sizeof (vdev_phys_t))) == NULL)
return (0);
memset(aiocbs, 0, sizeof(aiocbs));
for (l = 0; l < VDEV_LABELS; l++) {
aiocbs[l].aio_fildes = fd;
aiocbs[l].aio_offset = label_offset(size, l);
aiocbs[l].aio_offset = label_offset(size, l) + VDEV_SKIP_SIZE;
aiocbs[l].aio_buf = &labels[l];
aiocbs[l].aio_nbytes = sizeof(vdev_label_t);
aiocbs[l].aio_nbytes = sizeof(vdev_phys_t);
aiocbs[l].aio_lio_opcode = LIO_READ;
aiocbps[l] = &aiocbs[l];
}
@ -962,17 +962,18 @@ zpool_read_all_labels(int fd, nvlist_t **config)
(void)aio_return(&aiocbs[l]);
}
}
free(labels);
return (0);
}
for (l = 0; l < VDEV_LABELS; l++) {
nvlist_t *temp = NULL;
if (aio_return(&aiocbs[l]) != sizeof(vdev_label_t))
if (aio_return(&aiocbs[l]) != sizeof(vdev_phys_t))
continue;
if (nvlist_unpack(labels[l].vl_vdev_phys.vp_nvlist,
sizeof (labels[l].vl_vdev_phys.vp_nvlist), &temp, 0) != 0)
if (nvlist_unpack(labels[l].vp_nvlist,
sizeof (labels[l].vp_nvlist), &temp, 0) != 0)
continue;
if (nvlist_lookup_uint64(temp, ZPOOL_CONFIG_POOL_STATE,