2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-04 22:47:00 +00:00
|
|
|
|
2011-09-23 17:01:19 -04:00
|
|
|
|
2017-10-20 12:53:28 +03:00
|
|
|
|
2010-06-06 18:37:16 -04:00
|
|
|
|
2009-12-04 19:36:06 -05:00
|
|
|
|
2019-03-22 11:11:06 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-15 15:02:41 -04:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-04 16:34:26 -04:00
|
|
|
|
2022-09-22 13:10:35 -04:00
|
|
|
|
2019-10-04 16:34:26 -04:00
|
|
|
|
|
|
|
|
|
2022-09-22 13:10:35 -04:00
|
|
|
|
|
|
|
|
|
2019-10-04 16:34:26 -04:00
|
|
|
|
|
|
|
|
|
2025-03-01 13:31:49 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-18 08:27:24 -08:00
|
|
|
|
2010-05-31 18:21:37 -04:00
|
|
|
|
2010-05-16 16:47:08 -04:00
|
|
|
|
2025-02-20 11:47:13 -05:00
|
|
|
|
2025-02-20 11:47:15 -05:00
|
|
|
|
2025-02-20 11:47:16 -05:00
|
|
|
|
2025-02-20 11:47:13 -05:00
|
|
|
|
2015-11-21 22:57:39 +01:00
|
|
|
|
2024-04-23 17:52:24 -04:00
|
|
|
|
2015-06-24 16:33:37 +08:00
|
|
|
|
2015-04-30 11:49:23 +02:00
|
|
|
|
2024-11-18 09:54:34 -05:00
|
|
|
|
2025-03-01 13:31:49 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-18 08:27:24 -08:00
|
|
|
|
|
|
|
|
|
2014-09-24 12:19:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 08:50:12 -04:00
|
|
|
|
2014-09-24 12:19:19 +02:00
|
|
|
|
|
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-08 12:07:44 -04:00
|
|
|
|
2017-10-20 12:53:28 +03:00
|
|
|
|
nfsd: split sc_status out of sc_type
sc_type identifies the type of a state - open, lock, deleg, layout - and
also the status of a state - closed or revoked.
This is a bit untidy and could get worse when "admin-revoked" states are
added. So clean it up.
With this patch, the type is now all that is stored in sc_type. This is
zero when the state is first added to ->cl_stateids (causing it to be
ignored), and is then set appropriately once it is fully initialised.
It is set under ->cl_lock to ensure atomicity w.r.t lookup. It is now
never cleared.
sc_type is still a bit-set even though at most one bit is set. This allows
lookup functions to be given a bitmap of acceptable types.
sc_type is now an unsigned short rather than char. There is no value in
restricting to just 8 bits.
All the constants now start SC_TYPE_ matching the field in which they
are stored. Keeping the existing names and ensuring clear separation
from non-type flags would have required something like
NFS4_STID_TYPE_CLOSED which is cumbersome. The "NFS4" prefix is
redundant was they only appear in NFS4 code, so remove that and change
STID to SC to match the field.
The status is stored in a separate unsigned short named "sc_status". It
has two flags: SC_STATUS_CLOSED and SC_STATUS_REVOKED.
CLOSED combines NFS4_CLOSED_STID, NFS4_CLOSED_DELEG_STID, and is used
for SC_TYPE_LOCK and SC_TYPE_LAYOUT instead of setting the sc_type to zero.
These flags are only ever set, never cleared.
For deleg stateids they are set under the global state_lock.
For open and lock stateids they are set under ->cl_lock.
For layout stateids they are set under ->ls_lock
nfs4_unhash_stid() has been removed, and we never set sc_type = 0. This
was only used for LOCK and LAYOUT stids and they now use
SC_STATUS_CLOSED.
Also TRACE_DEFINE_NUM() calls for the various STID #define have been
removed because these things are not enums, and so that call is
incorrect.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2024-01-30 12:08:25 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-24 08:28:11 -05:00
|
|
|
|
nfsd: split sc_status out of sc_type
sc_type identifies the type of a state - open, lock, deleg, layout - and
also the status of a state - closed or revoked.
This is a bit untidy and could get worse when "admin-revoked" states are
added. So clean it up.
With this patch, the type is now all that is stored in sc_type. This is
zero when the state is first added to ->cl_stateids (causing it to be
ignored), and is then set appropriately once it is fully initialised.
It is set under ->cl_lock to ensure atomicity w.r.t lookup. It is now
never cleared.
sc_type is still a bit-set even though at most one bit is set. This allows
lookup functions to be given a bitmap of acceptable types.
sc_type is now an unsigned short rather than char. There is no value in
restricting to just 8 bits.
All the constants now start SC_TYPE_ matching the field in which they
are stored. Keeping the existing names and ensuring clear separation
from non-type flags would have required something like
NFS4_STID_TYPE_CLOSED which is cumbersome. The "NFS4" prefix is
redundant was they only appear in NFS4 code, so remove that and change
STID to SC to match the field.
The status is stored in a separate unsigned short named "sc_status". It
has two flags: SC_STATUS_CLOSED and SC_STATUS_REVOKED.
CLOSED combines NFS4_CLOSED_STID, NFS4_CLOSED_DELEG_STID, and is used
for SC_TYPE_LOCK and SC_TYPE_LAYOUT instead of setting the sc_type to zero.
These flags are only ever set, never cleared.
For deleg stateids they are set under the global state_lock.
For open and lock stateids they are set under ->cl_lock.
For layout stateids they are set under ->ls_lock
nfs4_unhash_stid() has been removed, and we never set sc_type = 0. This
was only used for LOCK and LAYOUT stids and they now use
SC_STATUS_CLOSED.
Also TRACE_DEFINE_NUM() calls for the various STID #define have been
removed because these things are not enums, and so that call is
incorrect.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2024-01-30 12:08:25 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-04-09 17:02:51 -04:00
|
|
|
|
nfsd: split sc_status out of sc_type
sc_type identifies the type of a state - open, lock, deleg, layout - and
also the status of a state - closed or revoked.
This is a bit untidy and could get worse when "admin-revoked" states are
added. So clean it up.
With this patch, the type is now all that is stored in sc_type. This is
zero when the state is first added to ->cl_stateids (causing it to be
ignored), and is then set appropriately once it is fully initialised.
It is set under ->cl_lock to ensure atomicity w.r.t lookup. It is now
never cleared.
sc_type is still a bit-set even though at most one bit is set. This allows
lookup functions to be given a bitmap of acceptable types.
sc_type is now an unsigned short rather than char. There is no value in
restricting to just 8 bits.
All the constants now start SC_TYPE_ matching the field in which they
are stored. Keeping the existing names and ensuring clear separation
from non-type flags would have required something like
NFS4_STID_TYPE_CLOSED which is cumbersome. The "NFS4" prefix is
redundant was they only appear in NFS4 code, so remove that and change
STID to SC to match the field.
The status is stored in a separate unsigned short named "sc_status". It
has two flags: SC_STATUS_CLOSED and SC_STATUS_REVOKED.
CLOSED combines NFS4_CLOSED_STID, NFS4_CLOSED_DELEG_STID, and is used
for SC_TYPE_LOCK and SC_TYPE_LAYOUT instead of setting the sc_type to zero.
These flags are only ever set, never cleared.
For deleg stateids they are set under the global state_lock.
For open and lock stateids they are set under ->cl_lock.
For layout stateids they are set under ->ls_lock
nfs4_unhash_stid() has been removed, and we never set sc_type = 0. This
was only used for LOCK and LAYOUT stids and they now use
SC_STATUS_CLOSED.
Also TRACE_DEFINE_NUM() calls for the various STID #define have been
removed because these things are not enums, and so that call is
incorrect.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2024-01-30 12:08:25 +11:00
|
|
|
|
2024-01-30 12:08:26 +11:00
|
|
|
|
nfsd: fix race between laundromat and free_stateid
There is a race between laundromat handling of revoked delegations
and a client sending free_stateid operation. Laundromat thread
finds that delegation has expired and needs to be revoked so it
marks the delegation stid revoked and it puts it on a reaper list
but then it unlock the state lock and the actual delegation revocation
happens without the lock. Once the stid is marked revoked a racing
free_stateid processing thread does the following (1) it calls
list_del_init() which removes it from the reaper list and (2) frees
the delegation stid structure. The laundromat thread ends up not
calling the revoke_delegation() function for this particular delegation
but that means it will no release the lock lease that exists on
the file.
Now, a new open for this file comes in and ends up finding that
lease list isn't empty and calls nfsd_breaker_owns_lease() which ends
up trying to derefence a freed delegation stateid. Leading to the
followint use-after-free KASAN warning:
kernel: ==================================================================
kernel: BUG: KASAN: slab-use-after-free in nfsd_breaker_owns_lease+0x140/0x160 [nfsd]
kernel: Read of size 8 at addr ffff0000e73cd0c8 by task nfsd/6205
kernel:
kernel: CPU: 2 UID: 0 PID: 6205 Comm: nfsd Kdump: loaded Not tainted 6.11.0-rc7+ #9
kernel: Hardware name: Apple Inc. Apple Virtualization Generic Platform, BIOS 2069.0.0.0.0 08/03/2024
kernel: Call trace:
kernel: dump_backtrace+0x98/0x120
kernel: show_stack+0x1c/0x30
kernel: dump_stack_lvl+0x80/0xe8
kernel: print_address_description.constprop.0+0x84/0x390
kernel: print_report+0xa4/0x268
kernel: kasan_report+0xb4/0xf8
kernel: __asan_report_load8_noabort+0x1c/0x28
kernel: nfsd_breaker_owns_lease+0x140/0x160 [nfsd]
kernel: nfsd_file_do_acquire+0xb3c/0x11d0 [nfsd]
kernel: nfsd_file_acquire_opened+0x84/0x110 [nfsd]
kernel: nfs4_get_vfs_file+0x634/0x958 [nfsd]
kernel: nfsd4_process_open2+0xa40/0x1a40 [nfsd]
kernel: nfsd4_open+0xa08/0xe80 [nfsd]
kernel: nfsd4_proc_compound+0xb8c/0x2130 [nfsd]
kernel: nfsd_dispatch+0x22c/0x718 [nfsd]
kernel: svc_process_common+0x8e8/0x1960 [sunrpc]
kernel: svc_process+0x3d4/0x7e0 [sunrpc]
kernel: svc_handle_xprt+0x828/0xe10 [sunrpc]
kernel: svc_recv+0x2cc/0x6a8 [sunrpc]
kernel: nfsd+0x270/0x400 [nfsd]
kernel: kthread+0x288/0x310
kernel: ret_from_fork+0x10/0x20
This patch proposes a fixed that's based on adding 2 new additional
stid's sc_status values that help coordinate between the laundromat
and other operations (nfsd4_free_stateid() and nfsd4_delegreturn()).
First to make sure, that once the stid is marked revoked, it is not
removed by the nfsd4_free_stateid(), the laundromat take a reference
on the stateid. Then, coordinating whether the stid has been put
on the cl_revoked list or we are processing FREE_STATEID and need to
make sure to remove it from the list, each check that state and act
accordingly. If laundromat has added to the cl_revoke list before
the arrival of FREE_STATEID, then nfsd4_free_stateid() knows to remove
it from the list. If nfsd4_free_stateid() finds that operations arrived
before laundromat has placed it on cl_revoke list, it marks the state
freed and then laundromat will no longer add it to the list.
Also, for nfsd4_delegreturn() when looking for the specified stid,
we need to access stid that are marked removed or freeable, it means
the laundromat has started processing it but hasn't finished and this
delegreturn needs to return nfserr_deleg_revoked and not
nfserr_bad_stateid. The latter will not trigger a FREE_STATEID and the
lack of it will leave this stid on the cl_revoked list indefinitely.
Fixes: 2d4a532d385f ("nfsd: ensure that clp->cl_revoked list is protected by clp->cl_lock")
CC: stable@vger.kernel.org
Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2024-10-18 15:24:58 -04:00
|
|
|
|
|
|
|
|
|
nfsd: split sc_status out of sc_type
sc_type identifies the type of a state - open, lock, deleg, layout - and
also the status of a state - closed or revoked.
This is a bit untidy and could get worse when "admin-revoked" states are
added. So clean it up.
With this patch, the type is now all that is stored in sc_type. This is
zero when the state is first added to ->cl_stateids (causing it to be
ignored), and is then set appropriately once it is fully initialised.
It is set under ->cl_lock to ensure atomicity w.r.t lookup. It is now
never cleared.
sc_type is still a bit-set even though at most one bit is set. This allows
lookup functions to be given a bitmap of acceptable types.
sc_type is now an unsigned short rather than char. There is no value in
restricting to just 8 bits.
All the constants now start SC_TYPE_ matching the field in which they
are stored. Keeping the existing names and ensuring clear separation
from non-type flags would have required something like
NFS4_STID_TYPE_CLOSED which is cumbersome. The "NFS4" prefix is
redundant was they only appear in NFS4 code, so remove that and change
STID to SC to match the field.
The status is stored in a separate unsigned short named "sc_status". It
has two flags: SC_STATUS_CLOSED and SC_STATUS_REVOKED.
CLOSED combines NFS4_CLOSED_STID, NFS4_CLOSED_DELEG_STID, and is used
for SC_TYPE_LOCK and SC_TYPE_LAYOUT instead of setting the sc_type to zero.
These flags are only ever set, never cleared.
For deleg stateids they are set under the global state_lock.
For open and lock stateids they are set under ->cl_lock.
For layout stateids they are set under ->ls_lock
nfs4_unhash_stid() has been removed, and we never set sc_type = 0. This
was only used for LOCK and LAYOUT stids and they now use
SC_STATUS_CLOSED.
Also TRACE_DEFINE_NUM() calls for the various STID #define have been
removed because these things are not enums, and so that call is
incorrect.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2024-01-30 12:08:25 +11:00
|
|
|
|
|
|
|
|
|
2019-10-04 16:34:26 -04:00
|
|
|
|
2015-10-01 09:05:50 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-08 12:07:44 -04:00
|
|
|
|
|
|
|
|
|
2019-10-04 16:34:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-04 16:31:52 +01:00
|
|
|
|
2019-10-04 16:34:26 -04:00
|
|
|
|
|
|
|
|
|
2024-10-31 09:40:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-15 14:05:21 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-12-09 16:14:00 -05:00
|
|
|
|
|
|
|
|
|
2024-02-15 14:05:22 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-15 14:05:21 -08:00
|
|
|
|
|
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2011-10-17 11:14:48 -04:00
|
|
|
|
2005-06-23 22:04:17 -07:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-04-27 14:50:14 +02:00
|
|
|
|
2019-11-04 16:31:52 +01:00
|
|
|
|
2025-03-03 12:25:59 -05:00
|
|
|
|
2025-07-30 09:24:37 -04:00
|
|
|
|
2009-05-01 20:11:12 -04:00
|
|
|
|
2010-02-18 08:27:24 -08:00
|
|
|
|
2022-05-02 14:19:21 -07:00
|
|
|
|
2025-07-30 09:24:37 -04:00
|
|
|
|
|
|
|
|
|
2024-02-15 14:05:21 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-30 09:24:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2024-12-09 16:13:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-30 09:24:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-01 08:05:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-04-29 19:09:19 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-08-14 12:57:57 -04:00
|
|
|
|
2010-12-15 14:09:01 +09:00
|
|
|
|
2009-08-14 12:57:57 -04:00
|
|
|
|
2010-10-19 17:31:50 -04:00
|
|
|
|
|
|
|
|
|
2009-06-16 04:20:53 +03:00
|
|
|
|
2010-03-08 12:37:27 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2011-09-09 09:06:12 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-12-12 08:47:04 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-08-28 08:45:04 -04:00
|
|
|
|
2014-03-12 15:17:18 -04:00
|
|
|
|
2009-08-28 08:45:01 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-03 08:28:15 +03:00
|
|
|
|
2009-04-03 08:27:43 +03:00
|
|
|
|
2009-08-28 08:45:04 -04:00
|
|
|
|
|
|
|
|
|
2017-10-17 20:38:49 -04:00
|
|
|
|
2025-03-01 13:31:50 -05:00
|
|
|
|
2009-08-28 08:45:04 -04:00
|
|
|
|
2012-02-13 16:39:00 -05:00
|
|
|
|
2024-12-12 08:47:08 +11:00
|
|
|
|
2012-02-13 16:39:00 -05:00
|
|
|
|
|
|
|
|
|
2012-02-13 16:56:19 -05:00
|
|
|
|
nfsd4: fix cached replies to solo SEQUENCE compounds
Currently our handling of 4.1+ requests without "cachethis" set is
confusing and not quite correct.
Suppose a client sends a compound consisting of only a single SEQUENCE
op, and it matches the seqid in a session slot (so it's a retry), but
the previous request with that seqid did not have "cachethis" set.
The obvious thing to do might be to return NFS4ERR_RETRY_UNCACHED_REP,
but the protocol only allows that to be returned on the op following the
SEQUENCE, and there is no such op in this case.
The protocol permits us to cache replies even if the client didn't ask
us to. And it's easy to do so in the case of solo SEQUENCE compounds.
So, when we get a solo SEQUENCE, we can either return the previously
cached reply or NFSERR_SEQ_FALSE_RETRY if we notice it differs in some
way from the original call.
Currently, we're returning a corrupt reply in the case a solo SEQUENCE
matches a previous compound with more ops. This actually matters
because the Linux client recently started doing this as a way to recover
from lost replies to idempotent operations in the case the process doing
the original reply was killed: in that case it's difficult to keep the
original arguments around to do a real retry, and the client no longer
cares what the result is anyway, but it would like to make sure that the
slot's sequence id has been incremented, and the solo SEQUENCE assures
that: if the server never got the original reply, it will increment the
sequence id. If it did get the original reply, it won't increment, and
nothing else that about the reply really matters much. But we can at
least attempt to return valid xdr!
Tested-by: Olga Kornievskaia <aglo@umich.edu>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2017-10-18 16:17:18 -04:00
|
|
|
|
2024-12-12 08:47:08 +11:00
|
|
|
|
2012-02-13 16:39:00 -05:00
|
|
|
|
2009-08-28 08:45:04 -04:00
|
|
|
|
2009-04-03 08:27:43 +03:00
|
|
|
|
|
|
|
|
|
2009-06-16 04:19:13 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-27 14:50:26 -04:00
|
|
|
|
2012-11-05 16:01:48 -05:00
|
|
|
|
2013-02-02 06:24:49 -08:00
|
|
|
|
|
|
|
|
|
2012-03-27 14:50:26 -04:00
|
|
|
|
|
|
|
|
|
2009-07-23 19:02:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-27 14:50:26 -04:00
|
|
|
|
2009-07-23 19:02:16 -04:00
|
|
|
|
|
|
|
|
|
2012-11-01 18:09:48 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-04 23:12:59 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-23 19:02:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-06 18:12:14 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-06 18:37:16 -04:00
|
|
|
|
|
|
|
|
|
2010-06-06 18:12:14 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-18 09:54:34 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-03 08:27:43 +03:00
|
|
|
|
2013-03-19 12:05:39 -04:00
|
|
|
|
2024-11-18 09:54:34 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-03 08:27:43 +03:00
|
|
|
|
|
|
|
|
|
2024-12-12 08:47:09 +11:00
|
|
|
|
2010-05-12 00:13:41 +03:00
|
|
|
|
2009-04-03 08:27:43 +03:00
|
|
|
|
2009-06-16 04:19:13 +03:00
|
|
|
|
2012-03-27 14:50:26 -04:00
|
|
|
|
2010-06-06 18:12:14 -04:00
|
|
|
|
2024-11-18 09:54:34 -05:00
|
|
|
|
2024-12-12 08:47:04 +11:00
|
|
|
|
2024-12-12 08:47:08 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-03 08:27:43 +03:00
|
|
|
|
|
|
|
|
|
2009-04-03 08:27:52 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-04 22:47:00 +00:00
|
|
|
|
|
|
|
|
|
2005-06-23 22:03:52 -07:00
|
|
|
|
2022-05-02 14:19:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-08 16:06:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-08 16:06:26 +08:00
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-12 15:00:56 -05:00
|
|
|
|
2014-07-29 21:34:36 -04:00
|
|
|
|
2005-06-23 22:04:17 -07:00
|
|
|
|
2011-09-23 17:01:19 -04:00
|
|
|
|
2005-06-23 22:04:17 -07:00
|
|
|
|
2013-04-09 17:02:51 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 13:11:59 +02:00
|
|
|
|
|
|
|
|
|
2026-02-13 10:36:30 -08:00
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 13:11:59 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2019-11-04 16:31:52 +01:00
|
|
|
|
2009-08-14 12:57:56 -04:00
|
|
|
|
2013-04-13 14:27:29 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-19 19:36:51 -04:00
|
|
|
|
2024-01-30 12:08:26 +11:00
|
|
|
|
2019-06-05 12:42:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-31 14:52:43 +01:00
|
|
|
|
2009-04-03 08:27:46 +03:00
|
|
|
|
2010-03-08 12:37:27 -05:00
|
|
|
|
|
|
|
|
|
2012-03-21 09:52:02 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-12 15:00:56 -05:00
|
|
|
|
2014-09-12 16:40:21 -04:00
|
|
|
|
2012-03-21 09:52:02 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-01 16:05:39 -04:00
|
|
|
|
|
|
|
|
|
2018-12-03 11:30:31 +11:00
|
|
|
|
2010-03-08 12:37:27 -05:00
|
|
|
|
2010-06-04 20:04:45 -04:00
|
|
|
|
2010-04-30 18:51:44 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-19 19:12:58 -07:00
|
|
|
|
2010-04-30 18:51:44 -04:00
|
|
|
|
2010-05-26 17:52:14 -04:00
|
|
|
|
2010-06-14 22:26:31 -04:00
|
|
|
|
2010-03-08 12:37:27 -05:00
|
|
|
|
2010-06-04 20:04:45 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-03 08:27:46 +03:00
|
|
|
|
|
|
|
|
|
2009-07-23 19:02:16 -04:00
|
|
|
|
2009-04-03 08:28:01 +03:00
|
|
|
|
2010-05-12 00:13:29 +03:00
|
|
|
|
2019-03-20 11:54:11 -04:00
|
|
|
|
2019-03-22 11:11:06 -04:00
|
|
|
|
2016-06-15 12:52:09 -04:00
|
|
|
|
2009-09-10 12:25:59 +03:00
|
|
|
|
2019-03-22 11:11:06 -04:00
|
|
|
|
|
|
|
|
|
2021-03-20 09:38:04 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-22 11:11:06 -04:00
|
|
|
|
2009-09-10 12:26:25 +03:00
|
|
|
|
|
|
|
|
|
2012-11-14 18:21:10 +03:00
|
|
|
|
2018-07-20 18:19:20 -04:00
|
|
|
|
|
|
|
|
|
2019-10-23 17:43:18 -04:00
|
|
|
|
2022-05-02 14:19:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-11-16 19:44:47 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-01-19 10:41:26 -05:00
|
|
|
|
|
|
|
|
|
2026-02-13 10:36:30 -08:00
|
|
|
|
2026-01-19 10:41:26 -05:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-12 15:00:55 -05:00
|
|
|
|
2019-03-26 18:06:26 -04:00
|
|
|
|
2019-09-09 16:10:31 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2026-02-24 11:33:35 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-24 12:10:34 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 23:28:59 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2026-02-24 12:10:34 -05:00
|
|
|
|
2009-02-02 17:23:10 -05:00
|
|
|
|
2024-12-06 13:55:52 +11:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-24 12:10:34 -05:00
|
|
|
|
|
|
|
|
|
2014-07-29 21:34:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-29 21:34:29 -04:00
|
|
|
|
2014-07-29 21:34:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2014-07-29 21:34:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-31 16:10:08 -04:00
|
|
|
|
2005-07-07 17:59:20 -07:00
|
|
|
|
2014-07-29 21:34:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-07-30 23:33:59 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-28 11:47:20 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-16 17:42:48 -04:00
|
|
|
|
2019-11-04 16:31:52 +01:00
|
|
|
|
2011-09-12 12:24:13 -04:00
|
|
|
|
|
|
|
|
|
2011-07-30 23:33:59 -04:00
|
|
|
|
|
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-09-16 16:28:24 -04:00
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
2011-07-30 23:33:59 -04:00
|
|
|
|
2016-09-16 16:28:24 -04:00
|
|
|
|
|
|
|
|
|
2011-07-30 23:33:59 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-27 14:50:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-20 12:53:29 +03:00
|
|
|
|
2015-04-27 14:50:14 +02:00
|
|
|
|
|
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-16 08:49:37 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2017-10-20 12:53:30 +03:00
|
|
|
|
2021-04-16 14:00:16 -04:00
|
|
|
|
|
|
|
|
|
2014-07-10 14:07:25 -04:00
|
|
|
|
NFSD: Use rhashtable for managing nfs4_file objects
fh_match() is costly, especially when filehandles are large (as is
the case for NFSv4). It needs to be used sparingly when searching
data structures. Unfortunately, with common workloads, I see
multiple thousands of objects stored in file_hashtbl[], which has
just 256 buckets, making its bucket hash chains quite lengthy.
Walking long hash chains with the state_lock held blocks other
activity that needs that lock. Sizable hash chains are a common
occurrance once the server has handed out some delegations, for
example -- IIUC, each delegated file is held open on the server by
an nfs4_file object.
To help mitigate the cost of searching with fh_match(), replace the
nfs4_file hash table with an rhashtable, which can dynamically
resize its bucket array to minimize hash chain length.
The result of this modification is an improvement in the latency of
NFSv4 operations, and the reduction of nfsd CPU utilization due to
eliminating the cost of multiple calls to fh_match() and reducing
the CPU cache misses incurred while walking long hash chains in the
nfs4_file hash table.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
2022-10-28 10:47:53 -04:00
|
|
|
|
2005-06-23 22:03:08 -07:00
|
|
|
|
2014-10-23 08:01:02 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-27 14:50:14 +02:00
|
|
|
|
2010-07-08 11:02:09 -04:00
|
|
|
|
2019-08-18 14:18:52 -04:00
|
|
|
|
2010-07-08 11:02:09 -04:00
|
|
|
|
2011-09-28 11:37:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-08 11:02:09 -04:00
|
|
|
|
2011-03-17 12:52:33 -04:00
|
|
|
|
nfsd: make deny mode enforcement more efficient and close races in it
The current enforcement of deny modes is both inefficient and scattered
across several places, which makes it hard to guarantee atomicity. The
inefficiency is a problem now, and the lack of atomicity will mean races
once the client_mutex is removed.
First, we address the inefficiency. We have to track deny modes on a
per-stateid basis to ensure that open downgrades are sane, but when the
server goes to enforce them it has to walk the entire list of stateids
and check against each one.
Instead of doing that, maintain a per-nfs4_file deny mode. When a file
is opened, we simply set any deny bits in that mode that were specified
in the OPEN call. We can then use that unified deny mode to do a simple
check to see whether there are any conflicts without needing to walk the
entire stateid list.
The only time we'll need to walk the entire list of stateids is when a
stateid that has a deny mode on it is being released, or one is having
its deny mode downgraded. In that case, we must walk the entire list and
recalculate the fi_share_deny field. Since deny modes are pretty rare
today, this should be very rare under normal workloads.
To address the potential for races once the client_mutex is removed,
protect fi_share_deny with the fi_lock. In nfs4_get_vfs_file, check to
make sure that any deny mode we want to apply won't conflict with
existing access. If that's ok, then have nfs4_file_get_access check that
new access to the file won't conflict with existing deny modes.
If that also passes, then get file access references, set the correct
access and deny bits in the stateid, and update the fi_share_deny field.
If opening the file or truncating it fails, then unwind the whole mess
and return the appropriate error.
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2014-07-10 14:07:34 -04:00
|
|
|
|
2019-08-18 14:18:53 -04:00
|
|
|
|
2025-05-13 09:10:51 -07:00
|
|
|
|
2014-12-13 09:11:40 -05:00
|
|
|
|
2014-07-23 16:17:38 -04:00
|
|
|
|
2007-07-17 04:04:40 -07:00
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 13:11:59 +02:00
|
|
|
|
|
|
|
|
|
2014-09-23 12:38:48 +02:00
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 13:11:59 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2014-08-05 15:13:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-07 16:06:42 -04:00
|
|
|
|
2015-09-17 07:47:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-07 17:32:21 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-09-17 07:47:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-06-14 23:28:04 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2011-09-07 16:06:42 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 13:11:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-18 14:18:53 -04:00
|
|
|
|
2014-09-23 12:38:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-09-17 07:58:24 -04:00
|
|
|
|
2026-02-13 10:36:30 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 13:11:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-24 12:19:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-23 12:38:48 +02:00
|
|
|
|
2018-07-20 18:19:17 -04:00
|
|
|
|
2014-09-24 12:19:17 +02:00
|
|
|
|
2016-09-16 16:28:23 -04:00
|
|
|
|
2022-11-16 19:44:46 -08:00
|
|
|
|
2024-02-15 14:05:21 -08:00
|
|
|
|
2014-09-24 12:19:17 +02:00
|
|
|
|
|
|
|
|
|
2016-05-05 06:53:47 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-24 12:19:17 +02:00
|
|
|
|
2016-09-16 16:28:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-09-16 16:28:23 -04:00
|
|
|
|
2016-09-16 16:28:24 -04:00
|
|
|
|
2016-09-16 16:28:25 -04:00
|
|
|
|
2019-11-04 16:31:52 +01:00
|
|
|
|
2016-09-16 16:28:23 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-17 09:49:39 +03:00
|
|
|
|
2016-09-16 16:28:23 -04:00
|
|
|
|
|
|
|
|
|
2009-04-03 08:28:41 +03:00
|
|
|
|
2012-07-25 16:57:45 +04:00
|
|
|
|
2018-07-20 18:19:20 -04:00
|
|
|
|
2009-04-03 08:28:41 +03:00
|
|
|
|
2015-06-18 16:45:00 +02:00
|
|
|
|
2015-12-03 12:59:51 +01:00
|
|
|
|
2019-10-04 16:34:26 -04:00
|
|
|
|
|
|
|
|
|
2014-08-14 08:44:57 +02:00
|
|
|
|
nfsd: split sc_status out of sc_type
sc_type identifies the type of a state - open, lock, deleg, layout - and
also the status of a state - closed or revoked.
This is a bit untidy and could get worse when "admin-revoked" states are
added. So clean it up.
With this patch, the type is now all that is stored in sc_type. This is
zero when the state is first added to ->cl_stateids (causing it to be
ignored), and is then set appropriately once it is fully initialised.
It is set under ->cl_lock to ensure atomicity w.r.t lookup. It is now
never cleared.
sc_type is still a bit-set even though at most one bit is set. This allows
lookup functions to be given a bitmap of acceptable types.
sc_type is now an unsigned short rather than char. There is no value in
restricting to just 8 bits.
All the constants now start SC_TYPE_ matching the field in which they
are stored. Keeping the existing names and ensuring clear separation
from non-type flags would have required something like
NFS4_STID_TYPE_CLOSED which is cumbersome. The "NFS4" prefix is
redundant was they only appear in NFS4 code, so remove that and change
STID to SC to match the field.
The status is stored in a separate unsigned short named "sc_status". It
has two flags: SC_STATUS_CLOSED and SC_STATUS_REVOKED.
CLOSED combines NFS4_CLOSED_STID, NFS4_CLOSED_DELEG_STID, and is used
for SC_TYPE_LOCK and SC_TYPE_LAYOUT instead of setting the sc_type to zero.
These flags are only ever set, never cleared.
For deleg stateids they are set under the global state_lock.
For open and lock stateids they are set under ->cl_lock.
For layout stateids they are set under ->ls_lock
nfs4_unhash_stid() has been removed, and we never set sc_type = 0. This
was only used for LOCK and LAYOUT stids and they now use
SC_STATUS_CLOSED.
Also TRACE_DEFINE_NUM() calls for the various STID #define have been
removed because these things are not enums, and so that call is
incorrect.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2024-01-30 12:08:25 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-18 19:04:42 +08:00
|
|
|
|
|
|
|
|
|
2019-10-04 16:34:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-29 21:34:06 -04:00
|
|
|
|
2015-10-01 09:05:50 -04:00
|
|
|
|
2012-11-14 18:21:16 +03:00
|
|
|
|
|
|
|
|
|
2019-03-26 18:06:26 -04:00
|
|
|
|
2012-11-14 18:21:16 +03:00
|
|
|
|
2021-01-21 17:57:44 -05:00
|
|
|
|
2010-10-19 17:56:52 -04:00
|
|
|
|
2010-12-09 15:52:19 -05:00
|
|
|
|
2010-10-19 17:56:52 -04:00
|
|
|
|
2025-03-01 13:31:49 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-24 12:19:18 +02:00
|
|
|
|
2015-11-21 22:57:39 +01:00
|
|
|
|
2022-09-26 14:41:01 -04:00
|
|
|
|
2025-02-20 11:47:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-04 20:04:45 -04:00
|
|
|
|
2018-07-20 18:19:20 -04:00
|
|
|
|
2026-01-07 19:40:11 -05:00
|
|
|
|
2024-10-31 09:40:07 -04:00
|
|
|
|
2024-10-31 09:40:06 -04:00
|
|
|
|
2019-03-26 18:06:26 -04:00
|
|
|
|
2019-09-09 16:10:31 -04:00
|
|
|
|
2019-03-26 18:06:26 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2014-08-14 08:50:16 +02:00
|
|
|
|
2019-10-04 16:34:26 -04:00
|
|
|
|
|
|
|
|
|
2019-10-09 11:50:48 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-14 08:50:16 +02:00
|
|
|
|
|
|
|
|
|
2017-10-20 12:53:30 +03:00
|
|
|
|
2014-08-14 08:50:16 +02:00
|
|
|
|
2019-08-18 14:18:53 -04:00
|
|
|
|
2014-08-14 08:50:16 +02:00
|
|
|
|
2024-01-30 12:08:26 +11:00
|
|
|
|
2025-12-15 14:10:36 -05:00
|
|
|
|
2026-01-07 19:40:11 -05:00
|
|
|
|
2026-03-13 12:31:48 -04:00
|
|
|
|
|
|
|
|
|
2024-01-30 12:08:26 +11:00
|
|
|
|
2025-12-15 14:10:36 -05:00
|
|
|
|
2024-01-30 12:08:26 +11:00
|
|
|
|
|
|
|
|
|
2026-01-07 19:40:11 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-03-13 12:31:48 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-30 12:08:26 +11:00
|
|
|
|
|
|
|
|
|
2014-09-12 16:40:21 -04:00
|
|
|
|
2025-12-13 13:41:59 -05:00
|
|
|
|
2014-09-12 16:40:21 -04:00
|
|
|
|
2012-03-21 16:42:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-12 16:40:20 -04:00
|
|
|
|
2012-11-27 09:35:10 -05:00
|
|
|
|
2022-05-02 14:19:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-29 18:52:39 -07:00
|
|
|
|
|
|
|
|
|
2024-10-04 09:16:46 -04:00
|
|
|
|
2025-11-11 09:12:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|