* Update the stored path or FRU for this vdev. */
| 7848 | * Update the stored path or FRU for this vdev. |
| 7849 | */ |
| 7850 | static int |
| 7851 | spa_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 | |
| 7887 | int |
| 7888 | spa_vdev_setpath(spa_t *spa, uint64_t guid, const char *newpath) |
no test coverage detected