Make md(4) support GEOM::ident for vnode-backed disks. It's based

on backing file device and inode numbers.

This is useful for gmountver(8) regression tests.

MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D12230
This commit is contained in:
Edward Tomasz Napierala 2017-10-04 12:23:34 +00:00
parent 5b4bc31eee
commit 253f5a2edb

View file

@ -207,6 +207,7 @@ struct md_s {
unsigned opencount;
unsigned fwheads;
unsigned fwsectors;
char ident[32];
unsigned flags;
char name[20];
struct proc *procp;
@ -1181,6 +1182,9 @@ md_kthread(void *arg)
sc->fwheads))) ||
g_handleattr_int(bp, "GEOM::candelete", 1))
error = -1;
else if (sc->ident[0] != '\0' &&
g_handleattr_str(bp, "GEOM::ident", sc->ident))
error = -1;
else if (g_handleattr_int(bp, "MNT::verified", isv))
error = -1;
else
@ -1414,6 +1418,8 @@ mdcreate_vnode(struct md_s *sc, struct md_ioctl *mdio, struct thread *td)
sc->fwsectors = mdio->md_fwsectors;
if (mdio->md_fwheads != 0)
sc->fwheads = mdio->md_fwheads;
snprintf(sc->ident, sizeof(sc->ident), "MD-DEV%ju-INO%ju",
(uintmax_t)vattr.va_fsid, (uintmax_t)vattr.va_fileid);
sc->flags = mdio->md_options & (MD_FORCE | MD_ASYNC | MD_VERIFY);
if (!(flags & FWRITE))
sc->flags |= MD_READONLY;
@ -1898,6 +1904,11 @@ g_md_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
indent, (uintmax_t) mp->fwheads);
sbuf_printf(sb, "%s<fwsectors>%ju</fwsectors>\n",
indent, (uintmax_t) mp->fwsectors);
if (mp->ident[0] != '\0') {
sbuf_printf(sb, "%s<ident>", indent);
g_conf_printf_escaped(sb, "%s", mp->ident);
sbuf_printf(sb, "</ident>\n");
}
sbuf_printf(sb, "%s<length>%ju</length>\n",
indent, (uintmax_t) mp->mediasize);
sbuf_printf(sb, "%s<compression>%s</compression>\n", indent,