zfs/lib/libzfs
Matthew Ahrens 610cb4fb8c
undocumented libzfs API changes broke "zfs list"
While OpenZFS does permit breaking changes to the libzfs API, we should
avoid these changes when reasonably possible, and take steps to mitigate
the impact to consumers when changes are necessary.

Commit e4288a8397 made a libzfs API change that is especially
difficult for consumers because there is no change to the function
signatures, only to their behavior.  Therefore, consumers can't notice
that there was a change at compile time.  Also, the API change was
incompletely and incorrectly documented.

The commit message mentions `zfs_get_prop()` [sic], but all callers of
`get_numeric_property()` are impacted: `zfs_prop_get()`,
`zfs_prop_get_numeric()`, and `zfs_prop_get_int()`.

`zfs_prop_get_int()` always calls `get_numeric_property(src=NULL)`, so
it assumes that the filesystem is not mounted.  This means that e.g.
`zfs_prop_get_int(ZFS_PROP_MOUNTED)` always returns 0.

The documentation says that to preserve the previous behavior, callers
should initialize `*src=ZPROP_SRC_NONE`, and some callers were changed
to do that.  However, the existing behavior is actually preserved by
initializing `*src=ZPROP_SRC_ALL`, not `NONE`.

The code comment above `zfs_prop_get()` says, "src: ... NULL will be
treated as ZPROP_SRC_ALL.".  However, the code actually treats NULL as
ZPROP_SRC_NONE.  i.e. `zfs_prop_get(src=NULL)` assumes that the
filesystem is not mounted.

There are several existing calls which use `src=NULL` which are impacted
by the API change, most noticeably those used by `zfs list`, which now
assumes that filesystems are not mounted.  For example,
`zfs list -o name,mounted` previously indicated whether a filesystem was
mounted or not, but now it always (incorrectly) indicates that the
filesystem is not mounted (`MOUNTED: no`).  Similarly, properties that
are set at mount time are ignored.  E.g. `zfs list -o name,atime` may
display an incorrect value if it was set at mount time.

To address these problems, this commit reverts commit e4288a8397bb1f:
"zfs get: don't lookup mount options when using "-s local""

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #11999
2021-05-06 11:24:56 -07:00
..
os lib/: set O_CLOEXEC on all fds 2021-04-11 15:45:59 -07:00
.gitignore Clean up lib dependencies 2020-07-10 14:26:00 -07:00
Makefile.am Bump libzfs.so and libzpool.so versions 2021-04-01 16:53:05 -07:00
THIRDPARTYLICENSE.openssl Fix typos in lib/ 2019-09-02 17:53:27 -07:00
THIRDPARTYLICENSE.openssl.descrip Encryption patch follow-up 2017-10-11 16:54:48 -04:00
libzfs.abi libzfs: get rid of unused libzfs_handle::libzfs_{storeerr,chassis_id} 2021-04-13 14:15:06 -07:00
libzfs.pc.in Spruce up pkg-config files for libzfs/libzfs_core 2020-09-04 11:11:18 -07:00
libzfs.suppr Library ABI tracking with abigail 2020-11-17 09:18:52 -08:00
libzfs_changelist.c Add 'zfs rename -u' to rename without remounting 2020-09-01 16:14:16 -07:00
libzfs_config.c Use zfs_ioctl with zfs_cmd_t in libzfs 2019-10-23 17:29:43 -07:00
libzfs_crypto.c libzfs: don't mark prompt+raw as retriable 2021-04-17 12:39:28 -07:00
libzfs_dataset.c undocumented libzfs API changes broke "zfs list" 2021-05-06 11:24:56 -07:00
libzfs_diff.c undocumented libzfs API changes broke "zfs list" 2021-05-06 11:24:56 -07:00
libzfs_import.c zpool: speed up importing large pools (#11469) 2021-01-21 12:55:54 -08:00
libzfs_iter.c lib/: set O_CLOEXEC on all fds 2021-04-11 15:45:59 -07:00
libzfs_mount.c undocumented libzfs API changes broke "zfs list" 2021-05-06 11:24:56 -07:00
libzfs_pool.c Improvements to the 'compatibility' property 2021-04-12 09:08:56 -07:00
libzfs_sendrecv.c undocumented libzfs API changes broke "zfs list" 2021-05-06 11:24:56 -07:00
libzfs_status.c Improvements to the 'compatibility' property 2021-04-12 09:08:56 -07:00
libzfs_util.c libzfs: get rid of libzfs_handle::libzfs_mnttab 2021-04-13 14:14:44 -07:00