From: Andreas Dilger <adilger@sun.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH] blkid detection for ZFS
Date: Thu, 14 Feb 2008 18:07:40 -0700 [thread overview]
Message-ID: <20080215010740.GZ3029@webber.adilger.int> (raw)
[-- Attachment #1: Type: text/plain, Size: 1295 bytes --]
Attached is a patch to detect ZFS in libblkid. It isn't by any means
complete, because it doesn't report the LABEL or UUID of the device,
nor names any of the constituent filesystems. The latter is quite
complex to implement and may be beyond the scope of libblkid.
Some input is welcome here also... There is a UUID (GUID) for the whole
"pool" (aggregation of devices that ZFS filesystems might live on), a
UUID for the "virtual device" (vdev) (akin to MD RAID set) that a disk
is part of and also a separate UUID for each device. There is a LABEL
(pool name) for the whole pool, but not one for an individual filesystem.
I'm thinking of making the blkid UUID be the GUID of the whole pool, as
any device in the pool would be sufficient to locate all of the component
devices. This means all devices in the same pool will return the same
UUID, but for identification that should be fine I think... I haven't
checked for pathologies in libblkid regarding that yet.
On a related note - on Solaris the ZFS filesystems always live in a GPT
partition table, and I note that libblkid doesn't identify this. Is that
something we want to start adding to libblkid (e.g. GPT, DOS, LVM, etc)?
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: e2fsprogs-blkid-zfs.patch --]
[-- Type: text/plain; NAME=e2fsprogs-blkid-zfs.patch; charset=utf-8, Size: 6200 bytes --]
Index: e2fsprogs-cfs/lib/blkid/probe.c
===================================================================
--- e2fsprogs-cfs.orig/lib/blkid/probe.c
+++ e2fsprogs-cfs/lib/blkid/probe.c
@@ -647,6 +647,21 @@ static int probe_jfs(struct blkid_probe
return 0;
}
+static int probe_zfs(struct blkid_probe *probe, struct blkid_magic *id,
+ unsigned char *buf)
+{
+ struct zfs_uber_block *zub;
+ char *vdev_label;
+ const char *pool_name = 0;
+
+ zub = (struct zfs_uber_block *)buf;
+
+ /* read nvpair data for pool name, pool GUID (complex) */
+ //blkid_set_tag(probe->dev, "LABEL", pool_name, sizeof(pool_name));
+ //set_uuid(probe->dev, pool_guid, 0);
+ return 0;
+}
+
static int probe_luks(struct blkid_probe *probe,
struct blkid_magic *id __BLKID_ATTR((unused)),
unsigned char *buf)
@@ -896,15 +911,6 @@ static int probe_hfsplus(struct blkid_pr
}
/*
- * BLKID_BLK_OFFS is at least as large as the highest bim_kboff defined
- * in the type_array table below + bim_kbalign.
- *
- * When probing for a lot of magics, we handle everything in 1kB buffers so
- * that we don't have to worry about reading each combination of block sizes.
- */
-#define BLKID_BLK_OFFS 64 /* currently reiserfs */
-
-/*
* Various filesystem magics that we can check for. Note that kboff and
* sboff are in kilobytes and bytes respectively. All magics are in
* byte strings so we don't worry about endian issues.
@@ -954,6 +960,8 @@ static struct blkid_magic type_array[] =
{ "iso9660", 32, 1, 5, "CD001", probe_iso9660 },
{ "iso9660", 32, 9, 5, "CDROM", probe_iso9660 },
{ "jfs", 32, 0, 4, "JFS1", probe_jfs },
+ { "zfs", 128, 0, 8, "\0\0\0\0\x00\xba\xb1\x0c", probe_zfs },
+ { "zfs", 128, 0, 8, "\x0c\xb1\xba\x00\0\0\0\0", probe_zfs },
{ "hfsplus", 1, 0, 2, "BD", probe_hfsplus },
{ "hfsplus", 1, 0, 2, "H+", 0 },
{ "hfs", 1, 0, 2, "BD", 0 },
@@ -1074,7 +1082,7 @@ try_again:
if (!buf)
continue;
- if (memcmp(id->bim_magic, buf + (id->bim_sboff&0x3ff),
+ if (memcmp(id->bim_magic, buf + (id->bim_sboff & 0x3ff),
id->bim_len))
continue;
@@ -1104,7 +1112,7 @@ try_again:
dev = 0;
goto found_type;
}
-
+
found_type:
if (dev && type) {
dev->bid_devno = st.st_rdev;
@@ -1113,7 +1121,7 @@ found_type:
cache->bic_flags |= BLKID_BIC_FL_CHANGED;
blkid_set_tag(dev, "TYPE", type, 0);
-
+
DBG(DEBUG_PROBE, printf("%s: devno 0x%04llx, type %s\n",
dev->bid_name, (long long)st.st_rdev, type));
}
Index: e2fsprogs-cfs/lib/blkid/probe.h
===================================================================
--- e2fsprogs-cfs.orig/lib/blkid/probe.h
+++ e2fsprogs-cfs/lib/blkid/probe.h
@@ -190,6 +190,16 @@ struct jfs_super_block {
unsigned char js_loguuid[16];
};
+#define UBERBLOCK_MAGIC 0x00bab10c /* oo-ba-bloc! */
+struct zfs_uberblock {
+ __u64 ub_magic; /* UBERBLOCK_MAGIC */
+ __u64 ub_version; /* ZFS_VERSION */
+ __u64 ub_txg; /* txg of last sync */
+ __u64 ub_guid_sum; /* sum of all vdev guids */
+ __u64 ub_timestamp; /* UTC time of last sync */
+ char ub_rootbp; /* MOS objset_phys_t */
+};
+
struct romfs_super_block {
unsigned char ros_magic[8];
__u32 ros_dummy1[2];
Index: e2fsprogs-cfs/lib/blkid/tests/zfs.results
===================================================================
--- /dev/null
+++ e2fsprogs-cfs/lib/blkid/tests/zfs.results
@@ -0,0 +1 @@
+TYPE='zfs'
Index: e2fsprogs-cfs/lib/blkid/tests/zfs.img.bz2
===================================================================
--- /dev/null
+++ e2fsprogs-cfs/lib/blkid/tests/zfs.img.bz2
@@ -0,0 +1,18 @@
+BZh91AY&SYgë
+=0'Ó\x13M2z\x11§¡\x1abL2i¤ö£i¨iôÍ dz3\x10diLOL\x06SL§B\x15#Rz\f©æ§£Jy¤\x13&§M1\x11á4ôi0
+m\r2LO4SPz¢\x13Iå<§¦§£\rCOSÐ&\f&LhdÓTöI©Í'¡5<£ÓM2z§©új'¤Ã\x11\f âMhôÒ\x18ÔÉèM¤Äô£\x10É'¡\x1a\x18h¦Q´ÔòMcDÉO)èL2\x016#M2i¡\x1aé=LL\r4Ä^[PÓOD\x182=OPÓ@e\fSƧ¦E?HÈõ5\x1f¤Oi\x0fIä\x13Í&\x11#Qý\x14üSÄÚ§å4FÔÓ
+z6hSÈfSSÒ~¤òOÒÕ?Tý\x14\x1f\x1a)´Ú§j(òÔõ=(=OhÒS44ýIê?TÓɦÕ\b¤M6<M h2OF4LhDÓSÒxSzSÉ<§fOPóI?TÚi5\x1eM'¦¦y =5=\f£Ê4ô§©êzSÄÅ=¥<Òa\x13ô)é\x1eQáOSÔòfاêPÌSõ4Ô \x12!\x01\x06F\x19¦\r\x19\f 4Ä\r4dѦ\x1a22zB\x1al¡§4d`hÐhÉ 4Ñ \x06F\x1a\x01§©¦Ñ§¤\x1ah\x1e Èh\vè(Åâ±²]&\x02Z@X¬_ErQg*rtLm¼¢aÐ\x13jõ$Ûf6~GQíWüZû"·!¶ÍÔp6Ûw\vmÂåq¨§Oq´TO ¦B! m9ófN6tú\x13çÐ Ph\x18Ðë÷Ì/[¦ªõ~©Úì>¾Îl7eüüø1®÷û3'Ôe¡\a'ÚªBÆ\x15¢½¨ðÿjä£çÓóÅêUð"\x10<ð/¿ñ\fÏY ¤?K\x15Ò}«uC»ïW\x0e6la>EºØâ'Õó\bz
ô;5èÍ\x05éØÌëÎï9ÖËä\x016
+]H°S0óbdªltª&òTlæççÍ·N\x05??+;Lx\x13"÷6$\x04$ÛH\x10%Ó°@Q°\x10SEK@èÁ.\x15ÈI*L*MæQ)=æ\©@Â+\x1cxhBI!W±$´\x02\x10X4¡0í \x16,£g$È}\v[\x16\x16¥f
+¥À³Î\x18|Ö8X2°¾4ÏÆJÊÔ#Ñ8_\x18p<rKÙ¦óK\x16Ã\x1c
+Ò\x1aw!?C?»óaÏàRT8L`mö\x0f$\x0få«E)\x06MEÇ=Òª1*_&_bÛwY\x1cQÿ²U@ëݶûU<ݼª<µ·\f\fÆAÏ×át©ÜnŽÑJ8¶æÆ#ÜI·Ùܲéxõý3Yf\x15\a*Ißðµh$3¢=\x1dsh!ú¤>iÔ\x1a>Ó
õ\x17¦ðñ !X¼£u2{ïòA\x17¬ë\ftçO\x11}ñ
+E\x19Û~ØÖ\x16
\x1aÈëTWjÞÛîÆ'9u++æùã¿D
\a,¡Ù\x06Ul]\x13ࣺZ*8/½ÔãÐD0³ýúÖ«w´h\x14º*\x18ÞC \x03å\aÓÍ6N[\x1en Bù}×\fIA¥ÎºXQü<(µÓ\x16ïÿâ\x12\x13\x17\x15yZ!e§(ëú¬¼Ã²k\x1a\x19à\ÌG%Z@°wÝ¡ÊíI\x1dè#°!Æà.nå<¾ÕOð÷¶±z\x14@`ÉNÔÜD§;û\x14G`Î+ûÚ\ríð¸ÝtYí_?£ñqÊéÝ\x03ÑÞKó\x01d6Sa³LòÛÝñÙ½vÊàFUîÄÕKá\x19\x1cªq¬\x13ëÝ~ ì
+0(\x02FÇTø}Ku¤xî4
+\x03È47¾¢Áì=LÕp[÷÷ÍZvÕÛëbÚkPöö\x1a\x17\x0eHìÄt,\x0eâd\v´èXe·Kû\x14 à
+#á\x1a®ìâ9Uë¿\x1aÜ=WT\x10ç£r»ó\x19"càîÎÍqØ\x1f¬ÞY¢\x1d:\x7f^[#¶f)
+=¤\x0f¬\x1aMýÃ/5]/\A{é~Cz|gN:F oÎ\x05þ#ß[?7@ÿ\x17Û5¤Ê?¬`ïlQ^;³x¬äÍT¦
Òèø¥ekß#uÙÇ\x16C;þ§\x12Ùž.@j^[º¢}sPÈ+'\x03"\x1e\x1c¾Ö\[n¾¶Ã§/Åò³§ËhÓi\x16XbSÒT<ø³\b\x05Ûãn<_¼N¥¤Ì±I`Ø\x12}Î\x10\x1e¡m¥¯aj\x19ñQÝ^[\x12ÙÛuw¢×\x11Z8UadV\x1fÉðOJ\x12\x0f,d\x02*Oü\x1cÎ%æ|f´óa¶=¸4¶ÿK¾i»IT¦£
+²°G¡eb®£rù6\x0fJ^:>vOè¨iª ø@j³þ\x1e¼\rijk\x0fóç30Ls³±Á\b\f\x18
+}µ\x160SÌIÇDÖi6I ,B\x1f.rª\x15ÖßiRõ«JTõÓz\fÚÍDÒP\x12'[\x04´ÒP¹Òu\x03\r»\b^\a¡X:\r
+-Ä\x1a\x16]¢ø-\x1côG¼´$íâΰc}ì$RI\x15¥)E´~
+×é\x10åd0\x0f: èI¿#\x15²<pd!âÜ\x05ÖØÿ59\x1d8\x12Ým¬\x0f©¦Ö¬\b6\fÇ\v9^Û¥i[\r¾¡ñ?IôèWU\x0eL·/>e\x15YëÓ6T3ñ \x18ü2í\x05ç *\x13Kðh×ð¼\x1dK\x034Éó3\x06[ê\x14õÖ\x05Ø\x14 \x15^\x03%9Q\x16V\fÈþmBámo0Òqô"ª¥"é°Z\x1a\x1eâ(»úÉ$
++ò]á8¢ÆüÉX÷PdÉÄFäïXf²^ZöWÇw\x19D¬7\bßè\x14U\x152õÉ5\x1aþ'½\x1dUøYÙ¯ª&!t^QãYêAÁÄ£¾wߣØU2{\x04¸\x10ä¤öL\bIL(
úm?ïí"½3øZ[H#èÌVhÇgbÁûhÄ\x11u³\vfñjZ\x02Ü~|Lc+ÓUóÙê=2ç«ÞÊ,C\x7f \x0eáóqçÇOSR$«üÒ!ÄÀ¶\x7faáÂìn\x16J9¨\x02³
È\x1dÆ}V\b\x1ftÚ>GÖâæíJ̾ ¤\x03³~\x18<¾M1ß>7å)OYòè+¹TjÚ\x16è-b\x1ccËisÁ$ûæ¨Á¯´Ý\x7fT)½ÂÛ\x17CbÀK*ß±÷\x7f¶6X\x12R«6_¥"!oX[Å\x11§Ñ^[\x17oê\vµê ~О0[¡NZödYÍ`õ\x11"n\x12I
+ÿû'w·Ëþ\x16ëâhµWßÓgI]¬Çr|\x15%§°åtÖ4Üî3ùúï\a\y@B\f\x06Î×?°uè¼W|ªZÿÄþzmhø\x1egÄEñ%]Í蝹ÅÝ~¹n\v/ûͶ§ÿÅÜN\x14$\x19ãúç
\ No newline at end of file
next reply other threads:[~2008-02-15 1:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-15 1:07 Andreas Dilger [this message]
2008-02-20 12:57 ` [PATCH] blkid detection for ZFS Theodore Tso
2008-02-21 9:20 ` Andreas Dilger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080215010740.GZ3029@webber.adilger.int \
--to=adilger@sun.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).