Page MenuHomeFreeBSD

ffs: skip upgrade from ro->rw if namei fails
ClosedPublic

Authored by rew on Jun 22 2021, 10:47 PM.
Tags
None
Referenced Files
F107590176: D30870.diff
Thu, Jan 16, 7:58 AM
Unknown Object (File)
Nov 10 2024, 5:17 PM
Unknown Object (File)
Nov 7 2024, 1:19 AM
Unknown Object (File)
Oct 22 2024, 1:34 AM
Unknown Object (File)
Oct 3 2024, 10:16 AM
Unknown Object (File)
Oct 1 2024, 4:54 PM
Unknown Object (File)
Sep 25 2024, 4:21 PM
Unknown Object (File)
Sep 25 2024, 4:20 PM
Subscribers

Details

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Warnings
SeverityLocationCodeMessage
Warningsys/ufs/ffs/ffs_vfsops.c:429SPELL1Possible Spelling Mistake
Unit
No Test Coverage
Build Status
Buildable 44040
Build 40928: arc lint + arc unit

Event Timeline

rew requested review of this revision.Jun 22 2021, 10:47 PM

You are locking (supposedly devfs) vnode for very long interval. For instance, ffs_flushfiles() now runs under this lock. I do not like it. If we ever lock devvp inside SU code, this would recurse.

In D30870#694401, @kib wrote:

You are locking (supposedly devfs) vnode for very long interval.

Which lock? I dropped the LOCKLEAF flag from NDINIT() thinking the vnode would be unlocked after namei(). Then after the MNT_UPDATE block, grab the lock.

For instance, ffs_flushfiles() now runs under this lock.

Is it the namei() call or the vfs_unbusy/busy switch that causes ffs_flushfiles to run under a different lock than before?

Ok, so you only referenced the devvp vnode in namei().

Well, this mean that there are some other issues:

  • the vnode needs to be vunref()ed on all error returns inside the update block
  • since vget() can return error, or it can return doomed vnode, we return to the similar situation as before, but under different condition.

No?

I fumbled on the command line and hit this issue

looking at the code leaves me with a couple questions..

Is there a reason why the namei() lookup and the access checks can't
happen before MNT_UPDATE starts going through the motions?

I've updated the review to give context to what I mean.

Also, I haven't figured out the semantics of MNTK_FPLOOKUP - sys/mount.h
says it's used to indicate that fast path lookup is supported. If I understand, MNTK_FPLOOKUP gets disabled in the beginning of ffs_mount() and renabled
at the end? But on error, MNTK_FPLOOKUP doesn't get set again?
Maybe it doesn't need to be? I assume I'm missing something here.

In D30870#768629, @rew wrote:

I fumbled on the command line and hit this issue

looking at the code leaves me with a couple questions..

Is there a reason why the namei() lookup and the access checks can't
happen before MNT_UPDATE starts going through the motions?

It can, but then you have more state to unwind (which your patch does not).

I've updated the review to give context to what I mean.

Also, I haven't figured out the semantics of MNTK_FPLOOKUP - sys/mount.h
says it's used to indicate that fast path lookup is supported. If I understand, MNTK_FPLOOKUP gets disabled in the beginning of ffs_mount() and renabled
at the end? But on error, MNTK_FPLOOKUP doesn't get set again?
Maybe it doesn't need to be? I assume I'm missing something here.

MNTK_FPLOOKUP is the indication of support for lockless cache lookup(9). So yes it is better to be kept since clearing it breaks the optimization. On the other hand, losing the flag does not make system unusable. This one is better to be fixed still, but in dedicated change.

In D30870#768901, @kib wrote:
In D30870#768629, @rew wrote:

Is there a reason why the namei() lookup and the access checks can't
happen before MNT_UPDATE starts going through the motions?

It can, but then you have more state to unwind (which your patch does not).

What state needs to be unwound in the updated patch?

MNTK_FPLOOKUP is the indication of support for lockless cache lookup(9). So yes it is better to be kept since clearing it breaks the optimization. On the other hand, losing the flag does not make system unusable. This one is better to be fixed still, but in dedicated change.

Thanks, that makes sense.

In D30870#768907, @rew wrote:
In D30870#768901, @kib wrote:
In D30870#768629, @rew wrote:

Is there a reason why the namei() lookup and the access checks can't
happen before MNT_UPDATE starts going through the motions?

It can, but then you have more state to unwind (which your patch does not).

What state needs to be unwound in the updated patch?

No state, I see that you vput/vrele devvp as needed.

kib added reviewers: mckusick, chs.
This revision is now accepted and ready to land.Jan 23 2022, 10:03 PM
This revision was landed with ongoing or failed builds.Mar 7 2022, 7:52 PM
This revision was automatically updated to reflect the committed changes.