2 * XXX replace all the checks on object validity with
3 * calls to valid<object>
6 * Copyright (c) 1997, 1998, 1999
7 * Nan Yang Computer Services Limited. All rights reserved.
9 * Parts copyright (c) 1997, 1998 Cybernet Corporation, NetMAX project.
11 * Written by Greg Lehey
13 * This software is distributed under the so-called ``Berkeley
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by Nan Yang Computer
28 * 4. Neither the name of the Company nor the names of its contributors
29 * may be used to endorse or promote products derived from this software
30 * without specific prior written permission.
32 * This software is provided ``as is'', and any express or implied
33 * warranties, including, but not limited to, the implied warranties of
34 * merchantability and fitness for a particular purpose are disclaimed.
35 * In no event shall the company or contributors be liable for any
36 * direct, indirect, incidental, special, exemplary, or consequential
37 * damages (including, but not limited to, procurement of substitute
38 * goods or services; loss of use, data, or profits; or business
39 * interruption) however caused and on any theory of liability, whether
40 * in contract, strict liability, or tort (including negligence or
41 * otherwise) arising in any way out of the use of this software, even if
42 * advised of the possibility of such damage.
44 * $Id: vinumioctl.c,v 1.14 2000/10/27 03:07:53 grog Exp grog $
45 * $FreeBSD: src/sys/dev/vinum/vinumioctl.c,v 1.25.2.4 2002/02/03 00:44:19 grog Exp $
46 * $DragonFly: src/sys/dev/raid/vinum/vinumioctl.c,v 1.9 2007/06/07 22:58:38 corecode Exp $
53 #include <sys/reboot.h>
56 void attachobject(struct vinum_ioctl_msg
*);
57 void detachobject(struct vinum_ioctl_msg
*);
58 void renameobject(struct vinum_rename_msg
*);
59 void replaceobject(struct vinum_ioctl_msg
*);
60 void moveobject(struct vinum_ioctl_msg
*);
62 jmp_buf command_fail
; /* return on a failed command */
66 vinumioctl(struct dev_ioctl_args
*ap
)
68 cdev_t dev
= ap
->a_head
.a_dev
;
69 u_long cmd
= ap
->a_cmd
;
70 caddr_t data
= ap
->a_data
;
72 unsigned int index
; /* for transferring config info */
73 unsigned int sdno
; /* for transferring config info */
74 int fe
; /* free list element number */
75 struct _ioctl_reply
*ioctl_reply
= (struct _ioctl_reply
*) data
; /* struct to return */
77 /* First, decide what we're looking at */
78 switch (DEVTYPE(dev
)) {
79 case VINUM_SUPERDEV_TYPE
: /* ordinary super device */
80 ioctl_reply
= (struct _ioctl_reply
*) data
; /* save the address to reply to */
84 if (((struct debuginfo
*) data
)->changeit
) /* change debug settings */
85 debug
= (((struct debuginfo
*) data
)->param
);
87 if (debug
& DEBUG_REMOTEGDB
)
88 boothowto
|= RB_GDB
; /* serial debug line */
90 boothowto
&= ~RB_GDB
; /* local ddb */
91 Debugger("vinum debug");
93 ioctl_reply
= (struct _ioctl_reply
*) data
; /* reinstate the address to reply to */
94 ioctl_reply
->error
= 0;
98 case VINUM_CREATE
: /* create a vinum object */
99 error
= lock_config(); /* get the config for us alone */
100 if (error
) /* can't do it, */
101 return error
; /* give up */
102 error
= setjmp(command_fail
); /* come back here on error */
103 if (error
== 0) /* first time, */
104 ioctl_reply
->error
= parse_user_config((char *) data
, /* update the config */
106 else if (ioctl_reply
->error
== 0) { /* longjmp, but no error status */
107 ioctl_reply
->error
= EINVAL
; /* note that something's up */
108 ioctl_reply
->msg
[0] = '\0'; /* no message? */
111 return 0; /* must be 0 to return the real error info */
113 case VINUM_GETCONFIG
: /* get the configuration information */
114 bcopy(&vinum_conf
, data
, sizeof(vinum_conf
));
117 /* start configuring the subsystem */
118 case VINUM_STARTCONFIG
:
119 return start_config(*(int *) data
); /* just lock it. Parameter is 'force' */
122 * Move the individual parts of the config to user space.
124 * Specify the index of the object in the first word of data,
125 * and return the object there
127 case VINUM_DRIVECONFIG
:
128 index
= *(int *) data
; /* get the index */
129 if (index
>= (unsigned) vinum_conf
.drives_allocated
) /* can't do it */
130 return ENXIO
; /* bang */
131 bcopy(&DRIVE
[index
], data
, sizeof(struct drive
)); /* copy the config item out */
135 index
= *(int *) data
; /* get the index */
136 if (index
>= (unsigned) vinum_conf
.subdisks_allocated
) /* can't do it */
137 return ENXIO
; /* bang */
138 bcopy(&SD
[index
], data
, sizeof(struct sd
)); /* copy the config item out */
141 case VINUM_PLEXCONFIG
:
142 index
= *(int *) data
; /* get the index */
143 if (index
>= (unsigned) vinum_conf
.plexes_allocated
) /* can't do it */
144 return ENXIO
; /* bang */
145 bcopy(&PLEX
[index
], data
, sizeof(struct plex
)); /* copy the config item out */
148 case VINUM_VOLCONFIG
:
149 index
= *(int *) data
; /* get the index */
150 if (index
>= (unsigned) vinum_conf
.volumes_allocated
) /* can't do it */
151 return ENXIO
; /* bang */
152 bcopy(&VOL
[index
], data
, sizeof(struct volume
)); /* copy the config item out */
155 case VINUM_PLEXSDCONFIG
:
156 index
= *(int *) data
; /* get the plex index */
157 sdno
= ((int *) data
)[1]; /* and the sd index */
158 if ((index
>= (unsigned) vinum_conf
.plexes_allocated
) /* plex doesn't exist */
159 ||(sdno
>= PLEX
[index
].subdisks
)) /* or it doesn't have this many subdisks */
160 return ENXIO
; /* bang */
161 bcopy(&SD
[PLEX
[index
].sdnos
[sdno
]], /* copy the config item out */
167 * We get called in two places: one from the
168 * userland config routines, which call us
169 * to complete the config and save it. This
170 * call supplies the value 0 as a parameter.
172 * The other place is from the user "saveconfig"
173 * routine, which can only work if we're *not*
174 * configuring. In this case, supply parameter 1.
176 case VINUM_SAVECONFIG
:
177 if (VFLAGS
& VF_CONFIGURING
) { /* must be us, the others are asleep */
178 if (*(int *) data
== 0) /* finish config */
179 finish_config(1); /* finish the configuration and update it */
181 return EBUSY
; /* can't do it now */
183 save_config(); /* save configuration to disk */
186 case VINUM_RELEASECONFIG
: /* release the config */
187 if (VFLAGS
& VF_CONFIGURING
) { /* must be us, the others are asleep */
188 finish_config(0); /* finish the configuration, don't change it */
189 save_config(); /* save configuration to disk */
191 error
= EINVAL
; /* release what config? */
195 ioctl_reply
= (struct _ioctl_reply
*) data
; /* reinstate the address to reply to */
196 ioctl_reply
->error
= 0;
199 case VINUM_RESETCONFIG
:
200 if (vinum_inactive(0)) { /* if the volumes are not active */
202 * Note the open count. We may be called from v, so we'll be open.
203 * Keep the count so we don't underflow
205 free_vinum(1); /* clean up everything */
206 log(LOG_NOTICE
, "vinum: CONFIGURATION OBLITERATED\n");
207 ioctl_reply
= (struct _ioctl_reply
*) data
; /* reinstate the address to reply to */
208 ioctl_reply
->error
= 0;
214 setstate((struct vinum_ioctl_msg
*) data
); /* set an object state */
218 * Set state by force, without changing
221 case VINUM_SETSTATE_FORCE
:
222 setstate_by_force((struct vinum_ioctl_msg
*) data
); /* set an object state */
230 case VINUM_MALLOCINFO
:
231 return vinum_mallocinfo(data
);
234 return vinum_rqinfo(data
);
237 case VINUM_LABEL
: /* label a volume */
238 ioctl_reply
->error
= write_volume_label(*(int *) data
); /* index of the volume to label */
239 ioctl_reply
->msg
[0] = '\0'; /* no message */
243 remove((struct vinum_ioctl_msg
*) data
); /* remove an object */
246 case VINUM_GETFREELIST
: /* get a drive free list element */
247 index
= *(int *) data
; /* get the drive index */
248 fe
= ((int *) data
)[1]; /* and the free list element */
249 if ((index
>= (unsigned) vinum_conf
.drives_allocated
) /* plex doesn't exist */
250 ||(DRIVE
[index
].state
== drive_unallocated
))
252 if (fe
>= DRIVE
[index
].freelist_entries
) /* no such entry */
254 bcopy(&DRIVE
[index
].freelist
[fe
],
256 sizeof(struct drive_freelist
));
259 case VINUM_RESETSTATS
:
260 resetstats((struct vinum_ioctl_msg
*) data
); /* reset object stats */
263 /* attach an object to a superordinate object */
265 attachobject((struct vinum_ioctl_msg
*) data
);
268 /* detach an object from a superordinate object */
270 detachobject((struct vinum_ioctl_msg
*) data
);
273 /* rename an object */
275 renameobject((struct vinum_rename_msg
*) data
);
278 /* replace an object */
280 replaceobject((struct vinum_ioctl_msg
*) data
);
284 vinum_daemon(); /* perform the daemon */
287 case VINUM_FINDDAEMON
: /* check for presence of daemon */
288 return vinum_finddaemon();
291 case VINUM_SETDAEMON
: /* set daemon flags */
292 return vinum_setdaemonopts(*(int *) data
);
294 case VINUM_GETDAEMON
: /* get daemon flags */
295 *(int *) data
= daemon_options
;
298 case VINUM_PARITYOP
: /* check/rebuild RAID-4/5 parity */
299 parityops((struct vinum_ioctl_msg
*) data
);
304 moveobject((struct vinum_ioctl_msg
*) data
);
311 case VINUM_DRIVE_TYPE
:
313 case VINUM_RAWSD_TYPE
:
314 case VINUM_RAWPLEX_TYPE
:
315 case VINUM_PLEX_TYPE
:
316 case VINUM_VOLUME_TYPE
:
319 "vinumioctl: invalid ioctl from process %d (%s): %lx\n",
329 * The following four functions check the supplied
330 * object index and return a pointer to the object
331 * if it exists. Otherwise they longjump out via
335 validdrive(int driveno
, struct _ioctl_reply
*reply
)
337 if ((driveno
< vinum_conf
.drives_allocated
)
338 && (DRIVE
[driveno
].state
> drive_referenced
))
339 return &DRIVE
[driveno
];
340 strcpy(reply
->msg
, "No such drive");
341 reply
->error
= ENOENT
;
346 validsd(int sdno
, struct _ioctl_reply
*reply
)
348 if ((sdno
< vinum_conf
.subdisks_allocated
)
349 && (SD
[sdno
].state
> sd_referenced
))
351 strcpy(reply
->msg
, "No such subdisk");
352 reply
->error
= ENOENT
;
357 validplex(int plexno
, struct _ioctl_reply
*reply
)
359 if ((plexno
< vinum_conf
.plexes_allocated
)
360 && (PLEX
[plexno
].state
> plex_referenced
))
361 return &PLEX
[plexno
];
362 strcpy(reply
->msg
, "No such plex");
363 reply
->error
= ENOENT
;
368 validvol(int volno
, struct _ioctl_reply
*reply
)
370 if ((volno
< vinum_conf
.volumes_allocated
)
371 && (VOL
[volno
].state
> volume_uninit
))
373 strcpy(reply
->msg
, "No such volume");
374 reply
->error
= ENOENT
;
378 /* reset an object's stats */
380 resetstats(struct vinum_ioctl_msg
*msg
)
382 struct _ioctl_reply
*reply
= (struct _ioctl_reply
*) msg
;
386 if (msg
->index
< vinum_conf
.drives_allocated
) {
387 struct drive
*drive
= &DRIVE
[msg
->index
];
388 if (drive
->state
> drive_referenced
) {
389 drive
->reads
= 0; /* number of reads on this drive */
390 drive
->writes
= 0; /* number of writes on this drive */
391 drive
->bytes_read
= 0; /* number of bytes read */
392 drive
->bytes_written
= 0; /* number of bytes written */
396 reply
->error
= EINVAL
;
400 if (msg
->index
< vinum_conf
.subdisks_allocated
) {
401 struct sd
*sd
= &SD
[msg
->index
];
402 if (sd
->state
> sd_referenced
) {
403 sd
->reads
= 0; /* number of reads on this subdisk */
404 sd
->writes
= 0; /* number of writes on this subdisk */
405 sd
->bytes_read
= 0; /* number of bytes read */
406 sd
->bytes_written
= 0; /* number of bytes written */
410 reply
->error
= EINVAL
;
416 if (msg
->index
< vinum_conf
.plexes_allocated
) {
417 struct plex
*plex
= &PLEX
[msg
->index
];
418 if (plex
->state
> plex_referenced
) {
420 plex
->writes
= 0; /* number of writes on this plex */
421 plex
->bytes_read
= 0; /* number of bytes read */
422 plex
->bytes_written
= 0; /* number of bytes written */
423 plex
->recovered_reads
= 0; /* number of recovered read operations */
424 plex
->degraded_writes
= 0; /* number of degraded writes */
425 plex
->parityless_writes
= 0; /* number of parityless writes */
426 plex
->multiblock
= 0; /* requests that needed more than one block */
427 plex
->multistripe
= 0; /* requests that needed more than one stripe */
431 reply
->error
= EINVAL
;
437 if (msg
->index
< vinum_conf
.volumes_allocated
) {
438 struct volume
*vol
= &VOL
[msg
->index
];
439 if (vol
->state
> volume_uninit
) {
440 vol
->bytes_read
= 0; /* number of bytes read */
441 vol
->bytes_written
= 0; /* number of bytes written */
442 vol
->reads
= 0; /* number of reads on this volume */
443 vol
->writes
= 0; /* number of writes on this volume */
444 vol
->recovered_reads
= 0; /* reads recovered from another plex */
448 reply
->error
= EINVAL
;
451 case invalid_object
: /* can't get this */
452 reply
->error
= EINVAL
;
457 /* attach an object to a superior object */
459 attachobject(struct vinum_ioctl_msg
*msg
)
461 struct _ioctl_reply
*reply
= (struct _ioctl_reply
*) msg
;
468 case drive_object
: /* you can't attach a drive to anything */
469 case volume_object
: /* nor a volume */
470 case invalid_object
: /* "this can't happen" */
471 reply
->error
= EINVAL
;
472 reply
->msg
[0] = '\0'; /* vinum(8) doesn't do this */
476 sd
= validsd(msg
->index
, reply
);
477 if (sd
== NULL
) /* not a valid subdisk */
479 plex
= validplex(msg
->otherobject
, reply
);
482 * We should be more intelligent about this.
483 * We should be able to reattach a dead
484 * subdisk, but if we want to increase the total
485 * number of subdisks, we have a lot of reshuffling
488 if ((plex
->organization
!= plex_concat
) /* can't attach to striped and RAID-4/5 */
489 &&(!msg
->force
)) { /* without using force */
490 reply
->error
= EINVAL
; /* no message, the user should check */
491 strcpy(reply
->msg
, "Can't attach to this plex organization");
494 if (sd
->plexno
>= 0) { /* already belong to a plex */
495 reply
->error
= EBUSY
; /* no message, the user should check */
496 reply
->msg
[0] = '\0';
499 sd
->plexoffset
= msg
->offset
; /* this is where we want it */
500 set_sd_state(sd
->sdno
, sd_stale
, setstate_force
); /* make sure it's stale */
501 give_sd_to_plex(plex
->plexno
, sd
->sdno
); /* and give it to the plex */
502 update_sd_config(sd
->sdno
, 0);
505 if (sd
->state
== sd_reviving
)
506 reply
->error
= EAGAIN
; /* need to revive it */
512 plex
= validplex(msg
->index
, reply
); /* get plex */
515 vol
= validvol(msg
->otherobject
, reply
); /* and volume information */
517 if ((vol
->plexes
== MAXPLEX
) /* we have too many already */
518 ||(plex
->volno
>= 0)) { /* or the plex has an owner */
519 reply
->error
= EINVAL
; /* no message, the user should check */
520 reply
->msg
[0] = '\0';
523 for (sdno
= 0; sdno
< plex
->subdisks
; sdno
++) {
524 sd
= &SD
[plex
->sdnos
[sdno
]];
526 if (sd
->state
> sd_down
) /* real subdisk, vaguely accessible */
527 set_sd_state(plex
->sdnos
[sdno
], sd_stale
, setstate_force
); /* make it stale */
529 set_plex_state(plex
->plexno
, plex_up
, setstate_none
); /* update plex state */
530 give_plex_to_volume(msg
->otherobject
, msg
->index
); /* and give it to the volume */
531 update_plex_config(plex
->plexno
, 0);
537 /* detach an object from a superior object */
539 detachobject(struct vinum_ioctl_msg
*msg
)
541 struct _ioctl_reply
*reply
= (struct _ioctl_reply
*) msg
;
549 case drive_object
: /* you can't detach a drive from anything */
550 case volume_object
: /* nor a volume */
551 case invalid_object
: /* "this can't happen" */
552 reply
->error
= EINVAL
;
553 reply
->msg
[0] = '\0'; /* vinum(8) doesn't do this */
557 sd
= validsd(msg
->index
, reply
);
560 if (sd
->plexno
< 0) { /* doesn't belong to a plex */
561 reply
->error
= ENOENT
;
562 strcpy(reply
->msg
, "Subdisk is not attached");
564 } else { /* valid plex number */
565 plex
= &PLEX
[sd
->plexno
];
566 if ((!msg
->force
) /* don't force things */
567 &&((plex
->state
== plex_up
) /* and the plex is up */
568 ||((plex
->state
== plex_flaky
) && sd
->state
== sd_up
))) { /* or flaky with this sd up */
569 reply
->error
= EBUSY
; /* we need this sd */
570 reply
->msg
[0] = '\0';
573 sd
->plexno
= -1; /* anonymous sd */
574 if (plex
->subdisks
== 1) { /* this was the only subdisk */
575 Free(plex
->sdnos
); /* free the subdisk array */
576 plex
->sdnos
= NULL
; /* and note the fact */
577 plex
->subdisks_allocated
= 0; /* no subdisk space */
579 for (sdno
= 0; sdno
< plex
->subdisks
; sdno
++) {
580 if (plex
->sdnos
[sdno
] == msg
->index
) /* found our subdisk */
583 if (sdno
< (plex
->subdisks
- 1)) /* not the last one, compact */
584 bcopy(&plex
->sdnos
[sdno
+ 1],
586 (plex
->subdisks
- 1 - sdno
) * sizeof(int));
589 if (!bcmp(plex
->name
, sd
->name
, strlen(plex
->name
) + 1))
590 /* this subdisk is named after the plex */
594 min(strlen(sd
->name
) + 1, MAXSDNAME
- 3));
595 bcopy("ex-", sd
->name
, 3);
596 sd
->name
[MAXSDNAME
- 1] = '\0';
598 update_plex_config(plex
->plexno
, 0);
599 if (isstriped(plex
)) /* we've just mutilated our plex, */
600 set_plex_state(plex
->plexno
,
602 setstate_force
| setstate_configuring
);
609 plex
= validplex(msg
->index
, reply
); /* get plex */
612 if (plex
->volno
>= 0) {
613 int volno
= plex
->volno
;
616 if ((!msg
->force
) /* don't force things */
617 &&((vol
->state
== volume_up
) /* and the volume is up */
618 &&(vol
->plexes
== 1))) { /* and this is the last plex */
620 * XXX As elsewhere, check whether we will lose
621 * mapping by removing this plex
623 reply
->error
= EBUSY
; /* we need this plex */
624 reply
->msg
[0] = '\0';
627 plex
->volno
= -1; /* anonymous plex */
628 for (plexno
= 0; plexno
< vol
->plexes
; plexno
++) {
629 if (vol
->plex
[plexno
] == msg
->index
) /* found our plex */
632 if (plexno
< (vol
->plexes
- 1)) /* not the last one, compact */
633 bcopy(&vol
->plex
[plexno
+ 1],
635 (vol
->plexes
- 1 - plexno
) * sizeof(int));
637 vol
->last_plex_read
= 0; /* don't go beyond the end */
638 if (!bcmp(vol
->name
, plex
->name
, strlen(vol
->name
) + 1))
639 /* this plex is named after the volume */
641 /* First, check if the subdisks are the same */
645 for (sdno
= 0; sdno
< plex
->subdisks
; sdno
++) {
646 struct sd
*sd
= &SD
[plex
->sdnos
[sdno
]];
648 if (!bcmp(plex
->name
, sd
->name
, strlen(plex
->name
) + 1))
649 /* subdisk is named after the plex */
653 min(strlen(sd
->name
) + 1, MAXSDNAME
- 3));
654 bcopy("ex-", sd
->name
, 3);
655 sd
->name
[MAXSDNAME
- 1] = '\0';
661 min(strlen(plex
->name
) + 1, MAXPLEXNAME
- 3));
662 bcopy("ex-", plex
->name
, 3);
663 plex
->name
[MAXPLEXNAME
- 1] = '\0';
665 update_volume_config(volno
, 0);
669 reply
->error
= ENOENT
;
670 strcpy(reply
->msg
, "Plex is not attached");
676 renameobject(struct vinum_rename_msg
*msg
)
678 struct _ioctl_reply
*reply
= (struct _ioctl_reply
*) msg
;
685 case drive_object
: /* you can't attach a drive to anything */
686 if (find_drive(msg
->newname
, 0) >= 0) { /* we have that name already, */
687 reply
->error
= EEXIST
;
688 reply
->msg
[0] = '\0';
691 drive
= validdrive(msg
->index
, reply
);
693 bcopy(msg
->newname
, drive
->label
.name
, MAXDRIVENAME
);
699 case sd_object
: /* you can't attach a subdisk to anything */
700 if (find_subdisk(msg
->newname
, 0) >= 0) { /* we have that name already, */
701 reply
->error
= EEXIST
;
702 reply
->msg
[0] = '\0';
705 sd
= validsd(msg
->index
, reply
);
707 bcopy(msg
->newname
, sd
->name
, MAXSDNAME
);
708 update_sd_config(sd
->sdno
, 0);
714 case plex_object
: /* you can't attach a plex to anything */
715 if (find_plex(msg
->newname
, 0) >= 0) { /* we have that name already, */
716 reply
->error
= EEXIST
;
717 reply
->msg
[0] = '\0';
720 plex
= validplex(msg
->index
, reply
);
722 bcopy(msg
->newname
, plex
->name
, MAXPLEXNAME
);
723 update_plex_config(plex
->plexno
, 0);
729 case volume_object
: /* you can't attach a volume to anything */
730 if (find_volume(msg
->newname
, 0) >= 0) { /* we have that name already, */
731 reply
->error
= EEXIST
;
732 reply
->msg
[0] = '\0';
735 vol
= validvol(msg
->index
, reply
);
737 bcopy(msg
->newname
, vol
->name
, MAXVOLNAME
);
738 update_volume_config(msg
->index
, 0);
745 reply
->error
= EINVAL
;
746 reply
->msg
[0] = '\0';
751 * Replace one object with another.
752 * Currently only for drives.
753 * message->index is the drive number of the old drive
754 * message->otherobject is the drive number of the new drive
757 replaceobject(struct vinum_ioctl_msg
*msg
)
759 struct _ioctl_reply
*reply
= (struct _ioctl_reply
*) msg
;
761 reply
->error
= ENODEV
; /* until I know how to do this */
762 strcpy(reply
->msg
, "replace not implemented yet");
763 /* save_config (); */
767 moveobject(struct vinum_ioctl_msg
*msg
)
769 struct _ioctl_reply
*reply
= (struct _ioctl_reply
*) msg
;
773 /* Check that our objects are valid (i.e. they exist) */
774 drive
= validdrive(msg
->index
, (struct _ioctl_reply
*) msg
);
777 sd
= validsd(msg
->otherobject
, (struct _ioctl_reply
*) msg
);
780 if (sd
->driveno
== msg
->index
) /* sd already belongs to drive */
783 if (sd
->state
> sd_stale
)
784 set_sd_state(sd
->sdno
, sd_stale
, setstate_force
); /* make the subdisk stale */
786 sd
->state
= sd_empty
;
787 if (sd
->plexno
>= 0) /* part of a plex, */
788 update_plex_state(sd
->plexno
); /* update its state */
790 /* Return the space on the old drive */
791 if ((sd
->driveno
>= 0) /* we have a drive, */
792 &&(sd
->sectors
> 0)) /* and some space on it */
793 return_drive_space(sd
->driveno
, /* return the space */
797 /* Reassign the old subdisk */
798 sd
->driveno
= msg
->index
;
799 sd
->driveoffset
= -1; /* let the drive decide where to put us */
800 give_sd_to_drive(sd
->sdno
);
804 /* Local Variables: */
805 /* fill-column: 50 */