Deleted Added
full compact
vdev_file.c (185319) vdev_file.c (209962)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 47 unchanged lines hidden (view full) ---

56 /*
57 * We always open the files from the root of the global zone, even if
58 * we're in a local zone. If the user has gotten to this point, the
59 * administrator has already decided that the pool should be available
60 * to local zone users, so the underlying devices should be as well.
61 */
62 ASSERT(vd->vdev_path != NULL && vd->vdev_path[0] == '/');
63 error = vn_openat(vd->vdev_path + 1, UIO_SYSSPACE,
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 47 unchanged lines hidden (view full) ---

56 /*
57 * We always open the files from the root of the global zone, even if
58 * we're in a local zone. If the user has gotten to this point, the
59 * administrator has already decided that the pool should be available
60 * to local zone users, so the underlying devices should be as well.
61 */
62 ASSERT(vd->vdev_path != NULL && vd->vdev_path[0] == '/');
63 error = vn_openat(vd->vdev_path + 1, UIO_SYSSPACE,
64 spa_mode | FOFFMAX, 0, &vp, 0, 0, rootdir, -1);
64 spa_mode(vd->vdev_spa) | FOFFMAX, 0, &vp, 0, 0, rootdir, -1);
65
66 if (error) {
67 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
68 return (error);
69 }
70
71 vf->vf_vnode = vp;
72
73#ifdef _KERNEL
74 /*
75 * Make sure it's a regular file.
76 */
77 if (vp->v_type != VREG) {
65
66 if (error) {
67 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
68 return (error);
69 }
70
71 vf->vf_vnode = vp;
72
73#ifdef _KERNEL
74 /*
75 * Make sure it's a regular file.
76 */
77 if (vp->v_type != VREG) {
78 (void) VOP_CLOSE(vp, spa_mode, 1, 0, kcred, NULL);
78 (void) VOP_CLOSE(vp, spa_mode(vd->vdev_spa), 1, 0, kcred, NULL);
79 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
80 return (ENODEV);
81 }
82#endif
83 /*
84 * Determine the physical size of the file.
85 */
86 vattr.va_mask = AT_SIZE;
87 vfslocked = VFS_LOCK_GIANT(vp->v_mount);
88 vn_lock(vp, LK_SHARED | LK_RETRY);
89 error = VOP_GETATTR(vp, &vattr, kcred);
90 VOP_UNLOCK(vp, 0);
91 VFS_UNLOCK_GIANT(vfslocked);
92 if (error) {
79 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
80 return (ENODEV);
81 }
82#endif
83 /*
84 * Determine the physical size of the file.
85 */
86 vattr.va_mask = AT_SIZE;
87 vfslocked = VFS_LOCK_GIANT(vp->v_mount);
88 vn_lock(vp, LK_SHARED | LK_RETRY);
89 error = VOP_GETATTR(vp, &vattr, kcred);
90 VOP_UNLOCK(vp, 0);
91 VFS_UNLOCK_GIANT(vfslocked);
92 if (error) {
93 (void) VOP_CLOSE(vp, spa_mode, 1, 0, kcred, NULL);
93 (void) VOP_CLOSE(vp, spa_mode(vd->vdev_spa), 1, 0, kcred, NULL);
94 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
95 return (error);
96 }
97
98 *psize = vattr.va_size;
99 *ashift = SPA_MINBLOCKSHIFT;
100
101 return (0);
102}
103
104static void
105vdev_file_close(vdev_t *vd)
106{
107 vdev_file_t *vf = vd->vdev_tsd;
108
109 if (vf == NULL)
110 return;
111
112 if (vf->vf_vnode != NULL)
94 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
95 return (error);
96 }
97
98 *psize = vattr.va_size;
99 *ashift = SPA_MINBLOCKSHIFT;
100
101 return (0);
102}
103
104static void
105vdev_file_close(vdev_t *vd)
106{
107 vdev_file_t *vf = vd->vdev_tsd;
108
109 if (vf == NULL)
110 return;
111
112 if (vf->vf_vnode != NULL)
113 (void) VOP_CLOSE(vf->vf_vnode, spa_mode, 1, 0, kcred, NULL);
113 (void) VOP_CLOSE(vf->vf_vnode, spa_mode(vd->vdev_spa), 1, 0,
114 kcred, NULL);
114 kmem_free(vf, sizeof (vdev_file_t));
115 vd->vdev_tsd = NULL;
116}
117
118static int
119vdev_file_io_start(zio_t *zio)
120{
121 vdev_t *vd = zio->io_vd;

--- 69 unchanged lines hidden ---
115 kmem_free(vf, sizeof (vdev_file_t));
116 vd->vdev_tsd = NULL;
117}
118
119static int
120vdev_file_io_start(zio_t *zio)
121{
122 vdev_t *vd = zio->io_vd;

--- 69 unchanged lines hidden ---