1998-12-28 04:56:24 +00:00
|
|
|
|
/*-
|
|
|
|
|
* 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.
|
1999-08-24 02:21:46 +00:00
|
|
|
|
*
|
1998-12-28 04:56:24 +00:00
|
|
|
|
* 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.
|
|
|
|
|
*
|
2003-05-23 01:13:43 +00:00
|
|
|
|
* $Id: vinumext.h,v 1.33 2003/05/23 00:57:48 grog Exp $
|
1999-08-28 01:08:13 +00:00
|
|
|
|
* $FreeBSD$
|
1998-12-28 04:56:24 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* vinumext.h: external definitions */
|
|
|
|
|
|
2001-05-22 02:30:44 +00:00
|
|
|
|
/* *sigh* We still need this at the moment. */
|
|
|
|
|
#ifdef _KERNEL
|
1998-12-28 04:56:24 +00:00
|
|
|
|
extern struct _vinum_conf vinum_conf; /* configuration information */
|
2003-05-23 01:13:43 +00:00
|
|
|
|
extern struct mtx plexmutex[]; /* mutexes for plexes to use */
|
2001-05-22 02:30:44 +00:00
|
|
|
|
#else
|
|
|
|
|
extern struct __vinum_conf vinum_conf; /* configuration information */
|
|
|
|
|
#endif
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
1998-12-28 16:28:24 +00:00
|
|
|
|
#ifdef VINUMDEBUG
|
1999-03-18 23:26:22 +00:00
|
|
|
|
extern int debug; /* debug flags */
|
1998-12-28 04:56:24 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2000-02-29 06:09:41 +00:00
|
|
|
|
/* Physical read and write drive */
|
2000-03-20 10:44:49 +00:00
|
|
|
|
#define read_drive(a, b, c, d) driveio (a, b, c, d, BIO_READ)
|
|
|
|
|
#define write_drive(a, b, c, d) driveio (a, b, c, d, BIO_WRITE)
|
2000-02-29 06:09:41 +00:00
|
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
|
#define CHECKALLOC(ptr, msg) \
|
|
|
|
|
if (ptr == NULL) \
|
|
|
|
|
{ \
|
|
|
|
|
printf (msg); \
|
|
|
|
|
longjmp (command_fail, -1); \
|
|
|
|
|
}
|
1999-12-29 04:46:21 +00:00
|
|
|
|
#ifndef _KERNEL
|
1998-12-28 04:56:24 +00:00
|
|
|
|
struct vnode;
|
2001-09-12 08:38:13 +00:00
|
|
|
|
struct thread;
|
1998-12-28 04:56:24 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
|
#ifdef _KERNEL
|
1999-03-13 07:46:34 +00:00
|
|
|
|
int vinum_inactive(int);
|
1999-03-02 06:53:42 +00:00
|
|
|
|
void free_vinum(int);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
int give_sd_to_plex(int plexno, int sdno);
|
2000-01-05 06:04:17 +00:00
|
|
|
|
void give_sd_to_drive(int sdno);
|
2003-05-05 07:50:15 +00:00
|
|
|
|
int give_plex_to_volume(int, int, int);
|
1999-01-21 00:31:59 +00:00
|
|
|
|
struct drive *check_drive(char *);
|
|
|
|
|
enum drive_label_info read_drive_label(struct drive *, int);
|
|
|
|
|
int parse_config(char *, struct keywordset *, int);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
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);
|
2003-05-01 01:29:52 +00:00
|
|
|
|
int find_drive_by_name(const char *devname, int create);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
int get_empty_sd(void);
|
|
|
|
|
int find_subdisk(const char *name, int create);
|
1999-03-02 06:53:42 +00:00
|
|
|
|
void return_drive_space(int driveno, int64_t offset, int length);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
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);
|
1999-01-21 00:31:59 +00:00
|
|
|
|
void config_subdisk(int);
|
|
|
|
|
void config_plex(int);
|
|
|
|
|
void config_volume(int);
|
|
|
|
|
void config_drive(int);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
void updateconfig(int);
|
|
|
|
|
void update_sd_config(int sdno, int kernelstate);
|
|
|
|
|
void update_plex_config(int plexno, int kernelstate);
|
2003-05-23 01:13:43 +00:00
|
|
|
|
void update_volume_config(int volno);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
void update_config(void);
|
|
|
|
|
void drive_io_done(struct buf *);
|
1999-01-21 00:31:59 +00:00
|
|
|
|
void save_config(void);
|
|
|
|
|
void daemon_save_config(void);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
void write_config(char *, int);
|
1999-03-23 04:47:33 +00:00
|
|
|
|
int start_config(int);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
void finish_config(int);
|
|
|
|
|
void remove(struct vinum_ioctl_msg *msg);
|
1999-09-28 22:43:59 +00:00
|
|
|
|
void remove_drive_entry(int driveno, int force);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
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);
|
|
|
|
|
|
1999-03-02 06:53:42 +00:00
|
|
|
|
void checkdiskconfig(char *);
|
2001-09-12 08:38:13 +00:00
|
|
|
|
int open_drive(struct drive *, struct thread *, int);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
void close_drive(struct drive *drive);
|
1999-06-24 08:54:09 +00:00
|
|
|
|
void close_locked_drive(struct drive *drive);
|
1999-01-21 00:31:59 +00:00
|
|
|
|
int driveio(struct drive *, char *, size_t, off_t, int);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
int set_drive_parms(struct drive *drive);
|
1999-01-21 00:31:59 +00:00
|
|
|
|
int init_drive(struct drive *, int);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
/* void throw_rude_remark (int, struct _ioctl_reply *, char *, ...); XXX */
|
|
|
|
|
void throw_rude_remark(int, char *,...);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2003-05-04 05:19:48 +00:00
|
|
|
|
int vinum_scandisk(char *drivename);
|
1999-01-21 00:31:59 +00:00
|
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
|
/* I/O */
|
|
|
|
|
d_open_t vinumopen;
|
|
|
|
|
d_close_t vinumclose;
|
|
|
|
|
d_strategy_t vinumstrategy;
|
|
|
|
|
d_ioctl_t vinumioctl;
|
|
|
|
|
|
2003-05-01 01:29:52 +00:00
|
|
|
|
int vinum_super_ioctl(dev_t, u_long, caddr_t);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
int vinumstart(struct buf *bp, int reviveok);
|
|
|
|
|
int launch_requests(struct request *rq, int reviveok);
|
1999-01-21 00:31:59 +00:00
|
|
|
|
void sdio(struct buf *bp);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
|
|
/* XXX Do we need this? */
|
|
|
|
|
int vinumpart(dev_t);
|
|
|
|
|
|
1999-03-28 08:53:23 +00:00
|
|
|
|
extern jmp_buf command_fail; /* return here if config fails */
|
|
|
|
|
|
1998-12-28 16:28:24 +00:00
|
|
|
|
#ifdef VINUMDEBUG
|
1998-12-28 04:56:24 +00:00
|
|
|
|
/* Memory allocation and request tracing */
|
|
|
|
|
void vinum_meminfo(caddr_t data);
|
|
|
|
|
int vinum_mallocinfo(caddr_t data);
|
|
|
|
|
int vinum_rqinfo(caddr_t data);
|
1999-03-28 08:53:23 +00:00
|
|
|
|
void LongJmp(jmp_buf, int);
|
1999-04-10 08:09:27 +00:00
|
|
|
|
char *basename(char *);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2003-05-23 01:13:43 +00:00
|
|
|
|
#ifdef VINUMDEBUG
|
|
|
|
|
void expand_table(void **, int, int, char *, int);
|
|
|
|
|
#else
|
1998-12-28 04:56:24 +00:00
|
|
|
|
void expand_table(void **, int, int);
|
2003-05-23 01:13:43 +00:00
|
|
|
|
#endif
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
2002-09-20 17:14:48 +00:00
|
|
|
|
struct disklabel;
|
1998-12-28 04:56:24 +00:00
|
|
|
|
struct request;
|
|
|
|
|
struct rqgroup *allocrqg(struct request *rq, int elements);
|
|
|
|
|
void deallocrqg(struct rqgroup *rqg);
|
|
|
|
|
|
1999-01-21 00:31:59 +00:00
|
|
|
|
/* Device number decoding */
|
|
|
|
|
int Volno(dev_t x);
|
|
|
|
|
int Plexno(dev_t x);
|
|
|
|
|
int Sdno(dev_t x);
|
|
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
|
/* State transitions */
|
1999-01-21 00:31:59 +00:00
|
|
|
|
int set_drive_state(int driveno, enum drivestate state, enum setstateflags flags);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
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);
|
1999-01-21 00:31:59 +00:00
|
|
|
|
void update_sd_state(int sdno);
|
1999-03-28 08:53:23 +00:00
|
|
|
|
void forceup(int plexno);
|
1999-01-21 00:31:59 +00:00
|
|
|
|
void update_plex_state(int plexno);
|
|
|
|
|
void update_volume_state(int volno);
|
|
|
|
|
void invalidate_subdisks(struct plex *, enum sdstate);
|
1999-08-14 06:25:14 +00:00
|
|
|
|
void get_volume_label(char *name, int plexes, u_int64_t size, struct disklabel *lp);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
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);
|
1999-08-24 02:21:46 +00:00
|
|
|
|
void setstate_by_force(struct vinum_ioctl_msg *msg);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
void vinum_label(int);
|
|
|
|
|
int vinum_writedisklabel(struct volume *, struct disklabel *);
|
1999-10-13 03:16:35 +00:00
|
|
|
|
int initsd(int, int);
|
2000-05-11 07:22:18 +00:00
|
|
|
|
struct buf *parityrebuild(struct plex *, u_int64_t, int, enum parityop, struct rangelock **, off_t *);
|
1999-08-14 06:25:14 +00:00
|
|
|
|
enum requeststatus sddownstate(struct request *rq);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
|
|
int restart_plex(int plexno);
|
1999-01-21 00:31:59 +00:00
|
|
|
|
int revive_read(struct sd *sd);
|
|
|
|
|
int revive_block(int sdno);
|
2000-05-11 07:22:18 +00:00
|
|
|
|
void parityops(struct vinum_ioctl_msg *);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
|
|
/* Auxiliary functions */
|
1999-01-21 00:31:59 +00:00
|
|
|
|
enum sdstates sdstatemap(struct plex *plex);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
enum volplexstate vpstate(struct plex *plex);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
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 *);
|
|
|
|
|
void resetstats(struct vinum_ioctl_msg *msg);
|
|
|
|
|
|
|
|
|
|
/* Locking */
|
1999-04-10 08:09:27 +00:00
|
|
|
|
#ifdef VINUMDEBUG
|
|
|
|
|
int lockdrive(struct drive *drive, char *, int);
|
|
|
|
|
#else
|
1999-01-21 00:31:59 +00:00
|
|
|
|
int lockdrive(struct drive *drive);
|
1999-04-10 08:09:27 +00:00
|
|
|
|
#endif
|
1999-01-21 00:31:59 +00:00
|
|
|
|
void unlockdrive(struct drive *drive);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
int lockvol(struct volume *vol);
|
|
|
|
|
void unlockvol(struct volume *vol);
|
|
|
|
|
int lockplex(struct plex *plex);
|
|
|
|
|
void unlockplex(struct plex *plex);
|
1999-08-14 06:25:14 +00:00
|
|
|
|
struct rangelock *lockrange(daddr_t stripe, struct buf *bp, struct plex *plex);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
int lock_config(void);
|
|
|
|
|
void unlock_config(void);
|
1999-01-21 00:31:59 +00:00
|
|
|
|
|
|
|
|
|
/* D<>mon */
|
|
|
|
|
|
|
|
|
|
void vinum_daemon(void);
|
|
|
|
|
int vinum_finddaemon(void);
|
|
|
|
|
int vinum_setdaemonopts(int);
|
|
|
|
|
extern struct daemonq *daemonq; /* daemon's work queue */
|
|
|
|
|
extern struct daemonq *dqend; /* and the end of the queue */
|
2001-05-23 05:26:40 +00:00
|
|
|
|
extern struct cdevsw vinum_cdevsw;
|
2000-02-29 06:09:41 +00:00
|
|
|
|
|
2001-05-22 02:30:44 +00:00
|
|
|
|
#undef Free /* defined in some funny net stuff */
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
|
#ifdef VINUMDEBUG
|
|
|
|
|
#define Malloc(x) MMalloc ((x), __FILE__, __LINE__) /* show where we came from */
|
|
|
|
|
#define Free(x) FFree ((x), __FILE__, __LINE__) /* show where we came from */
|
|
|
|
|
caddr_t MMalloc(int size, char *, int);
|
|
|
|
|
void FFree(void *mem, char *, int);
|
|
|
|
|
#define LOCKDRIVE(d) lockdrive (d, __FILE__, __LINE__)
|
|
|
|
|
#else
|
|
|
|
|
#define Malloc(x) malloc((x), M_DEVBUF, \
|
2003-02-19 05:47:46 +00:00
|
|
|
|
curthread->td_proc->p_intr_nesting_level == 0? M_WAITOK: M_NOWAIT)
|
2001-05-22 02:30:44 +00:00
|
|
|
|
#define Free(x) free((x), M_DEVBUF)
|
|
|
|
|
#define LOCKDRIVE(d) lockdrive (d)
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
#define Malloc(x) malloc ((x)) /* just the size */
|
|
|
|
|
#define Free(x) free ((x)) /* just the address */
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-09-28 22:43:59 +00:00
|
|
|
|
/* Local Variables: */
|
|
|
|
|
/* fill-column: 50 */
|
|
|
|
|
/* End: */
|