Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
Show First 20 Lines • Show All 950 Lines • ▼ Show 20 Lines | zfsvfs_init(zfsvfs_t *zfsvfs, objset_t *os) | ||||
error = zap_lookup(os, MASTER_NODE_OBJ, ZFS_SHARES_DIR, 8, 1, | error = zap_lookup(os, MASTER_NODE_OBJ, ZFS_SHARES_DIR, 8, 1, | ||||
&zfsvfs->z_shares_dir); | &zfsvfs->z_shares_dir); | ||||
if (error == ENOENT) | if (error == ENOENT) | ||||
zfsvfs->z_shares_dir = 0; | zfsvfs->z_shares_dir = 0; | ||||
else if (error != 0) | else if (error != 0) | ||||
return (error); | return (error); | ||||
/* | |||||
* Only use the name cache if we are looking for a | |||||
* name on a file system that does not require normalization | |||||
* or case folding. We can also look there if we happen to be | |||||
* on a non-normalizing, mixed sensitivity file system IF we | |||||
* are looking for the exact name (which is always the case on | |||||
* FreeBSD). | |||||
*/ | |||||
zfsvfs->z_use_namecache = !zfsvfs->z_norm || | |||||
((zfsvfs->z_case == ZFS_CASE_MIXED) && | |||||
!(zfsvfs->z_norm & ~U8_TEXTPREP_TOUPPER)); | |||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
zfsvfs_create(const char *osname, zfsvfs_t **zfvp) | zfsvfs_create(const char *osname, zfsvfs_t **zfvp) | ||||
{ | { | ||||
objset_t *os; | objset_t *os; | ||||
zfsvfs_t *zfsvfs; | zfsvfs_t *zfsvfs; | ||||
Show All 24 Lines | zfsvfs_create(const char *osname, zfsvfs_t **zfvp) | ||||
zfsvfs->z_vfs = NULL; | zfsvfs->z_vfs = NULL; | ||||
zfsvfs->z_parent = zfsvfs; | zfsvfs->z_parent = zfsvfs; | ||||
mutex_init(&zfsvfs->z_znodes_lock, NULL, MUTEX_DEFAULT, NULL); | mutex_init(&zfsvfs->z_znodes_lock, NULL, MUTEX_DEFAULT, NULL); | ||||
mutex_init(&zfsvfs->z_lock, NULL, MUTEX_DEFAULT, NULL); | mutex_init(&zfsvfs->z_lock, NULL, MUTEX_DEFAULT, NULL); | ||||
list_create(&zfsvfs->z_all_znodes, sizeof (znode_t), | list_create(&zfsvfs->z_all_znodes, sizeof (znode_t), | ||||
offsetof(znode_t, z_link_node)); | offsetof(znode_t, z_link_node)); | ||||
#ifdef DIAGNOSTIC | |||||
rrm_init(&zfsvfs->z_teardown_lock, B_TRUE); | |||||
#else | |||||
rrm_init(&zfsvfs->z_teardown_lock, B_FALSE); | rrm_init(&zfsvfs->z_teardown_lock, B_FALSE); | ||||
#endif | |||||
rw_init(&zfsvfs->z_teardown_inactive_lock, NULL, RW_DEFAULT, NULL); | rw_init(&zfsvfs->z_teardown_inactive_lock, NULL, RW_DEFAULT, NULL); | ||||
rw_init(&zfsvfs->z_fuid_lock, NULL, RW_DEFAULT, NULL); | rw_init(&zfsvfs->z_fuid_lock, NULL, RW_DEFAULT, NULL); | ||||
for (int i = 0; i != ZFS_OBJ_MTX_SZ; i++) | for (int i = 0; i != ZFS_OBJ_MTX_SZ; i++) | ||||
mutex_init(&zfsvfs->z_hold_mtx[i], NULL, MUTEX_DEFAULT, NULL); | mutex_init(&zfsvfs->z_hold_mtx[i], NULL, MUTEX_DEFAULT, NULL); | ||||
error = zfsvfs_init(zfsvfs, os); | error = zfsvfs_init(zfsvfs, os); | ||||
if (error != 0) { | if (error != 0) { | ||||
dmu_objset_disown(os, zfsvfs); | dmu_objset_disown(os, zfsvfs); | ||||
▲ Show 20 Lines • Show All 1,030 Lines • ▼ Show 20 Lines | zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp) | ||||
*/ | */ | ||||
if (ino == ZFSCTL_INO_ROOT || ino == ZFSCTL_INO_SNAPDIR || | if (ino == ZFSCTL_INO_ROOT || ino == ZFSCTL_INO_SNAPDIR || | ||||
(zfsvfs->z_shares_dir != 0 && ino == zfsvfs->z_shares_dir)) | (zfsvfs->z_shares_dir != 0 && ino == zfsvfs->z_shares_dir)) | ||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
ZFS_ENTER(zfsvfs); | ZFS_ENTER(zfsvfs); | ||||
err = zfs_zget(zfsvfs, ino, &zp); | err = zfs_zget(zfsvfs, ino, &zp); | ||||
if (err == 0 && zp->z_unlinked) { | if (err == 0 && zp->z_unlinked) { | ||||
VN_RELE(ZTOV(zp)); | vrele(ZTOV(zp)); | ||||
err = EINVAL; | err = EINVAL; | ||||
} | } | ||||
if (err == 0) | if (err == 0) | ||||
*vpp = ZTOV(zp); | *vpp = ZTOV(zp); | ||||
ZFS_EXIT(zfsvfs); | ZFS_EXIT(zfsvfs); | ||||
if (err == 0) | if (err == 0) | ||||
err = vn_lock(*vpp, flags); | err = vn_lock(*vpp, flags); | ||||
if (err != 0) | if (err != 0) | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | if ((fid_gen == 0 && | ||||
ASSERT(*vpp != NULL); | ASSERT(*vpp != NULL); | ||||
if (object == ZFSCTL_INO_SNAPDIR) { | if (object == ZFSCTL_INO_SNAPDIR) { | ||||
VERIFY(zfsctl_root_lookup(*vpp, "snapshot", vpp, NULL, | VERIFY(zfsctl_root_lookup(*vpp, "snapshot", vpp, NULL, | ||||
0, NULL, NULL, NULL, NULL, NULL) == 0); | 0, NULL, NULL, NULL, NULL, NULL) == 0); | ||||
} else if (object == zfsvfs->z_shares_dir) { | } else if (object == zfsvfs->z_shares_dir) { | ||||
VERIFY(zfsctl_root_lookup(*vpp, "shares", vpp, NULL, | VERIFY(zfsctl_root_lookup(*vpp, "shares", vpp, NULL, | ||||
0, NULL, NULL, NULL, NULL, NULL) == 0); | 0, NULL, NULL, NULL, NULL, NULL) == 0); | ||||
} else { | } else { | ||||
VN_HOLD(*vpp); | vref(*vpp); | ||||
} | } | ||||
ZFS_EXIT(zfsvfs); | ZFS_EXIT(zfsvfs); | ||||
err = vn_lock(*vpp, flags); | err = vn_lock(*vpp, flags); | ||||
if (err != 0) | if (err != 0) | ||||
*vpp = NULL; | *vpp = NULL; | ||||
return (err); | return (err); | ||||
} | } | ||||
gen_mask = -1ULL >> (64 - 8 * i); | gen_mask = -1ULL >> (64 - 8 * i); | ||||
dprintf("getting %llu [%u mask %llx]\n", object, fid_gen, gen_mask); | dprintf("getting %llu [%u mask %llx]\n", object, fid_gen, gen_mask); | ||||
if (err = zfs_zget(zfsvfs, object, &zp)) { | if (err = zfs_zget(zfsvfs, object, &zp)) { | ||||
ZFS_EXIT(zfsvfs); | ZFS_EXIT(zfsvfs); | ||||
return (err); | return (err); | ||||
} | } | ||||
(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(zfsvfs), &zp_gen, | (void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(zfsvfs), &zp_gen, | ||||
sizeof (uint64_t)); | sizeof (uint64_t)); | ||||
zp_gen = zp_gen & gen_mask; | zp_gen = zp_gen & gen_mask; | ||||
if (zp_gen == 0) | if (zp_gen == 0) | ||||
zp_gen = 1; | zp_gen = 1; | ||||
if (zp->z_unlinked || zp_gen != fid_gen) { | if (zp->z_unlinked || zp_gen != fid_gen) { | ||||
dprintf("znode gen (%u) != fid gen (%u)\n", zp_gen, fid_gen); | dprintf("znode gen (%u) != fid gen (%u)\n", zp_gen, fid_gen); | ||||
VN_RELE(ZTOV(zp)); | vrele(ZTOV(zp)); | ||||
ZFS_EXIT(zfsvfs); | ZFS_EXIT(zfsvfs); | ||||
return (SET_ERROR(EINVAL)); | return (SET_ERROR(EINVAL)); | ||||
} | } | ||||
*vpp = ZTOV(zp); | *vpp = ZTOV(zp); | ||||
ZFS_EXIT(zfsvfs); | ZFS_EXIT(zfsvfs); | ||||
err = vn_lock(*vpp, flags | LK_RETRY); | err = vn_lock(*vpp, flags | LK_RETRY); | ||||
if (err == 0) | if (err == 0) | ||||
▲ Show 20 Lines • Show All 324 Lines • Show Last 20 Lines |