[PATCH] Consistently use zfs_ioctl()

Pawel Jakub Dawidek pjd at FreeBSD.org
Tue Jul 26 13:21:21 UTC 2011


On Mon, Jul 25, 2011 at 01:26:36PM -0700, Xin LI wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Hi,
> 
> Here is a patch that makes libzfs use zfs_ioctl consistently.  Some
> functionality in libzfs calls ioctl() directly with raw ZFS ioctls,
> which causes some kernel message like:
> 
> WARNING pid 30031 (initial thread): ioctl sign-extension ioctl
> ffffffffd5985a3a
> 
> Objections?  I have kept #sun'ed out blocks out.

zfs_ioctl() does something with history records, I think. Are you sure
zfs_ioctl() is 1-to-1 equivalent of plain ioctl()?

Some minor nits inline.

> Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
> ===================================================================
> --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	(revision 224337)
> +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	(working copy)
> @@ -2382,6 +2382,7 @@ zfs_prop_get_userquota_common(zfs_handle_t *zhp, c
>  {
>  	int err;
>  	zfs_cmd_t zc = { 0 };
> +	libzfs_handle_t *hdl = zhp->zfs_hdl;
>  
>  	(void) strncpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
>  
> @@ -2392,7 +2393,7 @@ zfs_prop_get_userquota_common(zfs_handle_t *zhp, c
>  	if (err)
>  		return (err);
>  
> -	err = ioctl(zhp->zfs_hdl->libzfs_fd, ZFS_IOC_USERSPACE_ONE, &zc);
> +	err = zfs_ioctl(hdl, ZFS_IOC_USERSPACE_ONE, &zc);

Do we really need additional variable that is used only once?
Wouldn't it be better to just replace ioctl(zhp->zfs_hdl->libzfs_fd)
with zfs_ioctl(zhp->zfs_hdl)?

> @@ -2458,11 +2459,12 @@ zfs_do_list_ioctl(zfs_handle_t *zhp, unsigned long
>  {
>  	int rc;
>  	uint64_t	orig_cookie;
> +	libzfs_handle_t *hdl = zhp->zfs_hdl;
>  
>  	orig_cookie = zc->zc_cookie;
>  top:
>  	(void) strlcpy(zc->zc_name, zhp->zfs_name, sizeof (zc->zc_name));
> -	rc = ioctl(zhp->zfs_hdl->libzfs_fd, arg, zc);
> +	rc = zfs_ioctl(hdl, arg, zc);

Same here.

> @@ -3924,6 +3926,7 @@ zfs_userspace(zfs_handle_t *zhp, zfs_userquota_pro
>      zfs_userspace_cb_t func, void *arg)
>  {
>  	zfs_cmd_t zc = { 0 };
> +	libzfs_handle_t *hdl = zhp->zfs_hdl;
>  	int error;
>  	zfs_useracct_t buf[100];
>  
> @@ -3937,7 +3940,7 @@ zfs_userspace(zfs_handle_t *zhp, zfs_userquota_pro
>  		zfs_useracct_t *zua = buf;
>  
>  		zc.zc_nvlist_dst_size = sizeof (buf);
> -		error = ioctl(zhp->zfs_hdl->libzfs_fd,
> +		error = zfs_ioctl(hdl,
>  		    ZFS_IOC_USERSPACE_MANY, &zc);

And here.

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/zfs-devel/attachments/20110726/f2588afa/attachment.pgp


More information about the zfs-devel mailing list