2003-04-01 13:19:14 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2003 Poul-Henning Kamp
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This software was developed for the FreeBSD Project by Poul-Henning Kamp
|
|
|
|
* and NAI Labs, the Security Research Division of Network Associates, Inc.
|
|
|
|
* under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
|
|
|
|
* DARPA CHATS research program.
|
|
|
|
*
|
|
|
|
* 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. The names of the authors may not be used to endorse or promote
|
|
|
|
* products derived from this software without specific prior written
|
|
|
|
* permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 AUTHOR 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.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GEOM_GEOM_DISK_H_
|
|
|
|
#define _GEOM_GEOM_DISK_H_
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
|
|
|
|
#include <sys/queue.h>
|
2003-04-02 20:41:18 +00:00
|
|
|
#include <sys/_lock.h>
|
|
|
|
#include <sys/_mutex.h>
|
2007-05-05 17:12:15 +00:00
|
|
|
#include <sys/disk.h>
|
2003-04-01 13:19:14 +00:00
|
|
|
|
2005-03-15 10:47:38 +00:00
|
|
|
struct disk;
|
|
|
|
|
2003-04-01 13:19:14 +00:00
|
|
|
typedef int disk_open_t(struct disk *);
|
|
|
|
typedef int disk_close_t(struct disk *);
|
|
|
|
typedef void disk_strategy_t(struct bio *bp);
|
|
|
|
typedef int disk_ioctl_t(struct disk *, u_long cmd, void *data,
|
|
|
|
int fflag, struct thread *td);
|
|
|
|
/* NB: disk_ioctl_t SHALL be cast'able to d_ioctl_t */
|
|
|
|
|
|
|
|
struct g_geom;
|
|
|
|
struct devstat;
|
|
|
|
|
|
|
|
struct disk {
|
|
|
|
/* Fields which are private to geom_disk */
|
|
|
|
struct g_geom *d_geom;
|
|
|
|
struct devstat *d_devstat;
|
2004-02-18 21:36:53 +00:00
|
|
|
int d_destroyed;
|
2003-04-01 13:19:14 +00:00
|
|
|
|
|
|
|
/* Shared fields */
|
|
|
|
u_int d_flags;
|
|
|
|
const char *d_name;
|
|
|
|
u_int d_unit;
|
2003-04-02 20:41:18 +00:00
|
|
|
struct bio_queue_head *d_queue;
|
|
|
|
struct mtx *d_lock;
|
2003-04-01 13:19:14 +00:00
|
|
|
|
|
|
|
/* Disk methods */
|
|
|
|
disk_open_t *d_open;
|
|
|
|
disk_close_t *d_close;
|
|
|
|
disk_strategy_t *d_strategy;
|
|
|
|
disk_ioctl_t *d_ioctl;
|
|
|
|
dumper_t *d_dump;
|
|
|
|
|
|
|
|
/* Info fields from driver to geom_disk.c. Valid when open */
|
|
|
|
u_int d_sectorsize;
|
|
|
|
off_t d_mediasize;
|
|
|
|
u_int d_fwsectors;
|
|
|
|
u_int d_fwheads;
|
|
|
|
u_int d_maxsize;
|
|
|
|
u_int d_stripeoffset;
|
|
|
|
u_int d_stripesize;
|
2007-05-05 17:12:15 +00:00
|
|
|
char d_ident[DISK_IDENT_SIZE];
|
2010-07-25 15:43:52 +00:00
|
|
|
uint16_t d_hba_vendor;
|
|
|
|
uint16_t d_hba_device;
|
|
|
|
uint16_t d_hba_subvendor;
|
|
|
|
uint16_t d_hba_subdevice;
|
2003-04-01 13:19:14 +00:00
|
|
|
|
|
|
|
/* Fields private to the driver */
|
|
|
|
void *d_drv1;
|
|
|
|
};
|
|
|
|
|
2004-02-18 21:36:53 +00:00
|
|
|
#define DISKFLAG_NEEDSGIANT 0x1
|
2003-04-01 13:19:14 +00:00
|
|
|
#define DISKFLAG_OPEN 0x2
|
|
|
|
#define DISKFLAG_CANDELETE 0x4
|
2006-10-31 21:12:43 +00:00
|
|
|
#define DISKFLAG_CANFLUSHCACHE 0x8
|
2003-04-01 13:19:14 +00:00
|
|
|
|
2004-02-18 21:36:53 +00:00
|
|
|
struct disk *disk_alloc(void);
|
|
|
|
void disk_create(struct disk *disk, int version);
|
2003-04-01 13:19:14 +00:00
|
|
|
void disk_destroy(struct disk *disk);
|
Fix a bug that caused some /dev entries to continue to exist after
the underlying drive had been hot-unplugged from the system. Here
is a specific example. Filesystem code had opened /dev/da1s1e.
Subsequently, the drive was hot-unplugged. This (correctly) caused
all of the associated /dev/da1* entries to be deleted. When the
filesystem later realized that the drive was gone it closed the
device, reducing the write-access counts to 0 on the geom providers
for da1s1e, da1s1, and da1. This caused geom to re-taste the
providers, resulting in the devices being created again. When the
drive was hot-plugged back in, it resulted in duplicate /dev entries
for da1s1e, da1s1, and da1.
This fix adds a new disk_gone() function which is called by CAM when a
drive goes away. It orphans all of the providers associated with the
drive, setting an error condition of ENXIO in each one. In addition,
we prevent a re-taste on last close for writing if an error condition
has been set in the provider.
Sponsored by: Isilon Systems
Reviewed by: phk
MFC after: 1 week
2005-11-18 02:43:49 +00:00
|
|
|
void disk_gone(struct disk *disk);
|
2003-04-01 13:19:14 +00:00
|
|
|
|
2004-02-18 21:36:53 +00:00
|
|
|
#define DISK_VERSION_00 0x58561059
|
2007-05-05 17:12:15 +00:00
|
|
|
#define DISK_VERSION_01 0x5856105a
|
|
|
|
#define DISK_VERSION DISK_VERSION_01
|
2003-04-01 13:19:14 +00:00
|
|
|
|
|
|
|
#endif /* _KERNEL */
|
|
|
|
#endif /* _GEOM_GEOM_DISK_H_ */
|