mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-20 11:11:24 +00:00
c285ca1254
kernel as a pseudo-device. The changes were: - #ifdef DEBUG -> #ifdef VINUMDEBUG - opt_vinum.h for holding above config variable - Fixing up a few stray problems where DEBUG wasn't optional. - config.c -> vinumconfig.c (there's already a config.o) - Other *.c -> vinum*.c (wasn't strictly necessary, but done in case we end up with something else conflicting later on and we might have to have yet more repository copies of files). - include file paths fixups.. (ie: get them all from the kernel tree instead of partly from the kernel and partly from /usr/include/machine) I've spoken with Greg about this.. I hope this doesn't mess him around too much..
205 lines
7.5 KiB
C
205 lines
7.5 KiB
C
/*-
|
|
* Copyright (c) 1997, 1998
|
|
* Nan Yang Computer Services Limited. All rights reserved.
|
|
*
|
|
* This software is distributed under the so-called ``Berkeley
|
|
* License'':
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
* must display the following acknowledgement:
|
|
* This product includes software developed by Nan Yang Computer
|
|
* Services Limited.
|
|
* 4. Neither the name of the Company nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* This software is provided ``as is'', and any express or implied
|
|
* warranties, including, but not limited to, the implied warranties of
|
|
* merchantability and fitness for a particular purpose are disclaimed.
|
|
* In no event shall the company or contributors be liable for any
|
|
* direct, indirect, incidental, special, exemplary, or consequential
|
|
* damages (including, but not limited to, procurement of substitute
|
|
* goods or services; loss of use, data, or profits; or business
|
|
* interruption) however caused and on any theory of liability, whether
|
|
* in contract, strict liability, or tort (including negligence or
|
|
* otherwise) arising in any way out of the use of this software, even if
|
|
* advised of the possibility of such damage.
|
|
*
|
|
* $Id: vinumext.h,v 1.4 1998/12/28 04:56:24 peter Exp $
|
|
*/
|
|
|
|
/* vinumext.h: external definitions */
|
|
|
|
extern struct _vinum_conf vinum_conf; /* configuration information */
|
|
|
|
#ifdef VINUMDEBUG
|
|
extern debug; /* debug flags */
|
|
#endif
|
|
|
|
#define CHECKALLOC(ptr, msg) \
|
|
if (ptr == NULL) \
|
|
{ \
|
|
printf (msg); \
|
|
longjmp (command_fail, -1); \
|
|
}
|
|
#ifndef KERNEL
|
|
struct vnode;
|
|
struct proc;
|
|
#endif
|
|
|
|
#ifdef KERNEL
|
|
int give_sd_to_plex(int plexno, int sdno);
|
|
int give_plex_to_volume(int volno, int plexno);
|
|
int check_drive(char *);
|
|
enum drive_label_info read_drive_label(struct drive *drive);
|
|
int parse_config(char *, struct keywordset *);
|
|
int parse_user_config(char *cptr, struct keywordset *keyset);
|
|
u_int64_t sizespec(char *spec);
|
|
int volume_index(struct volume *volume);
|
|
int plex_index(struct plex *plex);
|
|
int sd_index(struct sd *sd);
|
|
int drive_index(struct drive *drive);
|
|
int my_plex(int volno, int plexno);
|
|
int my_sd(int plexno, int sdno);
|
|
int get_empty_drive(void);
|
|
int find_drive(const char *name, int create);
|
|
int find_drive_by_dev(const char *devname, int create);
|
|
int get_empty_sd(void);
|
|
int find_subdisk(const char *name, int create);
|
|
void free_sd(int sdno);
|
|
void free_volume(int volno);
|
|
int get_empty_plex(void);
|
|
int find_plex(const char *name, int create);
|
|
void free_plex(int plexno);
|
|
int get_empty_volume(void);
|
|
int find_volume(const char *name, int create);
|
|
void config_subdisk(void);
|
|
void config_plex(void);
|
|
void config_volume(void);
|
|
void config_drive(void);
|
|
void updateconfig(int);
|
|
void update_sd_config(int sdno, int kernelstate);
|
|
void update_plex_config(int plexno, int kernelstate);
|
|
void update_volume_config(int volno, int kernelstate);
|
|
void update_config(void);
|
|
void drive_io_done(struct buf *);
|
|
int save_config(void);
|
|
void write_config(char *, int);
|
|
int start_config(void);
|
|
void finish_config(int);
|
|
void remove(struct vinum_ioctl_msg *msg);
|
|
void remove_drive_entry(int driveno, int force, int recurse);
|
|
void remove_sd_entry(int sdno, int force, int recurse);
|
|
void remove_plex_entry(int plexno, int force, int recurse);
|
|
void remove_volume_entry(int volno, int force, int recurse);
|
|
|
|
void checkernel(char *);
|
|
int open_drive(struct drive *, struct proc *);
|
|
void close_drive(struct drive *drive);
|
|
int driveio(struct drive *, void *, size_t, off_t, int);
|
|
/* #define read_drive(a, b, c, d) driveio (a, b, c, d, B_READ)
|
|
#define write_drive(a, b, c, d) driveio (a, b, c, d, B_WRITE) */
|
|
int set_drive_parms(struct drive *drive);
|
|
int init_drive(struct drive *);
|
|
/* void throw_rude_remark (int, struct _ioctl_reply *, char *, ...); XXX */
|
|
void throw_rude_remark(int, char *,...);
|
|
|
|
int read_drive(struct drive *drive, void *buf, size_t length, off_t offset);
|
|
int write_drive(struct drive *drive, void *buf, size_t length, off_t offset);
|
|
void format_config(char *config, int len);
|
|
void checkkernel(char *op);
|
|
void free_drive(struct drive *drive);
|
|
void down_drive(struct drive *drive);
|
|
void remove_drive(int driveno);
|
|
|
|
/* I/O */
|
|
d_open_t vinumopen;
|
|
d_close_t vinumclose;
|
|
d_strategy_t vinumstrategy;
|
|
d_ioctl_t vinumioctl;
|
|
d_dump_t vinumdump;
|
|
d_psize_t vinumsize;
|
|
d_read_t vinumread;
|
|
d_write_t vinumwrite;
|
|
|
|
int vinumstart(struct buf *bp, int reviveok);
|
|
int launch_requests(struct request *rq, int reviveok);
|
|
|
|
/* XXX Do we need this? */
|
|
int vinumpart(dev_t);
|
|
|
|
#ifdef VINUMDEBUG
|
|
/* Memory allocation and request tracing */
|
|
void vinum_meminfo(caddr_t data);
|
|
int vinum_mallocinfo(caddr_t data);
|
|
int vinum_rqinfo(caddr_t data);
|
|
#endif
|
|
|
|
void expand_table(void **, int, int);
|
|
|
|
void add_defective_region(struct plex *plex, off_t offset, size_t length);
|
|
void add_unmapped_region(struct plex *plex, off_t offset, size_t length);
|
|
void rebuild_plex_unmappedlist(struct plex *plex);
|
|
struct request;
|
|
struct rqgroup *allocrqg(struct request *rq, int elements);
|
|
void deallocrqg(struct rqgroup *rqg);
|
|
|
|
/* State transitions */
|
|
int set_drive_state(int driveno, enum drivestate state, int force);
|
|
int set_sd_state(int sdno, enum sdstate state, enum setstateflags flags);
|
|
enum requeststatus checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t diskend);
|
|
int set_plex_state(int plexno, enum plexstate state, enum setstateflags flags);
|
|
int set_volume_state(int volumeno, enum volumestate state, enum setstateflags flags);
|
|
void get_volume_label(struct volume *vol, struct disklabel *lp);
|
|
int write_volume_label(int);
|
|
void start_object(struct vinum_ioctl_msg *);
|
|
void stop_object(struct vinum_ioctl_msg *);
|
|
void setstate(struct vinum_ioctl_msg *msg);
|
|
void vinum_label(int);
|
|
int vinum_writedisklabel(struct volume *, struct disklabel *);
|
|
int initsd(int);
|
|
|
|
int restart_plex(int plexno);
|
|
int revive_block(int plexno);
|
|
|
|
/* Auxiliary functions */
|
|
enum sdstates sdstatemap(struct plex *plex, int *sddowncount);
|
|
enum volplexstate vpstate(struct plex *plex);
|
|
#endif
|
|
|
|
enum keyword get_keyword(char *, struct keywordset *);
|
|
void listconfig(void);
|
|
char *drive_state(enum drivestate);
|
|
char *volume_state(enum volumestate);
|
|
char *plex_state(enum plexstate);
|
|
char *plex_org(enum plexorg);
|
|
char *sd_state(enum sdstate);
|
|
enum drivestate DriveState(char *text);
|
|
enum sdstate SdState(char *text);
|
|
enum plexstate PlexState(char *text);
|
|
enum volumestate VolState(char *text);
|
|
struct drive *validdrive(int driveno, struct _ioctl_reply *);
|
|
struct sd *validsd(int sdno, struct _ioctl_reply *);
|
|
struct plex *validplex(int plexno, struct _ioctl_reply *);
|
|
struct volume *validvol(int volno, struct _ioctl_reply *);
|
|
int tokenize(char *, char *[]);
|
|
void resetstats(struct vinum_ioctl_msg *msg);
|
|
|
|
/* Locking */
|
|
int lockvol(struct volume *vol);
|
|
void unlockvol(struct volume *vol);
|
|
int lockplex(struct plex *plex);
|
|
void unlockplex(struct plex *plex);
|
|
int lockrange(struct plex *plex, off_t first, off_t last);
|
|
void unlockrange(struct plex *plex, off_t first, off_t last);
|
|
int lock_config(void);
|
|
void unlock_config(void);
|