Project

General

Profile

Actions

Bug #12235

closed

Add libzutil for libzfs or libzpool consumers

Added by Jerry Jelinek over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
zfs - Zettabyte File System
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

To simplify our on-going work to better align with OpenZFS, port the following commit:
e89f1295d4 Add libzutil for libzfs or libzpool consumers

Actions #1

Updated by Jerry Jelinek over 1 year ago

Since this is just a reactoring, there are no new tests. I ran the zfs test suite on both DEBUG and non-DEBUG builds. The test suite does make use of zhack and zdb. I also did ztest runs and I manually verified zpool history still works after I merged those recent upstream changes in.

Actions #2

Updated by Jerry Jelinek over 1 year ago

To hep clarify the rationale for this refactoring, here is the OpenZFS commit msg

Adds a libzutil for utility functions that are common to libzfs and
libzpool consumers (most of what was in libzfs_import.c).  This
removes the need for utilities to link against both libzpool and libzfs.

That explanation doesn't really help very much, but the original PR has a better explanation.
Motivation and Context
NOTE: This is an alternate solution to what was proposed in PR-7989.

The ztest(8) binary uses libzpool, which is comprised of the zfs module sources, to exercise the zfs module implementation. On the other hand, the zfs(8) and zpool(8) CLI use libzfs to interact with the running zfs kernel module.

The property tables in the libzpool instance are initialized via kernel_init() --> spa_init() -> zpool_prop_init(). ztest(8) can also call the property functions, like zpool_prop_to_name() directly and assumes that they were properly initialized as described above. We have encountered cases where these direct calls fail since there are identical symbols for these property functions inside libzfs. ztest(8) currently links against libzfs but doesn't call libzfs_init() in the normal code paths (only for the '-E' option).

It should also be noted that the libzfs version of the property functions have an additional step that will check if the running kernel supports a property. We don't want any runtime dependencies like this from within a ztest(8) context, so initializing libzfs to work around this identical symbol issue is not really an option.

Description
Adds a libzutil library for utility functions that are common to libzfs and libzpool consumers (most of what was in libzfs_import.c). This refactoring allows libzfs and libzpool to separately share a common pool config code and other functions.

The win: The binaries for ztest, zdb, and zhack no longer need to include libzfs and can be run without root privileges.

Actions #3

Updated by Electric Monk over 1 year ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit d8ab6e129d75d7c3f21a7909bf811a3de65faea8

commit  d8ab6e129d75d7c3f21a7909bf811a3de65faea8
Author: Don Brady <don.brady@delphix.com>
Date:   2020-02-07T14:51:26.000Z

    12235 Add libzutil for libzfs or libzpool consumers
    Portions contributed by: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Matthew Ahrens <mahrens@delphix.com>
    Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
    Reviewed by: C Fraire <cfraire@me.com>
    Reviewed by: Jason King <jason.king@joyent.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF