Page MenuHomeFreeBSD

zfs_mount(MS_REMOUNT): protect zfs_(un)register_callbacks calls

Authored by avg on Jun 19 2015, 7:30 AM.



We now take z_teardown_lock as a writer to ensure that there is no
I/O while the filesystem state is in a flux.
Also, zfs_suspend_fs() -> zfsvfs_teardown() call zfs_unregister_callbacks()
and zfs_resume_fs() -> zfsvfs_setup() call zfs_unregister_callbacks().
Previously there was no synchronization between those calls and the calls
in the re-mounting case. That could lead to concurrent execution
and a crash.

Diff Detail

rS FreeBSD src repository
No Linters Available
No Unit Test Coverage

Event Timeline

avg updated this revision to Diff 6320.Jun 19 2015, 7:30 AM
avg retitled this revision from to zfs_mount(MS_REMOUNT): protect zfs_(un)register_callbacks calls.
avg updated this object.
avg edited the test plan for this revision. (Show Details)
avg added a reviewer: mahrens.
avg added a subscriber: ZFS.
delphij added inline comments.Jun 19 2015, 8:04 AM

I wonder if we should mark zfs_unregister_callbacks static, just like zfs_register_callbacks? (Or is this intentional to make them DTrace proble eligible?)


I'm not very convinced that we can safely do unregister without having z_teardown_lock held here... If it's safe, maybe we should document it in the comment?

delphij added a reviewer: pho.Jun 19 2015, 8:04 AM
avg added inline comments.Jun 19 2015, 8:17 AM

It looks like this function can be made static, but I'd do it as a separate commit.


If !unmounting we, in fact, do hold the lock here.
And if unmounting then no other thread can operate on the filesystem because of z_unmounted.
See line 1886 above and 1918 too.

delphij accepted this revision.Jun 19 2015, 6:42 PM
delphij edited edge metadata.
This revision is now accepted and ready to land.Jun 19 2015, 6:42 PM
pho accepted this revision.Jun 20 2015, 7:34 AM
pho edited edge metadata.

No problems seen with the few zfs tests I have.

mahrens accepted this revision.Jun 20 2015, 3:30 PM
mahrens edited edge metadata.
will accepted this revision.Jun 23 2015, 3:59 PM
will edited edge metadata.


avg closed this revision.Jul 2 2015, 9:14 AM

Committed in rS285021