Page MenuHomeFreeBSD

nfsrvd_readdirplus: for some errors, skip an entry instead of failing the request
ClosedPublic

Authored by avg on May 14 2018, 12:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 6, 4:27 PM
Unknown Object (File)
Feb 23 2024, 5:12 AM
Unknown Object (File)
Feb 17 2024, 4:29 PM
Unknown Object (File)
Feb 15 2024, 3:23 PM
Unknown Object (File)
Jan 28 2024, 9:45 PM
Unknown Object (File)
Jan 3 2024, 8:22 PM
Unknown Object (File)
Dec 22 2023, 11:37 PM
Unknown Object (File)
Dec 14 2023, 6:47 AM
Subscribers

Details

Summary

This change consist of two primary changes.

A failure to vget or lookup an entry is considered to be a result of a concurrent removal,
which is the only resonable explanation given that the filesystem is busied.
So, the entry would be silently skipped.

In the case of a failure to get attributes of an entry for an NFSv3 request, the entry
would be silently skipped. There can be legitimate reasons for the failure, but NFSv3
does not provide any means to report the error, so we have two options: either fail the
whole request or ignore the failed entry. Traditionally, the old NFS server used the latter option,
so the code is reverted to it. Making the whole directory unreadable because of a single entry
seems to be unpractical.

Additionally, some bits of code are slightly re-arranged to account for the new control flow and
to honor style(9).

Sponsored by Panzura.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 16619
Build 16524: arc lint + arc unit

Event Timeline

only one thought really.

sys/fs/nfsserver/nfs_nfsdport.c
2175

become, not became.. it's in this case would be short for "it has".
Possibly Best to actually spell it that way.

2254

You are really sure about nvp never being NULL right? (e.g. line 2162)

avg marked an inline comment as done.May 15 2018, 6:07 AM
avg added inline comments.
sys/fs/nfsserver/nfs_nfsdport.c
2254

Yes, I am. With this change, the code detects much earlier if it failed to get nvp. So, past that point nvp cannot be NULL. Modulo bugs, of course.

See the first inline comment. I think you need the vput(nvp)... before "goto invalid;" for the
"if ((nd->nd_flag & ND_NFSV3) != 0)".

Or you could move this "if..goto" down into the "if" block that follows it to just before
the "nd->nd_repstat = r;" line. This will work, but may be less clear because you need
to know that NFSATTRBIT_RDATTRERROR is never set for NFSv3.

sys/fs/nfsserver/nfs_nfsdport.c
2182

Maybe you could stick a
KASSERT(nvp != NULL. ...);
here as a asafety belt against future changes that might result in the code
getting down here without a valid nvp?
(I agree that it should be non-NULL when you get here after your changes.)

2220

Shouldn't there be a
{

vput(nvp);
if (needs_unbusy != 0)
      vfs_unbusy(new_mp);
goto invalid;

}
in this "if" as well as the code that follows, since "invalid:" is after code that does this,
instead of just a "goto invalid;"?

This revision now requires changes to proceed.May 15 2018, 7:48 PM
sys/fs/nfsserver/nfs_nfsdport.c
2182

The only reason I didn't add such an assertion is that NULL pointer dereference is a very obvious kind of bug. But I agree that the assertion can be helpful to readers and maintainers of the code, so I am adding it now.
Also, I overlooked the case where we get a non-NULL refp for NFSv4, so we do not get nvp at all.

2220

Good catch! I think that needs_unbusy is for NFSv4 only, but nvp must be released.

2254

Actually, I was very wrong! In the case of NFSv4, if all attribute bits are zero or if the entry has a referral, then we do not look up nvp at all, so it remains NULL.
Thank you for alerting me to this.

fix bugs pointed out by the reviewers

  • restore formatting of a block that has no functional changes
  • re-arrange the code that handles attribute errors per Rick's suggestion
avg marked 7 inline comments as done.May 16 2018, 7:56 AM

This version looks fine to me. Thanks, rick

This revision is now accepted and ready to land.May 16 2018, 12:02 PM
This revision was automatically updated to reflect the committed changes.