Hi Sagi, kernel test robot noticed the following build warnings: [auto build test WARNING on linus/master] [also build test WARNING on v6.11-rc1 next-20240729] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Sagi-Grimberg/nfsd-don-t-assume-copy-notify-when-preprocessing-the-stateid/20240729-044834 base: linus/master patch link: https://lore.kernel.org/r/20240728204104.519041-3-sagi%40grimberg.me patch subject: [PATCH v2 2/3] nfsd: Offer write delegations for o_wronly opens config: sparc64-randconfig-r121-20240729 (https://download.01.org/0day-ci/archive/20240730/202407300630.V7R20Aao-lkp@xxxxxxxxx/config) compiler: sparc64-linux-gcc (GCC) 14.1.0 reproduce: (https://download.01.org/0day-ci/archive/20240730/202407300630.V7R20Aao-lkp@xxxxxxxxx/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@xxxxxxxxx> | Closes: https://lore.kernel.org/oe-kbuild-all/202407300630.V7R20Aao-lkp@xxxxxxxxx/ sparse warnings: (new ones prefixed by >>) >> fs/nfsd/nfs4state.c:5985:32: sparse: sparse: incorrect type in assignment (different base types) @@ expected int status @@ got restricted __be32 @@ fs/nfsd/nfs4state.c:5985:32: sparse: expected int status fs/nfsd/nfs4state.c:5985:32: sparse: got restricted __be32 fs/nfsd/nfs4state.c: note: in included file (through include/linux/wait.h, include/linux/wait_bit.h, include/linux/fs.h): include/linux/list.h:218:19: sparse: sparse: context imbalance in 'put_clnt_odstate' - unexpected unlock fs/nfsd/nfs4state.c:1197:9: sparse: sparse: context imbalance in 'nfs4_put_stid' - unexpected unlock vim +5985 fs/nfsd/nfs4state.c 5895 5896 /* 5897 * The Linux NFS server does not offer write delegations to NFSv4.0 5898 * clients in order to avoid conflicts between write delegations and 5899 * GETATTRs requesting CHANGE or SIZE attributes. 5900 * 5901 * With NFSv4.1 and later minorversions, the SEQUENCE operation that 5902 * begins each COMPOUND contains a client ID. Delegation recall can 5903 * be avoided when the server recognizes the client sending a 5904 * GETATTR also holds write delegation it conflicts with. 5905 * 5906 * However, the NFSv4.0 protocol does not enable a server to 5907 * determine that a GETATTR originated from the client holding the 5908 * conflicting delegation versus coming from some other client. Per 5909 * RFC 7530 Section 16.7.5, the server must recall or send a 5910 * CB_GETATTR even when the GETATTR originates from the client that 5911 * holds the conflicting delegation. 5912 * 5913 * An NFSv4.0 client can trigger a pathological situation if it 5914 * always sends a DELEGRETURN preceded by a conflicting GETATTR in 5915 * the same COMPOUND. COMPOUND execution will always stop at the 5916 * GETATTR and the DELEGRETURN will never get executed. The server 5917 * eventually revokes the delegation, which can result in loss of 5918 * open or lock state. 5919 */ 5920 static void 5921 nfs4_open_delegation(struct svc_rqst *rqstp, struct nfsd4_open *open, 5922 struct nfs4_ol_stateid *stp, struct svc_fh *currentfh) 5923 { 5924 struct nfs4_delegation *dp; 5925 struct nfs4_openowner *oo = openowner(stp->st_stateowner); 5926 struct nfs4_client *clp = stp->st_stid.sc_client; 5927 struct svc_fh *parent = NULL; 5928 int cb_up; 5929 int status = 0; 5930 struct kstat stat; 5931 struct path path; 5932 5933 cb_up = nfsd4_cb_channel_good(oo->oo_owner.so_client); 5934 open->op_recall = false; 5935 switch (open->op_claim_type) { 5936 case NFS4_OPEN_CLAIM_PREVIOUS: 5937 if (!cb_up) 5938 open->op_recall = true; 5939 break; 5940 case NFS4_OPEN_CLAIM_NULL: 5941 parent = currentfh; 5942 fallthrough; 5943 case NFS4_OPEN_CLAIM_FH: 5944 /* 5945 * Let's not give out any delegations till everyone's 5946 * had the chance to reclaim theirs, *and* until 5947 * NLM locks have all been reclaimed: 5948 */ 5949 if (locks_in_grace(clp->net)) 5950 goto out_no_deleg; 5951 if (!cb_up || !(oo->oo_flags & NFS4_OO_CONFIRMED)) 5952 goto out_no_deleg; 5953 if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE && 5954 !clp->cl_minorversion) 5955 goto out_no_deleg; 5956 break; 5957 default: 5958 goto out_no_deleg; 5959 } 5960 dp = nfs4_set_delegation(open, stp, parent); 5961 if (IS_ERR(dp)) 5962 goto out_no_deleg; 5963 5964 memcpy(&open->op_delegate_stateid, &dp->dl_stid.sc_stateid, sizeof(dp->dl_stid.sc_stateid)); 5965 5966 if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) { 5967 open->op_delegate_type = NFS4_OPEN_DELEGATE_WRITE; 5968 trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid); 5969 path.mnt = currentfh->fh_export->ex_path.mnt; 5970 path.dentry = currentfh->fh_dentry; 5971 if (vfs_getattr(&path, &stat, 5972 (STATX_SIZE | STATX_CTIME | STATX_CHANGE_COOKIE), 5973 AT_STATX_SYNC_AS_STAT)) { 5974 nfs4_put_stid(&dp->dl_stid); 5975 destroy_delegation(dp); 5976 goto out_no_deleg; 5977 } 5978 dp->dl_cb_fattr.ncf_cur_fsize = stat.size; 5979 dp->dl_cb_fattr.ncf_initial_cinfo = 5980 nfsd4_change_attribute(&stat, d_inode(currentfh->fh_dentry)); 5981 if ((open->op_share_access & NFS4_SHARE_ACCESS_BOTH) != NFS4_SHARE_ACCESS_BOTH) { 5982 struct nfsd_file *nf = NULL; 5983 5984 /* make sure the file is opened locally for O_RDWR */ > 5985 status = nfsd_file_acquire_opened(rqstp, currentfh, 5986 nfs4_access_to_access(NFS4_SHARE_ACCESS_BOTH), 5987 open->op_filp, &nf); 5988 if (status) { 5989 nfs4_put_stid(&dp->dl_stid); 5990 destroy_delegation(dp); 5991 goto out_no_deleg; 5992 } 5993 stp->st_stid.sc_file->fi_fds[O_RDWR] = nf; 5994 } 5995 } else { 5996 open->op_delegate_type = NFS4_OPEN_DELEGATE_READ; 5997 trace_nfsd_deleg_read(&dp->dl_stid.sc_stateid); 5998 } 5999 nfs4_put_stid(&dp->dl_stid); 6000 return; 6001 out_no_deleg: 6002 open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE; 6003 if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS && 6004 open->op_delegate_type != NFS4_OPEN_DELEGATE_NONE) { 6005 dprintk("NFSD: WARNING: refusing delegation reclaim\n"); 6006 open->op_recall = true; 6007 } 6008 6009 /* 4.1 client asking for a delegation? */ 6010 if (open->op_deleg_want) 6011 nfsd4_open_deleg_none_ext(open, status); 6012 return; 6013 } 6014 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki