MCPcopy Create free account
hub / github.com/F-Stack/f-stack / spa_vdev_set_common

Function spa_vdev_set_common

freebsd/contrib/openzfs/module/zfs/spa.c:7850–7885  ·  view source on GitHub ↗

* Update the stored path or FRU for this vdev. */

Source from the content-addressed store, hash-verified

7848 * Update the stored path or FRU for this vdev.
7849 */
7850static int
7851spa_vdev_set_common(spa_t *spa, uint64_t guid, const char *value,
7852 boolean_t ispath)
7853{
7854 vdev_t *vd;
7855 boolean_t sync = B_FALSE;
7856
7857 ASSERT(spa_writeable(spa));
7858
7859 spa_vdev_state_enter(spa, SCL_ALL);
7860
7861 if ((vd = spa_lookup_by_guid(spa, guid, B_TRUE)) == NULL)
7862 return (spa_vdev_state_exit(spa, NULL, ENOENT));
7863
7864 if (!vd->vdev_ops->vdev_op_leaf)
7865 return (spa_vdev_state_exit(spa, NULL, ENOTSUP));
7866
7867 if (ispath) {
7868 if (strcmp(value, vd->vdev_path) != 0) {
7869 spa_strfree(vd->vdev_path);
7870 vd->vdev_path = spa_strdup(value);
7871 sync = B_TRUE;
7872 }
7873 } else {
7874 if (vd->vdev_fru == NULL) {
7875 vd->vdev_fru = spa_strdup(value);
7876 sync = B_TRUE;
7877 } else if (strcmp(value, vd->vdev_fru) != 0) {
7878 spa_strfree(vd->vdev_fru);
7879 vd->vdev_fru = spa_strdup(value);
7880 sync = B_TRUE;
7881 }
7882 }
7883
7884 return (spa_vdev_state_exit(spa, sync ? vd : NULL, 0));
7885}
7886
7887int
7888spa_vdev_setpath(spa_t *spa, uint64_t guid, const char *newpath)

Callers 2

spa_vdev_setpathFunction · 0.85
spa_vdev_setfruFunction · 0.85

Calls 7

spa_writeableFunction · 0.85
spa_vdev_state_enterFunction · 0.85
spa_lookup_by_guidFunction · 0.85
spa_vdev_state_exitFunction · 0.85
strcmpFunction · 0.85
spa_strfreeFunction · 0.85
spa_strdupFunction · 0.85

Tested by

no test coverage detected