summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2006-10-31 21:12:43 +0000
committerpjd <pjd@FreeBSD.org>2006-10-31 21:12:43 +0000
commit67c00d09c15829fc438fdaf3ed5b6bb694301114 (patch)
tree07dd690b1b3a4b092441c9211b64625a2b9015a8 /sys/geom
parentd5cc90945161b6ca3448116aa23c9ae0b75a6e94 (diff)
downloadFreeBSD-src-67c00d09c15829fc438fdaf3ed5b6bb694301114.zip
FreeBSD-src-67c00d09c15829fc438fdaf3ed5b6bb694301114.tar.gz
Add a new disk flag - DISKFLAG_CANFLUSHCACHE, which indicates that the disk
can handle BIO_FLUSH requests. Sponsored by: home.pl
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/geom_disk.c22
-rw-r--r--sys/geom/geom_disk.h1
2 files changed, 22 insertions, 1 deletions
diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c
index 6115106..1a65d89 100644
--- a/sys/geom/geom_disk.c
+++ b/sys/geom/geom_disk.c
@@ -202,8 +202,10 @@ g_disk_done(struct bio *bp)
if (bp2->bio_error == 0)
bp2->bio_error = bp->bio_error;
bp2->bio_completed += bp->bio_completed;
- if ((dp = bp2->bio_to->geom->softc))
+ if ((bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_DELETE)) &&
+ (dp = bp2->bio_to->geom->softc)) {
devstat_end_transaction_bio(dp->d_devstat, bp);
+ }
g_destroy_bio(bp);
bp2->bio_inbed++;
if (bp2->bio_children == bp2->bio_inbed) {
@@ -304,6 +306,24 @@ g_disk_start(struct bio *bp)
else
error = ENOIOCTL;
break;
+ case BIO_FLUSH:
+ g_trace(G_T_TOPOLOGY, "g_disk_flushcache(%s)",
+ bp->bio_to->name);
+ if (!(dp->d_flags & DISKFLAG_CANFLUSHCACHE)) {
+ g_io_deliver(bp, ENODEV);
+ return;
+ }
+ bp2 = g_clone_bio(bp);
+ if (bp2 == NULL) {
+ g_io_deliver(bp, ENOMEM);
+ return;
+ }
+ bp2->bio_done = g_disk_done;
+ bp2->bio_disk = dp;
+ g_disk_lock_giant(dp);
+ dp->d_strategy(bp2);
+ g_disk_unlock_giant(dp);
+ break;
default:
error = EOPNOTSUPP;
break;
diff --git a/sys/geom/geom_disk.h b/sys/geom/geom_disk.h
index 23719bf..9e8b1ef 100644
--- a/sys/geom/geom_disk.h
+++ b/sys/geom/geom_disk.h
@@ -91,6 +91,7 @@ struct disk {
#define DISKFLAG_NEEDSGIANT 0x1
#define DISKFLAG_OPEN 0x2
#define DISKFLAG_CANDELETE 0x4
+#define DISKFLAG_CANFLUSHCACHE 0x8
struct disk *disk_alloc(void);
void disk_create(struct disk *disk, int version);
OpenPOWER on IntegriCloud