mbox series

[v3,0/2] NFSD: add support for NFSv4 write delegation

Message ID 1684366690-28029-1-git-send-email-dai.ngo@oracle.com (mailing list archive)
Headers show
Series NFSD: add support for NFSv4 write delegation | expand

Message

Dai Ngo May 17, 2023, 11:38 p.m. UTC
NFSD: add support for NFSv4 write delegation

The NFSv4 server currently supports read delegation using VFS lease
which is implemented using file_lock. 

This patch series add write delegation support for NFSv4 server by:

    . remove the check for F_WRLCK in generic_add_lease to allow
      file_lock to be used for write delegation.  

    . grant write delegation for OPEN with NFS4_SHARE_ACCESS_WRITE
      if there is no conflict with other OPENs.

Write delegation conflict with another OPEN, REMOVE, RENAME and SETATTR
are handled the same as read delegation using notify_change, try_break_deleg.

Changes since v1:

[PATCH 3/4] NFSD: add supports for CB_GETATTR callback
- remove WARN_ON_ONCE from encode_bitmap4
- replace decode_bitmap4 with xdr_stream_decode_uint32_array
- replace xdr_inline_decode and xdr_decode_hyper in decode_cb_getattr
   with xdr_stream_decode_u64. Also remove the un-needed likely().
- modify signature of encode_cb_getattr4args to take pointer to
   nfs4_cb_fattr
- replace decode_attr_length with xdr_stream_decode_u32
- rename decode_cb_getattr to decode_cb_fattr4
- fold the initialization of cb_cinfo and cb_fsize into decode_cb_fattr4
- rename ncf_cb_cinfo to ncf_cb_change to avoid confusion of cindo usage
  in fs/nfsd/nfs4xdr.c
- correct NFS4_dec_cb_getattr_sz and update size description

[PATCH 4/4] NFSD: handle GETATTR conflict with write delegation
- change nfs4_handle_wrdeleg_conflict returns __be32 to fix test robot
- change ncf_cb_cinfo to ncf_cb_change to avoid confusion of cindo usage
  in fs/nfsd/nfs4xdr.c

Changes since v2:

[PATCH 2/4] NFSD: enable support for write delegation
- rename 'deleg' to 'dl_type' in nfs4_set_delegation
- remove 'wdeleg' in nfs4_open_delegation

- drop [PATCH 3/4] NFSD: add supports for CB_GETATTR callback
  and [PATCH 4/4] NFSD: handle GETATTR conflict with write delegation
  for futher clarification of the benefits of using CB_GETATTR
  for handling GETATTR from the 2nd client

Comments

Jeffrey Layton May 18, 2023, 1:51 p.m. UTC | #1
On Wed, 2023-05-17 at 16:38 -0700, Dai Ngo wrote:
> NFSD: add support for NFSv4 write delegation
> 
> The NFSv4 server currently supports read delegation using VFS lease
> which is implemented using file_lock. 
> 
> This patch series add write delegation support for NFSv4 server by:
> 
>     . remove the check for F_WRLCK in generic_add_lease to allow
>       file_lock to be used for write delegation.  
> 
>     . grant write delegation for OPEN with NFS4_SHARE_ACCESS_WRITE
>       if there is no conflict with other OPENs.
> 
> Write delegation conflict with another OPEN, REMOVE, RENAME and SETATTR
> are handled the same as read delegation using notify_change, try_break_deleg.
> 
> Changes since v1:
> 
> [PATCH 3/4] NFSD: add supports for CB_GETATTR callback
> - remove WARN_ON_ONCE from encode_bitmap4
> - replace decode_bitmap4 with xdr_stream_decode_uint32_array
> - replace xdr_inline_decode and xdr_decode_hyper in decode_cb_getattr
>    with xdr_stream_decode_u64. Also remove the un-needed likely().
> - modify signature of encode_cb_getattr4args to take pointer to
>    nfs4_cb_fattr
> - replace decode_attr_length with xdr_stream_decode_u32
> - rename decode_cb_getattr to decode_cb_fattr4
> - fold the initialization of cb_cinfo and cb_fsize into decode_cb_fattr4
> - rename ncf_cb_cinfo to ncf_cb_change to avoid confusion of cindo usage
>   in fs/nfsd/nfs4xdr.c
> - correct NFS4_dec_cb_getattr_sz and update size description
> 
> [PATCH 4/4] NFSD: handle GETATTR conflict with write delegation
> - change nfs4_handle_wrdeleg_conflict returns __be32 to fix test robot
> - change ncf_cb_cinfo to ncf_cb_change to avoid confusion of cindo usage
>   in fs/nfsd/nfs4xdr.c
> 
> Changes since v2:
> 
> [PATCH 2/4] NFSD: enable support for write delegation
> - rename 'deleg' to 'dl_type' in nfs4_set_delegation
> - remove 'wdeleg' in nfs4_open_delegation
> 
> - drop [PATCH 3/4] NFSD: add supports for CB_GETATTR callback
>   and [PATCH 4/4] NFSD: handle GETATTR conflict with write delegation
>   for futher clarification of the benefits of using CB_GETATTR
>   for handling GETATTR from the 2nd client
> 

Pretty straightforward. Not as useful (IMO) without CB_GETATTR, since
even a stray 'ls -l' in the parent directory will cause the delegation
to be recalled, but it's a reasonable first step.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Dai Ngo May 18, 2023, 5:15 p.m. UTC | #2
On 5/18/23 6:51 AM, Jeff Layton wrote:
> On Wed, 2023-05-17 at 16:38 -0700, Dai Ngo wrote:
>> NFSD: add support for NFSv4 write delegation
>>
>> The NFSv4 server currently supports read delegation using VFS lease
>> which is implemented using file_lock.
>>
>> This patch series add write delegation support for NFSv4 server by:
>>
>>      . remove the check for F_WRLCK in generic_add_lease to allow
>>        file_lock to be used for write delegation.
>>
>>      . grant write delegation for OPEN with NFS4_SHARE_ACCESS_WRITE
>>        if there is no conflict with other OPENs.
>>
>> Write delegation conflict with another OPEN, REMOVE, RENAME and SETATTR
>> are handled the same as read delegation using notify_change, try_break_deleg.
>>
>> Changes since v1:
>>
>> [PATCH 3/4] NFSD: add supports for CB_GETATTR callback
>> - remove WARN_ON_ONCE from encode_bitmap4
>> - replace decode_bitmap4 with xdr_stream_decode_uint32_array
>> - replace xdr_inline_decode and xdr_decode_hyper in decode_cb_getattr
>>     with xdr_stream_decode_u64. Also remove the un-needed likely().
>> - modify signature of encode_cb_getattr4args to take pointer to
>>     nfs4_cb_fattr
>> - replace decode_attr_length with xdr_stream_decode_u32
>> - rename decode_cb_getattr to decode_cb_fattr4
>> - fold the initialization of cb_cinfo and cb_fsize into decode_cb_fattr4
>> - rename ncf_cb_cinfo to ncf_cb_change to avoid confusion of cindo usage
>>    in fs/nfsd/nfs4xdr.c
>> - correct NFS4_dec_cb_getattr_sz and update size description
>>
>> [PATCH 4/4] NFSD: handle GETATTR conflict with write delegation
>> - change nfs4_handle_wrdeleg_conflict returns __be32 to fix test robot
>> - change ncf_cb_cinfo to ncf_cb_change to avoid confusion of cindo usage
>>    in fs/nfsd/nfs4xdr.c
>>
>> Changes since v2:
>>
>> [PATCH 2/4] NFSD: enable support for write delegation
>> - rename 'deleg' to 'dl_type' in nfs4_set_delegation
>> - remove 'wdeleg' in nfs4_open_delegation
>>
>> - drop [PATCH 3/4] NFSD: add supports for CB_GETATTR callback
>>    and [PATCH 4/4] NFSD: handle GETATTR conflict with write delegation
>>    for futher clarification of the benefits of using CB_GETATTR
>>    for handling GETATTR from the 2nd client
>>
> Pretty straightforward. Not as useful (IMO) without CB_GETATTR, since
> even a stray 'ls -l' in the parent directory will cause the delegation
> to be recalled, but it's a reasonable first step.

Oh I forgot to leave to code to recall the write delegation in when
there is GETATTR. Will fix in v4.

Yes, let just run with this simple code for awhile to make sure nothing
break then we can add the CB_GETATTR later it it's needed.

-Dai

>
> Reviewed-by: Jeff Layton <jlayton@kernel.org>