Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21571425rwd; Thu, 29 Jun 2023 18:53:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4h6BkF8iMJhJ6X0lWGU1a91oBuQxFbnEGU3KlFmeDucVLRlp2s8pGn4a6iey2kN3sKa5HQ X-Received: by 2002:a05:6830:1d54:b0:6b8:9a3a:ea12 with SMTP id p20-20020a0568301d5400b006b89a3aea12mr1917099oth.12.1688089997279; Thu, 29 Jun 2023 18:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688089997; cv=none; d=google.com; s=arc-20160816; b=TBjRwoZ/BflUGa1F0NdD75m15HKV5LZwGWmdvE4QaDDr0U5i2/GVOHbez0HDyUbIvT fogtNEj3+ttU9dEUZSb3Q23xi8L0VXJQxjJbvT5lyICzy9ni0vkEL3d05Fq2nigcImgh iELVOUeqH+oW0ykVemwKlA7txyVw5TSpn0HBbPSy9lRwTf04ulfXbH8nAO/MesyJJLzH 6ujRqQHYZLyyEjgQtbl05QBZYFE5XeS6SwAZVnZthmQM1uTDZXqw5XVitq5961Tpb+PK 3AkY/2TmBw//UFqJw/as+qPIVEVxOspNfzz1qVoyz+E5F7dK6xoNyoBUBigKH3hi9eYY NTeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=2CfafyYfVVpAejWC5nlcIhibUPgsWoZu6VC/qLHctT0=; fh=v8xUtyFkmzGZMmWmAQ4FadTGq5GKhFfG2qkBWhr83JU=; b=hdcwzTewz1v3/ubBvsIrBUNQomLc8DXbjNsbnI17GgIpRJ8WH/GSc5UoVGmwlKwFOt sT8KFQ+iitaSoEa5U4v+Y8aVCm7xrz22PrvmpfogArToMPZaj9MRhQAiMU9wEvWwODRA VZPTRXN2QYrD/v0OjXTHwgQ/H5uxvxzvNA8VzxCurSQjocb+DvRkSeBL2CUDYyhTI1Tm IOJSscoAvMYR4KxdAEa68K7M/y7ZnOJ/DGSjU0j0wSzW+KkkjoD8aoteQZSUrSesR/1u oOouaoe3s31szRt8wy90xqx06MI2nYyVyVoVk1HsKHdkS4OB4ur6F09q7ydwXARoAoub Pz/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=34obVVFN; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h191-20020a6383c8000000b0055b5ef64503si624837pge.251.2023.06.29.18.53.02; Thu, 29 Jun 2023 18:53:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=34obVVFN; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231393AbjF3BxA (ORCPT + 99 others); Thu, 29 Jun 2023 21:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbjF3Bw7 (ORCPT ); Thu, 29 Jun 2023 21:52:59 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6E1CA1 for ; Thu, 29 Jun 2023 18:52:57 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35U0BIKI000821; Fri, 30 Jun 2023 01:52:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2023-03-30; bh=2CfafyYfVVpAejWC5nlcIhibUPgsWoZu6VC/qLHctT0=; b=34obVVFNJTs4Mvrm0/BPmiAkI6pIGlU9F9SGuxusJjbmiXDzbM7DCbR5reFb8/UF9GKJ fiSuhYzbY/7CpAcchTGNTug6kpq60Hs9xTmRbhgmLZaPmGnLfyNNHURmT+LgneToXAXP MdHQbmXK1q3tnRoO6NsmeihETHcMFSczpdvmY12gfA1u8WKK3X+dq353Ak1IJVab88ba zCysi5x/RpXxdJusILaODs/OHu83jEdOUnWnVyVEy+WBnLnepakYv103e3nHYTzb7YW+ eX3JEaXkcvjcny8wltsAs9Unk811acM+k/eRtvTQBqK2l227JLEZ4yE3iG25S9Z5fNBo JA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdrhcy16k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Jun 2023 01:52:52 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35U0Vd5W019908; Fri, 30 Jun 2023 01:52:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxdypyg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Jun 2023 01:52:52 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35U1qpep034790; Fri, 30 Jun 2023 01:52:51 GMT Received: from ca-common-hq.us.oracle.com (ca-common-hq.us.oracle.com [10.211.9.209]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3rdpxdypy9-1; Fri, 30 Jun 2023 01:52:51 +0000 From: Dai Ngo To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v7 0/4] NFSD: add support for NFSv4.1+ write delegation Date: Thu, 29 Jun 2023 18:52:36 -0700 Message-Id: <1688089960-24568-1-git-send-email-dai.ngo@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-29_10,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300014 X-Proofpoint-GUID: y-qJiNo4JUTfI75BZRn2VY4-szIPvM8x X-Proofpoint-ORIG-GUID: y-qJiNo4JUTfI75BZRn2VY4-szIPvM8x X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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.1+ client 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. The write delegation support is for NFSv4.1+ client only since the NFSv4.0 Linux client behavior is not compliant with RFC 7530 Section 16.7.5. It expects the server to look ahead in the compound to find a stateid in order to determine whether the client that sends the GETATTR is the same client that holds the write delegation. RFC 7530 spec does not call for the server to look ahead in order to service the GETATTR op. 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 these patches Changes since v3: - recall write delegation when there is GETATTR from 2nd client - add trace point to track when write delegation is granted Changes since v4: - squash 4/4 into 2/4 - apply 1/4 last instead of first - combine nfs4_wrdeleg_filelock and nfs4_handle_wrdeleg_conflict to nfsd4_deleg_getattr_conflict and move it to fs/nfsd/nfs4state.c - check for lock belongs to delegation before proceed and do it under the fl_lock - check and skip FL_LAYOUT file_locks Changes since v5: - [patch 2/5] disable write delegation for NFSv4.0 client - [patch 4/5] allow client to use write delegation stateid for READ (same behavior as Solaris server) When the server receives a READ request with write delegation stateid the server may returns the NFS4ERR_OPENMODE or allows the READ to proceed to accommodate clients whose WRITE implementation may unavoidably do reads (e.g., due to buffer cache constraints). Per RFC 8881 section 9.1.2. Use of the Stateid and Locking Returning NFS4ERR_OPENMODE causes the client and server to enter an infinite loop of READ, NFS4ERR_OPENMODE, TEST_STATEID, READs, NFS4ERR_OPENMODEs, TEST_STATEID, READs, NFS4ERR_OPENMODEs. The Linux NFS client can not recover from NFS4ERR_OPENMODE for READ request if the file was opened with OPEN4_SHARE_ACCESS_WRITE. This READ was initiated internally from the NFS client and not from the read(2) system call. - pass git regression test with 40 threads Changes since v6: - [patch 2/4] Patch 'NFSD: allow client to use write delegation stateid for READ' was moved to before patch 'NFSD: Enable write delegation support for NFSv4.1+ client' to avoid bisect error. - [patch 4/4] Update comment on why write delegation for NFSv4.0 client is not supported. Move to last in the series. - [patch 3/4] Correct typo in function comment of nfsd4_deleg_getattr_conflict. Add comment on the need for CB_GETATTR in commit message. Squash patch 'NFSD: add counter for write delegation recall due to conflict GETATTR' into this patch.