author | Eric Taylor <Eric.Taylor@Sun.COM> |
Tue, 07 Apr 2009 13:03:48 -0600 | |
changeset 9303 | 587ef5ac9176 |
parent 9277 | 3e67eb420d44 |
child 9401 | afae664f76f6 |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 7 |
* |
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
/* |
|
8524
a56dffa8fba9
6770534 zvols do not observe character device semantics
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
8227
diff
changeset
|
22 |
* Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
/* |
|
27 |
* ZFS volume emulation driver. |
|
28 |
* |
|
29 |
* Makes a DMU object look like a volume of arbitrary size, up to 2^64 bytes. |
|
30 |
* Volumes are accessed through the symbolic links named: |
|
31 |
* |
|
32 |
* /dev/zvol/dsk/<pool_name>/<dataset_name> |
|
33 |
* /dev/zvol/rdsk/<pool_name>/<dataset_name> |
|
34 |
* |
|
35 |
* These links are created by the ZFS-specific devfsadm link generator. |
|
36 |
* Volumes are persistent through reboot. No user command needs to be |
|
37 |
* run before opening and using a device. |
|
38 |
*/ |
|
39 |
||
40 |
#include <sys/types.h> |
|
41 |
#include <sys/param.h> |
|
42 |
#include <sys/errno.h> |
|
43 |
#include <sys/uio.h> |
|
44 |
#include <sys/buf.h> |
|
45 |
#include <sys/modctl.h> |
|
46 |
#include <sys/open.h> |
|
47 |
#include <sys/kmem.h> |
|
48 |
#include <sys/conf.h> |
|
49 |
#include <sys/cmn_err.h> |
|
50 |
#include <sys/stat.h> |
|
51 |
#include <sys/zap.h> |
|
52 |
#include <sys/spa.h> |
|
53 |
#include <sys/zio.h> |
|
6423 | 54 |
#include <sys/dmu_traverse.h> |
55 |
#include <sys/dnode.h> |
|
56 |
#include <sys/dsl_dataset.h> |
|
789 | 57 |
#include <sys/dsl_prop.h> |
58 |
#include <sys/dkio.h> |
|
59 |
#include <sys/efi_partition.h> |
|
60 |
#include <sys/byteorder.h> |
|
61 |
#include <sys/pathname.h> |
|
62 |
#include <sys/ddi.h> |
|
63 |
#include <sys/sunddi.h> |
|
64 |
#include <sys/crc32.h> |
|
65 |
#include <sys/dirent.h> |
|
66 |
#include <sys/policy.h> |
|
67 |
#include <sys/fs/zfs.h> |
|
68 |
#include <sys/zfs_ioctl.h> |
|
69 |
#include <sys/mkdev.h> |
|
1141 | 70 |
#include <sys/zil.h> |
2237 | 71 |
#include <sys/refcount.h> |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
72 |
#include <sys/zfs_znode.h> |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
73 |
#include <sys/zfs_rlock.h> |
6423 | 74 |
#include <sys/vdev_disk.h> |
75 |
#include <sys/vdev_impl.h> |
|
76 |
#include <sys/zvol.h> |
|
77 |
#include <sys/dumphdr.h> |
|
8227 | 78 |
#include <sys/zil_impl.h> |
789 | 79 |
|
80 |
#include "zfs_namecheck.h" |
|
81 |
||
6423 | 82 |
static void *zvol_state; |
789 | 83 |
|
6423 | 84 |
#define ZVOL_DUMPSIZE "dumpsize" |
789 | 85 |
|
86 |
/* |
|
87 |
* This lock protects the zvol_state structure from being modified |
|
88 |
* while it's being used, e.g. an open that comes in before a create |
|
89 |
* finishes. It also protects temporary opens of the dataset so that, |
|
90 |
* e.g., an open doesn't get a spurious EBUSY. |
|
91 |
*/ |
|
92 |
static kmutex_t zvol_state_lock; |
|
93 |
static uint32_t zvol_minors; |
|
94 |
||
6423 | 95 |
typedef struct zvol_extent { |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
96 |
list_node_t ze_node; |
6423 | 97 |
dva_t ze_dva; /* dva associated with this extent */ |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
98 |
uint64_t ze_nblks; /* number of blocks in extent */ |
6423 | 99 |
} zvol_extent_t; |
100 |
||
101 |
/* |
|
789 | 102 |
* The in-core state of each volume. |
103 |
*/ |
|
104 |
typedef struct zvol_state { |
|
105 |
char zv_name[MAXPATHLEN]; /* pool/dd name */ |
|
106 |
uint64_t zv_volsize; /* amount of space we advertise */ |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
107 |
uint64_t zv_volblocksize; /* volume block size */ |
789 | 108 |
minor_t zv_minor; /* minor number */ |
109 |
uint8_t zv_min_bs; /* minimum addressable block shift */ |
|
9303
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
110 |
uint8_t zv_flags; /* readonly, dumpified, etc. */ |
789 | 111 |
objset_t *zv_objset; /* objset handle */ |
112 |
uint32_t zv_mode; /* DS_MODE_* flags at open time */ |
|
113 |
uint32_t zv_open_count[OTYPCNT]; /* open counts */ |
|
114 |
uint32_t zv_total_opens; /* total open count */ |
|
1141 | 115 |
zilog_t *zv_zilog; /* ZIL handle */ |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
116 |
list_t zv_extents; /* List of extents for dump */ |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
117 |
znode_t zv_znode; /* for range locking */ |
789 | 118 |
} zvol_state_t; |
119 |
||
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
120 |
/* |
6423 | 121 |
* zvol specific flags |
122 |
*/ |
|
123 |
#define ZVOL_RDONLY 0x1 |
|
124 |
#define ZVOL_DUMPIFIED 0x2 |
|
7405
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
125 |
#define ZVOL_EXCL 0x4 |
9303
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
126 |
#define ZVOL_WCE 0x8 |
6423 | 127 |
|
128 |
/* |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
129 |
* zvol maximum transfer in one DMU tx. |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
130 |
*/ |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
131 |
int zvol_maxphys = DMU_MAX_ACCESS/2; |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
132 |
|
6423 | 133 |
extern int zfs_set_prop_nvlist(const char *, nvlist_t *); |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
134 |
static int zvol_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio); |
6423 | 135 |
static int zvol_dumpify(zvol_state_t *zv); |
136 |
static int zvol_dump_fini(zvol_state_t *zv); |
|
137 |
static int zvol_dump_init(zvol_state_t *zv, boolean_t resize); |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
138 |
|
789 | 139 |
static void |
4787 | 140 |
zvol_size_changed(zvol_state_t *zv, major_t maj) |
789 | 141 |
{ |
4787 | 142 |
dev_t dev = makedevice(maj, zv->zv_minor); |
789 | 143 |
|
144 |
VERIFY(ddi_prop_update_int64(dev, zfs_dip, |
|
145 |
"Size", zv->zv_volsize) == DDI_SUCCESS); |
|
146 |
VERIFY(ddi_prop_update_int64(dev, zfs_dip, |
|
147 |
"Nblocks", lbtodb(zv->zv_volsize)) == DDI_SUCCESS); |
|
6423 | 148 |
|
149 |
/* Notify specfs to invalidate the cached size */ |
|
150 |
spec_size_invalidate(dev, VBLK); |
|
151 |
spec_size_invalidate(dev, VCHR); |
|
789 | 152 |
} |
153 |
||
154 |
int |
|
2676 | 155 |
zvol_check_volsize(uint64_t volsize, uint64_t blocksize) |
789 | 156 |
{ |
2676 | 157 |
if (volsize == 0) |
789 | 158 |
return (EINVAL); |
159 |
||
2676 | 160 |
if (volsize % blocksize != 0) |
1133
335d069294d1
6357470 vdev_raidz.c has unused RAIDZ_SINGLE define, code
eschrock
parents:
849
diff
changeset
|
161 |
return (EINVAL); |
335d069294d1
6357470 vdev_raidz.c has unused RAIDZ_SINGLE define, code
eschrock
parents:
849
diff
changeset
|
162 |
|
789 | 163 |
#ifdef _ILP32 |
2676 | 164 |
if (volsize - 1 > SPEC_MAXOFFSET_T) |
789 | 165 |
return (EOVERFLOW); |
166 |
#endif |
|
167 |
return (0); |
|
168 |
} |
|
169 |
||
170 |
int |
|
2676 | 171 |
zvol_check_volblocksize(uint64_t volblocksize) |
789 | 172 |
{ |
2676 | 173 |
if (volblocksize < SPA_MINBLOCKSIZE || |
174 |
volblocksize > SPA_MAXBLOCKSIZE || |
|
175 |
!ISP2(volblocksize)) |
|
789 | 176 |
return (EDOM); |
177 |
||
178 |
return (0); |
|
179 |
} |
|
180 |
||
181 |
static void |
|
182 |
zvol_readonly_changed_cb(void *arg, uint64_t newval) |
|
183 |
{ |
|
184 |
zvol_state_t *zv = arg; |
|
185 |
||
6423 | 186 |
if (newval) |
187 |
zv->zv_flags |= ZVOL_RDONLY; |
|
188 |
else |
|
189 |
zv->zv_flags &= ~ZVOL_RDONLY; |
|
789 | 190 |
} |
191 |
||
192 |
int |
|
2885 | 193 |
zvol_get_stats(objset_t *os, nvlist_t *nv) |
789 | 194 |
{ |
195 |
int error; |
|
196 |
dmu_object_info_t doi; |
|
2885 | 197 |
uint64_t val; |
789 | 198 |
|
199 |
||
2885 | 200 |
error = zap_lookup(os, ZVOL_ZAP_OBJ, "size", 8, 1, &val); |
789 | 201 |
if (error) |
202 |
return (error); |
|
203 |
||
2885 | 204 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_VOLSIZE, val); |
205 |
||
789 | 206 |
error = dmu_object_info(os, ZVOL_OBJ, &doi); |
207 |
||
2885 | 208 |
if (error == 0) { |
209 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_VOLBLOCKSIZE, |
|
210 |
doi.doi_data_block_size); |
|
211 |
} |
|
789 | 212 |
|
213 |
return (error); |
|
214 |
} |
|
215 |
||
216 |
/* |
|
217 |
* Find a free minor number. |
|
218 |
*/ |
|
219 |
static minor_t |
|
220 |
zvol_minor_alloc(void) |
|
221 |
{ |
|
222 |
minor_t minor; |
|
223 |
||
224 |
ASSERT(MUTEX_HELD(&zvol_state_lock)); |
|
225 |
||
226 |
for (minor = 1; minor <= ZVOL_MAX_MINOR; minor++) |
|
227 |
if (ddi_get_soft_state(zvol_state, minor) == NULL) |
|
228 |
return (minor); |
|
229 |
||
230 |
return (0); |
|
231 |
} |
|
232 |
||
233 |
static zvol_state_t * |
|
2676 | 234 |
zvol_minor_lookup(const char *name) |
789 | 235 |
{ |
236 |
minor_t minor; |
|
237 |
zvol_state_t *zv; |
|
238 |
||
239 |
ASSERT(MUTEX_HELD(&zvol_state_lock)); |
|
240 |
||
241 |
for (minor = 1; minor <= ZVOL_MAX_MINOR; minor++) { |
|
242 |
zv = ddi_get_soft_state(zvol_state, minor); |
|
243 |
if (zv == NULL) |
|
244 |
continue; |
|
245 |
if (strcmp(zv->zv_name, name) == 0) |
|
246 |
break; |
|
247 |
} |
|
248 |
||
249 |
return (zv); |
|
250 |
} |
|
251 |
||
6423 | 252 |
/* extent mapping arg */ |
253 |
struct maparg { |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
254 |
zvol_state_t *ma_zv; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
255 |
uint64_t ma_blks; |
6423 | 256 |
}; |
257 |
||
258 |
/*ARGSUSED*/ |
|
259 |
static int |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
260 |
zvol_map_block(spa_t *spa, blkptr_t *bp, const zbookmark_t *zb, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
261 |
const dnode_phys_t *dnp, void *arg) |
6423 | 262 |
{ |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
263 |
struct maparg *ma = arg; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
264 |
zvol_extent_t *ze; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
265 |
int bs = ma->ma_zv->zv_volblocksize; |
6423 | 266 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
267 |
if (bp == NULL || zb->zb_object != ZVOL_OBJ || zb->zb_level != 0) |
6423 | 268 |
return (0); |
269 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
270 |
VERIFY3U(ma->ma_blks, ==, zb->zb_blkid); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
271 |
ma->ma_blks++; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
272 |
|
6423 | 273 |
/* Abort immediately if we have encountered gang blocks */ |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
274 |
if (BP_IS_GANG(bp)) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
275 |
return (EFRAGS); |
6423 | 276 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
277 |
/* |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
278 |
* See if the block is at the end of the previous extent. |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
279 |
*/ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
280 |
ze = list_tail(&ma->ma_zv->zv_extents); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
281 |
if (ze && |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
282 |
DVA_GET_VDEV(BP_IDENTITY(bp)) == DVA_GET_VDEV(&ze->ze_dva) && |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
283 |
DVA_GET_OFFSET(BP_IDENTITY(bp)) == |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
284 |
DVA_GET_OFFSET(&ze->ze_dva) + ze->ze_nblks * bs) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
285 |
ze->ze_nblks++; |
6423 | 286 |
return (0); |
287 |
} |
|
288 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
289 |
dprintf_bp(bp, "%s", "next blkptr:"); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
290 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
291 |
/* start a new extent */ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
292 |
ze = kmem_zalloc(sizeof (zvol_extent_t), KM_SLEEP); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
293 |
ze->ze_dva = bp->blk_dva[0]; /* structure assignment */ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
294 |
ze->ze_nblks = 1; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
295 |
list_insert_tail(&ma->ma_zv->zv_extents, ze); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
296 |
return (0); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
297 |
} |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
298 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
299 |
static void |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
300 |
zvol_free_extents(zvol_state_t *zv) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
301 |
{ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
302 |
zvol_extent_t *ze; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
303 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
304 |
while (ze = list_head(&zv->zv_extents)) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
305 |
list_remove(&zv->zv_extents, ze); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
306 |
kmem_free(ze, sizeof (zvol_extent_t)); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
307 |
} |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
308 |
} |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
309 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
310 |
static int |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
311 |
zvol_get_lbas(zvol_state_t *zv) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
312 |
{ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
313 |
struct maparg ma; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
314 |
int err; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
315 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
316 |
ma.ma_zv = zv; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
317 |
ma.ma_blks = 0; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
318 |
zvol_free_extents(zv); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
319 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
320 |
err = traverse_dataset(dmu_objset_ds(zv->zv_objset), 0, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
321 |
TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA, zvol_map_block, &ma); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
322 |
if (err || ma.ma_blks != (zv->zv_volsize / zv->zv_volblocksize)) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
323 |
zvol_free_extents(zv); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
324 |
return (err ? err : EIO); |
6423 | 325 |
} |
326 |
||
327 |
return (0); |
|
328 |
} |
|
329 |
||
4543 | 330 |
/* ARGSUSED */ |
789 | 331 |
void |
4543 | 332 |
zvol_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx) |
789 | 333 |
{ |
5331 | 334 |
zfs_creat_t *zct = arg; |
335 |
nvlist_t *nvprops = zct->zct_props; |
|
789 | 336 |
int error; |
2676 | 337 |
uint64_t volblocksize, volsize; |
789 | 338 |
|
4543 | 339 |
VERIFY(nvlist_lookup_uint64(nvprops, |
2676 | 340 |
zfs_prop_to_name(ZFS_PROP_VOLSIZE), &volsize) == 0); |
4543 | 341 |
if (nvlist_lookup_uint64(nvprops, |
2676 | 342 |
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), &volblocksize) != 0) |
343 |
volblocksize = zfs_prop_default_numeric(ZFS_PROP_VOLBLOCKSIZE); |
|
344 |
||
345 |
/* |
|
6423 | 346 |
* These properties must be removed from the list so the generic |
2676 | 347 |
* property setting step won't apply to them. |
348 |
*/ |
|
4543 | 349 |
VERIFY(nvlist_remove_all(nvprops, |
2676 | 350 |
zfs_prop_to_name(ZFS_PROP_VOLSIZE)) == 0); |
4543 | 351 |
(void) nvlist_remove_all(nvprops, |
2676 | 352 |
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE)); |
353 |
||
354 |
error = dmu_object_claim(os, ZVOL_OBJ, DMU_OT_ZVOL, volblocksize, |
|
789 | 355 |
DMU_OT_NONE, 0, tx); |
356 |
ASSERT(error == 0); |
|
357 |
||
358 |
error = zap_create_claim(os, ZVOL_ZAP_OBJ, DMU_OT_ZVOL_PROP, |
|
359 |
DMU_OT_NONE, 0, tx); |
|
360 |
ASSERT(error == 0); |
|
361 |
||
2676 | 362 |
error = zap_update(os, ZVOL_ZAP_OBJ, "size", 8, 1, &volsize, tx); |
789 | 363 |
ASSERT(error == 0); |
364 |
} |
|
365 |
||
366 |
/* |
|
1141 | 367 |
* Replay a TX_WRITE ZIL transaction that didn't get committed |
368 |
* after a system failure |
|
369 |
*/ |
|
370 |
static int |
|
371 |
zvol_replay_write(zvol_state_t *zv, lr_write_t *lr, boolean_t byteswap) |
|
372 |
{ |
|
373 |
objset_t *os = zv->zv_objset; |
|
374 |
char *data = (char *)(lr + 1); /* data follows lr_write_t */ |
|
375 |
uint64_t off = lr->lr_offset; |
|
376 |
uint64_t len = lr->lr_length; |
|
377 |
dmu_tx_t *tx; |
|
378 |
int error; |
|
379 |
||
380 |
if (byteswap) |
|
381 |
byteswap_uint64_array(lr, sizeof (*lr)); |
|
382 |
||
383 |
tx = dmu_tx_create(os); |
|
384 |
dmu_tx_hold_write(tx, ZVOL_OBJ, off, len); |
|
8227 | 385 |
error = dmu_tx_assign(tx, TXG_WAIT); |
1141 | 386 |
if (error) { |
387 |
dmu_tx_abort(tx); |
|
388 |
} else { |
|
389 |
dmu_write(os, ZVOL_OBJ, off, len, data, tx); |
|
390 |
dmu_tx_commit(tx); |
|
391 |
} |
|
392 |
||
393 |
return (error); |
|
394 |
} |
|
395 |
||
396 |
/* ARGSUSED */ |
|
397 |
static int |
|
398 |
zvol_replay_err(zvol_state_t *zv, lr_t *lr, boolean_t byteswap) |
|
399 |
{ |
|
400 |
return (ENOTSUP); |
|
401 |
} |
|
402 |
||
403 |
/* |
|
404 |
* Callback vectors for replaying records. |
|
405 |
* Only TX_WRITE is needed for zvol. |
|
406 |
*/ |
|
407 |
zil_replay_func_t *zvol_replay_vector[TX_MAX_TYPE] = { |
|
408 |
zvol_replay_err, /* 0 no such transaction type */ |
|
409 |
zvol_replay_err, /* TX_CREATE */ |
|
410 |
zvol_replay_err, /* TX_MKDIR */ |
|
411 |
zvol_replay_err, /* TX_MKXATTR */ |
|
412 |
zvol_replay_err, /* TX_SYMLINK */ |
|
413 |
zvol_replay_err, /* TX_REMOVE */ |
|
414 |
zvol_replay_err, /* TX_RMDIR */ |
|
415 |
zvol_replay_err, /* TX_LINK */ |
|
416 |
zvol_replay_err, /* TX_RENAME */ |
|
417 |
zvol_replay_write, /* TX_WRITE */ |
|
418 |
zvol_replay_err, /* TX_TRUNCATE */ |
|
419 |
zvol_replay_err, /* TX_SETATTR */ |
|
420 |
zvol_replay_err, /* TX_ACL */ |
|
421 |
}; |
|
422 |
||
423 |
/* |
|
6423 | 424 |
* Create a minor node (plus a whole lot more) for the specified volume. |
789 | 425 |
*/ |
426 |
int |
|
4787 | 427 |
zvol_create_minor(const char *name, major_t maj) |
789 | 428 |
{ |
429 |
zvol_state_t *zv; |
|
430 |
objset_t *os; |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
431 |
dmu_object_info_t doi; |
789 | 432 |
uint64_t volsize; |
433 |
minor_t minor = 0; |
|
434 |
struct pathname linkpath; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6423
diff
changeset
|
435 |
int ds_mode = DS_MODE_OWNER; |
789 | 436 |
vnode_t *vp = NULL; |
437 |
char *devpath; |
|
6423 | 438 |
size_t devpathlen = strlen(ZVOL_FULL_DEV_DIR) + strlen(name) + 1; |
789 | 439 |
char chrbuf[30], blkbuf[30]; |
440 |
int error; |
|
441 |
||
442 |
mutex_enter(&zvol_state_lock); |
|
443 |
||
444 |
if ((zv = zvol_minor_lookup(name)) != NULL) { |
|
445 |
mutex_exit(&zvol_state_lock); |
|
446 |
return (EEXIST); |
|
447 |
} |
|
448 |
||
449 |
if (strchr(name, '@') != 0) |
|
450 |
ds_mode |= DS_MODE_READONLY; |
|
451 |
||
452 |
error = dmu_objset_open(name, DMU_OST_ZVOL, ds_mode, &os); |
|
453 |
||
454 |
if (error) { |
|
455 |
mutex_exit(&zvol_state_lock); |
|
456 |
return (error); |
|
457 |
} |
|
458 |
||
459 |
error = zap_lookup(os, ZVOL_ZAP_OBJ, "size", 8, 1, &volsize); |
|
460 |
||
461 |
if (error) { |
|
462 |
dmu_objset_close(os); |
|
463 |
mutex_exit(&zvol_state_lock); |
|
464 |
return (error); |
|
465 |
} |
|
466 |
||
467 |
/* |
|
468 |
* If there's an existing /dev/zvol symlink, try to use the |
|
469 |
* same minor number we used last time. |
|
470 |
*/ |
|
471 |
devpath = kmem_alloc(devpathlen, KM_SLEEP); |
|
472 |
||
6423 | 473 |
(void) sprintf(devpath, "%s%s", ZVOL_FULL_DEV_DIR, name); |
789 | 474 |
|
475 |
error = lookupname(devpath, UIO_SYSSPACE, NO_FOLLOW, NULL, &vp); |
|
476 |
||
477 |
kmem_free(devpath, devpathlen); |
|
478 |
||
479 |
if (error == 0 && vp->v_type != VLNK) |
|
480 |
error = EINVAL; |
|
481 |
||
482 |
if (error == 0) { |
|
483 |
pn_alloc(&linkpath); |
|
484 |
error = pn_getsymlink(vp, &linkpath, kcred); |
|
485 |
if (error == 0) { |
|
486 |
char *ms = strstr(linkpath.pn_path, ZVOL_PSEUDO_DEV); |
|
487 |
if (ms != NULL) { |
|
488 |
ms += strlen(ZVOL_PSEUDO_DEV); |
|
489 |
minor = stoi(&ms); |
|
490 |
} |
|
491 |
} |
|
492 |
pn_free(&linkpath); |
|
493 |
} |
|
494 |
||
495 |
if (vp != NULL) |
|
496 |
VN_RELE(vp); |
|
497 |
||
498 |
/* |
|
499 |
* If we found a minor but it's already in use, we must pick a new one. |
|
500 |
*/ |
|
501 |
if (minor != 0 && ddi_get_soft_state(zvol_state, minor) != NULL) |
|
502 |
minor = 0; |
|
503 |
||
504 |
if (minor == 0) |
|
505 |
minor = zvol_minor_alloc(); |
|
506 |
||
507 |
if (minor == 0) { |
|
508 |
dmu_objset_close(os); |
|
509 |
mutex_exit(&zvol_state_lock); |
|
510 |
return (ENXIO); |
|
511 |
} |
|
512 |
||
513 |
if (ddi_soft_state_zalloc(zvol_state, minor) != DDI_SUCCESS) { |
|
514 |
dmu_objset_close(os); |
|
515 |
mutex_exit(&zvol_state_lock); |
|
516 |
return (EAGAIN); |
|
517 |
} |
|
518 |
||
2676 | 519 |
(void) ddi_prop_update_string(minor, zfs_dip, ZVOL_PROP_NAME, |
520 |
(char *)name); |
|
789 | 521 |
|
522 |
(void) sprintf(chrbuf, "%uc,raw", minor); |
|
523 |
||
524 |
if (ddi_create_minor_node(zfs_dip, chrbuf, S_IFCHR, |
|
525 |
minor, DDI_PSEUDO, 0) == DDI_FAILURE) { |
|
526 |
ddi_soft_state_free(zvol_state, minor); |
|
527 |
dmu_objset_close(os); |
|
528 |
mutex_exit(&zvol_state_lock); |
|
529 |
return (EAGAIN); |
|
530 |
} |
|
531 |
||
532 |
(void) sprintf(blkbuf, "%uc", minor); |
|
533 |
||
534 |
if (ddi_create_minor_node(zfs_dip, blkbuf, S_IFBLK, |
|
535 |
minor, DDI_PSEUDO, 0) == DDI_FAILURE) { |
|
536 |
ddi_remove_minor_node(zfs_dip, chrbuf); |
|
537 |
ddi_soft_state_free(zvol_state, minor); |
|
538 |
dmu_objset_close(os); |
|
539 |
mutex_exit(&zvol_state_lock); |
|
540 |
return (EAGAIN); |
|
541 |
} |
|
542 |
||
543 |
zv = ddi_get_soft_state(zvol_state, minor); |
|
544 |
||
545 |
(void) strcpy(zv->zv_name, name); |
|
546 |
zv->zv_min_bs = DEV_BSHIFT; |
|
547 |
zv->zv_minor = minor; |
|
548 |
zv->zv_volsize = volsize; |
|
549 |
zv->zv_objset = os; |
|
550 |
zv->zv_mode = ds_mode; |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
551 |
zv->zv_zilog = zil_open(os, zvol_get_data); |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
552 |
mutex_init(&zv->zv_znode.z_range_lock, NULL, MUTEX_DEFAULT, NULL); |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
553 |
avl_create(&zv->zv_znode.z_range_avl, zfs_range_compare, |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
554 |
sizeof (rl_t), offsetof(rl_t, r_node)); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
555 |
list_create(&zv->zv_extents, sizeof (zvol_extent_t), |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
556 |
offsetof(zvol_extent_t, ze_node)); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
557 |
/* get and cache the blocksize */ |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
558 |
error = dmu_object_info(os, ZVOL_OBJ, &doi); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
559 |
ASSERT(error == 0); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
560 |
zv->zv_volblocksize = doi.doi_data_block_size; |
1141 | 561 |
|
8227 | 562 |
zil_replay(os, zv, zvol_replay_vector); |
4787 | 563 |
zvol_size_changed(zv, maj); |
789 | 564 |
|
1544 | 565 |
/* XXX this should handle the possible i/o error */ |
789 | 566 |
VERIFY(dsl_prop_register(dmu_objset_ds(zv->zv_objset), |
567 |
"readonly", zvol_readonly_changed_cb, zv) == 0); |
|
568 |
||
569 |
zvol_minors++; |
|
570 |
||
571 |
mutex_exit(&zvol_state_lock); |
|
572 |
||
573 |
return (0); |
|
574 |
} |
|
575 |
||
576 |
/* |
|
577 |
* Remove minor node for the specified volume. |
|
578 |
*/ |
|
579 |
int |
|
2676 | 580 |
zvol_remove_minor(const char *name) |
789 | 581 |
{ |
582 |
zvol_state_t *zv; |
|
583 |
char namebuf[30]; |
|
584 |
||
585 |
mutex_enter(&zvol_state_lock); |
|
586 |
||
2676 | 587 |
if ((zv = zvol_minor_lookup(name)) == NULL) { |
789 | 588 |
mutex_exit(&zvol_state_lock); |
589 |
return (ENXIO); |
|
590 |
} |
|
591 |
||
592 |
if (zv->zv_total_opens != 0) { |
|
593 |
mutex_exit(&zvol_state_lock); |
|
594 |
return (EBUSY); |
|
595 |
} |
|
596 |
||
597 |
(void) sprintf(namebuf, "%uc,raw", zv->zv_minor); |
|
598 |
ddi_remove_minor_node(zfs_dip, namebuf); |
|
599 |
||
600 |
(void) sprintf(namebuf, "%uc", zv->zv_minor); |
|
601 |
ddi_remove_minor_node(zfs_dip, namebuf); |
|
602 |
||
603 |
VERIFY(dsl_prop_unregister(dmu_objset_ds(zv->zv_objset), |
|
604 |
"readonly", zvol_readonly_changed_cb, zv) == 0); |
|
605 |
||
1141 | 606 |
zil_close(zv->zv_zilog); |
607 |
zv->zv_zilog = NULL; |
|
789 | 608 |
dmu_objset_close(zv->zv_objset); |
609 |
zv->zv_objset = NULL; |
|
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
610 |
avl_destroy(&zv->zv_znode.z_range_avl); |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
611 |
mutex_destroy(&zv->zv_znode.z_range_lock); |
789 | 612 |
|
613 |
ddi_soft_state_free(zvol_state, zv->zv_minor); |
|
614 |
||
615 |
zvol_minors--; |
|
616 |
||
617 |
mutex_exit(&zvol_state_lock); |
|
618 |
||
619 |
return (0); |
|
620 |
} |
|
621 |
||
6423 | 622 |
int |
623 |
zvol_prealloc(zvol_state_t *zv) |
|
624 |
{ |
|
625 |
objset_t *os = zv->zv_objset; |
|
626 |
dmu_tx_t *tx; |
|
627 |
uint64_t refd, avail, usedobjs, availobjs; |
|
628 |
uint64_t resid = zv->zv_volsize; |
|
629 |
uint64_t off = 0; |
|
630 |
||
631 |
/* Check the space usage before attempting to allocate the space */ |
|
632 |
dmu_objset_space(os, &refd, &avail, &usedobjs, &availobjs); |
|
633 |
if (avail < zv->zv_volsize) |
|
634 |
return (ENOSPC); |
|
635 |
||
636 |
/* Free old extents if they exist */ |
|
637 |
zvol_free_extents(zv); |
|
638 |
||
639 |
while (resid != 0) { |
|
640 |
int error; |
|
641 |
uint64_t bytes = MIN(resid, SPA_MAXBLOCKSIZE); |
|
642 |
||
643 |
tx = dmu_tx_create(os); |
|
644 |
dmu_tx_hold_write(tx, ZVOL_OBJ, off, bytes); |
|
645 |
error = dmu_tx_assign(tx, TXG_WAIT); |
|
646 |
if (error) { |
|
647 |
dmu_tx_abort(tx); |
|
6992 | 648 |
(void) dmu_free_long_range(os, ZVOL_OBJ, 0, off); |
6423 | 649 |
return (error); |
650 |
} |
|
7872
40a9434212f6
6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
651 |
dmu_prealloc(os, ZVOL_OBJ, off, bytes, tx); |
6423 | 652 |
dmu_tx_commit(tx); |
653 |
off += bytes; |
|
654 |
resid -= bytes; |
|
655 |
} |
|
656 |
txg_wait_synced(dmu_objset_pool(os), 0); |
|
657 |
||
658 |
return (0); |
|
659 |
} |
|
660 |
||
661 |
int |
|
662 |
zvol_update_volsize(zvol_state_t *zv, major_t maj, uint64_t volsize) |
|
663 |
{ |
|
664 |
dmu_tx_t *tx; |
|
665 |
int error; |
|
666 |
||
667 |
ASSERT(MUTEX_HELD(&zvol_state_lock)); |
|
668 |
||
669 |
tx = dmu_tx_create(zv->zv_objset); |
|
670 |
dmu_tx_hold_zap(tx, ZVOL_ZAP_OBJ, TRUE, NULL); |
|
671 |
error = dmu_tx_assign(tx, TXG_WAIT); |
|
672 |
if (error) { |
|
673 |
dmu_tx_abort(tx); |
|
674 |
return (error); |
|
675 |
} |
|
676 |
||
677 |
error = zap_update(zv->zv_objset, ZVOL_ZAP_OBJ, "size", 8, 1, |
|
678 |
&volsize, tx); |
|
679 |
dmu_tx_commit(tx); |
|
680 |
||
681 |
if (error == 0) |
|
6992 | 682 |
error = dmu_free_long_range(zv->zv_objset, |
683 |
ZVOL_OBJ, volsize, DMU_OBJECT_END); |
|
6423 | 684 |
|
7265 | 685 |
/* |
686 |
* If we are using a faked-up state (zv_minor == 0) then don't |
|
687 |
* try to update the in-core zvol state. |
|
688 |
*/ |
|
689 |
if (error == 0 && zv->zv_minor) { |
|
6423 | 690 |
zv->zv_volsize = volsize; |
691 |
zvol_size_changed(zv, maj); |
|
692 |
} |
|
693 |
return (error); |
|
694 |
} |
|
695 |
||
789 | 696 |
int |
4787 | 697 |
zvol_set_volsize(const char *name, major_t maj, uint64_t volsize) |
789 | 698 |
{ |
699 |
zvol_state_t *zv; |
|
700 |
int error; |
|
1133
335d069294d1
6357470 vdev_raidz.c has unused RAIDZ_SINGLE define, code
eschrock
parents:
849
diff
changeset
|
701 |
dmu_object_info_t doi; |
6423 | 702 |
uint64_t old_volsize = 0ULL; |
7265 | 703 |
zvol_state_t state = { 0 }; |
789 | 704 |
|
705 |
mutex_enter(&zvol_state_lock); |
|
706 |
||
2676 | 707 |
if ((zv = zvol_minor_lookup(name)) == NULL) { |
7265 | 708 |
/* |
709 |
* If we are doing a "zfs clone -o volsize=", then the |
|
710 |
* minor node won't exist yet. |
|
711 |
*/ |
|
712 |
error = dmu_objset_open(name, DMU_OST_ZVOL, DS_MODE_OWNER, |
|
713 |
&state.zv_objset); |
|
714 |
if (error != 0) |
|
715 |
goto out; |
|
716 |
zv = &state; |
|
789 | 717 |
} |
6423 | 718 |
old_volsize = zv->zv_volsize; |
789 | 719 |
|
1133
335d069294d1
6357470 vdev_raidz.c has unused RAIDZ_SINGLE define, code
eschrock
parents:
849
diff
changeset
|
720 |
if ((error = dmu_object_info(zv->zv_objset, ZVOL_OBJ, &doi)) != 0 || |
2676 | 721 |
(error = zvol_check_volsize(volsize, |
7265 | 722 |
doi.doi_data_block_size)) != 0) |
723 |
goto out; |
|
1133
335d069294d1
6357470 vdev_raidz.c has unused RAIDZ_SINGLE define, code
eschrock
parents:
849
diff
changeset
|
724 |
|
6423 | 725 |
if (zv->zv_flags & ZVOL_RDONLY || (zv->zv_mode & DS_MODE_READONLY)) { |
7265 | 726 |
error = EROFS; |
727 |
goto out; |
|
789 | 728 |
} |
729 |
||
6423 | 730 |
error = zvol_update_volsize(zv, maj, volsize); |
789 | 731 |
|
6423 | 732 |
/* |
733 |
* Reinitialize the dump area to the new size. If we |
|
734 |
* failed to resize the dump area then restore the it back to |
|
735 |
* it's original size. |
|
736 |
*/ |
|
737 |
if (error == 0 && zv->zv_flags & ZVOL_DUMPIFIED) { |
|
738 |
if ((error = zvol_dumpify(zv)) != 0 || |
|
739 |
(error = dumpvp_resize()) != 0) { |
|
740 |
(void) zvol_update_volsize(zv, maj, old_volsize); |
|
741 |
error = zvol_dumpify(zv); |
|
742 |
} |
|
789 | 743 |
} |
744 |
||
7265 | 745 |
out: |
746 |
if (state.zv_objset) |
|
747 |
dmu_objset_close(state.zv_objset); |
|
748 |
||
789 | 749 |
mutex_exit(&zvol_state_lock); |
750 |
||
751 |
return (error); |
|
752 |
} |
|
753 |
||
754 |
int |
|
2676 | 755 |
zvol_set_volblocksize(const char *name, uint64_t volblocksize) |
789 | 756 |
{ |
757 |
zvol_state_t *zv; |
|
758 |
dmu_tx_t *tx; |
|
759 |
int error; |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
760 |
boolean_t needlock; |
789 | 761 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
762 |
/* |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
763 |
* The lock may already be held if we are being called from |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
764 |
* zvol_dump_init(). |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
765 |
*/ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
766 |
needlock = !MUTEX_HELD(&zvol_state_lock); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
767 |
if (needlock) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
768 |
mutex_enter(&zvol_state_lock); |
789 | 769 |
|
2676 | 770 |
if ((zv = zvol_minor_lookup(name)) == NULL) { |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
771 |
if (needlock) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
772 |
mutex_exit(&zvol_state_lock); |
789 | 773 |
return (ENXIO); |
774 |
} |
|
6423 | 775 |
if (zv->zv_flags & ZVOL_RDONLY || (zv->zv_mode & DS_MODE_READONLY)) { |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
776 |
if (needlock) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
777 |
mutex_exit(&zvol_state_lock); |
789 | 778 |
return (EROFS); |
779 |
} |
|
780 |
||
781 |
tx = dmu_tx_create(zv->zv_objset); |
|
782 |
dmu_tx_hold_bonus(tx, ZVOL_OBJ); |
|
783 |
error = dmu_tx_assign(tx, TXG_WAIT); |
|
784 |
if (error) { |
|
785 |
dmu_tx_abort(tx); |
|
786 |
} else { |
|
787 |
error = dmu_object_set_blocksize(zv->zv_objset, ZVOL_OBJ, |
|
2676 | 788 |
volblocksize, 0, tx); |
789 | 789 |
if (error == ENOTSUP) |
790 |
error = EBUSY; |
|
791 |
dmu_tx_commit(tx); |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
792 |
if (error == 0) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
793 |
zv->zv_volblocksize = volblocksize; |
789 | 794 |
} |
795 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
796 |
if (needlock) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
797 |
mutex_exit(&zvol_state_lock); |
789 | 798 |
|
799 |
return (error); |
|
800 |
} |
|
801 |
||
802 |
/*ARGSUSED*/ |
|
803 |
int |
|
804 |
zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr) |
|
805 |
{ |
|
806 |
minor_t minor = getminor(*devp); |
|
807 |
zvol_state_t *zv; |
|
808 |
||
809 |
if (minor == 0) /* This is the control device */ |
|
810 |
return (0); |
|
811 |
||
812 |
mutex_enter(&zvol_state_lock); |
|
813 |
||
814 |
zv = ddi_get_soft_state(zvol_state, minor); |
|
815 |
if (zv == NULL) { |
|
816 |
mutex_exit(&zvol_state_lock); |
|
817 |
return (ENXIO); |
|
818 |
} |
|
819 |
||
820 |
ASSERT(zv->zv_objset != NULL); |
|
821 |
||
822 |
if ((flag & FWRITE) && |
|
6423 | 823 |
(zv->zv_flags & ZVOL_RDONLY || (zv->zv_mode & DS_MODE_READONLY))) { |
789 | 824 |
mutex_exit(&zvol_state_lock); |
825 |
return (EROFS); |
|
826 |
} |
|
7405
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
827 |
if (zv->zv_flags & ZVOL_EXCL) { |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
828 |
mutex_exit(&zvol_state_lock); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
829 |
return (EBUSY); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
830 |
} |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
831 |
if (flag & FEXCL) { |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
832 |
if (zv->zv_total_opens != 0) { |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
833 |
mutex_exit(&zvol_state_lock); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
834 |
return (EBUSY); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
835 |
} |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
836 |
zv->zv_flags |= ZVOL_EXCL; |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
837 |
} |
789 | 838 |
|
839 |
if (zv->zv_open_count[otyp] == 0 || otyp == OTYP_LYR) { |
|
840 |
zv->zv_open_count[otyp]++; |
|
841 |
zv->zv_total_opens++; |
|
842 |
} |
|
843 |
||
844 |
mutex_exit(&zvol_state_lock); |
|
845 |
||
846 |
return (0); |
|
847 |
} |
|
848 |
||
849 |
/*ARGSUSED*/ |
|
850 |
int |
|
851 |
zvol_close(dev_t dev, int flag, int otyp, cred_t *cr) |
|
852 |
{ |
|
853 |
minor_t minor = getminor(dev); |
|
854 |
zvol_state_t *zv; |
|
855 |
||
856 |
if (minor == 0) /* This is the control device */ |
|
857 |
return (0); |
|
858 |
||
859 |
mutex_enter(&zvol_state_lock); |
|
860 |
||
861 |
zv = ddi_get_soft_state(zvol_state, minor); |
|
862 |
if (zv == NULL) { |
|
863 |
mutex_exit(&zvol_state_lock); |
|
864 |
return (ENXIO); |
|
865 |
} |
|
866 |
||
7405
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
867 |
if (zv->zv_flags & ZVOL_EXCL) { |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
868 |
ASSERT(zv->zv_total_opens == 1); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
869 |
zv->zv_flags &= ~ZVOL_EXCL; |
789 | 870 |
} |
871 |
||
872 |
/* |
|
873 |
* If the open count is zero, this is a spurious close. |
|
874 |
* That indicates a bug in the kernel / DDI framework. |
|
875 |
*/ |
|
876 |
ASSERT(zv->zv_open_count[otyp] != 0); |
|
877 |
ASSERT(zv->zv_total_opens != 0); |
|
878 |
||
879 |
/* |
|
880 |
* You may get multiple opens, but only one close. |
|
881 |
*/ |
|
882 |
zv->zv_open_count[otyp]--; |
|
883 |
zv->zv_total_opens--; |
|
884 |
||
885 |
mutex_exit(&zvol_state_lock); |
|
886 |
||
887 |
return (0); |
|
888 |
} |
|
889 |
||
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
890 |
static void |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
891 |
zvol_get_done(dmu_buf_t *db, void *vzgd) |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
892 |
{ |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
893 |
zgd_t *zgd = (zgd_t *)vzgd; |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
894 |
rl_t *rl = zgd->zgd_rl; |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
895 |
|
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
896 |
dmu_buf_rele(db, vzgd); |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
897 |
zfs_range_unlock(rl); |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5331
diff
changeset
|
898 |
zil_add_block(zgd->zgd_zilog, zgd->zgd_bp); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
899 |
kmem_free(zgd, sizeof (zgd_t)); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
900 |
} |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
901 |
|
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
902 |
/* |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
903 |
* Get data to generate a TX_WRITE intent log record. |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
904 |
*/ |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
905 |
static int |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
906 |
zvol_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio) |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
907 |
{ |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
908 |
zvol_state_t *zv = arg; |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
909 |
objset_t *os = zv->zv_objset; |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
910 |
dmu_buf_t *db; |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
911 |
rl_t *rl; |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
912 |
zgd_t *zgd; |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
913 |
uint64_t boff; /* block starting offset */ |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
914 |
int dlen = lr->lr_length; /* length of user data */ |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
915 |
int error; |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
916 |
|
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
917 |
ASSERT(zio); |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
918 |
ASSERT(dlen != 0); |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
919 |
|
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
920 |
/* |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
921 |
* Write records come in two flavors: immediate and indirect. |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
922 |
* For small writes it's cheaper to store the data with the |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
923 |
* log record (immediate); for large writes it's cheaper to |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
924 |
* sync the data and get a pointer to it (indirect) so that |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
925 |
* we don't have to write the data twice. |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
926 |
*/ |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
927 |
if (buf != NULL) /* immediate write */ |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
928 |
return (dmu_read(os, ZVOL_OBJ, lr->lr_offset, dlen, buf)); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
929 |
|
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
930 |
zgd = (zgd_t *)kmem_alloc(sizeof (zgd_t), KM_SLEEP); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
931 |
zgd->zgd_zilog = zv->zv_zilog; |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
932 |
zgd->zgd_bp = &lr->lr_blkptr; |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
933 |
|
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
934 |
/* |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
935 |
* Lock the range of the block to ensure that when the data is |
6423 | 936 |
* written out and its checksum is being calculated that no other |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
937 |
* thread can change the block. |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
938 |
*/ |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
939 |
boff = P2ALIGN_TYPED(lr->lr_offset, zv->zv_volblocksize, uint64_t); |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
940 |
rl = zfs_range_lock(&zv->zv_znode, boff, zv->zv_volblocksize, |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
941 |
RL_READER); |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
942 |
zgd->zgd_rl = rl; |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
943 |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
944 |
VERIFY(0 == dmu_buf_hold(os, ZVOL_OBJ, lr->lr_offset, zgd, &db)); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
945 |
error = dmu_sync(zio, db, &lr->lr_blkptr, |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
946 |
lr->lr_common.lrc_txg, zvol_get_done, zgd); |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
947 |
if (error == 0) |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5331
diff
changeset
|
948 |
zil_add_block(zv->zv_zilog, &lr->lr_blkptr); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
949 |
/* |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
950 |
* If we get EINPROGRESS, then we need to wait for a |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
951 |
* write IO initiated by dmu_sync() to complete before |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
952 |
* we can release this dbuf. We will finish everything |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
953 |
* up in the zvol_get_done() callback. |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
954 |
*/ |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
955 |
if (error == EINPROGRESS) |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
956 |
return (0); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
957 |
dmu_buf_rele(db, zgd); |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
958 |
zfs_range_unlock(rl); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
959 |
kmem_free(zgd, sizeof (zgd_t)); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
960 |
return (error); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
961 |
} |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
962 |
|
1861
7929434f26fb
6413125 zvol_strategy() race can lead to on-disk corruption.
perrin
parents:
1669
diff
changeset
|
963 |
/* |
7929434f26fb
6413125 zvol_strategy() race can lead to on-disk corruption.
perrin
parents:
1669
diff
changeset
|
964 |
* zvol_log_write() handles synchronous writes using TX_WRITE ZIL transactions. |
1141 | 965 |
* |
966 |
* We store data in the log buffers if it's small enough. |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
967 |
* Otherwise we will later flush the data out via dmu_sync(). |
1141 | 968 |
*/ |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
969 |
ssize_t zvol_immediate_write_sz = 32768; |
1141 | 970 |
|
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
971 |
static void |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
972 |
zvol_log_write(zvol_state_t *zv, dmu_tx_t *tx, offset_t off, ssize_t len) |
1141 | 973 |
{ |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
974 |
uint32_t blocksize = zv->zv_volblocksize; |
8227 | 975 |
zilog_t *zilog = zv->zv_zilog; |
1141 | 976 |
lr_write_t *lr; |
1861
7929434f26fb
6413125 zvol_strategy() race can lead to on-disk corruption.
perrin
parents:
1669
diff
changeset
|
977 |
|
8227 | 978 |
if (zilog->zl_replay) { |
979 |
dsl_dataset_dirty(dmu_objset_ds(zilog->zl_os), tx); |
|
980 |
zilog->zl_replayed_seq[dmu_tx_get_txg(tx) & TXG_MASK] = |
|
981 |
zilog->zl_replaying_seq; |
|
982 |
return; |
|
983 |
} |
|
984 |
||
1861
7929434f26fb
6413125 zvol_strategy() race can lead to on-disk corruption.
perrin
parents:
1669
diff
changeset
|
985 |
while (len) { |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
986 |
ssize_t nbytes = MIN(len, blocksize - P2PHASE(off, blocksize)); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
987 |
itx_t *itx = zil_itx_create(TX_WRITE, sizeof (*lr)); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
988 |
|
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
989 |
itx->itx_wr_state = |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
990 |
len > zvol_immediate_write_sz ? WR_INDIRECT : WR_NEED_COPY; |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
991 |
itx->itx_private = zv; |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
992 |
lr = (lr_write_t *)&itx->itx_lr; |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
993 |
lr->lr_foid = ZVOL_OBJ; |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
994 |
lr->lr_offset = off; |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
995 |
lr->lr_length = nbytes; |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
996 |
lr->lr_blkoff = off - P2ALIGN_TYPED(off, blocksize, uint64_t); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
997 |
BP_ZERO(&lr->lr_blkptr); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
998 |
|
8227 | 999 |
(void) zil_itx_assign(zilog, itx, tx); |
1861
7929434f26fb
6413125 zvol_strategy() race can lead to on-disk corruption.
perrin
parents:
1669
diff
changeset
|
1000 |
len -= nbytes; |
7929434f26fb
6413125 zvol_strategy() race can lead to on-disk corruption.
perrin
parents:
1669
diff
changeset
|
1001 |
off += nbytes; |
1141 | 1002 |
} |
1003 |
} |
|
1004 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1005 |
static int |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1006 |
zvol_dumpio_vdev(vdev_t *vd, void *addr, uint64_t offset, uint64_t size, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1007 |
boolean_t doread, boolean_t isdump) |
6423 | 1008 |
{ |
1009 |
vdev_disk_t *dvd; |
|
1010 |
int c; |
|
1011 |
int numerrors = 0; |
|
1012 |
||
1013 |
for (c = 0; c < vd->vdev_children; c++) { |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1014 |
ASSERT(vd->vdev_ops == &vdev_mirror_ops); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1015 |
int err = zvol_dumpio_vdev(vd->vdev_child[c], |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1016 |
addr, offset, size, doread, isdump); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1017 |
if (err != 0) { |
6423 | 1018 |
numerrors++; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1019 |
} else if (doread) { |
6423 | 1020 |
break; |
1021 |
} |
|
1022 |
} |
|
1023 |
||
1024 |
if (!vd->vdev_ops->vdev_op_leaf) |
|
1025 |
return (numerrors < vd->vdev_children ? 0 : EIO); |
|
1026 |
||
7903
4c8fa38f91ec
6760985 assertion failure with dump device on pool with non-writeable vdev
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7872
diff
changeset
|
1027 |
if (doread && !vdev_readable(vd)) |
4c8fa38f91ec
6760985 assertion failure with dump device on pool with non-writeable vdev
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7872
diff
changeset
|
1028 |
return (EIO); |
4c8fa38f91ec
6760985 assertion failure with dump device on pool with non-writeable vdev
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7872
diff
changeset
|
1029 |
else if (!doread && !vdev_writeable(vd)) |
6423 | 1030 |
return (EIO); |
1031 |
||
1032 |
dvd = vd->vdev_tsd; |
|
1033 |
ASSERT3P(dvd, !=, NULL); |
|
1034 |
offset += VDEV_LABEL_START_SIZE; |
|
1035 |
||
1036 |
if (ddi_in_panic() || isdump) { |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1037 |
ASSERT(!doread); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1038 |
if (doread) |
6423 | 1039 |
return (EIO); |
1040 |
return (ldi_dump(dvd->vd_lh, addr, lbtodb(offset), |
|
1041 |
lbtodb(size))); |
|
1042 |
} else { |
|
1043 |
return (vdev_disk_physio(dvd->vd_lh, addr, size, offset, |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1044 |
doread ? B_READ : B_WRITE)); |
6423 | 1045 |
} |
1046 |
} |
|
1047 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1048 |
static int |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1049 |
zvol_dumpio(zvol_state_t *zv, void *addr, uint64_t offset, uint64_t size, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1050 |
boolean_t doread, boolean_t isdump) |
6423 | 1051 |
{ |
1052 |
vdev_t *vd; |
|
1053 |
int error; |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1054 |
zvol_extent_t *ze; |
6423 | 1055 |
spa_t *spa = dmu_objset_spa(zv->zv_objset); |
1056 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1057 |
/* Must be sector aligned, and not stradle a block boundary. */ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1058 |
if (P2PHASE(offset, DEV_BSIZE) || P2PHASE(size, DEV_BSIZE) || |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1059 |
P2BOUNDARY(offset, size, zv->zv_volblocksize)) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1060 |
return (EINVAL); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1061 |
} |
6423 | 1062 |
ASSERT(size <= zv->zv_volblocksize); |
1063 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1064 |
/* Locate the extent this belongs to */ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1065 |
ze = list_head(&zv->zv_extents); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1066 |
while (offset >= ze->ze_nblks * zv->zv_volblocksize) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1067 |
offset -= ze->ze_nblks * zv->zv_volblocksize; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1068 |
ze = list_next(&zv->zv_extents, ze); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1069 |
} |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
1070 |
spa_config_enter(spa, SCL_STATE, FTAG, RW_READER); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1071 |
vd = vdev_lookup_top(spa, DVA_GET_VDEV(&ze->ze_dva)); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1072 |
offset += DVA_GET_OFFSET(&ze->ze_dva); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1073 |
error = zvol_dumpio_vdev(vd, addr, offset, size, doread, isdump); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
1074 |
spa_config_exit(spa, SCL_STATE, FTAG); |
6423 | 1075 |
return (error); |
1076 |
} |
|
1077 |
||
1078 |
int |
|
789 | 1079 |
zvol_strategy(buf_t *bp) |
1080 |
{ |
|
1081 |
zvol_state_t *zv = ddi_get_soft_state(zvol_state, getminor(bp->b_edev)); |
|
1082 |
uint64_t off, volsize; |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1083 |
size_t resid; |
789 | 1084 |
char *addr; |
1141 | 1085 |
objset_t *os; |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
1086 |
rl_t *rl; |
789 | 1087 |
int error = 0; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1088 |
boolean_t doread = bp->b_flags & B_READ; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1089 |
boolean_t is_dump = zv->zv_flags & ZVOL_DUMPIFIED; |
789 | 1090 |
|
1091 |
if (zv == NULL) { |
|
1092 |
bioerror(bp, ENXIO); |
|
1093 |
biodone(bp); |
|
1094 |
return (0); |
|
1095 |
} |
|
1096 |
||
1097 |
if (getminor(bp->b_edev) == 0) { |
|
1098 |
bioerror(bp, EINVAL); |
|
1099 |
biodone(bp); |
|
1100 |
return (0); |
|
1101 |
} |
|
1102 |
||
6423 | 1103 |
if (!(bp->b_flags & B_READ) && |
1104 |
(zv->zv_flags & ZVOL_RDONLY || |
|
1105 |
zv->zv_mode & DS_MODE_READONLY)) { |
|
789 | 1106 |
bioerror(bp, EROFS); |
1107 |
biodone(bp); |
|
1108 |
return (0); |
|
1109 |
} |
|
1110 |
||
1111 |
off = ldbtob(bp->b_blkno); |
|
1112 |
volsize = zv->zv_volsize; |
|
1113 |
||
1141 | 1114 |
os = zv->zv_objset; |
1115 |
ASSERT(os != NULL); |
|
789 | 1116 |
|
1117 |
bp_mapin(bp); |
|
1118 |
addr = bp->b_un.b_addr; |
|
1119 |
resid = bp->b_bcount; |
|
1120 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1121 |
if (resid > 0 && (off < 0 || off >= volsize)) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1122 |
bioerror(bp, EIO); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1123 |
biodone(bp); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1124 |
return (0); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1125 |
} |
7013
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1126 |
|
1861
7929434f26fb
6413125 zvol_strategy() race can lead to on-disk corruption.
perrin
parents:
1669
diff
changeset
|
1127 |
/* |
7929434f26fb
6413125 zvol_strategy() race can lead to on-disk corruption.
perrin
parents:
1669
diff
changeset
|
1128 |
* There must be no buffer changes when doing a dmu_sync() because |
7929434f26fb
6413125 zvol_strategy() race can lead to on-disk corruption.
perrin
parents:
1669
diff
changeset
|
1129 |
* we can't change the data whilst calculating the checksum. |
7929434f26fb
6413125 zvol_strategy() race can lead to on-disk corruption.
perrin
parents:
1669
diff
changeset
|
1130 |
*/ |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
1131 |
rl = zfs_range_lock(&zv->zv_znode, off, resid, |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1132 |
doread ? RL_READER : RL_WRITER); |
6423 | 1133 |
|
789 | 1134 |
while (resid != 0 && off < volsize) { |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1135 |
size_t size = MIN(resid, zvol_maxphys); |
6423 | 1136 |
if (is_dump) { |
1137 |
size = MIN(size, P2END(off, zv->zv_volblocksize) - off); |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1138 |
error = zvol_dumpio(zv, addr, off, size, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1139 |
doread, B_FALSE); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1140 |
} else if (doread) { |
1861
7929434f26fb
6413125 zvol_strategy() race can lead to on-disk corruption.
perrin
parents:
1669
diff
changeset
|
1141 |
error = dmu_read(os, ZVOL_OBJ, off, size, addr); |
789 | 1142 |
} else { |
1141 | 1143 |
dmu_tx_t *tx = dmu_tx_create(os); |
789 | 1144 |
dmu_tx_hold_write(tx, ZVOL_OBJ, off, size); |
1145 |
error = dmu_tx_assign(tx, TXG_WAIT); |
|
1146 |
if (error) { |
|
1147 |
dmu_tx_abort(tx); |
|
1148 |
} else { |
|
1141 | 1149 |
dmu_write(os, ZVOL_OBJ, off, size, addr, tx); |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1150 |
zvol_log_write(zv, tx, off, size); |
789 | 1151 |
dmu_tx_commit(tx); |
1152 |
} |
|
1153 |
} |
|
7294 | 1154 |
if (error) { |
1155 |
/* convert checksum errors into IO errors */ |
|
1156 |
if (error == ECKSUM) |
|
1157 |
error = EIO; |
|
789 | 1158 |
break; |
7294 | 1159 |
} |
789 | 1160 |
off += size; |
1161 |
addr += size; |
|
1162 |
resid -= size; |
|
1163 |
} |
|
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
1164 |
zfs_range_unlock(rl); |
789 | 1165 |
|
1166 |
if ((bp->b_resid = resid) == bp->b_bcount) |
|
1167 |
bioerror(bp, off > volsize ? EINVAL : error); |
|
1168 |
||
9303
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1169 |
if (!(bp->b_flags & B_ASYNC) && !doread && !zil_disable && |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1170 |
!is_dump && !(zv->zv_flags & ZVOL_WCE)) |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1171 |
zil_commit(zv->zv_zilog, UINT64_MAX, ZVOL_OBJ); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1172 |
biodone(bp); |
1141 | 1173 |
|
789 | 1174 |
return (0); |
1175 |
} |
|
1176 |
||
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1177 |
/* |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1178 |
* Set the buffer count to the zvol maximum transfer. |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1179 |
* Using our own routine instead of the default minphys() |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1180 |
* means that for larger writes we write bigger buffers on X86 |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1181 |
* (128K instead of 56K) and flush the disk write cache less often |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1182 |
* (every zvol_maxphys - currently 1MB) instead of minphys (currently |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1183 |
* 56K on X86 and 128K on sparc). |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1184 |
*/ |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1185 |
void |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1186 |
zvol_minphys(struct buf *bp) |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1187 |
{ |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1188 |
if (bp->b_bcount > zvol_maxphys) |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1189 |
bp->b_bcount = zvol_maxphys; |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1190 |
} |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
3016
diff
changeset
|
1191 |
|
6423 | 1192 |
int |
1193 |
zvol_dump(dev_t dev, caddr_t addr, daddr_t blkno, int nblocks) |
|
1194 |
{ |
|
1195 |
minor_t minor = getminor(dev); |
|
1196 |
zvol_state_t *zv; |
|
1197 |
int error = 0; |
|
1198 |
uint64_t size; |
|
1199 |
uint64_t boff; |
|
1200 |
uint64_t resid; |
|
1201 |
||
1202 |
if (minor == 0) /* This is the control device */ |
|
1203 |
return (ENXIO); |
|
1204 |
||
1205 |
zv = ddi_get_soft_state(zvol_state, minor); |
|
1206 |
if (zv == NULL) |
|
1207 |
return (ENXIO); |
|
1208 |
||
1209 |
boff = ldbtob(blkno); |
|
1210 |
resid = ldbtob(nblocks); |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1211 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1212 |
VERIFY3U(boff + resid, <=, zv->zv_volsize); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1213 |
|
6423 | 1214 |
while (resid) { |
1215 |
size = MIN(resid, P2END(boff, zv->zv_volblocksize) - boff); |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1216 |
error = zvol_dumpio(zv, addr, boff, size, B_FALSE, B_TRUE); |
6423 | 1217 |
if (error) |
1218 |
break; |
|
1219 |
boff += size; |
|
1220 |
addr += size; |
|
1221 |
resid -= size; |
|
1222 |
} |
|
1223 |
||
1224 |
return (error); |
|
1225 |
} |
|
1226 |
||
789 | 1227 |
/*ARGSUSED*/ |
1228 |
int |
|
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1229 |
zvol_read(dev_t dev, uio_t *uio, cred_t *cr) |
789 | 1230 |
{ |
4107 | 1231 |
minor_t minor = getminor(dev); |
1232 |
zvol_state_t *zv; |
|
7013
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1233 |
uint64_t volsize; |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
1234 |
rl_t *rl; |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1235 |
int error = 0; |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1236 |
|
4107 | 1237 |
if (minor == 0) /* This is the control device */ |
1238 |
return (ENXIO); |
|
1239 |
||
1240 |
zv = ddi_get_soft_state(zvol_state, minor); |
|
1241 |
if (zv == NULL) |
|
1242 |
return (ENXIO); |
|
1243 |
||
7013
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1244 |
volsize = zv->zv_volsize; |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1245 |
if (uio->uio_resid > 0 && |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1246 |
(uio->uio_loffset < 0 || uio->uio_loffset >= volsize)) |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1247 |
return (EIO); |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1248 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1249 |
if (zv->zv_flags & ZVOL_DUMPIFIED) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1250 |
error = physio(zvol_strategy, NULL, dev, B_READ, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1251 |
zvol_minphys, uio); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1252 |
return (error); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1253 |
} |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1254 |
|
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
1255 |
rl = zfs_range_lock(&zv->zv_znode, uio->uio_loffset, uio->uio_resid, |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
1256 |
RL_READER); |
7013
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1257 |
while (uio->uio_resid > 0 && uio->uio_loffset < volsize) { |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1258 |
uint64_t bytes = MIN(uio->uio_resid, DMU_MAX_ACCESS >> 1); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1259 |
|
7013
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1260 |
/* don't read past the end */ |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1261 |
if (bytes > volsize - uio->uio_loffset) |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1262 |
bytes = volsize - uio->uio_loffset; |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1263 |
|
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1264 |
error = dmu_read_uio(zv->zv_objset, ZVOL_OBJ, uio, bytes); |
7294 | 1265 |
if (error) { |
1266 |
/* convert checksum errors into IO errors */ |
|
1267 |
if (error == ECKSUM) |
|
1268 |
error = EIO; |
|
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1269 |
break; |
7294 | 1270 |
} |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1271 |
} |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
1272 |
zfs_range_unlock(rl); |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1273 |
return (error); |
789 | 1274 |
} |
1275 |
||
1276 |
/*ARGSUSED*/ |
|
1277 |
int |
|
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1278 |
zvol_write(dev_t dev, uio_t *uio, cred_t *cr) |
789 | 1279 |
{ |
4107 | 1280 |
minor_t minor = getminor(dev); |
1281 |
zvol_state_t *zv; |
|
7013
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1282 |
uint64_t volsize; |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
1283 |
rl_t *rl; |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1284 |
int error = 0; |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1285 |
|
4107 | 1286 |
if (minor == 0) /* This is the control device */ |
1287 |
return (ENXIO); |
|
1288 |
||
1289 |
zv = ddi_get_soft_state(zvol_state, minor); |
|
1290 |
if (zv == NULL) |
|
1291 |
return (ENXIO); |
|
1292 |
||
7013
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1293 |
volsize = zv->zv_volsize; |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1294 |
if (uio->uio_resid > 0 && |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1295 |
(uio->uio_loffset < 0 || uio->uio_loffset >= volsize)) |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1296 |
return (EIO); |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1297 |
|
6423 | 1298 |
if (zv->zv_flags & ZVOL_DUMPIFIED) { |
1299 |
error = physio(zvol_strategy, NULL, dev, B_WRITE, |
|
1300 |
zvol_minphys, uio); |
|
1301 |
return (error); |
|
1302 |
} |
|
1303 |
||
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
1304 |
rl = zfs_range_lock(&zv->zv_znode, uio->uio_loffset, uio->uio_resid, |
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
1305 |
RL_WRITER); |
7013
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1306 |
while (uio->uio_resid > 0 && uio->uio_loffset < volsize) { |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1307 |
uint64_t bytes = MIN(uio->uio_resid, DMU_MAX_ACCESS >> 1); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1308 |
uint64_t off = uio->uio_loffset; |
7013
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1309 |
dmu_tx_t *tx = dmu_tx_create(zv->zv_objset); |
789 | 1310 |
|
7013
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1311 |
if (bytes > volsize - off) /* don't write past the end */ |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1312 |
bytes = volsize - off; |
540c400de3b4
6596419 zvol character (raw) devices allow read/write past the end of the device
gw25295
parents:
6992
diff
changeset
|
1313 |
|
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1314 |
dmu_tx_hold_write(tx, ZVOL_OBJ, off, bytes); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1315 |
error = dmu_tx_assign(tx, TXG_WAIT); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1316 |
if (error) { |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1317 |
dmu_tx_abort(tx); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1318 |
break; |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1319 |
} |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1320 |
error = dmu_write_uio(zv->zv_objset, ZVOL_OBJ, uio, bytes, tx); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1321 |
if (error == 0) |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1322 |
zvol_log_write(zv, tx, off, bytes); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1323 |
dmu_tx_commit(tx); |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1324 |
|
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1325 |
if (error) |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1326 |
break; |
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1327 |
} |
3755
8708c35cb823
6525008 panic: dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC, file: ../../common/fs/zfs/dbuf.c, line: 676
perrin
parents:
3638
diff
changeset
|
1328 |
zfs_range_unlock(rl); |
9303
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1329 |
if (!zil_disable && !(zv->zv_flags & ZVOL_WCE)) |
8524
a56dffa8fba9
6770534 zvols do not observe character device semantics
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
8227
diff
changeset
|
1330 |
zil_commit(zv->zv_zilog, UINT64_MAX, ZVOL_OBJ); |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1331 |
return (error); |
789 | 1332 |
} |
1333 |
||
7405
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1334 |
int |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1335 |
zvol_getefi(void *arg, int flag, uint64_t vs, uint8_t bs) |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1336 |
{ |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1337 |
struct uuid uuid = EFI_RESERVED; |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1338 |
efi_gpe_t gpe = { 0 }; |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1339 |
uint32_t crc; |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1340 |
dk_efi_t efi; |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1341 |
int length; |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1342 |
char *ptr; |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1343 |
|
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1344 |
if (ddi_copyin(arg, &efi, sizeof (dk_efi_t), flag)) |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1345 |
return (EFAULT); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1346 |
ptr = (char *)(uintptr_t)efi.dki_data_64; |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1347 |
length = efi.dki_length; |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1348 |
/* |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1349 |
* Some clients may attempt to request a PMBR for the |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1350 |
* zvol. Currently this interface will return EINVAL to |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1351 |
* such requests. These requests could be supported by |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1352 |
* adding a check for lba == 0 and consing up an appropriate |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1353 |
* PMBR. |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1354 |
*/ |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1355 |
if (efi.dki_lba < 1 || efi.dki_lba > 2 || length <= 0) |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1356 |
return (EINVAL); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1357 |
|
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1358 |
gpe.efi_gpe_StartingLBA = LE_64(34ULL); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1359 |
gpe.efi_gpe_EndingLBA = LE_64((vs >> bs) - 1); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1360 |
UUID_LE_CONVERT(gpe.efi_gpe_PartitionTypeGUID, uuid); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1361 |
|
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1362 |
if (efi.dki_lba == 1) { |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1363 |
efi_gpt_t gpt = { 0 }; |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1364 |
|
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1365 |
gpt.efi_gpt_Signature = LE_64(EFI_SIGNATURE); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1366 |
gpt.efi_gpt_Revision = LE_32(EFI_VERSION_CURRENT); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1367 |
gpt.efi_gpt_HeaderSize = LE_32(sizeof (gpt)); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1368 |
gpt.efi_gpt_MyLBA = LE_64(1ULL); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1369 |
gpt.efi_gpt_FirstUsableLBA = LE_64(34ULL); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1370 |
gpt.efi_gpt_LastUsableLBA = LE_64((vs >> bs) - 1); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1371 |
gpt.efi_gpt_PartitionEntryLBA = LE_64(2ULL); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1372 |
gpt.efi_gpt_NumberOfPartitionEntries = LE_32(1); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1373 |
gpt.efi_gpt_SizeOfPartitionEntry = |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1374 |
LE_32(sizeof (efi_gpe_t)); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1375 |
CRC32(crc, &gpe, sizeof (gpe), -1U, crc32_table); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1376 |
gpt.efi_gpt_PartitionEntryArrayCRC32 = LE_32(~crc); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1377 |
CRC32(crc, &gpt, sizeof (gpt), -1U, crc32_table); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1378 |
gpt.efi_gpt_HeaderCRC32 = LE_32(~crc); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1379 |
if (ddi_copyout(&gpt, ptr, MIN(sizeof (gpt), length), |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1380 |
flag)) |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1381 |
return (EFAULT); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1382 |
ptr += sizeof (gpt); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1383 |
length -= sizeof (gpt); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1384 |
} |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1385 |
if (length > 0 && ddi_copyout(&gpe, ptr, MIN(sizeof (gpe), |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1386 |
length), flag)) |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1387 |
return (EFAULT); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1388 |
return (0); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1389 |
} |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1390 |
|
789 | 1391 |
/* |
1392 |
* Dirtbag ioctls to support mkfs(1M) for UFS filesystems. See dkio(7I). |
|
1393 |
*/ |
|
1394 |
/*ARGSUSED*/ |
|
1395 |
int |
|
1396 |
zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp) |
|
1397 |
{ |
|
1398 |
zvol_state_t *zv; |
|
3897
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1399 |
struct dk_cinfo dki; |
789 | 1400 |
struct dk_minfo dkm; |
3897
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1401 |
struct dk_callback *dkc; |
789 | 1402 |
int error = 0; |
6423 | 1403 |
rl_t *rl; |
789 | 1404 |
|
1405 |
mutex_enter(&zvol_state_lock); |
|
1406 |
||
1407 |
zv = ddi_get_soft_state(zvol_state, getminor(dev)); |
|
1408 |
||
1409 |
if (zv == NULL) { |
|
1410 |
mutex_exit(&zvol_state_lock); |
|
1411 |
return (ENXIO); |
|
1412 |
} |
|
9303
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1413 |
ASSERT(zv->zv_total_opens > 0); |
789 | 1414 |
|
1415 |
switch (cmd) { |
|
1416 |
||
1417 |
case DKIOCINFO: |
|
3897
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1418 |
bzero(&dki, sizeof (dki)); |
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1419 |
(void) strcpy(dki.dki_cname, "zvol"); |
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1420 |
(void) strcpy(dki.dki_dname, "zvol"); |
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1421 |
dki.dki_ctype = DKC_UNKNOWN; |
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1422 |
dki.dki_maxtransfer = 1 << (SPA_MAXBLOCKSHIFT - zv->zv_min_bs); |
789 | 1423 |
mutex_exit(&zvol_state_lock); |
3897
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1424 |
if (ddi_copyout(&dki, (void *)arg, sizeof (dki), flag)) |
789 | 1425 |
error = EFAULT; |
1426 |
return (error); |
|
1427 |
||
1428 |
case DKIOCGMEDIAINFO: |
|
1429 |
bzero(&dkm, sizeof (dkm)); |
|
1430 |
dkm.dki_lbsize = 1U << zv->zv_min_bs; |
|
1431 |
dkm.dki_capacity = zv->zv_volsize >> zv->zv_min_bs; |
|
1432 |
dkm.dki_media_type = DK_UNKNOWN; |
|
1433 |
mutex_exit(&zvol_state_lock); |
|
1434 |
if (ddi_copyout(&dkm, (void *)arg, sizeof (dkm), flag)) |
|
1435 |
error = EFAULT; |
|
1436 |
return (error); |
|
1437 |
||
1438 |
case DKIOCGETEFI: |
|
7405
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1439 |
{ |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1440 |
uint64_t vs = zv->zv_volsize; |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1441 |
uint8_t bs = zv->zv_min_bs; |
3016 | 1442 |
|
1443 |
mutex_exit(&zvol_state_lock); |
|
7405
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1444 |
error = zvol_getefi((void *)arg, flag, vs, bs); |
22b4aeef8023
6612759 zvol DKIOCGETEFI should return GPT and GPE when possible
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7294
diff
changeset
|
1445 |
return (error); |
3016 | 1446 |
} |
789 | 1447 |
|
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1448 |
case DKIOCFLUSHWRITECACHE: |
3897
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1449 |
dkc = (struct dk_callback *)arg; |
9303
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1450 |
mutex_exit(&zvol_state_lock); |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1451 |
zil_commit(zv->zv_zilog, UINT64_MAX, ZVOL_OBJ); |
3897
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1452 |
if ((flag & FKIOCTL) && dkc != NULL && dkc->dkc_callback) { |
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1453 |
(*dkc->dkc_callback)(dkc->dkc_cookie, error); |
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1454 |
error = 0; |
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3755
diff
changeset
|
1455 |
} |
9303
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1456 |
return (error); |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1457 |
|
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1458 |
case DKIOCGETWCE: |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1459 |
{ |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1460 |
int wce = (zv->zv_flags & ZVOL_WCE) ? 1 : 0; |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1461 |
if (ddi_copyout(&wce, (void *)arg, sizeof (int), |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1462 |
flag)) |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1463 |
error = EFAULT; |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1464 |
break; |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1465 |
} |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1466 |
case DKIOCSETWCE: |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1467 |
{ |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1468 |
int wce; |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1469 |
if (ddi_copyin((void *)arg, &wce, sizeof (int), |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1470 |
flag)) { |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1471 |
error = EFAULT; |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1472 |
break; |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1473 |
} |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1474 |
if (wce) { |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1475 |
zv->zv_flags |= ZVOL_WCE; |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1476 |
mutex_exit(&zvol_state_lock); |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1477 |
} else { |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1478 |
zv->zv_flags &= ~ZVOL_WCE; |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1479 |
mutex_exit(&zvol_state_lock); |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1480 |
zil_commit(zv->zv_zilog, UINT64_MAX, ZVOL_OBJ); |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1481 |
} |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1482 |
return (0); |
587ef5ac9176
6794730 need zvol support for DKIOCSETWCE and friends
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
9277
diff
changeset
|
1483 |
} |
3638
6b28ebc717aa
6496357 spec_fsync() is useless on devices that do write caching
billm
parents:
3461
diff
changeset
|
1484 |
|
3245
0c86ad4b2673
6493634 zvol should return ENOTSUP on DKIOCGVTOC ioctl
maybee
parents:
3080
diff
changeset
|
1485 |
case DKIOCGGEOM: |
0c86ad4b2673
6493634 zvol should return ENOTSUP on DKIOCGVTOC ioctl
maybee
parents:
3080
diff
changeset
|
1486 |
case DKIOCGVTOC: |
6423 | 1487 |
/* |
1488 |
* commands using these (like prtvtoc) expect ENOTSUP |
|
1489 |
* since we're emulating an EFI label |
|
1490 |
*/ |
|
3245
0c86ad4b2673
6493634 zvol should return ENOTSUP on DKIOCGVTOC ioctl
maybee
parents:
3080
diff
changeset
|
1491 |
error = ENOTSUP; |
0c86ad4b2673
6493634 zvol should return ENOTSUP on DKIOCGVTOC ioctl
maybee
parents:
3080
diff
changeset
|
1492 |
break; |
0c86ad4b2673
6493634 zvol should return ENOTSUP on DKIOCGVTOC ioctl
maybee
parents:
3080
diff
changeset
|
1493 |
|
6423 | 1494 |
case DKIOCDUMPINIT: |
1495 |
rl = zfs_range_lock(&zv->zv_znode, 0, zv->zv_volsize, |
|
1496 |
RL_WRITER); |
|
1497 |
error = zvol_dumpify(zv); |
|
1498 |
zfs_range_unlock(rl); |
|
1499 |
break; |
|
1500 |
||
1501 |
case DKIOCDUMPFINI: |
|
9277
3e67eb420d44
6817316 data corruption: failed zvol dumpify erases tmpfs data
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
8524
diff
changeset
|
1502 |
if (!(zv->zv_flags & ZVOL_DUMPIFIED)) |
3e67eb420d44
6817316 data corruption: failed zvol dumpify erases tmpfs data
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
8524
diff
changeset
|
1503 |
break; |
6423 | 1504 |
rl = zfs_range_lock(&zv->zv_znode, 0, zv->zv_volsize, |
1505 |
RL_WRITER); |
|
1506 |
error = zvol_dump_fini(zv); |
|
1507 |
zfs_range_unlock(rl); |
|
1508 |
break; |
|
1509 |
||
789 | 1510 |
default: |
3016 | 1511 |
error = ENOTTY; |
789 | 1512 |
break; |
1513 |
||
1514 |
} |
|
1515 |
mutex_exit(&zvol_state_lock); |
|
1516 |
return (error); |
|
1517 |
} |
|
1518 |
||
1519 |
int |
|
1520 |
zvol_busy(void) |
|
1521 |
{ |
|
1522 |
return (zvol_minors != 0); |
|
1523 |
} |
|
1524 |
||
1525 |
void |
|
1526 |
zvol_init(void) |
|
1527 |
{ |
|
1528 |
VERIFY(ddi_soft_state_init(&zvol_state, sizeof (zvol_state_t), 1) == 0); |
|
1529 |
mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL); |
|
1530 |
} |
|
1531 |
||
1532 |
void |
|
1533 |
zvol_fini(void) |
|
1534 |
{ |
|
1535 |
mutex_destroy(&zvol_state_lock); |
|
1536 |
ddi_soft_state_fini(&zvol_state); |
|
1537 |
} |
|
6423 | 1538 |
|
1539 |
static boolean_t |
|
1540 |
zvol_is_swap(zvol_state_t *zv) |
|
1541 |
{ |
|
1542 |
vnode_t *vp; |
|
1543 |
boolean_t ret = B_FALSE; |
|
1544 |
char *devpath; |
|
1545 |
size_t devpathlen; |
|
1546 |
int error; |
|
1547 |
||
1548 |
devpathlen = strlen(ZVOL_FULL_DEV_DIR) + strlen(zv->zv_name) + 1; |
|
1549 |
devpath = kmem_alloc(devpathlen, KM_SLEEP); |
|
1550 |
(void) sprintf(devpath, "%s%s", ZVOL_FULL_DEV_DIR, zv->zv_name); |
|
1551 |
error = lookupname(devpath, UIO_SYSSPACE, FOLLOW, NULLVPP, &vp); |
|
1552 |
kmem_free(devpath, devpathlen); |
|
1553 |
||
1554 |
ret = !error && IS_SWAPVP(common_specvp(vp)); |
|
1555 |
||
1556 |
if (vp != NULL) |
|
1557 |
VN_RELE(vp); |
|
1558 |
||
1559 |
return (ret); |
|
1560 |
} |
|
1561 |
||
1562 |
static int |
|
1563 |
zvol_dump_init(zvol_state_t *zv, boolean_t resize) |
|
1564 |
{ |
|
1565 |
dmu_tx_t *tx; |
|
1566 |
int error = 0; |
|
1567 |
objset_t *os = zv->zv_objset; |
|
1568 |
nvlist_t *nv = NULL; |
|
1569 |
||
1570 |
ASSERT(MUTEX_HELD(&zvol_state_lock)); |
|
1571 |
||
1572 |
tx = dmu_tx_create(os); |
|
1573 |
dmu_tx_hold_zap(tx, ZVOL_ZAP_OBJ, TRUE, NULL); |
|
1574 |
error = dmu_tx_assign(tx, TXG_WAIT); |
|
1575 |
if (error) { |
|
1576 |
dmu_tx_abort(tx); |
|
1577 |
return (error); |
|
1578 |
} |
|
1579 |
||
1580 |
/* |
|
1581 |
* If we are resizing the dump device then we only need to |
|
1582 |
* update the refreservation to match the newly updated |
|
1583 |
* zvolsize. Otherwise, we save off the original state of the |
|
1584 |
* zvol so that we can restore them if the zvol is ever undumpified. |
|
1585 |
*/ |
|
1586 |
if (resize) { |
|
1587 |
error = zap_update(os, ZVOL_ZAP_OBJ, |
|
1588 |
zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 8, 1, |
|
1589 |
&zv->zv_volsize, tx); |
|
1590 |
} else { |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1591 |
uint64_t checksum, compress, refresrv, vbs; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1592 |
|
6423 | 1593 |
error = dsl_prop_get_integer(zv->zv_name, |
1594 |
zfs_prop_to_name(ZFS_PROP_COMPRESSION), &compress, NULL); |
|
1595 |
error = error ? error : dsl_prop_get_integer(zv->zv_name, |
|
1596 |
zfs_prop_to_name(ZFS_PROP_CHECKSUM), &checksum, NULL); |
|
1597 |
error = error ? error : dsl_prop_get_integer(zv->zv_name, |
|
1598 |
zfs_prop_to_name(ZFS_PROP_REFRESERVATION), &refresrv, NULL); |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1599 |
error = error ? error : dsl_prop_get_integer(zv->zv_name, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1600 |
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), &vbs, NULL); |
6423 | 1601 |
|
1602 |
error = error ? error : zap_update(os, ZVOL_ZAP_OBJ, |
|
1603 |
zfs_prop_to_name(ZFS_PROP_COMPRESSION), 8, 1, |
|
1604 |
&compress, tx); |
|
1605 |
error = error ? error : zap_update(os, ZVOL_ZAP_OBJ, |
|
1606 |
zfs_prop_to_name(ZFS_PROP_CHECKSUM), 8, 1, &checksum, tx); |
|
1607 |
error = error ? error : zap_update(os, ZVOL_ZAP_OBJ, |
|
1608 |
zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 8, 1, |
|
1609 |
&refresrv, tx); |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1610 |
error = error ? error : zap_update(os, ZVOL_ZAP_OBJ, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1611 |
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), 8, 1, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1612 |
&vbs, tx); |
6423 | 1613 |
} |
1614 |
dmu_tx_commit(tx); |
|
1615 |
||
1616 |
/* Truncate the file */ |
|
1617 |
if (!error) |
|
6992 | 1618 |
error = dmu_free_long_range(zv->zv_objset, |
1619 |
ZVOL_OBJ, 0, DMU_OBJECT_END); |
|
6423 | 1620 |
|
1621 |
if (error) |
|
1622 |
return (error); |
|
1623 |
||
1624 |
/* |
|
1625 |
* We only need update the zvol's property if we are initializing |
|
1626 |
* the dump area for the first time. |
|
1627 |
*/ |
|
1628 |
if (!resize) { |
|
1629 |
VERIFY(nvlist_alloc(&nv, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
|
1630 |
VERIFY(nvlist_add_uint64(nv, |
|
1631 |
zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 0) == 0); |
|
1632 |
VERIFY(nvlist_add_uint64(nv, |
|
1633 |
zfs_prop_to_name(ZFS_PROP_COMPRESSION), |
|
1634 |
ZIO_COMPRESS_OFF) == 0); |
|
1635 |
VERIFY(nvlist_add_uint64(nv, |
|
1636 |
zfs_prop_to_name(ZFS_PROP_CHECKSUM), |
|
1637 |
ZIO_CHECKSUM_OFF) == 0); |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1638 |
VERIFY(nvlist_add_uint64(nv, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1639 |
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1640 |
SPA_MAXBLOCKSIZE) == 0); |
6423 | 1641 |
|
1642 |
error = zfs_set_prop_nvlist(zv->zv_name, nv); |
|
1643 |
nvlist_free(nv); |
|
1644 |
||
1645 |
if (error) |
|
1646 |
return (error); |
|
1647 |
} |
|
1648 |
||
1649 |
/* Allocate the space for the dump */ |
|
1650 |
error = zvol_prealloc(zv); |
|
1651 |
return (error); |
|
1652 |
} |
|
1653 |
||
1654 |
static int |
|
1655 |
zvol_dumpify(zvol_state_t *zv) |
|
1656 |
{ |
|
1657 |
int error = 0; |
|
1658 |
uint64_t dumpsize = 0; |
|
1659 |
dmu_tx_t *tx; |
|
1660 |
objset_t *os = zv->zv_objset; |
|
1661 |
||
1662 |
if (zv->zv_flags & ZVOL_RDONLY || (zv->zv_mode & DS_MODE_READONLY)) |
|
1663 |
return (EROFS); |
|
1664 |
||
1665 |
/* |
|
1666 |
* We do not support swap devices acting as dump devices. |
|
1667 |
*/ |
|
1668 |
if (zvol_is_swap(zv)) |
|
1669 |
return (ENOTSUP); |
|
1670 |
||
1671 |
if (zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, ZVOL_DUMPSIZE, |
|
1672 |
8, 1, &dumpsize) != 0 || dumpsize != zv->zv_volsize) { |
|
1673 |
boolean_t resize = (dumpsize > 0) ? B_TRUE : B_FALSE; |
|
1674 |
||
1675 |
if ((error = zvol_dump_init(zv, resize)) != 0) { |
|
1676 |
(void) zvol_dump_fini(zv); |
|
1677 |
return (error); |
|
1678 |
} |
|
1679 |
} |
|
1680 |
||
1681 |
/* |
|
1682 |
* Build up our lba mapping. |
|
1683 |
*/ |
|
1684 |
error = zvol_get_lbas(zv); |
|
1685 |
if (error) { |
|
1686 |
(void) zvol_dump_fini(zv); |
|
1687 |
return (error); |
|
1688 |
} |
|
1689 |
||
1690 |
tx = dmu_tx_create(os); |
|
1691 |
dmu_tx_hold_zap(tx, ZVOL_ZAP_OBJ, TRUE, NULL); |
|
1692 |
error = dmu_tx_assign(tx, TXG_WAIT); |
|
1693 |
if (error) { |
|
1694 |
dmu_tx_abort(tx); |
|
1695 |
(void) zvol_dump_fini(zv); |
|
1696 |
return (error); |
|
1697 |
} |
|
1698 |
||
1699 |
zv->zv_flags |= ZVOL_DUMPIFIED; |
|
1700 |
error = zap_update(os, ZVOL_ZAP_OBJ, ZVOL_DUMPSIZE, 8, 1, |
|
1701 |
&zv->zv_volsize, tx); |
|
1702 |
dmu_tx_commit(tx); |
|
1703 |
||
1704 |
if (error) { |
|
1705 |
(void) zvol_dump_fini(zv); |
|
1706 |
return (error); |
|
1707 |
} |
|
1708 |
||
1709 |
txg_wait_synced(dmu_objset_pool(os), 0); |
|
1710 |
return (0); |
|
1711 |
} |
|
1712 |
||
1713 |
static int |
|
1714 |
zvol_dump_fini(zvol_state_t *zv) |
|
1715 |
{ |
|
1716 |
dmu_tx_t *tx; |
|
1717 |
objset_t *os = zv->zv_objset; |
|
1718 |
nvlist_t *nv; |
|
1719 |
int error = 0; |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1720 |
uint64_t checksum, compress, refresrv, vbs; |
6423 | 1721 |
|
7080
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1722 |
/* |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1723 |
* Attempt to restore the zvol back to its pre-dumpified state. |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1724 |
* This is a best-effort attempt as it's possible that not all |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1725 |
* of these properties were initialized during the dumpify process |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1726 |
* (i.e. error during zvol_dump_init). |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1727 |
*/ |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1728 |
|
6423 | 1729 |
tx = dmu_tx_create(os); |
1730 |
dmu_tx_hold_zap(tx, ZVOL_ZAP_OBJ, TRUE, NULL); |
|
1731 |
error = dmu_tx_assign(tx, TXG_WAIT); |
|
1732 |
if (error) { |
|
1733 |
dmu_tx_abort(tx); |
|
1734 |
return (error); |
|
1735 |
} |
|
7080
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1736 |
(void) zap_remove(os, ZVOL_ZAP_OBJ, ZVOL_DUMPSIZE, tx); |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1737 |
dmu_tx_commit(tx); |
6423 | 1738 |
|
1739 |
(void) zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, |
|
1740 |
zfs_prop_to_name(ZFS_PROP_CHECKSUM), 8, 1, &checksum); |
|
1741 |
(void) zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, |
|
1742 |
zfs_prop_to_name(ZFS_PROP_COMPRESSION), 8, 1, &compress); |
|
1743 |
(void) zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, |
|
1744 |
zfs_prop_to_name(ZFS_PROP_REFRESERVATION), 8, 1, &refresrv); |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1745 |
(void) zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1746 |
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), 8, 1, &vbs); |
6423 | 1747 |
|
1748 |
VERIFY(nvlist_alloc(&nv, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
|
1749 |
(void) nvlist_add_uint64(nv, |
|
1750 |
zfs_prop_to_name(ZFS_PROP_CHECKSUM), checksum); |
|
1751 |
(void) nvlist_add_uint64(nv, |
|
1752 |
zfs_prop_to_name(ZFS_PROP_COMPRESSION), compress); |
|
1753 |
(void) nvlist_add_uint64(nv, |
|
1754 |
zfs_prop_to_name(ZFS_PROP_REFRESERVATION), refresrv); |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1755 |
(void) nvlist_add_uint64(nv, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1756 |
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), vbs); |
6423 | 1757 |
(void) zfs_set_prop_nvlist(zv->zv_name, nv); |
1758 |
nvlist_free(nv); |
|
1759 |
||
7080
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1760 |
zvol_free_extents(zv); |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1761 |
zv->zv_flags &= ~ZVOL_DUMPIFIED; |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1762 |
(void) dmu_free_long_range(os, ZVOL_OBJ, 0, DMU_OBJECT_END); |
13a30a37ddc0
6724533 assertion failed: file: ../../common/fs/zfs/dmu_tx.c, line: 983
maybee
parents:
7013
diff
changeset
|
1763 |
|
6423 | 1764 |
return (0); |
1765 |
} |