md.c revision 1.81 1 /* $NetBSD: md.c,v 1.81 2019/05/26 10:22:07 hannken Exp $ */
2
3 /*
4 * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 /*
29 * This implements a general-purpose memory-disk.
30 * See md.h for notes on the config types.
31 *
32 * Note that this driver provides the same functionality
33 * as the MFS filesystem hack, but this is better because
34 * you can use this for any filesystem type you'd like!
35 *
36 * Credit for most of the kmem ramdisk code goes to:
37 * Leo Weppelman (atari) and Phil Nelson (pc532)
38 * Credit for the ideas behind the "user space memory" code goes
39 * to the authors of the MFS implementation.
40 */
41
42 #include <sys/cdefs.h>
43 __KERNEL_RCSID(0, "$NetBSD: md.c,v 1.81 2019/05/26 10:22:07 hannken Exp $");
44
45 #ifdef _KERNEL_OPT
46 #include "opt_md.h"
47 #else
48 #define MEMORY_DISK_SERVER 1
49 #endif
50
51 #include <sys/param.h>
52 #include <sys/kernel.h>
53 #include <sys/malloc.h>
54 #include <sys/systm.h>
55 #include <sys/buf.h>
56 #include <sys/bufq.h>
57 #include <sys/device.h>
58 #include <sys/disk.h>
59 #include <sys/stat.h>
60 #include <sys/proc.h>
61 #include <sys/conf.h>
62 #include <sys/disklabel.h>
63
64 #include <uvm/uvm_extern.h>
65
66 #include <dev/md.h>
67
68 #include "ioconf.h"
69 /*
70 * The user-space functionality is included by default.
71 * Use `options MEMORY_DISK_SERVER=0' to turn it off.
72 */
73 #ifndef MEMORY_DISK_SERVER
74 #error MEMORY_DISK_SERVER should be defined by opt_md.h
75 #endif /* MEMORY_DISK_SERVER */
76
77 /*
78 * We should use the raw partition for ioctl.
79 */
80 #define MD_UNIT(unit) DISKUNIT(unit)
81
82 /* autoconfig stuff... */
83
84 struct md_softc {
85 device_t sc_dev; /* Self. */
86 struct disk sc_dkdev; /* hook for generic disk handling */
87 struct md_conf sc_md;
88 kmutex_t sc_lock; /* Protect self. */
89 kcondvar_t sc_cv; /* Wait here for work. */
90 struct bufq_state *sc_buflist;
91 };
92 /* shorthand for fields in sc_md: */
93 #define sc_addr sc_md.md_addr
94 #define sc_size sc_md.md_size
95 #define sc_type sc_md.md_type
96
97 static void md_attach(device_t, device_t, void *);
98 static int md_detach(device_t, int);
99
100 static dev_type_open(mdopen);
101 static dev_type_close(mdclose);
102 static dev_type_read(mdread);
103 static dev_type_write(mdwrite);
104 static dev_type_ioctl(mdioctl);
105 static dev_type_strategy(mdstrategy);
106 static dev_type_size(mdsize);
107
108 const struct bdevsw md_bdevsw = {
109 .d_open = mdopen,
110 .d_close = mdclose,
111 .d_strategy = mdstrategy,
112 .d_ioctl = mdioctl,
113 .d_dump = nodump,
114 .d_psize = mdsize,
115 .d_discard = nodiscard,
116 .d_flag = D_DISK | D_MPSAFE
117 };
118
119 const struct cdevsw md_cdevsw = {
120 .d_open = mdopen,
121 .d_close = mdclose,
122 .d_read = mdread,
123 .d_write = mdwrite,
124 .d_ioctl = mdioctl,
125 .d_stop = nostop,
126 .d_tty = notty,
127 .d_poll = nopoll,
128 .d_mmap = nommap,
129 .d_kqfilter = nokqfilter,
130 .d_discard = nodiscard,
131 .d_flag = D_DISK
132 };
133
134 static struct dkdriver mddkdriver = {
135 .d_strategy = mdstrategy
136 };
137
138 CFATTACH_DECL3_NEW(md, sizeof(struct md_softc),
139 0, md_attach, md_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
140
141 static kmutex_t md_device_lock; /* Protect unit creation / deletion. */
142 extern size_t md_root_size;
143
144 static void md_set_disklabel(struct md_softc *);
145
146 /*
147 * This is called if we are configured as a pseudo-device
148 */
149 void
150 mdattach(int n)
151 {
152
153 mutex_init(&md_device_lock, MUTEX_DEFAULT, IPL_NONE);
154 if (config_cfattach_attach(md_cd.cd_name, &md_ca)) {
155 aprint_error("%s: cfattach_attach failed\n", md_cd.cd_name);
156 return;
157 }
158 }
159
160 static void
161 md_attach(device_t parent, device_t self, void *aux)
162 {
163 struct md_softc *sc = device_private(self);
164
165 sc->sc_dev = self;
166 sc->sc_type = MD_UNCONFIGURED;
167 mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
168 cv_init(&sc->sc_cv, "mdidle");
169 bufq_alloc(&sc->sc_buflist, "fcfs", 0);
170
171 /* XXX - Could accept aux info here to set the config. */
172 #ifdef MEMORY_DISK_HOOKS
173 /*
174 * This external function might setup a pre-loaded disk.
175 * All it would need to do is setup the md_conf struct.
176 * See sys/dev/md_root.c for an example.
177 */
178 md_attach_hook(device_unit(self), &sc->sc_md);
179 #endif
180
181 /*
182 * Initialize and attach the disk structure.
183 */
184 disk_init(&sc->sc_dkdev, device_xname(self), &mddkdriver);
185 disk_attach(&sc->sc_dkdev);
186
187 if (sc->sc_type != MD_UNCONFIGURED)
188 md_set_disklabel(sc);
189
190 if (!pmf_device_register(self, NULL, NULL))
191 aprint_error_dev(self, "couldn't establish power handler\n");
192 }
193
194 static int
195 md_detach(device_t self, int flags)
196 {
197 struct md_softc *sc = device_private(self);
198 int rc;
199
200 rc = 0;
201 mutex_enter(&sc->sc_dkdev.dk_openlock);
202 if (sc->sc_dkdev.dk_openmask == 0 && sc->sc_type == MD_UNCONFIGURED)
203 ; /* nothing to do */
204 else if ((flags & DETACH_FORCE) == 0)
205 rc = EBUSY;
206 mutex_exit(&sc->sc_dkdev.dk_openlock);
207
208 if (rc != 0)
209 return rc;
210
211 pmf_device_deregister(self);
212 disk_detach(&sc->sc_dkdev);
213 disk_destroy(&sc->sc_dkdev);
214 bufq_free(sc->sc_buflist);
215 mutex_destroy(&sc->sc_lock);
216 cv_destroy(&sc->sc_cv);
217 return 0;
218 }
219
220 /*
221 * operational routines:
222 * open, close, read, write, strategy,
223 * ioctl, dump, size
224 */
225
226 #if MEMORY_DISK_SERVER
227 static int md_server_loop(struct md_softc *sc);
228 static int md_ioctl_server(struct md_softc *sc, struct md_conf *umd,
229 struct lwp *l);
230 #endif /* MEMORY_DISK_SERVER */
231 static int md_ioctl_kalloc(struct md_softc *sc, struct md_conf *umd,
232 struct lwp *l);
233
234 static int
235 mdsize(dev_t dev)
236 {
237 struct md_softc *sc;
238 int res;
239
240 sc = device_lookup_private(&md_cd, MD_UNIT(dev));
241 if (sc == NULL)
242 return 0;
243
244 mutex_enter(&sc->sc_lock);
245 if (sc->sc_type == MD_UNCONFIGURED)
246 res = 0;
247 else
248 res = sc->sc_size >> DEV_BSHIFT;
249 mutex_exit(&sc->sc_lock);
250
251 return res;
252 }
253
254 static int
255 mdopen(dev_t dev, int flag, int fmt, struct lwp *l)
256 {
257 int unit;
258 int part = DISKPART(dev);
259 int pmask = 1 << part;
260 cfdata_t cf;
261 struct md_softc *sc;
262 struct disk *dk;
263 #ifdef MEMORY_DISK_HOOKS
264 bool configured;
265 #endif
266
267 mutex_enter(&md_device_lock);
268 unit = MD_UNIT(dev);
269 sc = device_lookup_private(&md_cd, unit);
270 if (sc == NULL) {
271 if (part != RAW_PART) {
272 mutex_exit(&md_device_lock);
273 return ENXIO;
274 }
275 cf = malloc(sizeof(*cf), M_DEVBUF, M_WAITOK);
276 cf->cf_name = md_cd.cd_name;
277 cf->cf_atname = md_cd.cd_name;
278 cf->cf_unit = unit;
279 cf->cf_fstate = FSTATE_STAR;
280 sc = device_private(config_attach_pseudo(cf));
281 if (sc == NULL) {
282 mutex_exit(&md_device_lock);
283 return ENOMEM;
284 }
285 }
286
287 dk = &sc->sc_dkdev;
288
289 /*
290 * The raw partition is used for ioctl to configure.
291 */
292 if (part == RAW_PART)
293 goto ok;
294
295 #ifdef MEMORY_DISK_HOOKS
296 /* Call the open hook to allow loading the device. */
297 configured = (sc->sc_type != MD_UNCONFIGURED);
298 md_open_hook(unit, &sc->sc_md);
299 /* initialize disklabel if the device is configured in open hook */
300 if (!configured && sc->sc_type != MD_UNCONFIGURED)
301 md_set_disklabel(sc);
302 #endif
303
304 /*
305 * This is a normal, "slave" device, so
306 * enforce initialized.
307 */
308 if (sc->sc_type == MD_UNCONFIGURED) {
309 mutex_exit(&md_device_lock);
310 return ENXIO;
311 }
312
313 ok:
314 /* XXX duplicates code in dk_open(). Call dk_open(), instead? */
315 mutex_enter(&dk->dk_openlock);
316 /* Mark our unit as open. */
317 switch (fmt) {
318 case S_IFCHR:
319 dk->dk_copenmask |= pmask;
320 break;
321 case S_IFBLK:
322 dk->dk_bopenmask |= pmask;
323 break;
324 }
325
326 dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask;
327
328 mutex_exit(&dk->dk_openlock);
329 mutex_exit(&md_device_lock);
330 return 0;
331 }
332
333 static int
334 mdclose(dev_t dev, int flag, int fmt, struct lwp *l)
335 {
336 int part = DISKPART(dev);
337 int pmask = 1 << part;
338 int error;
339 cfdata_t cf;
340 struct md_softc *sc;
341 struct disk *dk;
342
343 sc = device_lookup_private(&md_cd, MD_UNIT(dev));
344 if (sc == NULL)
345 return ENXIO;
346
347 dk = &sc->sc_dkdev;
348
349 mutex_enter(&dk->dk_openlock);
350
351 switch (fmt) {
352 case S_IFCHR:
353 dk->dk_copenmask &= ~pmask;
354 break;
355 case S_IFBLK:
356 dk->dk_bopenmask &= ~pmask;
357 break;
358 }
359 dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask;
360 if (dk->dk_openmask != 0) {
361 mutex_exit(&dk->dk_openlock);
362 return 0;
363 }
364
365 mutex_exit(&dk->dk_openlock);
366
367 mutex_enter(&md_device_lock);
368 cf = device_cfdata(sc->sc_dev);
369 error = config_detach(sc->sc_dev, DETACH_QUIET);
370 if (! error)
371 free(cf, M_DEVBUF);
372 mutex_exit(&md_device_lock);
373 return error;
374 }
375
376 static int
377 mdread(dev_t dev, struct uio *uio, int flags)
378 {
379 struct md_softc *sc;
380
381 sc = device_lookup_private(&md_cd, MD_UNIT(dev));
382
383 if (sc == NULL || sc->sc_type == MD_UNCONFIGURED)
384 return ENXIO;
385
386 return (physio(mdstrategy, NULL, dev, B_READ, minphys, uio));
387 }
388
389 static int
390 mdwrite(dev_t dev, struct uio *uio, int flags)
391 {
392 struct md_softc *sc;
393
394 sc = device_lookup_private(&md_cd, MD_UNIT(dev));
395
396 if (sc == NULL || sc->sc_type == MD_UNCONFIGURED)
397 return ENXIO;
398
399 return (physio(mdstrategy, NULL, dev, B_WRITE, minphys, uio));
400 }
401
402 /*
403 * Handle I/O requests, either directly, or
404 * by passing them to the server process.
405 */
406 static void
407 mdstrategy(struct buf *bp)
408 {
409 struct md_softc *sc;
410 void * addr;
411 size_t off, xfer;
412 bool is_read;
413
414 sc = device_lookup_private(&md_cd, MD_UNIT(bp->b_dev));
415
416 if (sc == NULL || sc->sc_type == MD_UNCONFIGURED) {
417 bp->b_error = ENXIO;
418 goto done;
419 }
420
421 mutex_enter(&sc->sc_lock);
422
423 switch (sc->sc_type) {
424 #if MEMORY_DISK_SERVER
425 case MD_UMEM_SERVER:
426 /* Just add this job to the server's queue. */
427 bufq_put(sc->sc_buflist, bp);
428 cv_signal(&sc->sc_cv);
429 mutex_exit(&sc->sc_lock);
430 /* see md_server_loop() */
431 /* no biodone in this case */
432 return;
433 #endif /* MEMORY_DISK_SERVER */
434
435 case MD_KMEM_FIXED:
436 case MD_KMEM_ALLOCATED:
437 /* These are in kernel space. Access directly. */
438 is_read = ((bp->b_flags & B_READ) == B_READ);
439 bp->b_resid = bp->b_bcount;
440 off = (bp->b_blkno << DEV_BSHIFT);
441 if (off >= sc->sc_size) {
442 if (is_read)
443 break; /* EOF */
444 goto set_eio;
445 }
446 xfer = bp->b_resid;
447 if (xfer > (sc->sc_size - off))
448 xfer = (sc->sc_size - off);
449 addr = (char *)sc->sc_addr + off;
450 disk_busy(&sc->sc_dkdev);
451 if (is_read)
452 memcpy(bp->b_data, addr, xfer);
453 else
454 memcpy(addr, bp->b_data, xfer);
455 disk_unbusy(&sc->sc_dkdev, xfer, is_read);
456 bp->b_resid -= xfer;
457 break;
458
459 default:
460 bp->b_resid = bp->b_bcount;
461 set_eio:
462 bp->b_error = EIO;
463 break;
464 }
465 mutex_exit(&sc->sc_lock);
466
467 done:
468
469 biodone(bp);
470 }
471
472 static int
473 mdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
474 {
475 struct md_softc *sc;
476 struct md_conf *umd;
477 int error;
478
479 if ((sc = device_lookup_private(&md_cd, MD_UNIT(dev))) == NULL)
480 return ENXIO;
481
482 if (sc->sc_type != MD_UNCONFIGURED) {
483 error = disk_ioctl(&sc->sc_dkdev, dev, cmd, data, flag, l);
484 if (error != EPASSTHROUGH) {
485 return error;
486 }
487 }
488
489 /* If this is not the raw partition, punt! */
490 if (DISKPART(dev) != RAW_PART) {
491 return ENOTTY;
492 }
493
494 mutex_enter(&sc->sc_lock);
495 umd = (struct md_conf *)data;
496 error = EINVAL;
497 switch (cmd) {
498 case MD_GETCONF:
499 *umd = sc->sc_md;
500 error = 0;
501 break;
502
503 case MD_SETCONF:
504 /* Can only set it once. */
505 if (sc->sc_type != MD_UNCONFIGURED)
506 break;
507 switch (umd->md_type) {
508 case MD_KMEM_ALLOCATED:
509 error = md_ioctl_kalloc(sc, umd, l);
510 break;
511 #if MEMORY_DISK_SERVER
512 case MD_UMEM_SERVER:
513 error = md_ioctl_server(sc, umd, l);
514 break;
515 #endif /* MEMORY_DISK_SERVER */
516 default:
517 break;
518 }
519 break;
520 }
521 mutex_exit(&sc->sc_lock);
522 return error;
523 }
524
525 static void
526 md_set_disklabel(struct md_softc *sc)
527 {
528 struct disk_geom *dg = &sc->sc_dkdev.dk_geom;
529 struct disklabel *lp = sc->sc_dkdev.dk_label;
530 struct partition *pp;
531
532 memset(lp, 0, sizeof(*lp));
533
534 lp->d_secsize = DEV_BSIZE;
535 lp->d_secperunit = sc->sc_size / DEV_BSIZE;
536 if (lp->d_secperunit >= (32*64)) {
537 lp->d_nsectors = 32;
538 lp->d_ntracks = 64;
539 lp->d_ncylinders = lp->d_secperunit / (32*64);
540 } else {
541 lp->d_nsectors = 1;
542 lp->d_ntracks = 1;
543 lp->d_ncylinders = lp->d_secperunit;
544 }
545 lp->d_secpercyl = lp->d_ntracks*lp->d_nsectors;
546
547 strncpy(lp->d_typename, md_cd.cd_name, sizeof(lp->d_typename));
548 lp->d_type = DKTYPE_MD;
549 strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
550 lp->d_rpm = 3600;
551 lp->d_interleave = 1;
552 lp->d_flags = 0;
553
554 pp = &lp->d_partitions[0];
555 pp->p_offset = 0;
556 pp->p_size = lp->d_secperunit;
557 pp->p_fstype = FS_BSDFFS;
558
559 pp = &lp->d_partitions[RAW_PART];
560 pp->p_offset = 0;
561 pp->p_size = lp->d_secperunit;
562 pp->p_fstype = FS_UNUSED;
563
564 lp->d_npartitions = RAW_PART+1;
565 lp->d_magic = DISKMAGIC;
566 lp->d_magic2 = DISKMAGIC;
567 lp->d_checksum = dkcksum(lp);
568
569 memset(dg, 0, sizeof(*dg));
570
571 dg->dg_secsize = lp->d_secsize;
572 dg->dg_secperunit = lp->d_secperunit;
573 dg->dg_nsectors = lp->d_nsectors;
574 dg->dg_ntracks = lp->d_ntracks = 64;;
575 dg->dg_ncylinders = lp->d_ncylinders;
576
577 disk_set_info(sc->sc_dev, &sc->sc_dkdev, NULL);
578 }
579
580 /*
581 * Handle ioctl MD_SETCONF for (sc_type == MD_KMEM_ALLOCATED)
582 * Just allocate some kernel memory and return.
583 */
584 static int
585 md_ioctl_kalloc(struct md_softc *sc, struct md_conf *umd,
586 struct lwp *l)
587 {
588 vaddr_t addr;
589 vsize_t size;
590
591 mutex_exit(&sc->sc_lock);
592
593 /* Sanity check the size. */
594 size = umd->md_size;
595 addr = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
596
597 mutex_enter(&sc->sc_lock);
598
599 if (!addr)
600 return ENOMEM;
601
602 /* If another thread beat us to configure this unit: fail. */
603 if (sc->sc_type != MD_UNCONFIGURED) {
604 uvm_km_free(kernel_map, addr, size, UVM_KMF_WIRED);
605 return EINVAL;
606 }
607
608 /* This unit is now configured. */
609 sc->sc_addr = (void *)addr; /* kernel space */
610 sc->sc_size = (size_t)size;
611 sc->sc_type = MD_KMEM_ALLOCATED;
612 md_set_disklabel(sc);
613 return 0;
614 }
615
616 #if MEMORY_DISK_SERVER
617
618 /*
619 * Handle ioctl MD_SETCONF for (sc_type == MD_UMEM_SERVER)
620 * Set config, then become the I/O server for this unit.
621 */
622 static int
623 md_ioctl_server(struct md_softc *sc, struct md_conf *umd,
624 struct lwp *l)
625 {
626 vaddr_t end;
627 int error;
628
629 KASSERT(mutex_owned(&sc->sc_lock));
630
631 /* Sanity check addr, size. */
632 end = (vaddr_t) ((char *)umd->md_addr + umd->md_size);
633
634 if (
635 #ifndef _RUMPKERNEL
636 /*
637 * On some architectures (e.g. powerpc) rump kernel provides
638 * "safe" low defaults which make this test fail since malloc
639 * does return higher addresses than the "safe" default.
640 */
641 (end >= VM_MAXUSER_ADDRESS) ||
642 #endif
643 (end < ((vaddr_t) umd->md_addr)))
644 return EINVAL;
645
646 /* This unit is now configured. */
647 sc->sc_addr = umd->md_addr; /* user space */
648 sc->sc_size = umd->md_size;
649 sc->sc_type = MD_UMEM_SERVER;
650 md_set_disklabel(sc);
651
652 /* Become the server daemon */
653 error = md_server_loop(sc);
654
655 /* This server is now going away! */
656 sc->sc_type = MD_UNCONFIGURED;
657 sc->sc_addr = 0;
658 sc->sc_size = 0;
659
660 return (error);
661 }
662
663 static int
664 md_server_loop(struct md_softc *sc)
665 {
666 struct buf *bp;
667 void *addr; /* user space address */
668 size_t off; /* offset into "device" */
669 size_t xfer; /* amount to transfer */
670 int error;
671 bool is_read;
672
673 KASSERT(mutex_owned(&sc->sc_lock));
674
675 for (;;) {
676 /* Wait for some work to arrive. */
677 while ((bp = bufq_get(sc->sc_buflist)) == NULL) {
678 error = cv_wait_sig(&sc->sc_cv, &sc->sc_lock);
679 if (error)
680 return error;
681 }
682
683 /* Do the transfer to/from user space. */
684 mutex_exit(&sc->sc_lock);
685 error = 0;
686 is_read = ((bp->b_flags & B_READ) == B_READ);
687 bp->b_resid = bp->b_bcount;
688 off = (bp->b_blkno << DEV_BSHIFT);
689 if (off >= sc->sc_size) {
690 if (is_read)
691 goto done; /* EOF (not an error) */
692 error = EIO;
693 goto done;
694 }
695 xfer = bp->b_resid;
696 if (xfer > (sc->sc_size - off))
697 xfer = (sc->sc_size - off);
698 addr = (char *)sc->sc_addr + off;
699 disk_busy(&sc->sc_dkdev);
700 if (is_read)
701 error = copyin(addr, bp->b_data, xfer);
702 else
703 error = copyout(bp->b_data, addr, xfer);
704 disk_unbusy(&sc->sc_dkdev, (error ? 0 : xfer), is_read);
705 if (!error)
706 bp->b_resid -= xfer;
707
708 done:
709 if (error) {
710 bp->b_error = error;
711 }
712 biodone(bp);
713 mutex_enter(&sc->sc_lock);
714 }
715 }
716 #endif /* MEMORY_DISK_SERVER */
717