mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-29 08:08:37 +00:00
stand/zfs: Refactor zfs_set_bootenv
Refactor zfs_set_bootenv to split out the lookup of spa from the rest. zfs_set_bootenv_spa flushes the benv to the vdevs and updates the cached benv. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D39410
This commit is contained in:
parent
6479bd1b7d
commit
4dcae288fe
@ -812,22 +812,12 @@ zfs_get_bootenv(void *vdev, nvlist_t **benvp)
|
||||
int
|
||||
zfs_set_bootenv(void *vdev, nvlist_t *benv)
|
||||
{
|
||||
struct zfs_devdesc *dev = (struct zfs_devdesc *)vdev;
|
||||
spa_t *spa;
|
||||
vdev_t *vd;
|
||||
|
||||
if (dev->dd.d_dev->dv_type != DEVT_ZFS)
|
||||
return (ENOTSUP);
|
||||
|
||||
if ((spa = spa_find_by_dev(dev)) == NULL)
|
||||
if ((spa = spa_find_by_dev((struct zfs_devdesc *)vdev)) == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
STAILQ_FOREACH(vd, &spa->spa_root_vdev->v_children, v_childlink) {
|
||||
vdev_write_bootenv(vd, benv);
|
||||
}
|
||||
|
||||
spa->spa_bootenv = benv;
|
||||
return (0);
|
||||
return (zfs_set_bootenv_spa(spa, benv));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3883,3 +3883,19 @@ zfs_get_bootenv_spa(spa_t *spa, nvlist_t **benvp)
|
||||
*benvp = benv;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Store nvlist to pool label bootenv area. Also updates cached pointer in spa.
|
||||
*/
|
||||
static int
|
||||
zfs_set_bootenv_spa(spa_t *spa, nvlist_t *benv)
|
||||
{
|
||||
vdev_t *vd;
|
||||
|
||||
STAILQ_FOREACH(vd, &spa->spa_root_vdev->v_children, v_childlink) {
|
||||
vdev_write_bootenv(vd, benv);
|
||||
}
|
||||
|
||||
spa->spa_bootenv = benv;
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user