diff options
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 200 |
1 files changed, 94 insertions, 106 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 3c028b9c6e0e..31673cd251c3 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -358,9 +358,22 @@ alloc_client(struct xdr_netobj name) | |||
358 | return clp; | 358 | return clp; |
359 | } | 359 | } |
360 | 360 | ||
361 | static void | ||
362 | shutdown_callback_client(struct nfs4_client *clp) | ||
363 | { | ||
364 | struct rpc_clnt *clnt = clp->cl_callback.cb_client; | ||
365 | |||
366 | /* shutdown rpc client, ending any outstanding recall rpcs */ | ||
367 | if (clnt) { | ||
368 | clp->cl_callback.cb_client = NULL; | ||
369 | rpc_shutdown_client(clnt); | ||
370 | } | ||
371 | } | ||
372 | |||
361 | static inline void | 373 | static inline void |
362 | free_client(struct nfs4_client *clp) | 374 | free_client(struct nfs4_client *clp) |
363 | { | 375 | { |
376 | shutdown_callback_client(clp); | ||
364 | if (clp->cl_cred.cr_group_info) | 377 | if (clp->cl_cred.cr_group_info) |
365 | put_group_info(clp->cl_cred.cr_group_info); | 378 | put_group_info(clp->cl_cred.cr_group_info); |
366 | kfree(clp->cl_name.data); | 379 | kfree(clp->cl_name.data); |
@@ -375,18 +388,6 @@ put_nfs4_client(struct nfs4_client *clp) | |||
375 | } | 388 | } |
376 | 389 | ||
377 | static void | 390 | static void |
378 | shutdown_callback_client(struct nfs4_client *clp) | ||
379 | { | ||
380 | struct rpc_clnt *clnt = clp->cl_callback.cb_client; | ||
381 | |||
382 | /* shutdown rpc client, ending any outstanding recall rpcs */ | ||
383 | if (clnt) { | ||
384 | clp->cl_callback.cb_client = NULL; | ||
385 | rpc_shutdown_client(clnt); | ||
386 | } | ||
387 | } | ||
388 | |||
389 | static void | ||
390 | expire_client(struct nfs4_client *clp) | 391 | expire_client(struct nfs4_client *clp) |
391 | { | 392 | { |
392 | struct nfs4_stateowner *sop; | 393 | struct nfs4_stateowner *sop; |
@@ -396,8 +397,6 @@ expire_client(struct nfs4_client *clp) | |||
396 | dprintk("NFSD: expire_client cl_count %d\n", | 397 | dprintk("NFSD: expire_client cl_count %d\n", |
397 | atomic_read(&clp->cl_count)); | 398 | atomic_read(&clp->cl_count)); |
398 | 399 | ||
399 | shutdown_callback_client(clp); | ||
400 | |||
401 | INIT_LIST_HEAD(&reaplist); | 400 | INIT_LIST_HEAD(&reaplist); |
402 | spin_lock(&recall_lock); | 401 | spin_lock(&recall_lock); |
403 | while (!list_empty(&clp->cl_delegations)) { | 402 | while (!list_empty(&clp->cl_delegations)) { |
@@ -462,26 +461,28 @@ copy_cred(struct svc_cred *target, struct svc_cred *source) { | |||
462 | } | 461 | } |
463 | 462 | ||
464 | static inline int | 463 | static inline int |
465 | same_name(const char *n1, const char *n2) { | 464 | same_name(const char *n1, const char *n2) |
465 | { | ||
466 | return 0 == memcmp(n1, n2, HEXDIR_LEN); | 466 | return 0 == memcmp(n1, n2, HEXDIR_LEN); |
467 | } | 467 | } |
468 | 468 | ||
469 | static int | 469 | static int |
470 | cmp_verf(nfs4_verifier *v1, nfs4_verifier *v2) { | 470 | same_verf(nfs4_verifier *v1, nfs4_verifier *v2) |
471 | return(!memcmp(v1->data,v2->data,sizeof(v1->data))); | 471 | { |
472 | return 0 == memcmp(v1->data, v2->data, sizeof(v1->data)); | ||
472 | } | 473 | } |
473 | 474 | ||
474 | static int | 475 | static int |
475 | cmp_clid(clientid_t * cl1, clientid_t * cl2) { | 476 | same_clid(clientid_t *cl1, clientid_t *cl2) |
476 | return((cl1->cl_boot == cl2->cl_boot) && | 477 | { |
477 | (cl1->cl_id == cl2->cl_id)); | 478 | return (cl1->cl_boot == cl2->cl_boot) && (cl1->cl_id == cl2->cl_id); |
478 | } | 479 | } |
479 | 480 | ||
480 | /* XXX what about NGROUP */ | 481 | /* XXX what about NGROUP */ |
481 | static int | 482 | static int |
482 | cmp_creds(struct svc_cred *cr1, struct svc_cred *cr2){ | 483 | same_creds(struct svc_cred *cr1, struct svc_cred *cr2) |
483 | return(cr1->cr_uid == cr2->cr_uid); | 484 | { |
484 | 485 | return cr1->cr_uid == cr2->cr_uid; | |
485 | } | 486 | } |
486 | 487 | ||
487 | static void | 488 | static void |
@@ -507,7 +508,7 @@ check_name(struct xdr_netobj name) { | |||
507 | if (name.len == 0) | 508 | if (name.len == 0) |
508 | return 0; | 509 | return 0; |
509 | if (name.len > NFS4_OPAQUE_LIMIT) { | 510 | if (name.len > NFS4_OPAQUE_LIMIT) { |
510 | printk("NFSD: check_name: name too long(%d)!\n", name.len); | 511 | dprintk("NFSD: check_name: name too long(%d)!\n", name.len); |
511 | return 0; | 512 | return 0; |
512 | } | 513 | } |
513 | return 1; | 514 | return 1; |
@@ -546,7 +547,7 @@ find_confirmed_client(clientid_t *clid) | |||
546 | unsigned int idhashval = clientid_hashval(clid->cl_id); | 547 | unsigned int idhashval = clientid_hashval(clid->cl_id); |
547 | 548 | ||
548 | list_for_each_entry(clp, &conf_id_hashtbl[idhashval], cl_idhash) { | 549 | list_for_each_entry(clp, &conf_id_hashtbl[idhashval], cl_idhash) { |
549 | if (cmp_clid(&clp->cl_clientid, clid)) | 550 | if (same_clid(&clp->cl_clientid, clid)) |
550 | return clp; | 551 | return clp; |
551 | } | 552 | } |
552 | return NULL; | 553 | return NULL; |
@@ -559,7 +560,7 @@ find_unconfirmed_client(clientid_t *clid) | |||
559 | unsigned int idhashval = clientid_hashval(clid->cl_id); | 560 | unsigned int idhashval = clientid_hashval(clid->cl_id); |
560 | 561 | ||
561 | list_for_each_entry(clp, &unconf_id_hashtbl[idhashval], cl_idhash) { | 562 | list_for_each_entry(clp, &unconf_id_hashtbl[idhashval], cl_idhash) { |
562 | if (cmp_clid(&clp->cl_clientid, clid)) | 563 | if (same_clid(&clp->cl_clientid, clid)) |
563 | return clp; | 564 | return clp; |
564 | } | 565 | } |
565 | return NULL; | 566 | return NULL; |
@@ -753,7 +754,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
753 | * or different ip_address | 754 | * or different ip_address |
754 | */ | 755 | */ |
755 | status = nfserr_clid_inuse; | 756 | status = nfserr_clid_inuse; |
756 | if (!cmp_creds(&conf->cl_cred, &rqstp->rq_cred) | 757 | if (!same_creds(&conf->cl_cred, &rqstp->rq_cred) |
757 | || conf->cl_addr != sin->sin_addr.s_addr) { | 758 | || conf->cl_addr != sin->sin_addr.s_addr) { |
758 | dprintk("NFSD: setclientid: string in use by client" | 759 | dprintk("NFSD: setclientid: string in use by client" |
759 | "at %u.%u.%u.%u\n", NIPQUAD(conf->cl_addr)); | 760 | "at %u.%u.%u.%u\n", NIPQUAD(conf->cl_addr)); |
@@ -772,14 +773,8 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
772 | new = create_client(clname, dname); | 773 | new = create_client(clname, dname); |
773 | if (new == NULL) | 774 | if (new == NULL) |
774 | goto out; | 775 | goto out; |
775 | copy_verf(new, &clverifier); | ||
776 | new->cl_addr = sin->sin_addr.s_addr; | ||
777 | copy_cred(&new->cl_cred,&rqstp->rq_cred); | ||
778 | gen_clid(new); | 776 | gen_clid(new); |
779 | gen_confirm(new); | 777 | } else if (same_verf(&conf->cl_verifier, &clverifier)) { |
780 | gen_callback(new, setclid); | ||
781 | add_to_unconfirmed(new, strhashval); | ||
782 | } else if (cmp_verf(&conf->cl_verifier, &clverifier)) { | ||
783 | /* | 778 | /* |
784 | * CASE 1: | 779 | * CASE 1: |
785 | * cl_name match, confirmed, principal match | 780 | * cl_name match, confirmed, principal match |
@@ -804,13 +799,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
804 | new = create_client(clname, dname); | 799 | new = create_client(clname, dname); |
805 | if (new == NULL) | 800 | if (new == NULL) |
806 | goto out; | 801 | goto out; |
807 | copy_verf(new,&conf->cl_verifier); | ||
808 | new->cl_addr = sin->sin_addr.s_addr; | ||
809 | copy_cred(&new->cl_cred,&rqstp->rq_cred); | ||
810 | copy_clid(new, conf); | 802 | copy_clid(new, conf); |
811 | gen_confirm(new); | ||
812 | gen_callback(new, setclid); | ||
813 | add_to_unconfirmed(new,strhashval); | ||
814 | } else if (!unconf) { | 803 | } else if (!unconf) { |
815 | /* | 804 | /* |
816 | * CASE 2: | 805 | * CASE 2: |
@@ -823,14 +812,8 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
823 | new = create_client(clname, dname); | 812 | new = create_client(clname, dname); |
824 | if (new == NULL) | 813 | if (new == NULL) |
825 | goto out; | 814 | goto out; |
826 | copy_verf(new,&clverifier); | ||
827 | new->cl_addr = sin->sin_addr.s_addr; | ||
828 | copy_cred(&new->cl_cred,&rqstp->rq_cred); | ||
829 | gen_clid(new); | 815 | gen_clid(new); |
830 | gen_confirm(new); | 816 | } else if (!same_verf(&conf->cl_confirm, &unconf->cl_confirm)) { |
831 | gen_callback(new, setclid); | ||
832 | add_to_unconfirmed(new, strhashval); | ||
833 | } else if (!cmp_verf(&conf->cl_confirm, &unconf->cl_confirm)) { | ||
834 | /* | 817 | /* |
835 | * CASE3: | 818 | * CASE3: |
836 | * confirmed found (name, principal match) | 819 | * confirmed found (name, principal match) |
@@ -850,19 +833,19 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
850 | new = create_client(clname, dname); | 833 | new = create_client(clname, dname); |
851 | if (new == NULL) | 834 | if (new == NULL) |
852 | goto out; | 835 | goto out; |
853 | copy_verf(new,&clverifier); | ||
854 | new->cl_addr = sin->sin_addr.s_addr; | ||
855 | copy_cred(&new->cl_cred,&rqstp->rq_cred); | ||
856 | gen_clid(new); | 836 | gen_clid(new); |
857 | gen_confirm(new); | ||
858 | gen_callback(new, setclid); | ||
859 | add_to_unconfirmed(new, strhashval); | ||
860 | } else { | 837 | } else { |
861 | /* No cases hit !!! */ | 838 | /* No cases hit !!! */ |
862 | status = nfserr_inval; | 839 | status = nfserr_inval; |
863 | goto out; | 840 | goto out; |
864 | 841 | ||
865 | } | 842 | } |
843 | copy_verf(new, &clverifier); | ||
844 | new->cl_addr = sin->sin_addr.s_addr; | ||
845 | copy_cred(&new->cl_cred, &rqstp->rq_cred); | ||
846 | gen_confirm(new); | ||
847 | gen_callback(new, setclid); | ||
848 | add_to_unconfirmed(new, strhashval); | ||
866 | setclid->se_clientid.cl_boot = new->cl_clientid.cl_boot; | 849 | setclid->se_clientid.cl_boot = new->cl_clientid.cl_boot; |
867 | setclid->se_clientid.cl_id = new->cl_clientid.cl_id; | 850 | setclid->se_clientid.cl_id = new->cl_clientid.cl_id; |
868 | memcpy(setclid->se_confirm.data, new->cl_confirm.data, sizeof(setclid->se_confirm.data)); | 851 | memcpy(setclid->se_confirm.data, new->cl_confirm.data, sizeof(setclid->se_confirm.data)); |
@@ -910,16 +893,16 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | |||
910 | goto out; | 893 | goto out; |
911 | 894 | ||
912 | if ((conf && unconf) && | 895 | if ((conf && unconf) && |
913 | (cmp_verf(&unconf->cl_confirm, &confirm)) && | 896 | (same_verf(&unconf->cl_confirm, &confirm)) && |
914 | (cmp_verf(&conf->cl_verifier, &unconf->cl_verifier)) && | 897 | (same_verf(&conf->cl_verifier, &unconf->cl_verifier)) && |
915 | (same_name(conf->cl_recdir,unconf->cl_recdir)) && | 898 | (same_name(conf->cl_recdir,unconf->cl_recdir)) && |
916 | (!cmp_verf(&conf->cl_confirm, &unconf->cl_confirm))) { | 899 | (!same_verf(&conf->cl_confirm, &unconf->cl_confirm))) { |
917 | /* CASE 1: | 900 | /* CASE 1: |
918 | * unconf record that matches input clientid and input confirm. | 901 | * unconf record that matches input clientid and input confirm. |
919 | * conf record that matches input clientid. | 902 | * conf record that matches input clientid. |
920 | * conf and unconf records match names, verifiers | 903 | * conf and unconf records match names, verifiers |
921 | */ | 904 | */ |
922 | if (!cmp_creds(&conf->cl_cred, &unconf->cl_cred)) | 905 | if (!same_creds(&conf->cl_cred, &unconf->cl_cred)) |
923 | status = nfserr_clid_inuse; | 906 | status = nfserr_clid_inuse; |
924 | else { | 907 | else { |
925 | /* XXX: We just turn off callbacks until we can handle | 908 | /* XXX: We just turn off callbacks until we can handle |
@@ -933,7 +916,7 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | |||
933 | } | 916 | } |
934 | } else if ((conf && !unconf) || | 917 | } else if ((conf && !unconf) || |
935 | ((conf && unconf) && | 918 | ((conf && unconf) && |
936 | (!cmp_verf(&conf->cl_verifier, &unconf->cl_verifier) || | 919 | (!same_verf(&conf->cl_verifier, &unconf->cl_verifier) || |
937 | !same_name(conf->cl_recdir, unconf->cl_recdir)))) { | 920 | !same_name(conf->cl_recdir, unconf->cl_recdir)))) { |
938 | /* CASE 2: | 921 | /* CASE 2: |
939 | * conf record that matches input clientid. | 922 | * conf record that matches input clientid. |
@@ -941,18 +924,18 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | |||
941 | * unconf->cl_name or unconf->cl_verifier don't match the | 924 | * unconf->cl_name or unconf->cl_verifier don't match the |
942 | * conf record. | 925 | * conf record. |
943 | */ | 926 | */ |
944 | if (!cmp_creds(&conf->cl_cred,&rqstp->rq_cred)) | 927 | if (!same_creds(&conf->cl_cred, &rqstp->rq_cred)) |
945 | status = nfserr_clid_inuse; | 928 | status = nfserr_clid_inuse; |
946 | else | 929 | else |
947 | status = nfs_ok; | 930 | status = nfs_ok; |
948 | } else if (!conf && unconf | 931 | } else if (!conf && unconf |
949 | && cmp_verf(&unconf->cl_confirm, &confirm)) { | 932 | && same_verf(&unconf->cl_confirm, &confirm)) { |
950 | /* CASE 3: | 933 | /* CASE 3: |
951 | * conf record not found. | 934 | * conf record not found. |
952 | * unconf record found. | 935 | * unconf record found. |
953 | * unconf->cl_confirm matches input confirm | 936 | * unconf->cl_confirm matches input confirm |
954 | */ | 937 | */ |
955 | if (!cmp_creds(&unconf->cl_cred, &rqstp->rq_cred)) { | 938 | if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred)) { |
956 | status = nfserr_clid_inuse; | 939 | status = nfserr_clid_inuse; |
957 | } else { | 940 | } else { |
958 | unsigned int hash = | 941 | unsigned int hash = |
@@ -967,8 +950,8 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | |||
967 | conf = unconf; | 950 | conf = unconf; |
968 | status = nfs_ok; | 951 | status = nfs_ok; |
969 | } | 952 | } |
970 | } else if ((!conf || (conf && !cmp_verf(&conf->cl_confirm, &confirm))) | 953 | } else if ((!conf || (conf && !same_verf(&conf->cl_confirm, &confirm))) |
971 | && (!unconf || (unconf && !cmp_verf(&unconf->cl_confirm, | 954 | && (!unconf || (unconf && !same_verf(&unconf->cl_confirm, |
972 | &confirm)))) { | 955 | &confirm)))) { |
973 | /* CASE 4: | 956 | /* CASE 4: |
974 | * conf record not found, or if conf, conf->cl_confirm does not | 957 | * conf record not found, or if conf, conf->cl_confirm does not |
@@ -1019,7 +1002,7 @@ nfsd4_free_slab(struct kmem_cache **slab) | |||
1019 | *slab = NULL; | 1002 | *slab = NULL; |
1020 | } | 1003 | } |
1021 | 1004 | ||
1022 | static void | 1005 | void |
1023 | nfsd4_free_slabs(void) | 1006 | nfsd4_free_slabs(void) |
1024 | { | 1007 | { |
1025 | nfsd4_free_slab(&stateowner_slab); | 1008 | nfsd4_free_slab(&stateowner_slab); |
@@ -1207,10 +1190,12 @@ move_to_close_lru(struct nfs4_stateowner *sop) | |||
1207 | } | 1190 | } |
1208 | 1191 | ||
1209 | static int | 1192 | static int |
1210 | cmp_owner_str(struct nfs4_stateowner *sop, struct xdr_netobj *owner, clientid_t *clid) { | 1193 | same_owner_str(struct nfs4_stateowner *sop, struct xdr_netobj *owner, |
1211 | return ((sop->so_owner.len == owner->len) && | 1194 | clientid_t *clid) |
1212 | !memcmp(sop->so_owner.data, owner->data, owner->len) && | 1195 | { |
1213 | (sop->so_client->cl_clientid.cl_id == clid->cl_id)); | 1196 | return (sop->so_owner.len == owner->len) && |
1197 | 0 == memcmp(sop->so_owner.data, owner->data, owner->len) && | ||
1198 | (sop->so_client->cl_clientid.cl_id == clid->cl_id); | ||
1214 | } | 1199 | } |
1215 | 1200 | ||
1216 | static struct nfs4_stateowner * | 1201 | static struct nfs4_stateowner * |
@@ -1219,7 +1204,7 @@ find_openstateowner_str(unsigned int hashval, struct nfsd4_open *open) | |||
1219 | struct nfs4_stateowner *so = NULL; | 1204 | struct nfs4_stateowner *so = NULL; |
1220 | 1205 | ||
1221 | list_for_each_entry(so, &ownerstr_hashtbl[hashval], so_strhash) { | 1206 | list_for_each_entry(so, &ownerstr_hashtbl[hashval], so_strhash) { |
1222 | if (cmp_owner_str(so, &open->op_owner, &open->op_clientid)) | 1207 | if (same_owner_str(so, &open->op_owner, &open->op_clientid)) |
1223 | return so; | 1208 | return so; |
1224 | } | 1209 | } |
1225 | return NULL; | 1210 | return NULL; |
@@ -1360,6 +1345,7 @@ void nfsd_break_deleg_cb(struct file_lock *fl) | |||
1360 | * lock) we know the server hasn't removed the lease yet, we know | 1345 | * lock) we know the server hasn't removed the lease yet, we know |
1361 | * it's safe to take a reference: */ | 1346 | * it's safe to take a reference: */ |
1362 | atomic_inc(&dp->dl_count); | 1347 | atomic_inc(&dp->dl_count); |
1348 | atomic_inc(&dp->dl_client->cl_count); | ||
1363 | 1349 | ||
1364 | spin_lock(&recall_lock); | 1350 | spin_lock(&recall_lock); |
1365 | list_add_tail(&dp->dl_recall_lru, &del_recall_lru); | 1351 | list_add_tail(&dp->dl_recall_lru, &del_recall_lru); |
@@ -1368,8 +1354,12 @@ void nfsd_break_deleg_cb(struct file_lock *fl) | |||
1368 | /* only place dl_time is set. protected by lock_kernel*/ | 1354 | /* only place dl_time is set. protected by lock_kernel*/ |
1369 | dp->dl_time = get_seconds(); | 1355 | dp->dl_time = get_seconds(); |
1370 | 1356 | ||
1371 | /* XXX need to merge NFSD_LEASE_TIME with fs/locks.c:lease_break_time */ | 1357 | /* |
1372 | fl->fl_break_time = jiffies + NFSD_LEASE_TIME * HZ; | 1358 | * We don't want the locks code to timeout the lease for us; |
1359 | * we'll remove it ourself if the delegation isn't returned | ||
1360 | * in time. | ||
1361 | */ | ||
1362 | fl->fl_break_time = 0; | ||
1373 | 1363 | ||
1374 | t = kthread_run(do_recall, dp, "%s", "nfs4_cb_recall"); | 1364 | t = kthread_run(do_recall, dp, "%s", "nfs4_cb_recall"); |
1375 | if (IS_ERR(t)) { | 1365 | if (IS_ERR(t)) { |
@@ -1378,6 +1368,7 @@ void nfsd_break_deleg_cb(struct file_lock *fl) | |||
1378 | printk(KERN_INFO "NFSD: Callback thread failed for " | 1368 | printk(KERN_INFO "NFSD: Callback thread failed for " |
1379 | "for client (clientid %08x/%08x)\n", | 1369 | "for client (clientid %08x/%08x)\n", |
1380 | clp->cl_clientid.cl_boot, clp->cl_clientid.cl_id); | 1370 | clp->cl_clientid.cl_boot, clp->cl_clientid.cl_id); |
1371 | put_nfs4_client(dp->dl_client); | ||
1381 | nfs4_put_delegation(dp); | 1372 | nfs4_put_delegation(dp); |
1382 | } | 1373 | } |
1383 | } | 1374 | } |
@@ -1738,7 +1729,7 @@ out: | |||
1738 | if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS | 1729 | if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS |
1739 | && flag == NFS4_OPEN_DELEGATE_NONE | 1730 | && flag == NFS4_OPEN_DELEGATE_NONE |
1740 | && open->op_delegate_type != NFS4_OPEN_DELEGATE_NONE) | 1731 | && open->op_delegate_type != NFS4_OPEN_DELEGATE_NONE) |
1741 | printk("NFSD: WARNING: refusing delegation reclaim\n"); | 1732 | dprintk("NFSD: WARNING: refusing delegation reclaim\n"); |
1742 | open->op_delegate_type = flag; | 1733 | open->op_delegate_type = flag; |
1743 | } | 1734 | } |
1744 | 1735 | ||
@@ -2147,7 +2138,7 @@ nfs4_preprocess_seqid_op(struct svc_fh *current_fh, u32 seqid, stateid_t *statei | |||
2147 | *sopp = NULL; | 2138 | *sopp = NULL; |
2148 | 2139 | ||
2149 | if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) { | 2140 | if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) { |
2150 | printk("NFSD: preprocess_seqid_op: magic stateid!\n"); | 2141 | dprintk("NFSD: preprocess_seqid_op: magic stateid!\n"); |
2151 | return nfserr_bad_stateid; | 2142 | return nfserr_bad_stateid; |
2152 | } | 2143 | } |
2153 | 2144 | ||
@@ -2181,25 +2172,24 @@ nfs4_preprocess_seqid_op(struct svc_fh *current_fh, u32 seqid, stateid_t *statei | |||
2181 | lkflg = setlkflg(lock->lk_type); | 2172 | lkflg = setlkflg(lock->lk_type); |
2182 | 2173 | ||
2183 | if (lock->lk_is_new) { | 2174 | if (lock->lk_is_new) { |
2184 | if (!sop->so_is_open_owner) | 2175 | if (!sop->so_is_open_owner) |
2185 | return nfserr_bad_stateid; | 2176 | return nfserr_bad_stateid; |
2186 | if (!cmp_clid(&clp->cl_clientid, lockclid)) | 2177 | if (!same_clid(&clp->cl_clientid, lockclid)) |
2187 | return nfserr_bad_stateid; | 2178 | return nfserr_bad_stateid; |
2188 | /* stp is the open stateid */ | 2179 | /* stp is the open stateid */ |
2189 | status = nfs4_check_openmode(stp, lkflg); | 2180 | status = nfs4_check_openmode(stp, lkflg); |
2190 | if (status) | 2181 | if (status) |
2191 | return status; | 2182 | return status; |
2192 | } else { | 2183 | } else { |
2193 | /* stp is the lock stateid */ | 2184 | /* stp is the lock stateid */ |
2194 | status = nfs4_check_openmode(stp->st_openstp, lkflg); | 2185 | status = nfs4_check_openmode(stp->st_openstp, lkflg); |
2195 | if (status) | 2186 | if (status) |
2196 | return status; | 2187 | return status; |
2197 | } | 2188 | } |
2198 | |||
2199 | } | 2189 | } |
2200 | 2190 | ||
2201 | if ((flags & CHECK_FH) && nfs4_check_fh(current_fh, stp)) { | 2191 | if ((flags & CHECK_FH) && nfs4_check_fh(current_fh, stp)) { |
2202 | printk("NFSD: preprocess_seqid_op: fh-stateid mismatch!\n"); | 2192 | dprintk("NFSD: preprocess_seqid_op: fh-stateid mismatch!\n"); |
2203 | return nfserr_bad_stateid; | 2193 | return nfserr_bad_stateid; |
2204 | } | 2194 | } |
2205 | 2195 | ||
@@ -2215,22 +2205,22 @@ nfs4_preprocess_seqid_op(struct svc_fh *current_fh, u32 seqid, stateid_t *statei | |||
2215 | goto check_replay; | 2205 | goto check_replay; |
2216 | 2206 | ||
2217 | if (sop->so_confirmed && flags & CONFIRM) { | 2207 | if (sop->so_confirmed && flags & CONFIRM) { |
2218 | printk("NFSD: preprocess_seqid_op: expected" | 2208 | dprintk("NFSD: preprocess_seqid_op: expected" |
2219 | " unconfirmed stateowner!\n"); | 2209 | " unconfirmed stateowner!\n"); |
2220 | return nfserr_bad_stateid; | 2210 | return nfserr_bad_stateid; |
2221 | } | 2211 | } |
2222 | if (!sop->so_confirmed && !(flags & CONFIRM)) { | 2212 | if (!sop->so_confirmed && !(flags & CONFIRM)) { |
2223 | printk("NFSD: preprocess_seqid_op: stateowner not" | 2213 | dprintk("NFSD: preprocess_seqid_op: stateowner not" |
2224 | " confirmed yet!\n"); | 2214 | " confirmed yet!\n"); |
2225 | return nfserr_bad_stateid; | 2215 | return nfserr_bad_stateid; |
2226 | } | 2216 | } |
2227 | if (stateid->si_generation > stp->st_stateid.si_generation) { | 2217 | if (stateid->si_generation > stp->st_stateid.si_generation) { |
2228 | printk("NFSD: preprocess_seqid_op: future stateid?!\n"); | 2218 | dprintk("NFSD: preprocess_seqid_op: future stateid?!\n"); |
2229 | return nfserr_bad_stateid; | 2219 | return nfserr_bad_stateid; |
2230 | } | 2220 | } |
2231 | 2221 | ||
2232 | if (stateid->si_generation < stp->st_stateid.si_generation) { | 2222 | if (stateid->si_generation < stp->st_stateid.si_generation) { |
2233 | printk("NFSD: preprocess_seqid_op: old stateid!\n"); | 2223 | dprintk("NFSD: preprocess_seqid_op: old stateid!\n"); |
2234 | return nfserr_old_stateid; | 2224 | return nfserr_old_stateid; |
2235 | } | 2225 | } |
2236 | renew_client(sop->so_client); | 2226 | renew_client(sop->so_client); |
@@ -2242,7 +2232,7 @@ check_replay: | |||
2242 | /* indicate replay to calling function */ | 2232 | /* indicate replay to calling function */ |
2243 | return nfserr_replay_me; | 2233 | return nfserr_replay_me; |
2244 | } | 2234 | } |
2245 | printk("NFSD: preprocess_seqid_op: bad seqid (expected %d, got %d)\n", | 2235 | dprintk("NFSD: preprocess_seqid_op: bad seqid (expected %d, got %d)\n", |
2246 | sop->so_seqid, seqid); | 2236 | sop->so_seqid, seqid); |
2247 | *sopp = NULL; | 2237 | *sopp = NULL; |
2248 | return nfserr_bad_seqid; | 2238 | return nfserr_bad_seqid; |
@@ -2561,7 +2551,7 @@ find_lockstateowner_str(struct inode *inode, clientid_t *clid, | |||
2561 | struct nfs4_stateowner *op; | 2551 | struct nfs4_stateowner *op; |
2562 | 2552 | ||
2563 | list_for_each_entry(op, &lock_ownerstr_hashtbl[hashval], so_strhash) { | 2553 | list_for_each_entry(op, &lock_ownerstr_hashtbl[hashval], so_strhash) { |
2564 | if (cmp_owner_str(op, owner, clid)) | 2554 | if (same_owner_str(op, owner, clid)) |
2565 | return op; | 2555 | return op; |
2566 | } | 2556 | } |
2567 | return NULL; | 2557 | return NULL; |
@@ -2855,7 +2845,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
2855 | file_lock.fl_type = F_WRLCK; | 2845 | file_lock.fl_type = F_WRLCK; |
2856 | break; | 2846 | break; |
2857 | default: | 2847 | default: |
2858 | printk("NFSD: nfs4_lockt: bad lock type!\n"); | 2848 | dprintk("NFSD: nfs4_lockt: bad lock type!\n"); |
2859 | status = nfserr_inval; | 2849 | status = nfserr_inval; |
2860 | goto out; | 2850 | goto out; |
2861 | } | 2851 | } |
@@ -3025,7 +3015,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, | |||
3025 | INIT_LIST_HEAD(&matches); | 3015 | INIT_LIST_HEAD(&matches); |
3026 | for (i = 0; i < LOCK_HASH_SIZE; i++) { | 3016 | for (i = 0; i < LOCK_HASH_SIZE; i++) { |
3027 | list_for_each_entry(sop, &lock_ownerid_hashtbl[i], so_idhash) { | 3017 | list_for_each_entry(sop, &lock_ownerid_hashtbl[i], so_idhash) { |
3028 | if (!cmp_owner_str(sop, owner, clid)) | 3018 | if (!same_owner_str(sop, owner, clid)) |
3029 | continue; | 3019 | continue; |
3030 | list_for_each_entry(stp, &sop->so_stateids, | 3020 | list_for_each_entry(stp, &sop->so_stateids, |
3031 | st_perstateowner) { | 3021 | st_perstateowner) { |
@@ -3149,11 +3139,14 @@ nfs4_check_open_reclaim(clientid_t *clid) | |||
3149 | 3139 | ||
3150 | /* initialization to perform at module load time: */ | 3140 | /* initialization to perform at module load time: */ |
3151 | 3141 | ||
3152 | void | 3142 | int |
3153 | nfs4_state_init(void) | 3143 | nfs4_state_init(void) |
3154 | { | 3144 | { |
3155 | int i; | 3145 | int i, status; |
3156 | 3146 | ||
3147 | status = nfsd4_init_slabs(); | ||
3148 | if (status) | ||
3149 | return status; | ||
3157 | for (i = 0; i < CLIENT_HASH_SIZE; i++) { | 3150 | for (i = 0; i < CLIENT_HASH_SIZE; i++) { |
3158 | INIT_LIST_HEAD(&conf_id_hashtbl[i]); | 3151 | INIT_LIST_HEAD(&conf_id_hashtbl[i]); |
3159 | INIT_LIST_HEAD(&conf_str_hashtbl[i]); | 3152 | INIT_LIST_HEAD(&conf_str_hashtbl[i]); |
@@ -3182,6 +3175,7 @@ nfs4_state_init(void) | |||
3182 | for (i = 0; i < CLIENT_HASH_SIZE; i++) | 3175 | for (i = 0; i < CLIENT_HASH_SIZE; i++) |
3183 | INIT_LIST_HEAD(&reclaim_str_hashtbl[i]); | 3176 | INIT_LIST_HEAD(&reclaim_str_hashtbl[i]); |
3184 | reclaim_str_hashtbl_size = 0; | 3177 | reclaim_str_hashtbl_size = 0; |
3178 | return 0; | ||
3185 | } | 3179 | } |
3186 | 3180 | ||
3187 | static void | 3181 | static void |
@@ -3242,20 +3236,15 @@ __nfs4_state_start(void) | |||
3242 | set_max_delegations(); | 3236 | set_max_delegations(); |
3243 | } | 3237 | } |
3244 | 3238 | ||
3245 | int | 3239 | void |
3246 | nfs4_state_start(void) | 3240 | nfs4_state_start(void) |
3247 | { | 3241 | { |
3248 | int status; | ||
3249 | |||
3250 | if (nfs4_init) | 3242 | if (nfs4_init) |
3251 | return 0; | 3243 | return; |
3252 | status = nfsd4_init_slabs(); | ||
3253 | if (status) | ||
3254 | return status; | ||
3255 | nfsd4_load_reboot_recovery_data(); | 3244 | nfsd4_load_reboot_recovery_data(); |
3256 | __nfs4_state_start(); | 3245 | __nfs4_state_start(); |
3257 | nfs4_init = 1; | 3246 | nfs4_init = 1; |
3258 | return 0; | 3247 | return; |
3259 | } | 3248 | } |
3260 | 3249 | ||
3261 | int | 3250 | int |
@@ -3313,7 +3302,6 @@ nfs4_state_shutdown(void) | |||
3313 | nfs4_lock_state(); | 3302 | nfs4_lock_state(); |
3314 | nfs4_release_reclaim(); | 3303 | nfs4_release_reclaim(); |
3315 | __nfs4_state_shutdown(); | 3304 | __nfs4_state_shutdown(); |
3316 | nfsd4_free_slabs(); | ||
3317 | nfs4_unlock_state(); | 3305 | nfs4_unlock_state(); |
3318 | } | 3306 | } |
3319 | 3307 | ||