A flag for the geom disk driver to indicate that it accepts the

unmapped i/o requests.

Sponsored by:	The FreeBSD Foundation
Tested by:	pho
This commit is contained in:
Konstantin Belousov 2013-03-19 14:49:15 +00:00
parent e81ff91e62
commit f8c19ba466
2 changed files with 20 additions and 1 deletions

View File

@ -320,13 +320,29 @@ g_disk_start(struct bio *bp)
do {
bp2->bio_offset += off;
bp2->bio_length -= off;
bp2->bio_data += off;
if ((bp->bio_flags & BIO_UNMAPPED) == 0) {
bp2->bio_data += off;
} else {
KASSERT((dp->d_flags & DISKFLAG_UNMAPPED_BIO)
!= 0,
("unmapped bio not supported by disk %s",
dp->d_name));
bp2->bio_ma += off / PAGE_SIZE;
bp2->bio_ma_offset += off;
bp2->bio_ma_offset %= PAGE_SIZE;
bp2->bio_ma_n -= off / PAGE_SIZE;
}
if (bp2->bio_length > dp->d_maxsize) {
/*
* XXX: If we have a stripesize we should really
* use it here.
*/
bp2->bio_length = dp->d_maxsize;
if ((bp->bio_flags & BIO_UNMAPPED) != 0) {
bp2->bio_ma_n = howmany(
bp2->bio_ma_offset +
bp2->bio_length, PAGE_SIZE);
}
off += dp->d_maxsize;
/*
* To avoid a race, we need to grab the next bio
@ -488,6 +504,8 @@ g_disk_create(void *arg, int flag)
pp->sectorsize = dp->d_sectorsize;
pp->stripeoffset = dp->d_stripeoffset;
pp->stripesize = dp->d_stripesize;
if ((dp->d_flags & DISKFLAG_UNMAPPED_BIO) != 0)
pp->flags |= G_PF_ACCEPT_UNMAPPED;
if (bootverbose)
printf("GEOM: new disk %s\n", gp->name);
sysctl_ctx_init(&sc->sysctl_ctx);

View File

@ -103,6 +103,7 @@ struct disk {
#define DISKFLAG_OPEN 0x2
#define DISKFLAG_CANDELETE 0x4
#define DISKFLAG_CANFLUSHCACHE 0x8
#define DISKFLAG_UNMAPPED_BIO 0x10
struct disk *disk_alloc(void);
void disk_create(struct disk *disk, int version);