@@ -1071,8 +1071,8 @@ nfsd_file_is_cached(struct inode *inode)
10711071
10721072static __be32
10731073nfsd_file_do_acquire (struct svc_rqst * rqstp , struct svc_fh * fhp ,
1074- unsigned int may_flags , struct nfsd_file * * pnf ,
1075- bool open , bool want_gc )
1074+ unsigned int may_flags , struct file * file ,
1075+ struct nfsd_file * * pnf , bool want_gc )
10761076{
10771077 struct nfsd_file_lookup_key key = {
10781078 .type = NFSD_FILE_KEY_FULL ,
@@ -1147,8 +1147,7 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
11471147 status = nfserrno (nfsd_open_break_lease (file_inode (nf -> nf_file ), may_flags ));
11481148out :
11491149 if (status == nfs_ok ) {
1150- if (open )
1151- this_cpu_inc (nfsd_file_acquisitions );
1150+ this_cpu_inc (nfsd_file_acquisitions );
11521151 * pnf = nf ;
11531152 } else {
11541153 if (refcount_dec_and_test (& nf -> nf_ref ))
@@ -1158,20 +1157,23 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
11581157
11591158out_status :
11601159 put_cred (key .cred );
1161- if (open )
1162- trace_nfsd_file_acquire (rqstp , key .inode , may_flags , nf , status );
1160+ trace_nfsd_file_acquire (rqstp , key .inode , may_flags , nf , status );
11631161 return status ;
11641162
11651163open_file :
11661164 trace_nfsd_file_alloc (nf );
11671165 nf -> nf_mark = nfsd_file_mark_find_or_create (nf , key .inode );
11681166 if (nf -> nf_mark ) {
1169- if (open ) {
1167+ if (file ) {
1168+ get_file (file );
1169+ nf -> nf_file = file ;
1170+ status = nfs_ok ;
1171+ trace_nfsd_file_opened (nf , status );
1172+ } else {
11701173 status = nfsd_open_verified (rqstp , fhp , may_flags ,
11711174 & nf -> nf_file );
11721175 trace_nfsd_file_open (nf , status );
1173- } else
1174- status = nfs_ok ;
1176+ }
11751177 } else
11761178 status = nfserr_jukebox ;
11771179 /*
@@ -1207,7 +1209,7 @@ __be32
12071209nfsd_file_acquire_gc (struct svc_rqst * rqstp , struct svc_fh * fhp ,
12081210 unsigned int may_flags , struct nfsd_file * * pnf )
12091211{
1210- return nfsd_file_do_acquire (rqstp , fhp , may_flags , pnf , true , true);
1212+ return nfsd_file_do_acquire (rqstp , fhp , may_flags , NULL , pnf , true);
12111213}
12121214
12131215/**
@@ -1228,28 +1230,30 @@ __be32
12281230nfsd_file_acquire (struct svc_rqst * rqstp , struct svc_fh * fhp ,
12291231 unsigned int may_flags , struct nfsd_file * * pnf )
12301232{
1231- return nfsd_file_do_acquire (rqstp , fhp , may_flags , pnf , true , false);
1233+ return nfsd_file_do_acquire (rqstp , fhp , may_flags , NULL , pnf , false);
12321234}
12331235
12341236/**
1235- * nfsd_file_create - Get a struct nfsd_file, do not open
1237+ * nfsd_file_acquire_opened - Get a struct nfsd_file using existing open file
12361238 * @rqstp: the RPC transaction being executed
12371239 * @fhp: the NFS filehandle of the file just created
12381240 * @may_flags: NFSD_MAY_ settings for the file
1241+ * @file: cached, already-open file (may be NULL)
12391242 * @pnf: OUT: new or found "struct nfsd_file" object
12401243 *
1241- * The nfsd_file_object returned by this API is reference-counted
1242- * but not garbage-collected. The object is released immediately
1243- * one RCU grace period after the final nfsd_file_put() .
1244+ * Acquire a nfsd_file object that is not GC'ed. If one doesn't already exist,
1245+ * and @file is non-NULL, use it to instantiate a new nfsd_file instead of
1246+ * opening a new one .
12441247 *
12451248 * Returns nfs_ok and sets @pnf on success; otherwise an nfsstat in
12461249 * network byte order is returned.
12471250 */
12481251__be32
1249- nfsd_file_create (struct svc_rqst * rqstp , struct svc_fh * fhp ,
1250- unsigned int may_flags , struct nfsd_file * * pnf )
1252+ nfsd_file_acquire_opened (struct svc_rqst * rqstp , struct svc_fh * fhp ,
1253+ unsigned int may_flags , struct file * file ,
1254+ struct nfsd_file * * pnf )
12511255{
1252- return nfsd_file_do_acquire (rqstp , fhp , may_flags , pnf , false , false);
1256+ return nfsd_file_do_acquire (rqstp , fhp , may_flags , file , pnf , false);
12531257}
12541258
12551259/*
0 commit comments