aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2009-09-02 19:50:40 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2009-09-02 23:54:48 -0400
commitbc6c53d5a1383d5d9632adf33bd03458cfc0869d (patch)
tree6caf2e75f17efca08884dcaccb750901e2af2b26
parent8e498751f2f36074ffa6fc7f0a9ec6e055b350e6 (diff)
nfsd: move fsid_type choice out of fh_compose
More trivial cleanup. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r--fs/nfsd/nfsfh.c77
1 files changed, 41 insertions, 36 deletions
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 78d8ebf162ca..bce0b2bfbc61 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -431,43 +431,17 @@ static bool fsid_type_ok_for_exp(u8 fsid_type, struct svc_export *exp)
431 return 1; 431 return 1;
432} 432}
433 433
434__be32
435fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
436 struct svc_fh *ref_fh)
437{
438 /* ref_fh is a reference file handle.
439 * if it is non-null and for the same filesystem, then we should compose
440 * a filehandle which is of the same version, where possible.
441 * Currently, that means that if ref_fh->fh_handle.fh_version == 0xca
442 * Then create a 32byte filehandle using nfs_fhbase_old
443 *
444 */
445 434
435static void set_version_and_fsid_type(struct svc_fh *fhp, struct svc_export *exp, struct svc_fh *ref_fh)
436{
446 u8 version; 437 u8 version;
447 u8 fsid_type = 0; 438 u8 fsid_type;
448 struct inode * inode = dentry->d_inode; 439retry:
449 struct dentry *parent = dentry->d_parent;
450 __u32 *datap;
451 dev_t ex_dev = exp_sb(exp)->s_dev;
452
453 dprintk("nfsd: fh_compose(exp %02x:%02x/%ld %s/%s, ino=%ld)\n",
454 MAJOR(ex_dev), MINOR(ex_dev),
455 (long) exp->ex_path.dentry->d_inode->i_ino,
456 parent->d_name.name, dentry->d_name.name,
457 (inode ? inode->i_ino : 0));
458
459 /* Choose filehandle version and fsid type based on
460 * the reference filehandle (if it is in the same export)
461 * or the export options.
462 */
463 retry:
464 version = 1; 440 version = 1;
465 if (ref_fh && ref_fh->fh_export == exp) { 441 if (ref_fh && ref_fh->fh_export == exp) {
466 version = ref_fh->fh_handle.fh_version; 442 version = ref_fh->fh_handle.fh_version;
467 fsid_type = ref_fh->fh_handle.fh_fsid_type; 443 fsid_type = ref_fh->fh_handle.fh_fsid_type;
468 444
469 if (ref_fh == fhp)
470 fh_put(ref_fh);
471 ref_fh = NULL; 445 ref_fh = NULL;
472 446
473 switch (version) { 447 switch (version) {
@@ -502,11 +476,44 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
502 else 476 else
503 fsid_type = FSID_UUID4_INUM; 477 fsid_type = FSID_UUID4_INUM;
504 } 478 }
505 } else if (!old_valid_dev(ex_dev)) 479 } else if (!old_valid_dev(exp_sb(exp)->s_dev))
506 /* for newer device numbers, we must use a newer fsid format */ 480 /* for newer device numbers, we must use a newer fsid format */
507 fsid_type = FSID_ENCODE_DEV; 481 fsid_type = FSID_ENCODE_DEV;
508 else 482 else
509 fsid_type = FSID_DEV; 483 fsid_type = FSID_DEV;
484 fhp->fh_handle.fh_version = version;
485 if (version)
486 fhp->fh_handle.fh_fsid_type = fsid_type;
487}
488
489__be32
490fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
491 struct svc_fh *ref_fh)
492{
493 /* ref_fh is a reference file handle.
494 * if it is non-null and for the same filesystem, then we should compose
495 * a filehandle which is of the same version, where possible.
496 * Currently, that means that if ref_fh->fh_handle.fh_version == 0xca
497 * Then create a 32byte filehandle using nfs_fhbase_old
498 *
499 */
500
501 struct inode * inode = dentry->d_inode;
502 struct dentry *parent = dentry->d_parent;
503 __u32 *datap;
504 dev_t ex_dev = exp_sb(exp)->s_dev;
505
506 dprintk("nfsd: fh_compose(exp %02x:%02x/%ld %s/%s, ino=%ld)\n",
507 MAJOR(ex_dev), MINOR(ex_dev),
508 (long) exp->ex_path.dentry->d_inode->i_ino,
509 parent->d_name.name, dentry->d_name.name,
510 (inode ? inode->i_ino : 0));
511
512 /* Choose filehandle version and fsid type based on
513 * the reference filehandle (if it is in the same export)
514 * or the export options.
515 */
516 set_version_and_fsid_type(fhp, exp, ref_fh);
510 517
511 if (ref_fh == fhp) 518 if (ref_fh == fhp)
512 fh_put(ref_fh); 519 fh_put(ref_fh);
@@ -524,7 +531,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
524 fhp->fh_export = exp; 531 fhp->fh_export = exp;
525 cache_get(&exp->h); 532 cache_get(&exp->h);
526 533
527 if (version == 0xca) { 534 if (fhp->fh_handle.fh_version == 0xca) {
528 /* old style filehandle please */ 535 /* old style filehandle please */
529 memset(&fhp->fh_handle.fh_base, 0, NFS_FHSIZE); 536 memset(&fhp->fh_handle.fh_base, 0, NFS_FHSIZE);
530 fhp->fh_handle.fh_size = NFS_FHSIZE; 537 fhp->fh_handle.fh_size = NFS_FHSIZE;
@@ -538,15 +545,13 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
538 _fh_update_old(dentry, exp, &fhp->fh_handle); 545 _fh_update_old(dentry, exp, &fhp->fh_handle);
539 } else { 546 } else {
540 int len; 547 int len;
541 fhp->fh_handle.fh_version = 1;
542 fhp->fh_handle.fh_auth_type = 0; 548 fhp->fh_handle.fh_auth_type = 0;
543 datap = fhp->fh_handle.fh_auth+0; 549 datap = fhp->fh_handle.fh_auth+0;
544 fhp->fh_handle.fh_fsid_type = fsid_type; 550 mk_fsid(fhp->fh_handle.fh_fsid_type, datap, ex_dev,
545 mk_fsid(fsid_type, datap, ex_dev,
546 exp->ex_path.dentry->d_inode->i_ino, 551 exp->ex_path.dentry->d_inode->i_ino,
547 exp->ex_fsid, exp->ex_uuid); 552 exp->ex_fsid, exp->ex_uuid);
548 553
549 len = key_len(fsid_type); 554 len = key_len(fhp->fh_handle.fh_fsid_type);
550 datap += len/4; 555 datap += len/4;
551 fhp->fh_handle.fh_size = 4 + len; 556 fhp->fh_handle.fh_size = 4 + len;
552 557