|
Lines 895-907
Link Here
|
| 895 |
mnttab_node_t *mtn; |
895 |
mnttab_node_t *mtn; |
| 896 |
|
896 |
|
| 897 |
pthread_mutex_lock(&hdl->libzfs_mnttab_cache_lock); |
897 |
pthread_mutex_lock(&hdl->libzfs_mnttab_cache_lock); |
| 898 |
if (avl_numnodes(&hdl->libzfs_mnttab_cache) == 0) { |
898 |
if (avl_numnodes(&hdl->libzfs_mnttab_cache) != 0) { |
| 899 |
mtn = zfs_alloc(hdl, sizeof (mnttab_node_t)); |
899 |
mtn = zfs_alloc(hdl, sizeof (mnttab_node_t)); |
| 900 |
mtn->mtn_mt.mnt_special = zfs_strdup(hdl, special); |
900 |
mtn->mtn_mt.mnt_special = zfs_strdup(hdl, special); |
| 901 |
mtn->mtn_mt.mnt_mountp = zfs_strdup(hdl, mountp); |
901 |
mtn->mtn_mt.mnt_mountp = zfs_strdup(hdl, mountp); |
| 902 |
mtn->mtn_mt.mnt_fstype = zfs_strdup(hdl, MNTTYPE_ZFS); |
902 |
mtn->mtn_mt.mnt_fstype = zfs_strdup(hdl, MNTTYPE_ZFS); |
| 903 |
mtn->mtn_mt.mnt_mntopts = zfs_strdup(hdl, mntopts); |
903 |
mtn->mtn_mt.mnt_mntopts = zfs_strdup(hdl, mntopts); |
| 904 |
avl_add(&hdl->libzfs_mnttab_cache, mtn); |
904 |
/* |
|
|
905 |
* Another thread may have already added this entry |
| 906 |
* via libzfs_mnttab_update. If so we should skip it. |
| 907 |
*/ |
| 908 |
if (avl_find(&hdl->libzfs_mnttab_cache, mtn, NULL) != NULL) { |
| 909 |
free(mtn->mtn_mt.mnt_special); |
| 910 |
free(mtn->mtn_mt.mnt_mountp); |
| 911 |
free(mtn->mtn_mt.mnt_fstype); |
| 912 |
free(mtn->mtn_mt.mnt_mntopts); |
| 913 |
free(mtn); |
| 914 |
} else { |
| 915 |
avl_add(&hdl->libzfs_mnttab_cache, mtn); |
| 916 |
} |
| 905 |
} |
917 |
} |
| 906 |
pthread_mutex_unlock(&hdl->libzfs_mnttab_cache_lock); |
918 |
pthread_mutex_unlock(&hdl->libzfs_mnttab_cache_lock); |
| 907 |
} |
919 |
} |