Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of libmount #8883

Closed
kusumi opened this issue Jun 11, 2019 · 4 comments
Closed

Use of libmount #8883

kusumi opened this issue Jun 11, 2019 · 4 comments
Labels
Type: Feature Feature request or new feature

Comments

@kusumi
Copy link
Member

kusumi commented Jun 11, 2019

System information

Type Version/Name
Distribution Name
Distribution Version
Linux Kernel
Architecture
ZFS Version master
SPL Version

Describe the problem you're observing

lib/libzfs/libzfs_mount.c in ZoL has this comment on fork/exec-ing mount(8) and umount(8).

 * The filesystem is mounted by invoking the system mount utility rather
 * than by the system call mount(2).  This ensures that the /etc/mtab
 * file is correctly locked for the update.  Performing our own locking
 * and /etc/mtab update requires making an unsafe assumption about how
 * the mount utility performs its locking.  Unfortunately, this also means
 * in the case of a mount failure we do not have the exact errno.  We must
 * make due with return value from the mount process.
 *
 * In the long term a shared library called libmount is under development
 * which provides a common API to address the locking and errno issues.
 * Once the standard mount utility has been updated to use this library
 * we can add an autoconf check to conditionally use it.

After seeing #8833, moving on to use libmount instead of fork/exec-ing from pthread looks to be clearer solution. illumos and FreeBSD just invoke a syscall.

Looking at upstream util-linux,

  1. mount(8) and umount(8) are based on libmount (i.e. best examples of how to use libmount).
  2. libmount can either fall back on mount(2) or mount.<type> executable.

In fact distros today do use libmount. libmount seems to have existed for the past 7-8 years, but I'm not sure if the API and its behavior have been consistent.

# ldd `which mount` | grep libmount
        libmount.so.1 => /lib64/libmount.so.1 (0x00007fda8df28000)
# ldd `which umount` | grep libmount
        libmount.so.1 => /lib64/libmount.so.1 (0x00007f6fa2124000)
# ldd `which mount.nfs`| grep libmount
        libmount.so.1 => /lib64/libmount.so.1 (0x00007f821fc3d000)
@kusumi kusumi added the Type: Feature Feature request or new feature label Jun 11, 2019
@youzhongyang
Copy link
Contributor

I've seen all kinds of strange issues related to zfs mount since I started evaluating ZFS on Linux. Running external program to do mount/unmount just seems awful to me.

@behlendorf
Copy link
Contributor

Thanks for opening this issue. Yes, migrating to libmount is something which has been planned since the very beginning but has never been prioritized. At this point I'd expect the interface to be quite stable and it would be great if someone could take on this project.

@kusumi
Copy link
Member Author

kusumi commented Jun 11, 2019

I'll look into some more details of libmount code in upstream util-linux first, and then try to move on to use it in ZoL if doable and makes sense.

@behlendorf
Copy link
Contributor

Closing. This issue has been addressed by #10294.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Feature request or new feature
Projects
None yet
Development

No branches or pull requests

3 participants