@@ -154,11 +154,12 @@ static inline __be32 check_pseudo_root(struct svc_rqst *rqstp,
154
154
static __be32 nfsd_set_fh_dentry (struct svc_rqst * rqstp , struct svc_fh * fhp )
155
155
{
156
156
struct knfsd_fh * fh = & fhp -> fh_handle ;
157
- struct fid * fid = NULL , sfid ;
157
+ struct fid * fid = NULL ;
158
158
struct svc_export * exp ;
159
159
struct dentry * dentry ;
160
160
int fileid_type ;
161
161
int data_left = fh -> fh_size /4 ;
162
+ int len ;
162
163
__be32 error ;
163
164
164
165
error = nfserr_stale ;
@@ -167,48 +168,35 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
167
168
if (rqstp -> rq_vers == 4 && fh -> fh_size == 0 )
168
169
return nfserr_nofilehandle ;
169
170
170
- if (fh -> fh_version == 1 ) {
171
- int len ;
172
-
173
- if (-- data_left < 0 )
174
- return error ;
175
- if (fh -> fh_auth_type != 0 )
176
- return error ;
177
- len = key_len (fh -> fh_fsid_type ) / 4 ;
178
- if (len == 0 )
179
- return error ;
180
- if (fh -> fh_fsid_type == FSID_MAJOR_MINOR ) {
181
- /* deprecated, convert to type 3 */
182
- len = key_len (FSID_ENCODE_DEV )/4 ;
183
- fh -> fh_fsid_type = FSID_ENCODE_DEV ;
184
- /*
185
- * struct knfsd_fh uses host-endian fields, which are
186
- * sometimes used to hold net-endian values. This
187
- * confuses sparse, so we must use __force here to
188
- * keep it from complaining.
189
- */
190
- fh -> fh_fsid [0 ] = new_encode_dev (MKDEV (ntohl ((__force __be32 )fh -> fh_fsid [0 ]),
191
- ntohl ((__force __be32 )fh -> fh_fsid [1 ])));
192
- fh -> fh_fsid [1 ] = fh -> fh_fsid [2 ];
193
- }
194
- data_left -= len ;
195
- if (data_left < 0 )
196
- return error ;
197
- exp = rqst_exp_find (rqstp , fh -> fh_fsid_type , fh -> fh_fsid );
198
- fid = (struct fid * )(fh -> fh_fsid + len );
199
- } else {
200
- __u32 tfh [2 ];
201
- dev_t xdev ;
202
- ino_t xino ;
203
-
204
- if (fh -> fh_size != NFS_FHSIZE )
205
- return error ;
206
- /* assume old filehandle format */
207
- xdev = old_decode_dev (fh -> ofh_xdev );
208
- xino = u32_to_ino_t (fh -> ofh_xino );
209
- mk_fsid (FSID_DEV , tfh , xdev , xino , 0 , NULL );
210
- exp = rqst_exp_find (rqstp , FSID_DEV , tfh );
171
+ if (fh -> fh_version != 1 )
172
+ return error ;
173
+
174
+ if (-- data_left < 0 )
175
+ return error ;
176
+ if (fh -> fh_auth_type != 0 )
177
+ return error ;
178
+ len = key_len (fh -> fh_fsid_type ) / 4 ;
179
+ if (len == 0 )
180
+ return error ;
181
+ if (fh -> fh_fsid_type == FSID_MAJOR_MINOR ) {
182
+ /* deprecated, convert to type 3 */
183
+ len = key_len (FSID_ENCODE_DEV )/4 ;
184
+ fh -> fh_fsid_type = FSID_ENCODE_DEV ;
185
+ /*
186
+ * struct knfsd_fh uses host-endian fields, which are
187
+ * sometimes used to hold net-endian values. This
188
+ * confuses sparse, so we must use __force here to
189
+ * keep it from complaining.
190
+ */
191
+ fh -> fh_fsid [0 ] = new_encode_dev (MKDEV (ntohl ((__force __be32 )fh -> fh_fsid [0 ]),
192
+ ntohl ((__force __be32 )fh -> fh_fsid [1 ])));
193
+ fh -> fh_fsid [1 ] = fh -> fh_fsid [2 ];
211
194
}
195
+ data_left -= len ;
196
+ if (data_left < 0 )
197
+ return error ;
198
+ exp = rqst_exp_find (rqstp , fh -> fh_fsid_type , fh -> fh_fsid );
199
+ fid = (struct fid * )(fh -> fh_fsid + len );
212
200
213
201
error = nfserr_stale ;
214
202
if (IS_ERR (exp )) {
@@ -253,18 +241,7 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
253
241
if (rqstp -> rq_vers > 2 )
254
242
error = nfserr_badhandle ;
255
243
256
- if (fh -> fh_version != 1 ) {
257
- sfid .i32 .ino = fh -> ofh_ino ;
258
- sfid .i32 .gen = fh -> ofh_generation ;
259
- sfid .i32 .parent_ino = fh -> ofh_dirino ;
260
- fid = & sfid ;
261
- data_left = 3 ;
262
- if (fh -> ofh_dirino == 0 )
263
- fileid_type = FILEID_INO32_GEN ;
264
- else
265
- fileid_type = FILEID_INO32_GEN_PARENT ;
266
- } else
267
- fileid_type = fh -> fh_fileid_type ;
244
+ fileid_type = fh -> fh_fileid_type ;
268
245
269
246
if (fileid_type == FILEID_ROOT )
270
247
dentry = dget (exp -> ex_path .dentry );
@@ -452,20 +429,6 @@ static void _fh_update(struct svc_fh *fhp, struct svc_export *exp,
452
429
}
453
430
}
454
431
455
- /*
456
- * for composing old style file handles
457
- */
458
- static inline void _fh_update_old (struct dentry * dentry ,
459
- struct svc_export * exp ,
460
- struct knfsd_fh * fh )
461
- {
462
- fh -> ofh_ino = ino_t_to_u32 (d_inode (dentry )-> i_ino );
463
- fh -> ofh_generation = d_inode (dentry )-> i_generation ;
464
- if (d_is_dir (dentry ) ||
465
- (exp -> ex_flags & NFSEXP_NOSUBTREECHECK ))
466
- fh -> ofh_dirino = 0 ;
467
- }
468
-
469
432
static bool is_root_export (struct svc_export * exp )
470
433
{
471
434
return exp -> ex_path .dentry == exp -> ex_path .dentry -> d_sb -> s_root ;
@@ -562,9 +525,6 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
562
525
/* ref_fh is a reference file handle.
563
526
* if it is non-null and for the same filesystem, then we should compose
564
527
* a filehandle which is of the same version, where possible.
565
- * Currently, that means that if ref_fh->fh_handle.fh_version == 0xca
566
- * Then create a 32byte filehandle using nfs_fhbase_old
567
- *
568
528
*/
569
529
570
530
struct inode * inode = d_inode (dentry );
@@ -600,35 +560,21 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
600
560
fhp -> fh_dentry = dget (dentry ); /* our internal copy */
601
561
fhp -> fh_export = exp_get (exp );
602
562
603
- if (fhp -> fh_handle .fh_version == 0xca ) {
604
- /* old style filehandle please */
605
- memset (& fhp -> fh_handle .fh_base , 0 , NFS_FHSIZE );
606
- fhp -> fh_handle .fh_size = NFS_FHSIZE ;
607
- fhp -> fh_handle .ofh_dcookie = 0xfeebbaca ;
608
- fhp -> fh_handle .ofh_dev = old_encode_dev (ex_dev );
609
- fhp -> fh_handle .ofh_xdev = fhp -> fh_handle .ofh_dev ;
610
- fhp -> fh_handle .ofh_xino =
611
- ino_t_to_u32 (d_inode (exp -> ex_path .dentry )-> i_ino );
612
- fhp -> fh_handle .ofh_dirino = ino_t_to_u32 (parent_ino (dentry ));
613
- if (inode )
614
- _fh_update_old (dentry , exp , & fhp -> fh_handle );
615
- } else {
616
- fhp -> fh_handle .fh_size =
617
- key_len (fhp -> fh_handle .fh_fsid_type ) + 4 ;
618
- fhp -> fh_handle .fh_auth_type = 0 ;
619
-
620
- mk_fsid (fhp -> fh_handle .fh_fsid_type ,
621
- fhp -> fh_handle .fh_fsid ,
622
- ex_dev ,
623
- d_inode (exp -> ex_path .dentry )-> i_ino ,
624
- exp -> ex_fsid , exp -> ex_uuid );
625
-
626
- if (inode )
627
- _fh_update (fhp , exp , dentry );
628
- if (fhp -> fh_handle .fh_fileid_type == FILEID_INVALID ) {
629
- fh_put (fhp );
630
- return nfserr_opnotsupp ;
631
- }
563
+ fhp -> fh_handle .fh_size =
564
+ key_len (fhp -> fh_handle .fh_fsid_type ) + 4 ;
565
+ fhp -> fh_handle .fh_auth_type = 0 ;
566
+
567
+ mk_fsid (fhp -> fh_handle .fh_fsid_type ,
568
+ fhp -> fh_handle .fh_fsid ,
569
+ ex_dev ,
570
+ d_inode (exp -> ex_path .dentry )-> i_ino ,
571
+ exp -> ex_fsid , exp -> ex_uuid );
572
+
573
+ if (inode )
574
+ _fh_update (fhp , exp , dentry );
575
+ if (fhp -> fh_handle .fh_fileid_type == FILEID_INVALID ) {
576
+ fh_put (fhp );
577
+ return nfserr_opnotsupp ;
632
578
}
633
579
634
580
return 0 ;
@@ -649,16 +595,12 @@ fh_update(struct svc_fh *fhp)
649
595
dentry = fhp -> fh_dentry ;
650
596
if (d_really_is_negative (dentry ))
651
597
goto out_negative ;
652
- if (fhp -> fh_handle .fh_version != 1 ) {
653
- _fh_update_old (dentry , fhp -> fh_export , & fhp -> fh_handle );
654
- } else {
655
- if (fhp -> fh_handle .fh_fileid_type != FILEID_ROOT )
656
- return 0 ;
598
+ if (fhp -> fh_handle .fh_fileid_type != FILEID_ROOT )
599
+ return 0 ;
657
600
658
- _fh_update (fhp , fhp -> fh_export , dentry );
659
- if (fhp -> fh_handle .fh_fileid_type == FILEID_INVALID )
660
- return nfserr_opnotsupp ;
661
- }
601
+ _fh_update (fhp , fhp -> fh_export , dentry );
602
+ if (fhp -> fh_handle .fh_fileid_type == FILEID_INVALID )
603
+ return nfserr_opnotsupp ;
662
604
return 0 ;
663
605
out_bad :
664
606
printk (KERN_ERR "fh_update: fh not verified!\n" );
0 commit comments