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

Prevent user accounting on readonly pool #8424

Merged
merged 1 commit into from
Feb 20, 2019

Conversation

loli10K
Copy link
Contributor

@loli10K loli10K commented Feb 16, 2019

Motivation and Context

Trying to rescue data from a dying pool which was imported readonly, used mount -t zfs -o zfsutil $mntpnt to override the mountpoint:

VERIFY(tx->tx_threads == 2) failed
PANIC at txg.c:649:txg_wait_synced()
Showing stack for process 843
CPU: 0 PID: 843 Comm: z_upgrade Tainted: P           O  3.16.0-4-amd64 #1 Debian 3.16.51-3
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
 0000000000000000 ffffffff8151ea00 ffffffffa070b8fa ffff8800d9883d08
 ffffffffa0447239 0000000000000003 0000000000000028 ffff8800d9883d18
 ffff8800d9883cb8 7428594649524556 68745f78743e2d78 3d3d207364616572
Call Trace:
 [<ffffffff8151ea00>] ? dump_stack+0x5d/0x78
 [<ffffffffa0447239>] ? spl_panic+0xc9/0x110 [spl]
 [<ffffffffa055e0d4>] ? dnode_next_offset+0x1d4/0x2c0 [zfs]
 [<ffffffffa0543296>] ? dmu_object_next+0xe6/0x130 [zfs]
 [<ffffffffa055b6d8>] ? dnode_rele_and_unlock+0x48/0xb0 [zfs]
 [<ffffffffa05b3fc1>] ? txg_wait_synced+0x1b1/0x1f0 [zfs]
 [<ffffffffa0546d7a>] ? dmu_objset_userobjspace_upgrade_cb+0xba/0xc0 [zfs]
 [<ffffffffa0544583>] ? dmu_objset_upgrade_task_cb+0xd3/0x150 [zfs]
 [<ffffffffa04449dc>] ? taskq_thread+0x2cc/0x5d0 [spl]
 [<ffffffff8109a8f0>] ? wake_up_state+0x10/0x10
 [<ffffffffa0444710>] ? taskq_thread_should_stop.part.3+0x70/0x70 [spl]
 [<ffffffff8108b13d>] ? kthread+0xbd/0xe0
 [<ffffffff8108b080>] ? kthread_create_on_node+0x180/0x180
 [<ffffffff81524c58>] ? ret_from_fork+0x58/0x90
 [<ffffffff8108b080>] ? kthread_create_on_node+0x180/0x180

This issue seems to affect both master and the zfs-0.7-release branch.

Description

Trying to mount a dataset from a readonly pool could inadvertently start the user accounting upgrade task, leading to the following failure:

VERIFY3(tx->tx_threads == 2) failed (0 == 2)
PANIC at txg.c:680:txg_wait_synced()
Showing stack for process 2541
CPU: 2 PID: 2541 Comm: z_upgrade Tainted: P           O  3.16.0-4-amd64 #1 Debian 3.16.51-3
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Call Trace:
 [<0>] ? dump_stack+0x5d/0x78
 [<0>] ? spl_panic+0xc9/0x110 [spl]
 [<0>] ? dnode_next_offset+0x1d4/0x2c0 [zfs]
 [<0>] ? dmu_object_next+0x77/0x130 [zfs]
 [<0>] ? dnode_rele_and_unlock+0x4d/0x120 [zfs]
 [<0>] ? txg_wait_synced+0x91/0x220 [zfs]
 [<0>] ? dmu_objset_id_quota_upgrade_cb+0x10f/0x140 [zfs]
 [<0>] ? dmu_objset_upgrade_task_cb+0xe3/0x170 [zfs]
 [<0>] ? taskq_thread+0x2cc/0x5d0 [spl]
 [<0>] ? wake_up_state+0x10/0x10
 [<0>] ? taskq_thread_should_stop.part.3+0x70/0x70 [spl]
 [<0>] ? kthread+0xbd/0xe0
 [<0>] ? kthread_create_on_node+0x180/0x180
 [<0>] ? ret_from_fork+0x58/0x90
 [<0>] ? kthread_create_on_node+0x180/0x180

This patch updates both functions responsible for checking if we can perform user accounting to verify the pool is not readonly.

How Has This Been Tested?

Tested manually with following snippet:

POOLNAME='testpool'
TMPDIR='/var/tmp'
mountpoint -q $TMPDIR || mount -t tmpfs tmpfs $TMPDIR
zpool destroy -f $POOLNAME
rm -f $TMPDIR/zpool.dat
truncate -s 128m $TMPDIR/zpool.dat
zpool create -f -O mountpoint=none $POOLNAME $TMPDIR/zpool.dat
zpool export $POOLNAME
zpool import -o readonly=on -d $TMPDIR $POOLNAME
mount -t zfs -o zfsutil $POOLNAME /mnt

Will add test case to "upgrade" group later.. Done

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)
  • Documentation (a change to man pages or other documentation)

Checklist:

@loli10K loli10K added the Status: Work in Progress Not yet ready for general review label Feb 16, 2019
@codecov
Copy link

codecov bot commented Feb 17, 2019

Codecov Report

Merging #8424 into master will increase coverage by 0.19%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8424      +/-   ##
==========================================
+ Coverage   78.43%   78.63%   +0.19%     
==========================================
  Files         380      380              
  Lines      115901   115903       +2     
==========================================
+ Hits        90909    91140     +231     
+ Misses      24992    24763     -229
Flag Coverage Δ
#kernel 79.07% <100%> (+0.04%) ⬆️
#user 67.34% <50%> (+0.45%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f545b6a...456291a. Read the comment docs.

Trying to mount a dataset from a readonly pool could inadvertently start
the user accounting upgrade task, leading to the following failure:

VERIFY3(tx->tx_threads == 2) failed (0 == 2)
PANIC at txg.c:680:txg_wait_synced()
Showing stack for process 2541
CPU: 2 PID: 2541 Comm: z_upgrade Tainted: P           O  3.16.0-4-amd64 openzfs#1 Debian 3.16.51-3
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Call Trace:
 [<0>] ? dump_stack+0x5d/0x78
 [<0>] ? spl_panic+0xc9/0x110 [spl]
 [<0>] ? dnode_next_offset+0x1d4/0x2c0 [zfs]
 [<0>] ? dmu_object_next+0x77/0x130 [zfs]
 [<0>] ? dnode_rele_and_unlock+0x4d/0x120 [zfs]
 [<0>] ? txg_wait_synced+0x91/0x220 [zfs]
 [<0>] ? dmu_objset_id_quota_upgrade_cb+0x10f/0x140 [zfs]
 [<0>] ? dmu_objset_upgrade_task_cb+0xe3/0x170 [zfs]
 [<0>] ? taskq_thread+0x2cc/0x5d0 [spl]
 [<0>] ? wake_up_state+0x10/0x10
 [<0>] ? taskq_thread_should_stop.part.3+0x70/0x70 [spl]
 [<0>] ? kthread+0xbd/0xe0
 [<0>] ? kthread_create_on_node+0x180/0x180
 [<0>] ? ret_from_fork+0x58/0x90
 [<0>] ? kthread_create_on_node+0x180/0x180

This patch updates both functions responsible for checking if we can
perform user accounting to verify the pool is not readonly.

Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
@loli10K loli10K force-pushed the userspace_upgrade_readonly_pool branch from 38463e7 to 456291a Compare February 17, 2019 09:11
@loli10K loli10K added Status: Code Review Needed Ready for review and testing and removed Status: Work in Progress Not yet ready for general review labels Feb 17, 2019
@loli10K
Copy link
Contributor Author

loli10K commented Feb 17, 2019

Test added to "upgrade" group. I wish we could include this fix, if/when it is merged, to the zfs-0.7-release branch, it could be useful to rescue legacy pools when imported readonly.

@behlendorf
Copy link
Contributor

@loli10K the fix looks same enough we might be able to include it in the 0.7 release, let's run it by @tonyhutter.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Feb 20, 2019
@behlendorf behlendorf merged commit bb1be77 into openzfs:master Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants