Page MenuHomeFreeBSD

unionfs: fix suspendability check bugs
ClosedPublic

Authored by markj on Jun 2 2015, 11:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 5 2024, 8:12 PM
Unknown Object (File)
Sep 27 2024, 3:34 PM
Unknown Object (File)
Sep 27 2024, 4:08 AM
Unknown Object (File)
Sep 26 2024, 7:29 AM
Unknown Object (File)
Sep 25 2024, 6:40 PM
Unknown Object (File)
Sep 25 2024, 5:48 PM
Unknown Object (File)
Sep 24 2024, 7:52 PM
Unknown Object (File)
Sep 23 2024, 10:34 AM
Subscribers

Details

Summary
  • MNTK_SUSPENDABLE is set in mnt_kern_flag, not mnt_flag.
  • The lower layer of a unionfs mount is read-only, so the mount should be suspendable iff the upper layer is suspendable.
  • While here, remove a couple of superfluous comments.
Test Plan

The fact that we weren't setting MNTK_SUSPENDABLE properly was triggering a KASSERT failure in tmpfs: tmpfs_alloc_node() verifies that mnt_writeopcount > 0, but vn_start_write() was a no-op for the non-suspendable unionfs mount. This change fixes the assertion failure.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj retitled this revision from to unionfs: fix suspendability check bugs.
markj edited the test plan for this revision. (Show Details)
markj updated this object.
markj added reviewers: mjg, kib.
kib edited edge metadata.
This revision is now accepted and ready to land.Jun 3 2015, 7:41 AM
mjg edited edge metadata.

Oops. The change looks right, thanks.

Note that MNTK_SUSPENDABLE business as implemented right now is a hack. vn_start_write performs the check on passed struct mount, but the actual operation is performed on a structure returned by VOP_GETWRITEMOUNT. I don't recall why the hack is in place, maybe there is no good reason after all. This would also get rid of room for crap mistakes like the one fixed here.

In D2714#51749, @mjg wrote:

Oops. The change looks right, thanks.

Note that MNTK_SUSPENDABLE business as implemented right now is a hack. vn_start_write performs the check on passed struct mount, but the actual operation is performed on a structure returned by VOP_GETWRITEMOUNT. I don't recall why the hack is in place, maybe there is no good reason after all. This would also get rid of room for crap mistakes like the one fixed here.

VOP_GETWRITEMOUNT() provides the stacking required for filesystems like nullfs or unionfs, to work.

This revision was automatically updated to reflect the committed changes.
In D2714#51824, @kib wrote:
In D2714#51749, @mjg wrote:

Oops. The change looks right, thanks.

Note that MNTK_SUSPENDABLE business as implemented right now is a hack. vn_start_write performs the check on passed struct mount, but the actual operation is performed on a structure returned by VOP_GETWRITEMOUNT. I don't recall why the hack is in place, maybe there is no good reason after all. This would also get rid of room for crap mistakes like the one fixed here.

VOP_GETWRITEMOUNT() provides the stacking required for filesystems like nullfs or unionfs, to work.

As I understand it, Mateusz's suggestion is to perform the suspendability check on the mount point returned by VOP_GETWRITEMOUNT(vp) rather than the vnode's mount. This would obviate the need to propagate the MNTK_SUSPENDABLE check through passthrough filesystems.

This (untested) patch implements that change: https://people.freebsd.org/~markj/patches/20150606-correct_suspend_mount.diff

With this, the checks in nullfs and unionfs could be removed entirely.

In D2714#52249, @markj wrote:
In D2714#51824, @kib wrote:
In D2714#51749, @mjg wrote:

Oops. The change looks right, thanks.

Note that MNTK_SUSPENDABLE business as implemented right now is a hack. vn_start_write performs the check on passed struct mount, but the actual operation is performed on a structure returned by VOP_GETWRITEMOUNT. I don't recall why the hack is in place, maybe there is no good reason after all. This would also get rid of room for crap mistakes like the one fixed here.

VOP_GETWRITEMOUNT() provides the stacking required for filesystems like nullfs or unionfs, to work.

As I understand it, Mateusz's suggestion is to perform the suspendability check on the mount point returned by VOP_GETWRITEMOUNT(vp) rather than the vnode's mount. This would obviate the need to propagate the MNTK_SUSPENDABLE check through passthrough filesystems.

This (untested) patch implements that change: https://people.freebsd.org/~markj/patches/20150606-correct_suspend_mount.diff

With this, the checks in nullfs and unionfs could be removed entirely.

The change probably works, modulo my note above about mnt_ref.

But this brings back the issue of r273271/r273336, since you could just test the mnt->vfs_susp_clean without the problem of r273271. In other words, MNTK_SUSPENDABLE can go away in any case.

Yes, tmpfs would need to provide dummy .vfs_susp_clean method again.

In D2714#52250, @kib wrote:
In D2714#52249, @markj wrote:
In D2714#51824, @kib wrote:
In D2714#51749, @mjg wrote:

Oops. The change looks right, thanks.

Note that MNTK_SUSPENDABLE business as implemented right now is a hack. vn_start_write performs the check on passed struct mount, but the actual operation is performed on a structure returned by VOP_GETWRITEMOUNT. I don't recall why the hack is in place, maybe there is no good reason after all. This would also get rid of room for crap mistakes like the one fixed here.

VOP_GETWRITEMOUNT() provides the stacking required for filesystems like nullfs or unionfs, to work.

As I understand it, Mateusz's suggestion is to perform the suspendability check on the mount point returned by VOP_GETWRITEMOUNT(vp) rather than the vnode's mount. This would obviate the need to propagate the MNTK_SUSPENDABLE check through passthrough filesystems.

This (untested) patch implements that change: https://people.freebsd.org/~markj/patches/20150606-correct_suspend_mount.diff

With this, the checks in nullfs and unionfs could be removed entirely.

The change probably works, modulo my note above about mnt_ref.

Hm, I don't see the note you're referring to.

But this brings back the issue of r273271/r273336, since you could just test the mnt->vfs_susp_clean without the problem of r273271. In other words, MNTK_SUSPENDABLE can go away in any case.

Ok, that makes sense to me. I'll test and submit a change to that effect.

In D2714#52492, @markj wrote:

Hm, I don't see the note you're referring to.

I mean that before the vn_suspendable(), the struct mount was always referenced after vn_start_write().

In D2714#52525, @kib wrote:
In D2714#52492, @markj wrote:

Hm, I don't see the note you're referring to.

I mean that before the vn_suspendable(), the struct mount was always referenced after vn_start_write().

Sorry, I don't quite follow. Are you pointing out that with the change, the reference acquired in VOP_GETWRITEMOUNT() may be leaked?

In D2714#53124, @markj wrote:
In D2714#52525, @kib wrote:
In D2714#52492, @markj wrote:

Hm, I don't see the note you're referring to.

I mean that before the vn_suspendable(), the struct mount was always referenced after vn_start_write().

Sorry, I don't quite follow. Are you pointing out that with the change, the reference acquired in VOP_GETWRITEMOUNT() may be leaked?

My comment is about vn_suspendable() existence, not about your changes.