annotate usr/src/uts/common/fs/zfs/vdev_file.c @ 13971:d1648d817bd6

3581 spa_zio_taskq[ZIO_TYPE_FREE][ZIO_TASKQ_ISSUE]->tq_lock is piping hot Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Christopher Siden <christopher.siden@delphix.com> Reviewed by: Gordon Ross <gordon.ross@nexenta.com> Approved by: Richard Lowe <richlowe@richlowe.net>
author Adam Leventhal <ahl@delphix.com>
date Mon, 25 Feb 2013 21:41:47 -0800
parents a9c12c2c1647
children d7059eb1884c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4 * The contents of this file are subject to the terms of the
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
5 * Common Development and Distribution License (the "License").
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
6 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
7 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
9 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
10 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
11 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
12 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
13 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
15 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
16 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
17 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
18 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
19 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
20 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
21 /*
12247
5bcd281629f8 6911420 ZFS device removal detection should work with SCSAv3
George Wilson <George.Wilson@Sun.COM>
parents: 11958
diff changeset
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
13570
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 12247
diff changeset
23 * Copyright (c) 2012 by Delphix. All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
24 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
25
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
26 #include <sys/zfs_context.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
27 #include <sys/spa.h>
13871
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
28 #include <sys/spa_impl.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
29 #include <sys/vdev_file.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
30 #include <sys/vdev_impl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
31 #include <sys/zio.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
32 #include <sys/fs/zfs.h>
6976
cae5f06df471 PSARC 2008/388 Short circuit for vdev probe failure
eschrock
parents: 6523
diff changeset
33 #include <sys/fm/fs/zfs.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
34
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
35 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
36 * Virtual device vector for files.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
37 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
38
11958
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
39 static void
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
40 vdev_file_hold(vdev_t *vd)
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
41 {
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
42 ASSERT(vd->vdev_path != NULL);
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
43 }
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
44
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
45 static void
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
46 vdev_file_rele(vdev_t *vd)
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
47 {
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
48 ASSERT(vd->vdev_path != NULL);
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
49 }
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
50
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
51 static int
13570
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 12247
diff changeset
52 vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 12247
diff changeset
53 uint64_t *ashift)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
54 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
55 vdev_file_t *vf;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
56 vnode_t *vp;
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 6976
diff changeset
57 vattr_t vattr;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
58 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
59
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
60 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
61 * We must have a pathname, and it must be absolute.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
62 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
63 if (vd->vdev_path == NULL || vd->vdev_path[0] != '/') {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
64 vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
65 return (EINVAL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
66 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
67
10850
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
68 /*
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
69 * Reopen the device if it's not currently open. Otherwise,
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
70 * just update the physical size of the device.
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
71 */
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
72 if (vd->vdev_tsd != NULL) {
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
73 ASSERT(vd->vdev_reopening);
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
74 vf = vd->vdev_tsd;
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
75 goto skip_open;
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
76 }
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
77
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
78 vf = vd->vdev_tsd = kmem_zalloc(sizeof (vdev_file_t), KM_SLEEP);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
79
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
80 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
81 * We always open the files from the root of the global zone, even if
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
82 * we're in a local zone. If the user has gotten to this point, the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
83 * administrator has already decided that the pool should be available
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
84 * to local zone users, so the underlying devices should be as well.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
85 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
86 ASSERT(vd->vdev_path != NULL && vd->vdev_path[0] == '/');
5329
33cb98223b2d PSARC 2007/567 zpool failmode property
gw25295
parents: 3059
diff changeset
87 error = vn_openat(vd->vdev_path + 1, UIO_SYSSPACE,
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7754
diff changeset
88 spa_mode(vd->vdev_spa) | FOFFMAX, 0, &vp, 0, 0, rootdir, -1);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
89
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
90 if (error) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
91 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
92 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
93 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
94
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
95 vf->vf_vnode = vp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
96
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
97 #ifdef _KERNEL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
98 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
99 * Make sure it's a regular file.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
100 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
101 if (vp->v_type != VREG) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
102 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
103 return (ENODEV);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
104 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
105 #endif
10850
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
106
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
107 skip_open:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
108 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
109 * Determine the physical size of the file.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
110 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
111 vattr.va_mask = AT_SIZE;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
112 error = VOP_GETATTR(vf->vf_vnode, &vattr, 0, kcred, NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
113 if (error) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
114 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
115 return (error);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
116 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
117
13570
3411fd5f1589 1948 zpool list should show more detailed pool information
George Wilson <George.Wilson@delphix.com>
parents: 12247
diff changeset
118 *max_psize = *psize = vattr.va_size;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
119 *ashift = SPA_MINBLOCKSHIFT;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
120
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
121 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
122 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
123
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
124 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
125 vdev_file_close(vdev_t *vd)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
126 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
127 vdev_file_t *vf = vd->vdev_tsd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
128
10850
bb29ac73664d 6840704 osol_0906 PV guests sometimes hang at login prompt
George Wilson <George.Wilson@Sun.COM>
parents: 8241
diff changeset
129 if (vd->vdev_reopening || vf == NULL)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
130 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
131
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
132 if (vf->vf_vnode != NULL) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
133 (void) VOP_PUTPAGE(vf->vf_vnode, 0, 0, B_INVAL, kcred, NULL);
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7754
diff changeset
134 (void) VOP_CLOSE(vf->vf_vnode, spa_mode(vd->vdev_spa), 1, 0,
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7754
diff changeset
135 kcred, NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
136 VN_RELE(vf->vf_vnode);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
137 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
138
12247
5bcd281629f8 6911420 ZFS device removal detection should work with SCSAv3
George Wilson <George.Wilson@Sun.COM>
parents: 11958
diff changeset
139 vd->vdev_delayed_close = B_FALSE;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
140 kmem_free(vf, sizeof (vdev_file_t));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
141 vd->vdev_tsd = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
142 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
143
13871
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
144 /*
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
145 * Implements the interrupt side for file vdev types. This routine will be
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
146 * called when the I/O completes allowing us to transfer the I/O to the
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
147 * interrupt taskqs. For consistency, the code structure mimics disk vdev
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
148 * types.
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
149 */
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
150 static void
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
151 vdev_file_io_intr(buf_t *bp)
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
152 {
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
153 vdev_buf_t *vb = (vdev_buf_t *)bp;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
154 zio_t *zio = vb->vb_io;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
155
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
156 zio->io_error = (geterror(bp) != 0 ? EIO : 0);
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
157 if (zio->io_error == 0 && bp->b_resid != 0)
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
158 zio->io_error = ENOSPC;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
159
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
160 kmem_free(vb, sizeof (vdev_buf_t));
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
161 zio_interrupt(zio);
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
162 }
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
163
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
164 static void
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
165 vdev_file_io_strategy(void *arg)
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
166 {
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
167 buf_t *bp = arg;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
168 vnode_t *vp = bp->b_private;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
169 ssize_t resid;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
170 int error;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
171
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
172 error = vn_rdwr((bp->b_flags & B_READ) ? UIO_READ : UIO_WRITE,
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
173 vp, bp->b_un.b_addr, bp->b_bcount, ldbtob(bp->b_lblkno),
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
174 UIO_SYSSPACE, 0, RLIM64_INFINITY, kcred, &resid);
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
175
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
176 if (error == 0) {
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
177 bp->b_resid = resid;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
178 biodone(bp);
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
179 } else {
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
180 bioerror(bp, error);
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
181 biodone(bp);
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
182 }
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
183 }
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
184
5329
33cb98223b2d PSARC 2007/567 zpool failmode property
gw25295
parents: 3059
diff changeset
185 static int
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
186 vdev_file_io_start(zio_t *zio)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
187 {
13871
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
188 spa_t *spa = zio->io_spa;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
189 vdev_t *vd = zio->io_vd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
190 vdev_file_t *vf = vd->vdev_tsd;
13871
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
191 vdev_buf_t *vb;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
192 buf_t *bp;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
193
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
194 if (zio->io_type == ZIO_TYPE_IOCTL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
195 /* XXPOLICY */
5329
33cb98223b2d PSARC 2007/567 zpool failmode property
gw25295
parents: 3059
diff changeset
196 if (!vdev_readable(vd)) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
197 zio->io_error = ENXIO;
5530
4ed96167d864 6354519 stack overflow in zfs due to zio pipeline
bonwick
parents: 5369
diff changeset
198 return (ZIO_PIPELINE_CONTINUE);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
199 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
200
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
201 switch (zio->io_cmd) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
202 case DKIOCFLUSHWRITECACHE:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
203 zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC,
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5329
diff changeset
204 kcred, NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
205 break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
206 default:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
207 zio->io_error = ENOTSUP;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
208 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
209
5530
4ed96167d864 6354519 stack overflow in zfs due to zio pipeline
bonwick
parents: 5369
diff changeset
210 return (ZIO_PIPELINE_CONTINUE);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
211 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
212
13871
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
213 vb = kmem_alloc(sizeof (vdev_buf_t), KM_SLEEP);
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
214
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
215 vb->vb_io = zio;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
216 bp = &vb->vb_buf;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
217
13871
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
218 bioinit(bp);
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
219 bp->b_flags = (zio->io_type == ZIO_TYPE_READ ? B_READ : B_WRITE);
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
220 bp->b_bcount = zio->io_size;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
221 bp->b_un.b_addr = zio->io_data;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
222 bp->b_lblkno = lbtodb(zio->io_offset);
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
223 bp->b_bufsize = zio->io_size;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
224 bp->b_private = vf->vf_vnode;
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
225 bp->b_iodone = (int (*)())vdev_file_io_intr;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
226
13971
d1648d817bd6 3581 spa_zio_taskq[ZIO_TYPE_FREE][ZIO_TASKQ_ISSUE]->tq_lock is piping hot
Adam Leventhal <ahl@delphix.com>
parents: 13871
diff changeset
227 spa_taskq_dispatch_ent(spa, ZIO_TYPE_FREE, ZIO_TASKQ_ISSUE,
13871
a9c12c2c1647 3306 zdb should be able to issue reads in parallel
George Wilson <george.wilson@delphix.com>
parents: 13570
diff changeset
228 vdev_file_io_strategy, bp, 0, &zio->io_tqent);
5530
4ed96167d864 6354519 stack overflow in zfs due to zio pipeline
bonwick
parents: 5369
diff changeset
229
4ed96167d864 6354519 stack overflow in zfs due to zio pipeline
bonwick
parents: 5369
diff changeset
230 return (ZIO_PIPELINE_STOP);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
231 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
232
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 6976
diff changeset
233 /* ARGSUSED */
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 6976
diff changeset
234 static void
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
235 vdev_file_io_done(zio_t *zio)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
236 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
237 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
238
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
239 vdev_ops_t vdev_file_ops = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
240 vdev_file_open,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
241 vdev_file_close,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
242 vdev_default_asize,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
243 vdev_file_io_start,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
244 vdev_file_io_done,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
245 NULL,
11958
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
246 vdev_file_hold,
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
247 vdev_file_rele,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
248 VDEV_TYPE_FILE, /* name of this vdev type */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
249 B_TRUE /* leaf vdev */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
250 };
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
251
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
252 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
253 * From userland we access disks just like files.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
254 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
255 #ifndef _KERNEL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
256
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
257 vdev_ops_t vdev_disk_ops = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
258 vdev_file_open,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
259 vdev_file_close,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
260 vdev_default_asize,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
261 vdev_file_io_start,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
262 vdev_file_io_done,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
263 NULL,
11958
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
264 vdev_file_hold,
575ffe1e978d 6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents: 10850
diff changeset
265 vdev_file_rele,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
266 VDEV_TYPE_DISK, /* name of this vdev type */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
267 B_TRUE /* leaf vdev */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
268 };
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
269
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
270 #endif