git: 4dcae288fe63 - main - stand/zfs: Refactor zfs_set_bootenv
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 01 May 2023 21:04:14 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4dcae288fe63667bdf930258b94e0e51a2d05787 commit 4dcae288fe63667bdf930258b94e0e51a2d05787 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2023-05-01 15:26:59 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2023-05-01 21:02:53 +0000 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 --- stand/libsa/zfs/zfs.c | 14 ++------------ stand/libsa/zfs/zfsimpl.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/stand/libsa/zfs/zfs.c b/stand/libsa/zfs/zfs.c index 17f213fe833c..7cdfa1a06df9 100644 --- a/stand/libsa/zfs/zfs.c +++ b/stand/libsa/zfs/zfs.c @@ -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)); } /* diff --git a/stand/libsa/zfs/zfsimpl.c b/stand/libsa/zfs/zfsimpl.c index 40a1448a0c9f..3b093dea3c41 100644 --- a/stand/libsa/zfs/zfsimpl.c +++ b/stand/libsa/zfs/zfsimpl.c @@ -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); +}