From d91e813c7b3dd2d89ef8ba12fb77abbe860a2e23 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 29 Dec 2010 12:11:07 +0000 Subject: [PATCH] Add reporting of GEOM::candelete BIO_GETATTR for md(4) and geom_disk(4). Non-zero value of attribute means that device supports BIO_DELETE. Suggested and reviewed by: pjd Tested by: pho MFC after: 1 week --- sys/dev/md/md.c | 5 +++-- sys/geom/geom_disk.c | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 314e289d5a3..ccd903910ff 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -717,11 +717,12 @@ md_kthread(void *arg) } mtx_unlock(&sc->queue_mtx); if (bp->bio_cmd == BIO_GETATTR) { - if (sc->fwsectors && sc->fwheads && + if ((sc->fwsectors && sc->fwheads && (g_handleattr_int(bp, "GEOM::fwsectors", sc->fwsectors) || g_handleattr_int(bp, "GEOM::fwheads", - sc->fwheads))) + sc->fwheads))) || + g_handleattr_int(bp, "GEOM::candelete", 1)) error = -1; else error = EOPNOTSUPP; diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index 25d2e3b92e6..4f918e87345 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -297,7 +297,11 @@ g_disk_start(struct bio *bp) } while (bp2 != NULL); break; case BIO_GETATTR: - if (g_handleattr_int(bp, "GEOM::fwsectors", dp->d_fwsectors)) + if (g_handleattr_int(bp, "GEOM::candelete", + (dp->d_flags & DISKFLAG_CANDELETE) != 0)) + break; + else if (g_handleattr_int(bp, "GEOM::fwsectors", + dp->d_fwsectors)) break; else if (g_handleattr_int(bp, "GEOM::fwheads", dp->d_fwheads)) break;