Youzhong Yang via illumos-developer
2014-09-15 17:31:48 UTC
Hi all,
When I tried to troubleshoot an issue of unable to mount a snapshot, I came
across something weird. Inside zfsctl_snapdir_lookup(), there is a jump to
'domount', in which case leaves 'snapname' uninitialized.
Is this a bug? I saw junk data passed to the 2nd arg of
zfsctl_snapdir_lookup() when dtracing it.
Thanks,
-Youzhong
http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/fs/zfs/zfs_ctldir.c#777
zfsctl_snapdir_lookup() {
.
.
.
char snapname[MAXNAMELEN];
.
.
.
mutex_enter(&sdp->sd_lock);
search.se_name = (char *)nm;
if ((sep = avl_find(&sdp->sd_snaps, &search, &where)) != NULL) {
*vpp = sep->se_root;
VN_HOLD(*vpp);
err = traverse(vpp);
if (err != 0) {
VN_RELE(*vpp);
*vpp = NULL;
} else if (*vpp == sep->se_root) {
/*
* The snapshot was unmounted behind our backs,
* try to remount it.
*/
goto domount;
} else {
/*
* VROOT was set during the traverse call. We need
* to clear it since we're pretending to be part
* of our parent's vfs.
*/
(*vpp)->v_flag &= ~VROOT;
}
mutex_exit(&sdp->sd_lock);
ZFS_EXIT(zfsvfs);
return (err);
}
.
.
.
domount:
mountpoint_len = strlen(refstr_value(dvp->v_vfsp->vfs_mntpt)) +
strlen("/.zfs/snapshot/") + strlen(nm) + 1;
mountpoint = kmem_alloc(mountpoint_len, KM_SLEEP);
(void) snprintf(mountpoint, mountpoint_len, "%s/.zfs/snapshot/%s",
refstr_value(dvp->v_vfsp->vfs_mntpt), nm);
margs.spec = snapname;
margs.dir = mountpoint;
margs.flags = MS_SYSSPACE | MS_NOMNTTAB;
margs.fstype = "zfs";
margs.dataptr = NULL;
margs.datalen = 0;
margs.optptr = NULL;
margs.optlen = 0;
err = domount("zfs", &margs, *vpp, kcred, &vfsp);
kmem_free(mountpoint, mountpoint_len);
.
.
.
}
-------------------------------------------
illumos-developer
Archives: https://www.listbox.com/member/archive/182179/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182179/21175072-86d49504
Modify Your Subscription: https://www.listbox.com/member/?member_id=21175072&id_secret=21175072-abdf7b7e
Powered by Listbox: http://www.listbox.com
When I tried to troubleshoot an issue of unable to mount a snapshot, I came
across something weird. Inside zfsctl_snapdir_lookup(), there is a jump to
'domount', in which case leaves 'snapname' uninitialized.
Is this a bug? I saw junk data passed to the 2nd arg of
zfsctl_snapdir_lookup() when dtracing it.
Thanks,
-Youzhong
http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/fs/zfs/zfs_ctldir.c#777
zfsctl_snapdir_lookup() {
.
.
.
char snapname[MAXNAMELEN];
.
.
.
mutex_enter(&sdp->sd_lock);
search.se_name = (char *)nm;
if ((sep = avl_find(&sdp->sd_snaps, &search, &where)) != NULL) {
*vpp = sep->se_root;
VN_HOLD(*vpp);
err = traverse(vpp);
if (err != 0) {
VN_RELE(*vpp);
*vpp = NULL;
} else if (*vpp == sep->se_root) {
/*
* The snapshot was unmounted behind our backs,
* try to remount it.
*/
goto domount;
} else {
/*
* VROOT was set during the traverse call. We need
* to clear it since we're pretending to be part
* of our parent's vfs.
*/
(*vpp)->v_flag &= ~VROOT;
}
mutex_exit(&sdp->sd_lock);
ZFS_EXIT(zfsvfs);
return (err);
}
.
.
.
domount:
mountpoint_len = strlen(refstr_value(dvp->v_vfsp->vfs_mntpt)) +
strlen("/.zfs/snapshot/") + strlen(nm) + 1;
mountpoint = kmem_alloc(mountpoint_len, KM_SLEEP);
(void) snprintf(mountpoint, mountpoint_len, "%s/.zfs/snapshot/%s",
refstr_value(dvp->v_vfsp->vfs_mntpt), nm);
margs.spec = snapname;
margs.dir = mountpoint;
margs.flags = MS_SYSSPACE | MS_NOMNTTAB;
margs.fstype = "zfs";
margs.dataptr = NULL;
margs.datalen = 0;
margs.optptr = NULL;
margs.optlen = 0;
err = domount("zfs", &margs, *vpp, kcred, &vfsp);
kmem_free(mountpoint, mountpoint_len);
.
.
.
}
-------------------------------------------
illumos-developer
Archives: https://www.listbox.com/member/archive/182179/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182179/21175072-86d49504
Modify Your Subscription: https://www.listbox.com/member/?member_id=21175072&id_secret=21175072-abdf7b7e
Powered by Listbox: http://www.listbox.com