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

[truenas/zfs-2.1-release] Prevent panic during concurrent snapshot rollback and zvol read #135

Merged
merged 1 commit into from
May 10, 2023

Conversation

ixhamza
Copy link

@ixhamza ixhamza commented May 10, 2023

Motivation and Context

Protect zvol_cdev_read with zv_suspend_lock to prevent concurrent release of the dnode, avoiding panic when a snapshot is rolled back in parallel during ongoing zvol read operation.
Closes: openzfs#14839

Description

In FreeBSD, when a zvol read operation is in progress, a snapshot rollback can lead to a panic if the volmode is set to dev. To prevent the panic, we protect the zvol_cdev_read function with the zv_suspend_lock. This ensures that the dnode is not concurrently released, thereby avoiding the panic.

How Has This Been Tested?

Tested through following commands in FreeBSD with zfs volmode set to dev.

truncate -s 8G /f1
zpool create -f tank /f1
zfs create -V 4G tank/zv1
zfs snapshot tank/zv1@sp1
dd if=/dev/urandom of=/dev/zvol/tank/zv1 bs=512 count=1M status=progress
zfs rollback -r tank/zv1@sp1 & dd if=/dev/zvol/tank/zv1 of=temp2 bs=512 count=1M status=progress

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:

Protect zvol_cdev_read with zv_suspend_lock to prevent concurrent
release of the dnode, avoiding panic when a snapshot is rolled back
in parallel during ongoing zvol read operation.

Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
@ixhamza ixhamza requested review from amotin and usaleem-ix May 10, 2023 16:15
@ixhamza ixhamza merged commit 0a06f12 into truenas/zfs-2.1-release May 10, 2023
@ixhamza ixhamza deleted the NAS-121492-truenas branch May 10, 2023 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants