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

Speed up "zpool import" on FreeBSD in the presence of many zvols #11502

Merged
merged 1 commit into from
Jan 25, 2021

Conversation

asomers
Copy link
Contributor

@asomers asomers commented Jan 22, 2021

Motivation and Context

By default, FreeBSD does not allow zpools to be backed by zvols (that can be changed with the "vfs.zfs.vol.recursive" sysctl). When that sysctl is set to 0, the kernel does not attempt to read zvols when looking for vdevs. But the zpool command still does.

Description

This change brings the zpool command into line with the kernel's behavior. It speeds "zpool import" when an already imported pool has many zvols, or a zvol with many snapshots.

How Has This Been Tested?

Tested with FreeBSD's ZFS test suite. And it shipped in FreeBSD 12.2-RELEASE.

Performance-wise, the time to import a nonexistent pool is linear in the number of geom devices present. That includes both disks and zvols. With an SSD-backed pool on my FreeBSD 13.0-CURRENT test system, I find that the import time takes about 13.3s with 10,000 zvols present. With the patch, that falls to 0.79s. For comparison, when no zvols are present it takes only 0.09s.

https://svnweb.freebsd.org/base?view=revision&revision=357235
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241083
https://reviews.freebsd.org/D22077

Obtained from: FreeBSD
PR: 241083
Reported by: Martin Birgmeier d8zNeCFG@aon.at
Sponsored by: Axcient
Signed-off-by: Alan Somers asomers@gmail.com

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

By default, FreeBSD does not allow zpools to be backed by zvols (that
can be changed with the "vfs.zfs.vol.recursive" sysctl). When that
sysctl is set to 0, the kernel does not attempt to read zvols when
looking for vdevs. But the zpool command still does. This change brings
the zpool command into line with the kernel's behavior. It speeds "zpool
import" when an already imported pool has many zvols, or a zvol with
many snapshots.

https://svnweb.freebsd.org/base?view=revision&revision=357235
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241083
https://reviews.freebsd.org/D22077

Obtained from:	FreeBSD
PR:		241083
Reported by:	Martin Birgmeier <d8zNeCFG@aon.at>
Sponsored by:	Axcient
Signed-off-by:	Alan Somers <asomers@gmail.com>
@asomers
Copy link
Contributor Author

asomers commented Jan 22, 2021

cc the original reviewers: @amotin @freqlabs

@ghost ghost added Component: Userspace user space functionality Status: Code Review Needed Ready for review and testing labels Jan 23, 2021
@ghost ghost requested review from a user and amotin January 23, 2021 00:50
Copy link
Member

@amotin amotin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part looks good to me. Just not sure why move some headers forward.

I am just thinking whether we should also somehow filter out /dev/zvol from the zpool_find_import_scan or it would be too big hack?

@asomers
Copy link
Contributor Author

asomers commented Jan 23, 2021

This part looks good to me. Just not sure why move some headers forward.

<sys/types.h> has to be first. And since I was in there, I moved all of the sys/ headers to the top as per style(9).

I am just thinking whether we should also somehow filter out /dev/zvol from the zpool_find_import_scan or it would be too big hack?

Good point. The zpool import -s option hadn't been added when I originally wrote this change, so I didn't think about it. I'll look into it now.

@asomers
Copy link
Contributor Author

asomers commented Jan 23, 2021

I am just thinking whether we should also somehow filter out /dev/zvol from the zpool_find_import_scan or it would be too big hack?

Good point. The zpool import -s option hadn't been added when I originally wrote this change, so I didn't think about it. I'll look into it now.

I don't think it would be worthwhile. zpool_find_import_scan is only used with the -s and -d options to zpool import. -s, AFAICT, is never useful on FreeBSD. And when using -d, the user must explicitly include /dev/zvol; it's not the default. So I don't see any point to changing zpool_find_import_scan.

@ghost ghost added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jan 23, 2021
@behlendorf behlendorf merged commit fd95af8 into openzfs:master Jan 25, 2021
@asomers asomers deleted the import_with_zvols branch March 7, 2021 22:48
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
By default, FreeBSD does not allow zpools to be backed by zvols (that
can be changed with the "vfs.zfs.vol.recursive" sysctl). When that
sysctl is set to 0, the kernel does not attempt to read zvols when
looking for vdevs. But the zpool command still does. This change brings
the zpool command into line with the kernel's behavior. It speeds "zpool
import" when an already imported pool has many zvols, or a zvol with
many snapshots.

https://svnweb.freebsd.org/base?view=revision&revision=357235
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241083
https://reviews.freebsd.org/D22077

Obtained from: FreeBSD
Reported by: Martin Birgmeier <d8zNeCFG@aon.at>
Sponsored by: Axcient
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Alan Somers <asomers@gmail.com>
Closes openzfs#11502
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
By default, FreeBSD does not allow zpools to be backed by zvols (that
can be changed with the "vfs.zfs.vol.recursive" sysctl). When that
sysctl is set to 0, the kernel does not attempt to read zvols when
looking for vdevs. But the zpool command still does. This change brings
the zpool command into line with the kernel's behavior. It speeds "zpool
import" when an already imported pool has many zvols, or a zvol with
many snapshots.

https://svnweb.freebsd.org/base?view=revision&revision=357235
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241083
https://reviews.freebsd.org/D22077

Obtained from: FreeBSD
Reported by: Martin Birgmeier <d8zNeCFG@aon.at>
Sponsored by: Axcient
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Alan Somers <asomers@gmail.com>
Closes openzfs#11502
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Userspace user space functionality Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants