- Add two fields to bio structure: 'bio_cflags' which can be used by

consumer and 'bio_pflags' which can be used by provider.
- Remove BIO_FLAG1 and BIO_FLAG2 flags. From now on new fields should be
  used for internal flags.
- Update g_bio(9) manual page.
- Update some comments.
- Update GEOM_MIRROR, which was the only one using BIO_FLAGs.

Idea from:	phk
Reviewed by:	phk
This commit is contained in:
Pawel Jakub Dawidek 2004-08-04 21:35:05 +00:00
parent 29fe871dae
commit 51385a3c00
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=133142
4 changed files with 38 additions and 35 deletions

View File

@ -72,24 +72,24 @@ Attributes are named by ascii strings and are stored in the
.Va bio_attribute
field.
.El
.It Va bio_offset
Offset into provider.
.It Va bio_data
Pointer to data buffer.
.It Va bio_flags
Available flags:
.Bl -tag -width ".Dv BIO_GETATTR"
.Bl -tag -width ".Dv BIO_ERROR"
.It Dv BIO_ERROR
Request failed (error value is stored in
.Va bio_error
field).
.It Dv BIO_DONE
Request finished.
.It Dv BIO_FLAG1
Available for private use.
.It Dv BIO_FLAG2
Available for private use.
.El
.It Va bio_cflags
Private use by the consumer.
.It Va bio_pflags
Private use by the provider.
.It Va bio_offset
Offset into provider.
.It Va bio_data
Pointer to data buffer.
.It Va bio_error
Error value when
.Dv BIO_ERROR
@ -97,13 +97,13 @@ is set.
.It Va bio_done
Pointer to function which will be called when the request is finished.
.It Va bio_driver1
Private use by the callee (i.e., the provider).
Private use by the provider.
.It Va bio_driver2
Private use by the callee (i.e., the provider).
Private use by the provider.
.It Va bio_caller1
Private use by the caller (i.e., the consumer).
Private use by the consumer.
.It Va bio_caller2
Private use by the caller (i.e., the consumer).
Private use by the consumer.
.It Va bio_attribute
Attribute string for
.Dv BIO_GETATTR

View File

@ -752,7 +752,7 @@ g_mirror_done(struct bio *bp)
struct g_mirror_softc *sc;
sc = bp->bio_from->geom->softc;
bp->bio_flags = BIO_FLAG1;
bp->bio_cflags |= G_MIRROR_BIO_FLAG_REGULAR;
mtx_lock(&sc->sc_queue_mtx);
bioq_disksort(&sc->sc_queue, bp);
wakeup(sc);
@ -853,7 +853,7 @@ g_mirror_sync_done(struct bio *bp)
G_MIRROR_LOGREQ(3, bp, "Synchronization request delivered.");
sc = bp->bio_from->geom->softc;
bp->bio_flags = BIO_FLAG2;
bp->bio_cflags |= G_MIRROR_BIO_FLAG_SYNC;
mtx_lock(&sc->sc_queue_mtx);
bioq_disksort(&sc->sc_queue, bp);
wakeup(sc);
@ -914,7 +914,7 @@ g_mirror_sync_one(struct g_mirror_disk *disk)
bp->bio_offset = disk->d_sync.ds_offset;
bp->bio_length = MIN(sc->sc_sync.ds_block,
sc->sc_mediasize - bp->bio_offset);
bp->bio_flags = 0;
bp->bio_cflags = 0;
bp->bio_done = g_mirror_sync_done;
bp->bio_data = uma_zalloc(sc->sc_sync.ds_zone, M_NOWAIT | M_ZERO);
if (bp->bio_data == NULL) {
@ -961,7 +961,7 @@ g_mirror_sync_request(struct bio *bp)
return;
}
bp->bio_cmd = BIO_WRITE;
bp->bio_flags = 0;
bp->bio_cflags = 0;
G_MIRROR_LOGREQ(3, bp, "Synchronization request finished.");
cp = disk->d_consumer;
KASSERT(cp->acr == 0 && cp->acw == 1 && cp->ace == 1,
@ -1423,9 +1423,9 @@ g_mirror_worker(void *arg)
bioq_remove(&sc->sc_queue, bp);
mtx_unlock(&sc->sc_queue_mtx);
if ((bp->bio_flags & BIO_FLAG1) != 0) {
if ((bp->bio_cflags & G_MIRROR_BIO_FLAG_REGULAR) != 0) {
g_mirror_regular_request(bp);
} else if ((bp->bio_flags & BIO_FLAG2) != 0) {
} else if ((bp->bio_cflags & G_MIRROR_BIO_FLAG_SYNC) != 0) {
u_int timeout, sps;
g_mirror_sync_request(bp);

View File

@ -83,6 +83,9 @@ extern u_int g_mirror_debug;
} \
} while (0)
#define G_MIRROR_BIO_FLAG_REGULAR 0x01
#define G_MIRROR_BIO_FLAG_SYNC 0x02
/*
* Informations needed for synchronization.
*/

View File

@ -49,20 +49,22 @@ typedef void bio_task_t(void *);
* The bio structure describes an I/O operation in the kernel.
*/
struct bio {
u_int bio_cmd; /* I/O operation. */
uint8_t bio_cmd; /* I/O operation. */
uint8_t bio_flags; /* General flags. */
uint8_t bio_cflags; /* Private use by the consumer. */
uint8_t bio_pflags; /* Private use by the provider. */
struct cdev *bio_dev; /* Device to do I/O on. */
struct disk *bio_disk; /* Valid below geom_disk.c only */
off_t bio_offset; /* Offset into file. */
long bio_bcount; /* Valid bytes in buffer. */
caddr_t bio_data; /* Memory, superblocks, indirect etc. */
u_int bio_flags; /* BIO_ flags. */
int bio_error; /* Errno for BIO_ERROR. */
long bio_resid; /* Remaining I/0 in bytes. */
void (*bio_done)(struct bio *);
void *bio_driver1; /* Private use by the callee. */
void *bio_driver2; /* Private use by the callee. */
void *bio_caller1; /* Private use by the caller. */
void *bio_caller2; /* Private use by the caller. */
void *bio_driver1; /* Private use by the provider. */
void *bio_driver2; /* Private use by the provider. */
void *bio_caller1; /* Private use by the consumer. */
void *bio_caller2; /* Private use by the consumer. */
TAILQ_ENTRY(bio) bio_queue; /* Disksort queue. */
const char *bio_attribute; /* Attribute for BIO_[GS]ETATTR */
struct g_consumer *bio_from; /* GEOM linkage */
@ -82,18 +84,16 @@ struct bio {
};
/* bio_cmd */
#define BIO_READ 0x00000001
#define BIO_WRITE 0x00000002
#define BIO_DELETE 0x00000004
#define BIO_GETATTR 0x00000008
#define BIO_CMD1 0x40000000 /* Available for local hacks */
#define BIO_CMD2 0x80000000 /* Available for local hacks */
#define BIO_READ 0x01
#define BIO_WRITE 0x02
#define BIO_DELETE 0x04
#define BIO_GETATTR 0x08
#define BIO_CMD1 0x40 /* Available for local hacks */
#define BIO_CMD2 0x80 /* Available for local hacks */
/* bio_flags */
#define BIO_ERROR 0x00000001
#define BIO_DONE 0x00000004
#define BIO_FLAG2 0x40000000 /* Available for local hacks */
#define BIO_FLAG1 0x80000000 /* Available for local hacks */
#define BIO_ERROR 0x01
#define BIO_DONE 0x02
#ifdef _KERNEL