Skip to contentSkip to conversation

nfsd changes for 3.5

DISCUSSION J. Bruce Fields 2 participants 8 messages May 31, 2012 – Jun 1, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Please pull the following nfsd and file-locking changes from the for-3.5 branch at:

	git://linux-nfs.org/~bfields/linux.git for-3.5

Sorry this is a bit late. In fact I still have a review backlog (at a minimum some bugfixes), so will send a second pull later.

This includes patches addressing a long-standing problem in our NFSv4 implementation, which is that read delegations aren't broken on certain local operations. (Hence a diffstat with a few lines in namei.c and attr.c). The problem isn't solved completely in the case of rename, where a small race remains; the patches to fix that will come in from Al Viro if they pass review. But there's no regression in nfsd behavior if those patches don't make it in.

Other than that:

- From Stanislav Kinsbursky, a bunch of NFS containerization work (still in progress).
- Fix a failure to process encrypted rpc's from Windows clients and servers due to our (incorrect) failure to handle gss tokens with rotated data.
- Fix some stuff caught by sparse (actual bugs are fairly minor); thanks to Al for reminding me to add sparse to my regular testing.
- Fixes for some protocol bugs in the procedures that establish 4.0 and 4.1 clients, and much cleaner code. (Thanks also to Chuck for a bugfix here, and Bryan and Trond for finding another bug.)
- Some cleanup and bugfixes from Jeff, Simo, and Dros.

--b.

Chuck Lever (1):
NFSD: SETCLIENTID_CONFIRM returns NFS4ERR_CLID_INUSE too often

J. Bruce Fields (44):
locks: introduce new FL_DELEG lock flag
locks: implement delegations
locks: break delegations on unlink
locks: break delegations on rename
locks: break delegations on link
locks: break delegations on any attribute modification
nfsd4: minor nfs4_setlease cleanup
nfsd4: delay setting current_fh in open
nfsd4: close open-deleg/unlink/rename lease
nfsd4: break only delegations when appropriate
nfsd: state.c should include current_stateid.h
nfsd4: fix missing "static"
nfsd4: preserve __user annotation on cld downcall msg
nfsd4: int/__be32 fixes
nfsd4: fix free_stateid return endianness
nfsd4: fix change attribute endianness
rpc: handle rotated gss data for Windows interoperability
svcrpc: fix a comment typo
nfsd4: exchange_id has a pointless copy
nfsd4: exchange_id error cleanup
nfsd4: exchange_id: check creds before killing confirmed client
nfsd4: allow an EXCHANGE_ID to kill a 4.0 client
nfsd4: exchange_id cleanup: local shorthands for repeated tests
nfsd4: exchange_id cleanup: comments
nfsd4: rearrange exchange_id logic to simplify
nfsd4: allow removing clients not holding state
nfsd4: move principal name into svc_cred
nfsd4: stricter cred comparison for setclientid/exchange_id
nfsd4: move rq_flavor into svc_cred
nfsd4: setclientid remove unnecessary terms from a logical expression
nfsd4: setclientid/confirm comment cleanup
nfsd4: merge last two setclientid cases
nfsd4: pull out common code from setclientid cases
nfsd4: merge 3 setclientid cases to 2
nfsd4: fix setclientid_confirm same_cred check
nfsd4: fix error return in non-matching-creds case
nfsd4: setclientid: remove pointless assignment
nfsd4: simpler ordering of setclientid_confirm checks
nfsd4: clarify that renewing expired client is a bug
nfsd4: fix exchange_id to return confirm flag
nfsd4: return "real" sequence id in confirmed case
nfsd4: remove some dprintk's and a comment
nfsd4: don't remove rebooted client record until confirmation
nfsd4: fix, consolidate client_has_state

Jeff Layton (8):
nfsd: trivial: remove unused variable from nfsd4_lock
nfsd: don't use locks_in_grace to determine whether to call nfs4_grace_end
nfsd: trivial: use SEEK_SET instead of 0 in vfs_llseek
sunrpc: do array overrun check in svc_recv before allocating pages
nfsd: consolidate set_access and set_deny
nfsd: make test_share a bool return
nfsd: wrap accesses to st_access_bmap
nfsd: wrap all accesses to st_deny_bmap

Simo Sorce (2):
svcauth: remove unused define
SUNRPC: split upcall function to extract reusable parts

Stanislav Kinsbursky (26):
nfsd: use passed cache_detail pointer expkey_parse()
nfsd: add link to owner cache detail to svc_export structure
nfsd: use cache detail pointer from svc_export structure on cache put
nfsd: use exp_put() for svc_export_cache put
nfsd: pass svc_export_cache pointer as private data to "exports" seq file ops
nfsd: use hash table from cache detail in nfsd export seq ops
nfsd: pass pointer to expkey cache down to stack wherever possible.
NFSd: remove hard-coded dereferences to name-to-id and id-to-name caches
Lockd: pass network namespace to creation and destruction routines
nfsd: pass network context to export caches init/shutdown routines
nfsd: pass pointer to export cache down to stack wherever possible.
nfsd: make export cache allocated per network namespace context
nfsd: make expkey cache allocated per network namespace context
nfsd: allocate export and expkey caches in per-net operations.
nfsd: pass network context to idmap init/exit functions
nfsd: make id-to-name cache allocated per network namespace context
nfsd: make name-to-id cache allocated per network namespace context
nfsd: allocate id-to-name and name-to-id caches in per-net operations.
SUNRPC: new svc_bind() routine introduced
SUNRPC: move per-net operations from svc_destroy()
LockD: pass service to per-net up and down functions
LockD: use existing per-net data function on service creation
LockD: service creation function introduced
LockD: move global usage counter manipulation from error path
LockD: service start function introduced
LockD: add debug message to start and stop functions

Weston Andros Adamson (2):
nfsd: add IPv6 addr escaping to fs_location hosts
nfsd: return 0 on reads of fault injection files

 fs/attr.c                           |    3 +
 fs/lockd/clntlock.c                 |   13 +-
 fs/lockd/svc.c                      |  148 +++++----
 fs/locks.c                          |   51 ++-
 fs/namei.c                          |   19 +-
 fs/nfs/callback.c                   |   13 +-
 fs/nfsd/auth.c                      |    2 +-
 fs/nfsd/export.c                    |  181 ++++++-----
 fs/nfsd/fault_inject.c              |    1 +
 fs/nfsd/idmap.h                     |    8 +-
 fs/nfsd/netns.h                     |    6 +
 fs/nfsd/nfs4callback.c              |    5 +-
 fs/nfsd/nfs4idmap.c                 |  113 ++++---
 fs/nfsd/nfs4proc.c                  |   36 ++-
 fs/nfsd/nfs4recover.c               |    4 +-
 fs/nfsd/nfs4state.c                 |  599 +++++++++++++++++------------------
 fs/nfsd/nfs4xdr.c                   |   62 ++--
 fs/nfsd/nfsctl.c                    |   67 ++--
 fs/nfsd/nfsfh.c                     |    2 +-
 fs/nfsd/nfssvc.c                    |   31 +-
 fs/nfsd/state.h                     |    1 -
 fs/nfsd/vfs.c                       |   33 +-
 fs/nfsd/xdr4.h                      |    9 +-
 include/linux/fs.h                  |   19 +-
 include/linux/lockd/bind.h          |    4 +-
 include/linux/nfsd/export.h         |   13 +-
 include/linux/sunrpc/svc.h          |    2 +-
 include/linux/sunrpc/svcauth.h      |   13 +-
 include/linux/sunrpc/svcauth_gss.h  |    1 -
 net/sunrpc/auth_gss/gss_krb5_wrap.c |   61 +++-
 net/sunrpc/auth_gss/svcauth_gss.c   |  127 ++++----
 net/sunrpc/rpcb_clnt.c              |   12 +-
 net/sunrpc/svc.c                    |   23 +-
 net/sunrpc/svc_xprt.c               |    4 +-
 net/sunrpc/svcauth_unix.c           |   19 +-
 35 files changed, 1009 insertions(+), 696 deletions(-)

--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw
Quoted 3 lines · J. Bruce Fields

Sorry this is a bit late.  In fact I still have a review backlog (at a minimum some bugfixes), so will send a second pull later.

Quite frankly, I'm not going to pull this without lots of explanations.

The VFS-level changes have no acks or sign-offs from anybody else, and quite frankly, if I understand them correctly they look f*cking disgusting. If I read them right, they break delegations of a file (which can involve long waits for clients - no?) while holding on to the directory inode lock (both directories for cross-inode renames). Which seems to be a singularly idiotic thing to do and sounds to me like a fundamental design mistake.

We simply don't do these kinds of VFS changes without having discussions and acks from people, notably Al.

As to "second pull later" - if you haven't reviewed the code already, it's damn well much too late in the merge window to do it now.

So quite frankly, this *all* looks like 3.6 material to me, and that's assuming you can convince people that file-delegation breaking really should happen with all lookups on the directory the file is in blocked by the directory inode mutex in the first place. Or tell me I'm a moron and I misread the patches and don't know what I'm talking about.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 8 lines · Linus Torvalds
Quoted 3 lines · J. Bruce Fields

Sorry this is a bit late.  In fact I still have a review backlog (at a minimum some bugfixes), so will send a second pull later.

Quite frankly, I'm not going to pull this without lots of explanations.

The VFS-level changes have no acks or sign-offs from anybody else,

Sorry, yes, at best I had a verbal OK from Al (and maybe I'm wrong about that). I got impatient.

Quoted 3 lines

and quite frankly, if I understand them correctly they look f*cking disgusting. If I read them right, they break delegations of a file (which can involve long waits for clients - no?)

Right. By default it's 90 seconds before we'll give up on the client.

Quoted 4 lines

while holding on to
the directory inode lock (both directories for cross-inode renames). Which seems to be a singularly idiotic thing to do and sounds to me like a fundamental design mistake.

I hate that too, and originally tried to avoid it with something like:

	retry:
		acquire locks
		lookup inode
		ret = try_to_break_deleg(inode);
		if (ret)
			drop locks
			really_break_deleg(inode);
			goto retry;
		... do the real work ...
		drop locks

I felt like I was making already complicated code logic like rename's even harder to follow.

And those operations don't really know the inode till they acquire the locks, so in pathological cases that could continue forever.

...

Quoted 5 lines

So quite frankly, this *all* looks like 3.6 material to me, and that's assuming you can convince people that file-delegation breaking really should happen with all lookups on the directory the file is in blocked by the directory inode mutex in the first place. Or tell me I'm a moron and I misread the patches and don't know what I'm talking about.

No, I think you understand correctly.

The presence of a delegation requires blocking certain operations until a client somewhere responds (or we time out).

So the question as I understand it is whether there's a way to lessen the impact by blocking only what we really need to.

I don't know if there's a way to do that without reworking the vfs directory locking to be much more fine-grained.

--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 2 lines · J. Bruce Fields

Right.  By default it's 90 seconds before we'll give up on the client.

So a slightly buggy client can basically DoS the server by getting a delegation and then crashing or something. Everybody else that tries to read that directory (not that file) will be dead in the water. Definitely not good.

Quoted 13 lines

I hate that too, and originally tried to avoid it with something like:

       retry:
               acquire locks
               lookup inode
               ret = try_to_break_deleg(inode);
               if (ret)
                       drop locks
                       really_break_deleg(inode);
                       goto retry;
               ... do the real work ...
               drop locks

Quoted 2 lines

I felt like I was making already complicated code logic like rename's even harder to follow.

I do think it's the only thing we can reasonably do. I'd love to have some kind of per-dentry lock for unlink/rename, but we don't. Long-term, we really do need to do something about the directory locking, though, because it's also a huge problem for readdir() concurrency. Or at least it used to be (samba in particular). Making it an rwsem might help readdir a tiny amount, but I suspect people actually depend on the mutex in readdir right now.

Quoted 2 lines

And those operations don't really know the inode till they acquire the locks, so in pathological cases that could continue forever.

I suspect at some point you just have to say "screw it".

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 22 lines · Linus Torvalds
Quoted 2 lines · J. Bruce Fields

Right.  By default it's 90 seconds before we'll give up on the client.

So a slightly buggy client can basically DoS the server by getting a delegation and then crashing or something. Everybody else that tries to read that directory (not that file) will be dead in the water. Definitely not good.

Quoted 13 lines

I hate that too, and originally tried to avoid it with something like:

       retry:
               acquire locks
               lookup inode
               ret = try_to_break_deleg(inode);
               if (ret)
                       drop locks
                       really_break_deleg(inode);
                       goto retry;
               ... do the real work ...
               drop locks

Quoted 4 lines
Quoted 2 lines

I felt like I was making already complicated code logic like rename's even harder to follow.

I do think it's the only thing we can reasonably do.

OK, I can give that another try. Al, does that sound like the more sensible choice to you?

Uh, that means ditching some work in my public git tree. Which I haven't rebased in years. So, a stupid process question; would you rather I:

- continue to be strict about rebasing and apply a bunch of reverts?
- ditch it and start over?

#1 looks like a mess to me, so I guess #2's my default. Probably nobody will notice but me.

Quoted 7 lines

I'd love to have
some kind of per-dentry lock for unlink/rename, but we don't. Long-term, we really do need to do something about the directory locking, though, because it's also a huge problem for readdir() concurrency. Or at least it used to be (samba in particular). Making it an rwsem might help readdir a tiny amount, but I suspect people actually depend on the mutex in readdir right now.

Al called this all "highly non-trivial":

	http://marc.info/?l=linux-fsdevel&m=132726495726326&w=2

I don't know who'd have the cycles.

--b.

Quoted 5 lines
Quoted 3 lines

And those operations don't really know the inode till they acquire the locks, so in pathological cases that could continue forever.

I suspect at some point you just have to say "screw it".

#5 lore raw
Quoted 9 lines · J. Bruce Fields

On Thu, May 31, 2012 at 01:17:26PM -0700, Linus Torvalds wrote:

Uh, that means ditching some work in my public git tree.  Which I haven't rebased in years.  So, a stupid process question; would you rather I:

       - continue to be strict about rebasing and apply a bunch of reverts?
       - ditch it and start over?

I think in this case rebasing is the right thing to do.

I hate rebasing, but what I hate about it is how people who use it as a development model cause problems for anybody else. I don't think it will cause problems in this particular case, but if somebody hollers, let me know.

Quoted 9 lines
Quoted 3 lines

Making
it an rwsem might help readdir a tiny amount, but I suspect people actually depend on the mutex in readdir right now.

Al called this all "highly non-trivial":

       http://marc.info/?l=linux-fsdevel&m=132726495726326&w=2

I don't know who'd have the cycles.

I agree, it's a rats nest.

Doing lookups in particular is ridiculously single-threaded for almost no good reason, though (and create is just a special case of that). It *should* be possible that push the i_mutex down into the filesystem, if we just created some fake dentry (with the appropriate support for lookup to stall on it) to make sure that lookups of the same *name* are serialized.

At that point, each filesystem could decide that they don't need the i_mutex for the whole thing.

Maybe.

And readdir() could be done mostly mechanically by changing i_mutex into an rwsem, making all lockers use a write lock, and pushing the locking down from the caller into the filesystem for ->readdir(). Again, at that point, I suspect many filesystems could do with much less locking.

But yeah, it's all nasty. Even the purely mechanical part of changing i_mutex to an rwsem would not only be a *huge* and painful patch, it would hit things like lockdep issues too (we don't support the nesting thing for rwsem annotations, afaik).

So nobody has really done it, and it's so painful that maybe nobody will. There are loads that hit this serialization point, but they are *fairly* rare and specialized.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 11 lines · Linus Torvalds
Quoted 9 lines · J. Bruce Fields

On Thu, May 31, 2012 at 01:17:26PM -0700, Linus Torvalds wrote:

Uh, that means ditching some work in my public git tree.  Which I haven't rebased in years.  So, a stupid process question; would you rather I:

       - continue to be strict about rebasing and apply a bunch of reverts?
       - ditch it and start over?

Quoted 6 lines

I think in this case rebasing is the right thing to do.

I hate rebasing, but what I hate about it is how people who use it as a development model cause problems for anybody else. I don't think it will cause problems in this particular case, but if somebody hollers, let me know.

OK, will do.

For now, would you mind pulling this?:

	git://linux-nfs.org/~bfields/linux.git for-3.5-take-2

It's literally just the previous tree cut off before the delegation stuff--so it's been in -next for a month, etc.

--b.

Jeff Layton (3):
nfsd: trivial: remove unused variable from nfsd4_lock
nfsd: don't use locks_in_grace to determine whether to call nfs4_grace_end
nfsd: trivial: use SEEK_SET instead of 0 in vfs_llseek

Simo Sorce (2):
svcauth: remove unused define
SUNRPC: split upcall function to extract reusable parts

Stanislav Kinsbursky (18):
nfsd: use passed cache_detail pointer expkey_parse()
nfsd: add link to owner cache detail to svc_export structure
nfsd: use cache detail pointer from svc_export structure on cache put
nfsd: use exp_put() for svc_export_cache put
nfsd: pass svc_export_cache pointer as private data to "exports" seq file ops
nfsd: use hash table from cache detail in nfsd export seq ops
nfsd: pass pointer to expkey cache down to stack wherever possible.
NFSd: remove hard-coded dereferences to name-to-id and id-to-name caches
Lockd: pass network namespace to creation and destruction routines
nfsd: pass network context to export caches init/shutdown routines
nfsd: pass pointer to export cache down to stack wherever possible.
nfsd: make export cache allocated per network namespace context
nfsd: make expkey cache allocated per network namespace context
nfsd: allocate export and expkey caches in per-net operations.
nfsd: pass network context to idmap init/exit functions
nfsd: make id-to-name cache allocated per network namespace context
nfsd: make name-to-id cache allocated per network namespace context
nfsd: allocate id-to-name and name-to-id caches in per-net operations.

 fs/lockd/clntlock.c               |   13 +--
 fs/lockd/svc.c                    |    7 +-
 fs/nfsd/export.c                  |  175 ++++++++++++++++++++++---------------
 fs/nfsd/idmap.h                   |    8 +-
 fs/nfsd/netns.h                   |    6 ++
 fs/nfsd/nfs4idmap.c               |  109 +++++++++++++----------
 fs/nfsd/nfs4state.c               |   13 ++-
 fs/nfsd/nfsctl.c                  |   55 ++++++++----
 fs/nfsd/nfsfh.c                   |    2 +-
 fs/nfsd/nfssvc.c                  |    8 +-
 fs/nfsd/vfs.c                     |    2 +-
 include/linux/lockd/bind.h        |    4 +-
 include/linux/nfsd/export.h       |   13 ++-
 include/linux/sunrpc/svcauth.h    |    3 +-
 net/sunrpc/auth_gss/svcauth_gss.c |  100 +++++++++++++--------
 net/sunrpc/svcauth_unix.c         |   13 +--
 16 files changed, 322 insertions(+), 209 deletions(-)
#7 lore raw
Quoted 6 lines · J. Bruce Fields

For now, would you mind pulling this?:

	git://linux-nfs.org/~bfields/linux.git for-3.5-take-2

It's literally just the previous tree cut off before the delegation stuff--so it's been in -next for a month, etc.

... and then I cherry-picked the remainder of the patches from the head of my previous branch to:

git://linux-nfs.org/~bfields/linux.git for-3.5

and ran some tests overnight--no surprises, as they're all quite independent from the delegation stuff. But if they've missed 3.5 it's not a tragedy.

--b.

Chuck Lever (1):
NFSD: SETCLIENTID_CONFIRM returns NFS4ERR_CLID_INUSE too often

J. Bruce Fields (34):
nfsd: state.c should include current_stateid.h
nfsd4: fix missing "static"
nfsd4: preserve __user annotation on cld downcall msg
nfsd4: int/__be32 fixes
nfsd4: fix free_stateid return endianness
nfsd4: fix change attribute endianness
rpc: handle rotated gss data for Windows interoperability
svcrpc: fix a comment typo
nfsd4: exchange_id has a pointless copy
nfsd4: exchange_id error cleanup
nfsd4: exchange_id: check creds before killing confirmed client
nfsd4: allow an EXCHANGE_ID to kill a 4.0 client
nfsd4: exchange_id cleanup: local shorthands for repeated tests
nfsd4: exchange_id cleanup: comments
nfsd4: rearrange exchange_id logic to simplify
nfsd4: allow removing clients not holding state
nfsd4: move principal name into svc_cred
nfsd4: stricter cred comparison for setclientid/exchange_id
nfsd4: move rq_flavor into svc_cred
nfsd4: setclientid remove unnecessary terms from a logical expression
nfsd4: setclientid/confirm comment cleanup
nfsd4: merge last two setclientid cases
nfsd4: pull out common code from setclientid cases
nfsd4: merge 3 setclientid cases to 2
nfsd4: fix setclientid_confirm same_cred check
nfsd4: fix error return in non-matching-creds case
nfsd4: setclientid: remove pointless assignment
nfsd4: simpler ordering of setclientid_confirm checks
nfsd4: clarify that renewing expired client is a bug
nfsd4: fix exchange_id to return confirm flag
nfsd4: return "real" sequence id in confirmed case
nfsd4: remove some dprintk's and a comment
nfsd4: don't remove rebooted client record until confirmation
nfsd4: fix, consolidate client_has_state

Jeff Layton (5):
sunrpc: do array overrun check in svc_recv before allocating pages
nfsd: consolidate set_access and set_deny
nfsd: make test_share a bool return
nfsd: wrap accesses to st_access_bmap
nfsd: wrap all accesses to st_deny_bmap

Stanislav Kinsbursky (8):
SUNRPC: new svc_bind() routine introduced
SUNRPC: move per-net operations from svc_destroy()
LockD: pass service to per-net up and down functions
LockD: use existing per-net data function on service creation
LockD: service creation function introduced
LockD: move global usage counter manipulation from error path
LockD: service start function introduced
LockD: add debug message to start and stop functions

Weston Andros Adamson (2):
nfsd: add IPv6 addr escaping to fs_location hosts
nfsd: return 0 on reads of fault injection files

 fs/lockd/svc.c                      |  145 ++++++----
 fs/nfs/callback.c                   |   13 +-
 fs/nfsd/auth.c                      |    2 +-
 fs/nfsd/export.c                    |    8 +-
 fs/nfsd/fault_inject.c              |    1 +
 fs/nfsd/nfs4callback.c              |    5 +-
 fs/nfsd/nfs4idmap.c                 |    4 +-
 fs/nfsd/nfs4recover.c               |    4 +-
 fs/nfsd/nfs4state.c                 |  525 ++++++++++++++++-------------------
 fs/nfsd/nfs4xdr.c                   |   62 +++--
 fs/nfsd/nfsctl.c                    |   12 +-
 fs/nfsd/nfssvc.c                    |   23 ++
 fs/nfsd/state.h                     |    1 -
 fs/nfsd/xdr4.h                      |    6 +-
 include/linux/sunrpc/svc.h          |    2 +-
 include/linux/sunrpc/svcauth.h      |   10 +
 include/linux/sunrpc/svcauth_gss.h  |    1 -
 net/sunrpc/auth_gss/gss_krb5_wrap.c |   61 ++--
 net/sunrpc/auth_gss/svcauth_gss.c   |   27 +-
 net/sunrpc/rpcb_clnt.c              |   12 +-
 net/sunrpc/svc.c                    |   23 +-
 net/sunrpc/svc_xprt.c               |    4 +-
 net/sunrpc/svcauth_unix.c           |    6 +-
 23 files changed, 522 insertions(+), 435 deletions(-)