OSDN Git Service

nfsd: handle drc over-allocation gracefully.
authorNeilBrown <neilb@suse.de>
Fri, 20 Sep 2019 06:33:16 +0000 (16:33 +1000)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 20 Sep 2019 16:30:02 +0000 (12:30 -0400)
commit7f49fd5d7acd82163685559045d04d49433581cc
treef58fc0bd9c69bf4ebea13bc820ec626eaa2dcc07
parent6ee95d1c899186c0798cafd25998d436bcdb9618
nfsd: handle drc over-allocation gracefully.

Currently, if there are more clients than allowed for by the
space allocation in set_max_drc(), we fail a SESSION_CREATE
request with NFS4ERR_DELAY.
This means that the client retries indefinitely, which isn't
a user-friendly response.

The RFC requires NFS4ERR_NOSPC, but that would at best result in a
clean failure on the client, which is not much more friendly.

The current space allocation is a best-guess and doesn't provide any
guarantees, we could still run out of space when trying to allocate
drc space.

So fail more gracefully - always give out at least one slot.
If all clients used all the space in all slots, we might start getting
memory pressure, but that is possible anyway.

So ensure 'num' is always at least 1, and remove the test for it
being zero.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c