diff options
author | pjd <pjd@FreeBSD.org> | 2007-05-05 17:02:19 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2007-05-05 17:02:19 +0000 |
commit | adc7ddd9913f83a3fe4cd2acab943466822f9927 (patch) | |
tree | 2589f8585d4af572f5d5fc0a96722d3dd5dd3b32 /sys/geom/geom_dev.c | |
parent | 835266e08861e25f33237e630f3095cc6ee3ee79 (diff) | |
download | FreeBSD-src-adc7ddd9913f83a3fe4cd2acab943466822f9927.zip FreeBSD-src-adc7ddd9913f83a3fe4cd2acab943466822f9927.tar.gz |
Implement three new ioctls that can be used with GEOM provider:
DIOCGFLUSH - Flush write cache (sends BIO_FLUSH).
DIOCGDELETE - Delete data (mark as unused) (sends BIO_DELETE).
DIOCGIDENT - Get provider's uniqe and fixed identifier (asks for
GEOM::ident attribute).
First two are self-explanatory, but the last one might not be. Here are
properties of provider's ident:
- ident value is preserved between reboots,
- provider can be detached/attached and ident is preserved,
- provider's name can change - ident can't,
- ident value should not be based on on-disk metadata; in other words
copying whole data from one disk to another should not yield the same
ident for the other disk,
- there could be more than one provider with the same ident, but only if
they point at exactly the same physical storage, this is the case for
multipathing for example,
- GEOM classes that consumes single providers and provide single providers,
like geli, gbde, should just attach class name to the ident of the
underlying provider,
- ident is an ASCII string (is printable),
- ident is optional and applications can't relay on its presence.
The main purpose for this is that application and remember provider's ident
and once it tries to open provider by its name again, it may compare idents
to be sure this is the right provider. If it is not (idents don't match),
then it can open provider by its ident.
OK'ed by: phk
Diffstat (limited to 'sys/geom/geom_dev.c')
-rw-r--r-- | sys/geom/geom_dev.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index fdf57e0..5c7ac66 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -245,6 +245,7 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread struct g_geom *gp; struct g_consumer *cp; struct g_kerneldump kd; + off_t offset, length; int i, error; u_int u; @@ -294,6 +295,25 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread if (!error) dev->si_flags |= SI_DUMPDEV; break; + case DIOCGFLUSH: + error = g_io_flush(cp); + break; + case DIOCGDELETE: + offset = ((off_t *)data)[0]; + length = ((off_t *)data)[1]; + if ((offset % cp->provider->sectorsize) != 0 || + (length % cp->provider->sectorsize) != 0 || + length <= 0 || length > MAXPHYS) { + printf("%s: offset=%jd length=%jd\n", __func__, offset, + length); + error = EINVAL; + break; + } + error = g_delete_data(cp, offset, length); + break; + case DIOCGIDENT: + error = g_io_getattr("GEOM::ident", cp, &i, data); + break; default: if (cp->provider->geom->ioctl != NULL) { |