ZFS multi-device and version 33 support.

* Makefile.util.def (libgrubkern): Add grub-core/fs/zfs/zfsinfo.c.
	* grub-core/fs/zfs/zfs.c (grub_zfs_device_desc): New struct.
	(grub_zfs_data): Add multidev-ice-related fields.
	(zio_checksum_verify): Zero-pad printed values. Print checksum name.
	(dva_get_offset): Make dva const.
	(zfs_fetch_nvlist): New function.
	(fill_vdev_info_real): Likewise.
	(fill_vdev_info): Likewise.
	(check_pool_label): Likewise.
	(scan_disk): Likewise.
	(scan_devices): Likewise.
	(read_device): Likewise.
	(read_dva): Likewise.
	(zio_read_gang): Use read_dva.
	(zio_read_data): Likewise.
	(zap_leaf_lookup): Add missing endian conversion.
	(zap_verify): Add missing endian conversion. All users updated.
	(fzap_lookup): Likewise.
	(fzap_iterate): Likewise.
	(dnode_get_path): Handle SA bonus.
	(nvlist_find_value): Make input const. All users updated.
	(unmount_device): New function.
	(zfs_unmount): Use unmount_device.
	(zfs_mount): Use scan_disk.
	(zfs_mtime): New function.
	(grub_zfs_open): Handle system attributes.
	(fill_fs_info): Likewise.
	(grub_zfs_dir): Likewise.
	(grub_zfs_fs): Add mtime.
	* grub-core/fs/zfs/zfsinfo.c (print_vdev_info): Add missing return.
	* include/grub/zfs/sa_impl.h (SA_TYPE_OFFSET): New definition.
	(SA_MTIME_OFFSET): Likewise.
	(SA_SYMLINK_OFFSET): Likewise.
	* include/grub/zfs/zfs.h (SPA_VERSION): Increase to 33.
	* util/grub-fstest.c (CMD_ZFSINFO): New enum value.
	(fstest): Support zfsinfo.
	(argp_parser): Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-10-27 02:49:50 +02:00
commit 1869edb5bc
7 changed files with 879 additions and 315 deletions

View file

@ -1,3 +1,45 @@
2011-10-26 Vladimir Serbinenko <phcoder@gmail.com>
ZFS multi-device and version 33 support.
* Makefile.util.def (libgrubkern): Add grub-core/fs/zfs/zfsinfo.c.
* grub-core/fs/zfs/zfs.c (grub_zfs_device_desc): New struct.
(grub_zfs_data): Add multidev-ice-related fields.
(zio_checksum_verify): Zero-pad printed values. Print checksum name.
(dva_get_offset): Make dva const.
(zfs_fetch_nvlist): New function.
(fill_vdev_info_real): Likewise.
(fill_vdev_info): Likewise.
(check_pool_label): Likewise.
(scan_disk): Likewise.
(scan_devices): Likewise.
(read_device): Likewise.
(read_dva): Likewise.
(zio_read_gang): Use read_dva.
(zio_read_data): Likewise.
(zap_leaf_lookup): Add missing endian conversion.
(zap_verify): Add missing endian conversion. All users updated.
(fzap_lookup): Likewise.
(fzap_iterate): Likewise.
(dnode_get_path): Handle SA bonus.
(nvlist_find_value): Make input const. All users updated.
(unmount_device): New function.
(zfs_unmount): Use unmount_device.
(zfs_mount): Use scan_disk.
(zfs_mtime): New function.
(grub_zfs_open): Handle system attributes.
(fill_fs_info): Likewise.
(grub_zfs_dir): Likewise.
(grub_zfs_fs): Add mtime.
* grub-core/fs/zfs/zfsinfo.c (print_vdev_info): Add missing return.
* include/grub/zfs/sa_impl.h (SA_TYPE_OFFSET): New definition.
(SA_MTIME_OFFSET): Likewise.
(SA_SYMLINK_OFFSET): Likewise.
* include/grub/zfs/zfs.h (SPA_VERSION): Increase to 33.
* util/grub-fstest.c (CMD_ZFSINFO): New enum value.
(fstest): Support zfsinfo.
(argp_parser): Likewise.
2011-10-26 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/datetime.h (grub_datetime2unixtime): Fix off-by-one

View file

@ -84,6 +84,7 @@ library = {
common = grub-core/fs/ufs.c;
common = grub-core/fs/xfs.c;
common = grub-core/fs/zfs/zfs.c;
common = grub-core/fs/zfs/zfsinfo.c;
common = grub-core/fs/zfs/zfs_lzjb.c;
common = grub-core/fs/zfs/zfs_sha256.c;
common = grub-core/fs/zfs/zfs_fletcher.c;

File diff suppressed because it is too large Load diff

View file

@ -141,7 +141,6 @@ print_vdev_info (char *nvlist, int tab)
}
grub_printf ("Mirror VDEV with %d children\n", nelm);
print_state (nvlist, tab);
for (i = 0; i < nelm; i++)
{
char *child;
@ -161,6 +160,7 @@ print_vdev_info (char *nvlist, int tab)
grub_free (child);
}
return GRUB_ERR_NONE;
}
print_tabs (tab);

View file

@ -29,6 +29,9 @@ typedef struct sa_hdr_phys {
} sa_hdr_phys_t;
#define SA_HDR_SIZE(hdr) BF32_GET_SB(hdr->sa_layout_info, 10, 16, 3, 0)
#define SA_TYPE_OFFSET 0x0
#define SA_SIZE_OFFSET 0x8
#define SA_MTIME_OFFSET 0x38
#define SA_SYMLINK_OFFSET 0xa0
#endif /* _SYS_SA_IMPL_H */

View file

@ -28,7 +28,7 @@
/*
* On-disk version number.
*/
#define SPA_VERSION 28ULL
#define SPA_VERSION 33ULL
/*
* The following are configuration names used in the nvlist describing a pool's
@ -112,12 +112,14 @@ grub_err_t grub_zfs_fetch_nvlist (grub_device_t dev, char **nvlist);
grub_err_t grub_zfs_getmdnobj (grub_device_t dev, const char *fsfilename,
grub_uint64_t *mdnobj);
char *grub_zfs_nvlist_lookup_string (char *nvlist, char *name);
char *grub_zfs_nvlist_lookup_nvlist (char *nvlist, char *name);
int grub_zfs_nvlist_lookup_uint64 (char *nvlist, char *name,
char *grub_zfs_nvlist_lookup_string (const char *nvlist, const char *name);
char *grub_zfs_nvlist_lookup_nvlist (const char *nvlist, const char *name);
int grub_zfs_nvlist_lookup_uint64 (const char *nvlist, const char *name,
grub_uint64_t *out);
char *grub_zfs_nvlist_lookup_nvlist_array (char *nvlist, char *name,
char *grub_zfs_nvlist_lookup_nvlist_array (const char *nvlist,
const char *name,
grub_size_t index);
int grub_zfs_nvlist_lookup_nvlist_array_get_nelm (char *nvlist, char *name);
int grub_zfs_nvlist_lookup_nvlist_array_get_nelm (const char *nvlist,
const char *name);
#endif /* ! GRUB_ZFS_HEADER */

View file

@ -62,9 +62,9 @@ enum {
CMD_HEX,
CMD_CRC,
CMD_BLOCKLIST,
CMD_TESTLOAD
CMD_TESTLOAD,
CMD_ZFSINFO
};
#define BUF_SIZE 32256
static grub_disk_addr_t skip, leng;
@ -354,6 +354,9 @@ fstest (int n, char **args)
case CMD_LS:
execute_command ("ls", n, args);
break;
case CMD_ZFSINFO:
execute_command ("zfsinfo", n, args);
break;
case CMD_CP:
cmd_cp (args[0], args[1]);
break;
@ -516,6 +519,10 @@ argp_parser (int key, char *arg, struct argp_state *state)
{
cmd = CMD_LS;
}
else if (!grub_strcmp (arg, "zfsinfo"))
{
cmd = CMD_ZFSINFO;
}
else if (!grub_strcmp (arg, "cp"))
{
cmd = CMD_CP;