diff options
-rw-r--r-- | fs/nfs/client.c | 2 | ||||
-rw-r--r-- | fs/nfs/dir.c | 2 | ||||
-rw-r--r-- | fs/nfs/direct.c | 9 | ||||
-rw-r--r-- | fs/nfs/inode.c | 45 | ||||
-rw-r--r-- | fs/nfs/internal.h | 1 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 18 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 8 | ||||
-rw-r--r-- | fs/nfs/nfs4xdr.c | 2 | ||||
-rw-r--r-- | fs/nfs/read.c | 16 | ||||
-rw-r--r-- | fs/nfs/unlink.c | 2 | ||||
-rw-r--r-- | fs/nfs/write.c | 63 | ||||
-rw-r--r-- | include/linux/sunrpc/auth.h | 13 | ||||
-rw-r--r-- | include/linux/sunrpc/clnt.h | 9 | ||||
-rw-r--r-- | include/linux/sunrpc/sched.h | 41 | ||||
-rw-r--r-- | net/sunrpc/Makefile | 2 | ||||
-rw-r--r-- | net/sunrpc/auth.c | 63 | ||||
-rw-r--r-- | net/sunrpc/auth_generic.c | 157 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/auth_gss.c | 7 | ||||
-rw-r--r-- | net/sunrpc/auth_null.c | 1 | ||||
-rw-r--r-- | net/sunrpc/auth_unix.c | 57 | ||||
-rw-r--r-- | net/sunrpc/clnt.c | 8 | ||||
-rw-r--r-- | net/sunrpc/rpcb_clnt.c | 2 | ||||
-rw-r--r-- | net/sunrpc/sched.c | 264 | ||||
-rw-r--r-- | net/sunrpc/xprt.c | 45 | ||||
-rw-r--r-- | net/sunrpc/xprtsock.c | 7 |
25 files changed, 527 insertions, 317 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index c5c0175898f6..06f064d8fbbe 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -170,6 +170,8 @@ static void nfs4_shutdown_client(struct nfs_client *clp) | |||
170 | BUG_ON(!RB_EMPTY_ROOT(&clp->cl_state_owners)); | 170 | BUG_ON(!RB_EMPTY_ROOT(&clp->cl_state_owners)); |
171 | if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state)) | 171 | if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state)) |
172 | nfs_idmap_delete(clp); | 172 | nfs_idmap_delete(clp); |
173 | |||
174 | rpc_destroy_wait_queue(&clp->cl_rpcwaitq); | ||
173 | #endif | 175 | #endif |
174 | } | 176 | } |
175 | 177 | ||
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 6cea7479c5b4..d583654a0b39 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1966,7 +1966,7 @@ force_lookup: | |||
1966 | if (!NFS_PROTO(inode)->access) | 1966 | if (!NFS_PROTO(inode)->access) |
1967 | goto out_notsup; | 1967 | goto out_notsup; |
1968 | 1968 | ||
1969 | cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0); | 1969 | cred = rpc_lookup_cred(); |
1970 | if (!IS_ERR(cred)) { | 1970 | if (!IS_ERR(cred)) { |
1971 | res = nfs_do_access(inode, cred, mask); | 1971 | res = nfs_do_access(inode, cred, mask); |
1972 | put_rpccred(cred); | 1972 | put_rpccred(cred); |
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 16844f98f50e..e44200579c8d 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -280,6 +280,7 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq, | |||
280 | .rpc_client = NFS_CLIENT(inode), | 280 | .rpc_client = NFS_CLIENT(inode), |
281 | .rpc_message = &msg, | 281 | .rpc_message = &msg, |
282 | .callback_ops = &nfs_read_direct_ops, | 282 | .callback_ops = &nfs_read_direct_ops, |
283 | .workqueue = nfsiod_workqueue, | ||
283 | .flags = RPC_TASK_ASYNC, | 284 | .flags = RPC_TASK_ASYNC, |
284 | }; | 285 | }; |
285 | unsigned int pgbase; | 286 | unsigned int pgbase; |
@@ -323,7 +324,7 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq, | |||
323 | data->inode = inode; | 324 | data->inode = inode; |
324 | data->cred = msg.rpc_cred; | 325 | data->cred = msg.rpc_cred; |
325 | data->args.fh = NFS_FH(inode); | 326 | data->args.fh = NFS_FH(inode); |
326 | data->args.context = ctx; | 327 | data->args.context = get_nfs_open_context(ctx); |
327 | data->args.offset = pos; | 328 | data->args.offset = pos; |
328 | data->args.pgbase = pgbase; | 329 | data->args.pgbase = pgbase; |
329 | data->args.pages = data->pagevec; | 330 | data->args.pages = data->pagevec; |
@@ -446,6 +447,7 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq) | |||
446 | struct rpc_task_setup task_setup_data = { | 447 | struct rpc_task_setup task_setup_data = { |
447 | .rpc_client = NFS_CLIENT(inode), | 448 | .rpc_client = NFS_CLIENT(inode), |
448 | .callback_ops = &nfs_write_direct_ops, | 449 | .callback_ops = &nfs_write_direct_ops, |
450 | .workqueue = nfsiod_workqueue, | ||
449 | .flags = RPC_TASK_ASYNC, | 451 | .flags = RPC_TASK_ASYNC, |
450 | }; | 452 | }; |
451 | 453 | ||
@@ -537,6 +539,7 @@ static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq) | |||
537 | .rpc_message = &msg, | 539 | .rpc_message = &msg, |
538 | .callback_ops = &nfs_commit_direct_ops, | 540 | .callback_ops = &nfs_commit_direct_ops, |
539 | .callback_data = data, | 541 | .callback_data = data, |
542 | .workqueue = nfsiod_workqueue, | ||
540 | .flags = RPC_TASK_ASYNC, | 543 | .flags = RPC_TASK_ASYNC, |
541 | }; | 544 | }; |
542 | 545 | ||
@@ -546,6 +549,7 @@ static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq) | |||
546 | data->args.fh = NFS_FH(data->inode); | 549 | data->args.fh = NFS_FH(data->inode); |
547 | data->args.offset = 0; | 550 | data->args.offset = 0; |
548 | data->args.count = 0; | 551 | data->args.count = 0; |
552 | data->args.context = get_nfs_open_context(dreq->ctx); | ||
549 | data->res.count = 0; | 553 | data->res.count = 0; |
550 | data->res.fattr = &data->fattr; | 554 | data->res.fattr = &data->fattr; |
551 | data->res.verf = &data->verf; | 555 | data->res.verf = &data->verf; |
@@ -682,6 +686,7 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq, | |||
682 | .rpc_client = NFS_CLIENT(inode), | 686 | .rpc_client = NFS_CLIENT(inode), |
683 | .rpc_message = &msg, | 687 | .rpc_message = &msg, |
684 | .callback_ops = &nfs_write_direct_ops, | 688 | .callback_ops = &nfs_write_direct_ops, |
689 | .workqueue = nfsiod_workqueue, | ||
685 | .flags = RPC_TASK_ASYNC, | 690 | .flags = RPC_TASK_ASYNC, |
686 | }; | 691 | }; |
687 | size_t wsize = NFS_SERVER(inode)->wsize; | 692 | size_t wsize = NFS_SERVER(inode)->wsize; |
@@ -728,7 +733,7 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq, | |||
728 | data->inode = inode; | 733 | data->inode = inode; |
729 | data->cred = msg.rpc_cred; | 734 | data->cred = msg.rpc_cred; |
730 | data->args.fh = NFS_FH(inode); | 735 | data->args.fh = NFS_FH(inode); |
731 | data->args.context = ctx; | 736 | data->args.context = get_nfs_open_context(ctx); |
732 | data->args.offset = pos; | 737 | data->args.offset = pos; |
733 | data->args.pgbase = pgbase; | 738 | data->args.pgbase = pgbase; |
734 | data->args.pages = data->pagevec; | 739 | data->args.pages = data->pagevec; |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index a4c7cf2bff3a..15f787355d27 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -522,8 +522,12 @@ struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx) | |||
522 | 522 | ||
523 | static void __put_nfs_open_context(struct nfs_open_context *ctx, int wait) | 523 | static void __put_nfs_open_context(struct nfs_open_context *ctx, int wait) |
524 | { | 524 | { |
525 | struct inode *inode = ctx->path.dentry->d_inode; | 525 | struct inode *inode; |
526 | 526 | ||
527 | if (ctx == NULL) | ||
528 | return; | ||
529 | |||
530 | inode = ctx->path.dentry->d_inode; | ||
527 | if (!atomic_dec_and_lock(&ctx->count, &inode->i_lock)) | 531 | if (!atomic_dec_and_lock(&ctx->count, &inode->i_lock)) |
528 | return; | 532 | return; |
529 | list_del(&ctx->list); | 533 | list_del(&ctx->list); |
@@ -609,7 +613,7 @@ int nfs_open(struct inode *inode, struct file *filp) | |||
609 | struct nfs_open_context *ctx; | 613 | struct nfs_open_context *ctx; |
610 | struct rpc_cred *cred; | 614 | struct rpc_cred *cred; |
611 | 615 | ||
612 | cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0); | 616 | cred = rpc_lookup_cred(); |
613 | if (IS_ERR(cred)) | 617 | if (IS_ERR(cred)) |
614 | return PTR_ERR(cred); | 618 | return PTR_ERR(cred); |
615 | ctx = alloc_nfs_open_context(filp->f_path.mnt, filp->f_path.dentry, cred); | 619 | ctx = alloc_nfs_open_context(filp->f_path.mnt, filp->f_path.dentry, cred); |
@@ -1217,6 +1221,36 @@ static void nfs_destroy_inodecache(void) | |||
1217 | kmem_cache_destroy(nfs_inode_cachep); | 1221 | kmem_cache_destroy(nfs_inode_cachep); |
1218 | } | 1222 | } |
1219 | 1223 | ||
1224 | struct workqueue_struct *nfsiod_workqueue; | ||
1225 | |||
1226 | /* | ||
1227 | * start up the nfsiod workqueue | ||
1228 | */ | ||
1229 | static int nfsiod_start(void) | ||
1230 | { | ||
1231 | struct workqueue_struct *wq; | ||
1232 | dprintk("RPC: creating workqueue nfsiod\n"); | ||
1233 | wq = create_singlethread_workqueue("nfsiod"); | ||
1234 | if (wq == NULL) | ||
1235 | return -ENOMEM; | ||
1236 | nfsiod_workqueue = wq; | ||
1237 | return 0; | ||
1238 | } | ||
1239 | |||
1240 | /* | ||
1241 | * Destroy the nfsiod workqueue | ||
1242 | */ | ||
1243 | static void nfsiod_stop(void) | ||
1244 | { | ||
1245 | struct workqueue_struct *wq; | ||
1246 | |||
1247 | wq = nfsiod_workqueue; | ||
1248 | if (wq == NULL) | ||
1249 | return; | ||
1250 | nfsiod_workqueue = NULL; | ||
1251 | destroy_workqueue(wq); | ||
1252 | } | ||
1253 | |||
1220 | /* | 1254 | /* |
1221 | * Initialize NFS | 1255 | * Initialize NFS |
1222 | */ | 1256 | */ |
@@ -1224,6 +1258,10 @@ static int __init init_nfs_fs(void) | |||
1224 | { | 1258 | { |
1225 | int err; | 1259 | int err; |
1226 | 1260 | ||
1261 | err = nfsiod_start(); | ||
1262 | if (err) | ||
1263 | goto out6; | ||
1264 | |||
1227 | err = nfs_fs_proc_init(); | 1265 | err = nfs_fs_proc_init(); |
1228 | if (err) | 1266 | if (err) |
1229 | goto out5; | 1267 | goto out5; |
@@ -1270,6 +1308,8 @@ out3: | |||
1270 | out4: | 1308 | out4: |
1271 | nfs_fs_proc_exit(); | 1309 | nfs_fs_proc_exit(); |
1272 | out5: | 1310 | out5: |
1311 | nfsiod_stop(); | ||
1312 | out6: | ||
1273 | return err; | 1313 | return err; |
1274 | } | 1314 | } |
1275 | 1315 | ||
@@ -1285,6 +1325,7 @@ static void __exit exit_nfs_fs(void) | |||
1285 | #endif | 1325 | #endif |
1286 | unregister_nfs_fs(); | 1326 | unregister_nfs_fs(); |
1287 | nfs_fs_proc_exit(); | 1327 | nfs_fs_proc_exit(); |
1328 | nfsiod_stop(); | ||
1288 | } | 1329 | } |
1289 | 1330 | ||
1290 | /* Not quite true; I just maintain it */ | 1331 | /* Not quite true; I just maintain it */ |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 931992763e68..4c1122a13844 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -146,6 +146,7 @@ extern struct rpc_procinfo nfs4_procedures[]; | |||
146 | extern int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask); | 146 | extern int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask); |
147 | 147 | ||
148 | /* inode.c */ | 148 | /* inode.c */ |
149 | extern struct workqueue_struct *nfsiod_workqueue; | ||
149 | extern struct inode *nfs_alloc_inode(struct super_block *sb); | 150 | extern struct inode *nfs_alloc_inode(struct super_block *sb); |
150 | extern void nfs_destroy_inode(struct inode *); | 151 | extern void nfs_destroy_inode(struct inode *); |
151 | extern int nfs_write_inode(struct inode *,int); | 152 | extern int nfs_write_inode(struct inode *,int); |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 7ce07862c2fb..f38d0573be18 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -51,6 +51,7 @@ | |||
51 | 51 | ||
52 | #include "nfs4_fs.h" | 52 | #include "nfs4_fs.h" |
53 | #include "delegation.h" | 53 | #include "delegation.h" |
54 | #include "internal.h" | ||
54 | #include "iostat.h" | 55 | #include "iostat.h" |
55 | 56 | ||
56 | #define NFSDBG_FACILITY NFSDBG_PROC | 57 | #define NFSDBG_FACILITY NFSDBG_PROC |
@@ -773,6 +774,7 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data) | |||
773 | .rpc_message = &msg, | 774 | .rpc_message = &msg, |
774 | .callback_ops = &nfs4_open_confirm_ops, | 775 | .callback_ops = &nfs4_open_confirm_ops, |
775 | .callback_data = data, | 776 | .callback_data = data, |
777 | .workqueue = nfsiod_workqueue, | ||
776 | .flags = RPC_TASK_ASYNC, | 778 | .flags = RPC_TASK_ASYNC, |
777 | }; | 779 | }; |
778 | int status; | 780 | int status; |
@@ -910,6 +912,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) | |||
910 | .rpc_message = &msg, | 912 | .rpc_message = &msg, |
911 | .callback_ops = &nfs4_open_ops, | 913 | .callback_ops = &nfs4_open_ops, |
912 | .callback_data = data, | 914 | .callback_data = data, |
915 | .workqueue = nfsiod_workqueue, | ||
913 | .flags = RPC_TASK_ASYNC, | 916 | .flags = RPC_TASK_ASYNC, |
914 | }; | 917 | }; |
915 | int status; | 918 | int status; |
@@ -1315,6 +1318,7 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait) | |||
1315 | .rpc_client = server->client, | 1318 | .rpc_client = server->client, |
1316 | .rpc_message = &msg, | 1319 | .rpc_message = &msg, |
1317 | .callback_ops = &nfs4_close_ops, | 1320 | .callback_ops = &nfs4_close_ops, |
1321 | .workqueue = nfsiod_workqueue, | ||
1318 | .flags = RPC_TASK_ASYNC, | 1322 | .flags = RPC_TASK_ASYNC, |
1319 | }; | 1323 | }; |
1320 | int status = -ENOMEM; | 1324 | int status = -ENOMEM; |
@@ -1404,7 +1408,7 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | |||
1404 | BUG_ON(nd->intent.open.flags & O_CREAT); | 1408 | BUG_ON(nd->intent.open.flags & O_CREAT); |
1405 | } | 1409 | } |
1406 | 1410 | ||
1407 | cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0); | 1411 | cred = rpc_lookup_cred(); |
1408 | if (IS_ERR(cred)) | 1412 | if (IS_ERR(cred)) |
1409 | return (struct dentry *)cred; | 1413 | return (struct dentry *)cred; |
1410 | parent = dentry->d_parent; | 1414 | parent = dentry->d_parent; |
@@ -1439,7 +1443,7 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st | |||
1439 | struct rpc_cred *cred; | 1443 | struct rpc_cred *cred; |
1440 | struct nfs4_state *state; | 1444 | struct nfs4_state *state; |
1441 | 1445 | ||
1442 | cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0); | 1446 | cred = rpc_lookup_cred(); |
1443 | if (IS_ERR(cred)) | 1447 | if (IS_ERR(cred)) |
1444 | return PTR_ERR(cred); | 1448 | return PTR_ERR(cred); |
1445 | state = nfs4_do_open(dir, &path, openflags, NULL, cred); | 1449 | state = nfs4_do_open(dir, &path, openflags, NULL, cred); |
@@ -1656,7 +1660,7 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | |||
1656 | 1660 | ||
1657 | nfs_fattr_init(fattr); | 1661 | nfs_fattr_init(fattr); |
1658 | 1662 | ||
1659 | cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0); | 1663 | cred = rpc_lookup_cred(); |
1660 | if (IS_ERR(cred)) | 1664 | if (IS_ERR(cred)) |
1661 | return PTR_ERR(cred); | 1665 | return PTR_ERR(cred); |
1662 | 1666 | ||
@@ -1892,7 +1896,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
1892 | struct rpc_cred *cred; | 1896 | struct rpc_cred *cred; |
1893 | int status = 0; | 1897 | int status = 0; |
1894 | 1898 | ||
1895 | cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0); | 1899 | cred = rpc_lookup_cred(); |
1896 | if (IS_ERR(cred)) { | 1900 | if (IS_ERR(cred)) { |
1897 | status = PTR_ERR(cred); | 1901 | status = PTR_ERR(cred); |
1898 | goto out; | 1902 | goto out; |
@@ -2761,10 +2765,10 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server) | |||
2761 | case -NFS4ERR_STALE_CLIENTID: | 2765 | case -NFS4ERR_STALE_CLIENTID: |
2762 | case -NFS4ERR_STALE_STATEID: | 2766 | case -NFS4ERR_STALE_STATEID: |
2763 | case -NFS4ERR_EXPIRED: | 2767 | case -NFS4ERR_EXPIRED: |
2764 | rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL, NULL); | 2768 | rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL); |
2765 | nfs4_schedule_state_recovery(clp); | 2769 | nfs4_schedule_state_recovery(clp); |
2766 | if (test_bit(NFS4CLNT_STATE_RECOVER, &clp->cl_state) == 0) | 2770 | if (test_bit(NFS4CLNT_STATE_RECOVER, &clp->cl_state) == 0) |
2767 | rpc_wake_up_task(task); | 2771 | rpc_wake_up_queued_task(&clp->cl_rpcwaitq, task); |
2768 | task->tk_status = 0; | 2772 | task->tk_status = 0; |
2769 | return -EAGAIN; | 2773 | return -EAGAIN; |
2770 | case -NFS4ERR_DELAY: | 2774 | case -NFS4ERR_DELAY: |
@@ -3235,6 +3239,7 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl, | |||
3235 | .rpc_client = NFS_CLIENT(lsp->ls_state->inode), | 3239 | .rpc_client = NFS_CLIENT(lsp->ls_state->inode), |
3236 | .rpc_message = &msg, | 3240 | .rpc_message = &msg, |
3237 | .callback_ops = &nfs4_locku_ops, | 3241 | .callback_ops = &nfs4_locku_ops, |
3242 | .workqueue = nfsiod_workqueue, | ||
3238 | .flags = RPC_TASK_ASYNC, | 3243 | .flags = RPC_TASK_ASYNC, |
3239 | }; | 3244 | }; |
3240 | 3245 | ||
@@ -3419,6 +3424,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f | |||
3419 | .rpc_client = NFS_CLIENT(state->inode), | 3424 | .rpc_client = NFS_CLIENT(state->inode), |
3420 | .rpc_message = &msg, | 3425 | .rpc_message = &msg, |
3421 | .callback_ops = &nfs4_lock_ops, | 3426 | .callback_ops = &nfs4_lock_ops, |
3427 | .workqueue = nfsiod_workqueue, | ||
3422 | .flags = RPC_TASK_ASYNC, | 3428 | .flags = RPC_TASK_ASYNC, |
3423 | }; | 3429 | }; |
3424 | int ret; | 3430 | int ret; |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index b962397004c1..7775435ea7a5 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -292,8 +292,10 @@ struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server, struct | |||
292 | spin_unlock(&clp->cl_lock); | 292 | spin_unlock(&clp->cl_lock); |
293 | if (sp == new) | 293 | if (sp == new) |
294 | get_rpccred(cred); | 294 | get_rpccred(cred); |
295 | else | 295 | else { |
296 | rpc_destroy_wait_queue(&new->so_sequence.wait); | ||
296 | kfree(new); | 297 | kfree(new); |
298 | } | ||
297 | return sp; | 299 | return sp; |
298 | } | 300 | } |
299 | 301 | ||
@@ -310,6 +312,7 @@ void nfs4_put_state_owner(struct nfs4_state_owner *sp) | |||
310 | return; | 312 | return; |
311 | nfs4_remove_state_owner(clp, sp); | 313 | nfs4_remove_state_owner(clp, sp); |
312 | spin_unlock(&clp->cl_lock); | 314 | spin_unlock(&clp->cl_lock); |
315 | rpc_destroy_wait_queue(&sp->so_sequence.wait); | ||
313 | put_rpccred(cred); | 316 | put_rpccred(cred); |
314 | kfree(sp); | 317 | kfree(sp); |
315 | } | 318 | } |
@@ -529,6 +532,7 @@ static void nfs4_free_lock_state(struct nfs4_lock_state *lsp) | |||
529 | spin_lock(&clp->cl_lock); | 532 | spin_lock(&clp->cl_lock); |
530 | nfs_free_unique_id(&clp->cl_lockowner_id, &lsp->ls_id); | 533 | nfs_free_unique_id(&clp->cl_lockowner_id, &lsp->ls_id); |
531 | spin_unlock(&clp->cl_lock); | 534 | spin_unlock(&clp->cl_lock); |
535 | rpc_destroy_wait_queue(&lsp->ls_sequence.wait); | ||
532 | kfree(lsp); | 536 | kfree(lsp); |
533 | } | 537 | } |
534 | 538 | ||
@@ -731,7 +735,7 @@ int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task) | |||
731 | list_add_tail(&seqid->list, &sequence->list); | 735 | list_add_tail(&seqid->list, &sequence->list); |
732 | if (list_first_entry(&sequence->list, struct nfs_seqid, list) == seqid) | 736 | if (list_first_entry(&sequence->list, struct nfs_seqid, list) == seqid) |
733 | goto unlock; | 737 | goto unlock; |
734 | rpc_sleep_on(&sequence->wait, task, NULL, NULL); | 738 | rpc_sleep_on(&sequence->wait, task, NULL); |
735 | status = -EAGAIN; | 739 | status = -EAGAIN; |
736 | unlock: | 740 | unlock: |
737 | spin_unlock(&sequence->lock); | 741 | spin_unlock(&sequence->lock); |
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index db1ed9c46ede..37421dd4805d 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -110,7 +110,7 @@ static int nfs4_stat_to_errno(int); | |||
110 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) | 110 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) |
111 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) | 111 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
112 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) | 112 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) |
113 | #define encode_fsinfo_maxsz (op_encode_hdr_maxsz + 2) | 113 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
114 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + 11) | 114 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + 11) |
115 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) | 115 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
116 | #define decode_renew_maxsz (op_decode_hdr_maxsz) | 116 | #define decode_renew_maxsz (op_decode_hdr_maxsz) |
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 5a70be589bbe..ab2f7d233e01 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -58,22 +58,19 @@ struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount) | |||
58 | return p; | 58 | return p; |
59 | } | 59 | } |
60 | 60 | ||
61 | static void nfs_readdata_rcu_free(struct rcu_head *head) | 61 | static void nfs_readdata_free(struct nfs_read_data *p) |
62 | { | 62 | { |
63 | struct nfs_read_data *p = container_of(head, struct nfs_read_data, task.u.tk_rcu); | ||
64 | if (p && (p->pagevec != &p->page_array[0])) | 63 | if (p && (p->pagevec != &p->page_array[0])) |
65 | kfree(p->pagevec); | 64 | kfree(p->pagevec); |
66 | mempool_free(p, nfs_rdata_mempool); | 65 | mempool_free(p, nfs_rdata_mempool); |
67 | } | 66 | } |
68 | 67 | ||
69 | static void nfs_readdata_free(struct nfs_read_data *rdata) | ||
70 | { | ||
71 | call_rcu_bh(&rdata->task.u.tk_rcu, nfs_readdata_rcu_free); | ||
72 | } | ||
73 | |||
74 | void nfs_readdata_release(void *data) | 68 | void nfs_readdata_release(void *data) |
75 | { | 69 | { |
76 | nfs_readdata_free(data); | 70 | struct nfs_read_data *rdata = data; |
71 | |||
72 | put_nfs_open_context(rdata->args.context); | ||
73 | nfs_readdata_free(rdata); | ||
77 | } | 74 | } |
78 | 75 | ||
79 | static | 76 | static |
@@ -174,6 +171,7 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data, | |||
174 | .rpc_message = &msg, | 171 | .rpc_message = &msg, |
175 | .callback_ops = call_ops, | 172 | .callback_ops = call_ops, |
176 | .callback_data = data, | 173 | .callback_data = data, |
174 | .workqueue = nfsiod_workqueue, | ||
177 | .flags = RPC_TASK_ASYNC | swap_flags, | 175 | .flags = RPC_TASK_ASYNC | swap_flags, |
178 | }; | 176 | }; |
179 | 177 | ||
@@ -186,7 +184,7 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data, | |||
186 | data->args.pgbase = req->wb_pgbase + offset; | 184 | data->args.pgbase = req->wb_pgbase + offset; |
187 | data->args.pages = data->pagevec; | 185 | data->args.pages = data->pagevec; |
188 | data->args.count = count; | 186 | data->args.count = count; |
189 | data->args.context = req->wb_context; | 187 | data->args.context = get_nfs_open_context(req->wb_context); |
190 | 188 | ||
191 | data->res.fattr = &data->fattr; | 189 | data->res.fattr = &data->fattr; |
192 | data->res.count = count; | 190 | data->res.count = count; |
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 757415363422..3adf8b266461 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c | |||
@@ -234,7 +234,7 @@ nfs_async_unlink(struct inode *dir, struct dentry *dentry) | |||
234 | if (data == NULL) | 234 | if (data == NULL) |
235 | goto out; | 235 | goto out; |
236 | 236 | ||
237 | data->cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0); | 237 | data->cred = rpc_lookup_cred(); |
238 | if (IS_ERR(data->cred)) { | 238 | if (IS_ERR(data->cred)) { |
239 | status = PTR_ERR(data->cred); | 239 | status = PTR_ERR(data->cred); |
240 | goto out_free; | 240 | goto out_free; |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index bed63416a55b..4cb88df12f83 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -59,19 +59,13 @@ struct nfs_write_data *nfs_commit_alloc(void) | |||
59 | return p; | 59 | return p; |
60 | } | 60 | } |
61 | 61 | ||
62 | static void nfs_commit_rcu_free(struct rcu_head *head) | 62 | void nfs_commit_free(struct nfs_write_data *p) |
63 | { | 63 | { |
64 | struct nfs_write_data *p = container_of(head, struct nfs_write_data, task.u.tk_rcu); | ||
65 | if (p && (p->pagevec != &p->page_array[0])) | 64 | if (p && (p->pagevec != &p->page_array[0])) |
66 | kfree(p->pagevec); | 65 | kfree(p->pagevec); |
67 | mempool_free(p, nfs_commit_mempool); | 66 | mempool_free(p, nfs_commit_mempool); |
68 | } | 67 | } |
69 | 68 | ||
70 | void nfs_commit_free(struct nfs_write_data *wdata) | ||
71 | { | ||
72 | call_rcu_bh(&wdata->task.u.tk_rcu, nfs_commit_rcu_free); | ||
73 | } | ||
74 | |||
75 | struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount) | 69 | struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount) |
76 | { | 70 | { |
77 | struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, GFP_NOFS); | 71 | struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, GFP_NOFS); |
@@ -93,21 +87,18 @@ struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount) | |||
93 | return p; | 87 | return p; |
94 | } | 88 | } |
95 | 89 | ||
96 | static void nfs_writedata_rcu_free(struct rcu_head *head) | 90 | static void nfs_writedata_free(struct nfs_write_data *p) |
97 | { | 91 | { |
98 | struct nfs_write_data *p = container_of(head, struct nfs_write_data, task.u.tk_rcu); | ||
99 | if (p && (p->pagevec != &p->page_array[0])) | 92 | if (p && (p->pagevec != &p->page_array[0])) |
100 | kfree(p->pagevec); | 93 | kfree(p->pagevec); |
101 | mempool_free(p, nfs_wdata_mempool); | 94 | mempool_free(p, nfs_wdata_mempool); |
102 | } | 95 | } |
103 | 96 | ||
104 | static void nfs_writedata_free(struct nfs_write_data *wdata) | 97 | void nfs_writedata_release(void *data) |
105 | { | 98 | { |
106 | call_rcu_bh(&wdata->task.u.tk_rcu, nfs_writedata_rcu_free); | 99 | struct nfs_write_data *wdata = data; |
107 | } | ||
108 | 100 | ||
109 | void nfs_writedata_release(void *wdata) | 101 | put_nfs_open_context(wdata->args.context); |
110 | { | ||
111 | nfs_writedata_free(wdata); | 102 | nfs_writedata_free(wdata); |
112 | } | 103 | } |
113 | 104 | ||
@@ -366,15 +357,13 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) | |||
366 | /* | 357 | /* |
367 | * Insert a write request into an inode | 358 | * Insert a write request into an inode |
368 | */ | 359 | */ |
369 | static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req) | 360 | static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req) |
370 | { | 361 | { |
371 | struct nfs_inode *nfsi = NFS_I(inode); | 362 | struct nfs_inode *nfsi = NFS_I(inode); |
372 | int error; | 363 | int error; |
373 | 364 | ||
374 | error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req); | 365 | error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req); |
375 | BUG_ON(error == -EEXIST); | 366 | BUG_ON(error); |
376 | if (error) | ||
377 | return error; | ||
378 | if (!nfsi->npages) { | 367 | if (!nfsi->npages) { |
379 | igrab(inode); | 368 | igrab(inode); |
380 | if (nfs_have_delegation(inode, FMODE_WRITE)) | 369 | if (nfs_have_delegation(inode, FMODE_WRITE)) |
@@ -384,8 +373,8 @@ static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req) | |||
384 | set_page_private(req->wb_page, (unsigned long)req); | 373 | set_page_private(req->wb_page, (unsigned long)req); |
385 | nfsi->npages++; | 374 | nfsi->npages++; |
386 | kref_get(&req->wb_kref); | 375 | kref_get(&req->wb_kref); |
387 | radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); | 376 | radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, |
388 | return 0; | 377 | NFS_PAGE_TAG_LOCKED); |
389 | } | 378 | } |
390 | 379 | ||
391 | /* | 380 | /* |
@@ -597,6 +586,13 @@ static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx, | |||
597 | /* Loop over all inode entries and see if we find | 586 | /* Loop over all inode entries and see if we find |
598 | * A request for the page we wish to update | 587 | * A request for the page we wish to update |
599 | */ | 588 | */ |
589 | if (new) { | ||
590 | if (radix_tree_preload(GFP_NOFS)) { | ||
591 | nfs_release_request(new); | ||
592 | return ERR_PTR(-ENOMEM); | ||
593 | } | ||
594 | } | ||
595 | |||
600 | spin_lock(&inode->i_lock); | 596 | spin_lock(&inode->i_lock); |
601 | req = nfs_page_find_request_locked(page); | 597 | req = nfs_page_find_request_locked(page); |
602 | if (req) { | 598 | if (req) { |
@@ -607,28 +603,27 @@ static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx, | |||
607 | error = nfs_wait_on_request(req); | 603 | error = nfs_wait_on_request(req); |
608 | nfs_release_request(req); | 604 | nfs_release_request(req); |
609 | if (error < 0) { | 605 | if (error < 0) { |
610 | if (new) | 606 | if (new) { |
607 | radix_tree_preload_end(); | ||
611 | nfs_release_request(new); | 608 | nfs_release_request(new); |
609 | } | ||
612 | return ERR_PTR(error); | 610 | return ERR_PTR(error); |
613 | } | 611 | } |
614 | continue; | 612 | continue; |
615 | } | 613 | } |
616 | spin_unlock(&inode->i_lock); | 614 | spin_unlock(&inode->i_lock); |
617 | if (new) | 615 | if (new) { |
616 | radix_tree_preload_end(); | ||
618 | nfs_release_request(new); | 617 | nfs_release_request(new); |
618 | } | ||
619 | break; | 619 | break; |
620 | } | 620 | } |
621 | 621 | ||
622 | if (new) { | 622 | if (new) { |
623 | int error; | ||
624 | nfs_lock_request_dontget(new); | 623 | nfs_lock_request_dontget(new); |
625 | error = nfs_inode_add_request(inode, new); | 624 | nfs_inode_add_request(inode, new); |
626 | if (error) { | ||
627 | spin_unlock(&inode->i_lock); | ||
628 | nfs_unlock_request(new); | ||
629 | return ERR_PTR(error); | ||
630 | } | ||
631 | spin_unlock(&inode->i_lock); | 625 | spin_unlock(&inode->i_lock); |
626 | radix_tree_preload_end(); | ||
632 | req = new; | 627 | req = new; |
633 | goto zero_page; | 628 | goto zero_page; |
634 | } | 629 | } |
@@ -806,6 +801,7 @@ static void nfs_write_rpcsetup(struct nfs_page *req, | |||
806 | .rpc_message = &msg, | 801 | .rpc_message = &msg, |
807 | .callback_ops = call_ops, | 802 | .callback_ops = call_ops, |
808 | .callback_data = data, | 803 | .callback_data = data, |
804 | .workqueue = nfsiod_workqueue, | ||
809 | .flags = flags, | 805 | .flags = flags, |
810 | .priority = priority, | 806 | .priority = priority, |
811 | }; | 807 | }; |
@@ -822,7 +818,7 @@ static void nfs_write_rpcsetup(struct nfs_page *req, | |||
822 | data->args.pgbase = req->wb_pgbase + offset; | 818 | data->args.pgbase = req->wb_pgbase + offset; |
823 | data->args.pages = data->pagevec; | 819 | data->args.pages = data->pagevec; |
824 | data->args.count = count; | 820 | data->args.count = count; |
825 | data->args.context = req->wb_context; | 821 | data->args.context = get_nfs_open_context(req->wb_context); |
826 | data->args.stable = NFS_UNSTABLE; | 822 | data->args.stable = NFS_UNSTABLE; |
827 | if (how & FLUSH_STABLE) { | 823 | if (how & FLUSH_STABLE) { |
828 | data->args.stable = NFS_DATA_SYNC; | 824 | data->args.stable = NFS_DATA_SYNC; |
@@ -1159,8 +1155,11 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) | |||
1159 | 1155 | ||
1160 | 1156 | ||
1161 | #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) | 1157 | #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) |
1162 | void nfs_commit_release(void *wdata) | 1158 | void nfs_commit_release(void *data) |
1163 | { | 1159 | { |
1160 | struct nfs_write_data *wdata = data; | ||
1161 | |||
1162 | put_nfs_open_context(wdata->args.context); | ||
1164 | nfs_commit_free(wdata); | 1163 | nfs_commit_free(wdata); |
1165 | } | 1164 | } |
1166 | 1165 | ||
@@ -1187,6 +1186,7 @@ static void nfs_commit_rpcsetup(struct list_head *head, | |||
1187 | .rpc_message = &msg, | 1186 | .rpc_message = &msg, |
1188 | .callback_ops = &nfs_commit_ops, | 1187 | .callback_ops = &nfs_commit_ops, |
1189 | .callback_data = data, | 1188 | .callback_data = data, |
1189 | .workqueue = nfsiod_workqueue, | ||
1190 | .flags = flags, | 1190 | .flags = flags, |
1191 | .priority = priority, | 1191 | .priority = priority, |
1192 | }; | 1192 | }; |
@@ -1203,6 +1203,7 @@ static void nfs_commit_rpcsetup(struct list_head *head, | |||
1203 | /* Note: we always request a commit of the entire inode */ | 1203 | /* Note: we always request a commit of the entire inode */ |
1204 | data->args.offset = 0; | 1204 | data->args.offset = 0; |
1205 | data->args.count = 0; | 1205 | data->args.count = 0; |
1206 | data->args.context = get_nfs_open_context(first->wb_context); | ||
1206 | data->res.count = 0; | 1207 | data->res.count = 0; |
1207 | data->res.fattr = &data->fattr; | 1208 | data->res.fattr = &data->fattr; |
1208 | data->res.verf = &data->verf; | 1209 | data->res.verf = &data->verf; |
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index 7a69ca3bebaf..e93cd8aa3eb6 100644 --- a/include/linux/sunrpc/auth.h +++ b/include/linux/sunrpc/auth.h | |||
@@ -59,8 +59,8 @@ struct rpc_cred { | |||
59 | /* | 59 | /* |
60 | * Client authentication handle | 60 | * Client authentication handle |
61 | */ | 61 | */ |
62 | #define RPC_CREDCACHE_NR 8 | 62 | #define RPC_CREDCACHE_HASHBITS 4 |
63 | #define RPC_CREDCACHE_MASK (RPC_CREDCACHE_NR - 1) | 63 | #define RPC_CREDCACHE_NR (1 << RPC_CREDCACHE_HASHBITS) |
64 | struct rpc_cred_cache { | 64 | struct rpc_cred_cache { |
65 | struct hlist_head hashtable[RPC_CREDCACHE_NR]; | 65 | struct hlist_head hashtable[RPC_CREDCACHE_NR]; |
66 | spinlock_t lock; | 66 | spinlock_t lock; |
@@ -89,7 +89,6 @@ struct rpc_auth { | |||
89 | 89 | ||
90 | /* Flags for rpcauth_lookupcred() */ | 90 | /* Flags for rpcauth_lookupcred() */ |
91 | #define RPCAUTH_LOOKUP_NEW 0x01 /* Accept an uninitialised cred */ | 91 | #define RPCAUTH_LOOKUP_NEW 0x01 /* Accept an uninitialised cred */ |
92 | #define RPCAUTH_LOOKUP_ROOTCREDS 0x02 /* This really ought to go! */ | ||
93 | 92 | ||
94 | /* | 93 | /* |
95 | * Client authentication ops | 94 | * Client authentication ops |
@@ -113,6 +112,7 @@ struct rpc_credops { | |||
113 | void (*crdestroy)(struct rpc_cred *); | 112 | void (*crdestroy)(struct rpc_cred *); |
114 | 113 | ||
115 | int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); | 114 | int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); |
115 | void (*crbind)(struct rpc_task *, struct rpc_cred *); | ||
116 | __be32 * (*crmarshal)(struct rpc_task *, __be32 *); | 116 | __be32 * (*crmarshal)(struct rpc_task *, __be32 *); |
117 | int (*crrefresh)(struct rpc_task *); | 117 | int (*crrefresh)(struct rpc_task *); |
118 | __be32 * (*crvalidate)(struct rpc_task *, __be32 *); | 118 | __be32 * (*crvalidate)(struct rpc_task *, __be32 *); |
@@ -126,9 +126,12 @@ extern const struct rpc_authops authunix_ops; | |||
126 | extern const struct rpc_authops authnull_ops; | 126 | extern const struct rpc_authops authnull_ops; |
127 | 127 | ||
128 | void __init rpc_init_authunix(void); | 128 | void __init rpc_init_authunix(void); |
129 | void __init rpc_init_generic_auth(void); | ||
129 | void __init rpcauth_init_module(void); | 130 | void __init rpcauth_init_module(void); |
130 | void __exit rpcauth_remove_module(void); | 131 | void __exit rpcauth_remove_module(void); |
132 | void __exit rpc_destroy_generic_auth(void); | ||
131 | 133 | ||
134 | struct rpc_cred * rpc_lookup_cred(void); | ||
132 | int rpcauth_register(const struct rpc_authops *); | 135 | int rpcauth_register(const struct rpc_authops *); |
133 | int rpcauth_unregister(const struct rpc_authops *); | 136 | int rpcauth_unregister(const struct rpc_authops *); |
134 | struct rpc_auth * rpcauth_create(rpc_authflavor_t, struct rpc_clnt *); | 137 | struct rpc_auth * rpcauth_create(rpc_authflavor_t, struct rpc_clnt *); |
@@ -136,8 +139,8 @@ void rpcauth_release(struct rpc_auth *); | |||
136 | struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int); | 139 | struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int); |
137 | void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); | 140 | void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); |
138 | struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); | 141 | struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); |
139 | struct rpc_cred * rpcauth_bindcred(struct rpc_task *); | 142 | void rpcauth_bindcred(struct rpc_task *, struct rpc_cred *, int); |
140 | void rpcauth_holdcred(struct rpc_task *); | 143 | void rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *); |
141 | void put_rpccred(struct rpc_cred *); | 144 | void put_rpccred(struct rpc_cred *); |
142 | void rpcauth_unbindcred(struct rpc_task *); | 145 | void rpcauth_unbindcred(struct rpc_task *); |
143 | __be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); | 146 | __be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); |
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 129a86e25d29..6fff7f82ef12 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h | |||
@@ -127,11 +127,12 @@ int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int); | |||
127 | void rpcb_getport_async(struct rpc_task *); | 127 | void rpcb_getport_async(struct rpc_task *); |
128 | 128 | ||
129 | void rpc_call_start(struct rpc_task *); | 129 | void rpc_call_start(struct rpc_task *); |
130 | int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, | 130 | int rpc_call_async(struct rpc_clnt *clnt, |
131 | int flags, const struct rpc_call_ops *tk_ops, | 131 | const struct rpc_message *msg, int flags, |
132 | const struct rpc_call_ops *tk_ops, | ||
132 | void *calldata); | 133 | void *calldata); |
133 | int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, | 134 | int rpc_call_sync(struct rpc_clnt *clnt, |
134 | int flags); | 135 | const struct rpc_message *msg, int flags); |
135 | struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, | 136 | struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, |
136 | int flags); | 137 | int flags); |
137 | void rpc_restart_call(struct rpc_task *); | 138 | void rpc_restart_call(struct rpc_task *); |
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index f689f02e6793..d1a5c8c1a0f1 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | #include <linux/timer.h> | 12 | #include <linux/timer.h> |
13 | #include <linux/sunrpc/types.h> | 13 | #include <linux/sunrpc/types.h> |
14 | #include <linux/rcupdate.h> | ||
15 | #include <linux/spinlock.h> | 14 | #include <linux/spinlock.h> |
16 | #include <linux/wait.h> | 15 | #include <linux/wait.h> |
17 | #include <linux/workqueue.h> | 16 | #include <linux/workqueue.h> |
@@ -33,7 +32,8 @@ struct rpc_wait_queue; | |||
33 | struct rpc_wait { | 32 | struct rpc_wait { |
34 | struct list_head list; /* wait queue links */ | 33 | struct list_head list; /* wait queue links */ |
35 | struct list_head links; /* Links to related tasks */ | 34 | struct list_head links; /* Links to related tasks */ |
36 | struct rpc_wait_queue * rpc_waitq; /* RPC wait queue we're on */ | 35 | struct list_head timer_list; /* Timer list */ |
36 | unsigned long expires; | ||
37 | }; | 37 | }; |
38 | 38 | ||
39 | /* | 39 | /* |
@@ -57,33 +57,25 @@ struct rpc_task { | |||
57 | __u8 tk_cred_retry; | 57 | __u8 tk_cred_retry; |
58 | 58 | ||
59 | /* | 59 | /* |
60 | * timeout_fn to be executed by timer bottom half | ||
61 | * callback to be executed after waking up | 60 | * callback to be executed after waking up |
62 | * action next procedure for async tasks | 61 | * action next procedure for async tasks |
63 | * tk_ops caller callbacks | 62 | * tk_ops caller callbacks |
64 | */ | 63 | */ |
65 | void (*tk_timeout_fn)(struct rpc_task *); | ||
66 | void (*tk_callback)(struct rpc_task *); | 64 | void (*tk_callback)(struct rpc_task *); |
67 | void (*tk_action)(struct rpc_task *); | 65 | void (*tk_action)(struct rpc_task *); |
68 | const struct rpc_call_ops *tk_ops; | 66 | const struct rpc_call_ops *tk_ops; |
69 | void * tk_calldata; | 67 | void * tk_calldata; |
70 | 68 | ||
71 | /* | ||
72 | * tk_timer is used for async processing by the RPC scheduling | ||
73 | * primitives. You should not access this directly unless | ||
74 | * you have a pathological interest in kernel oopses. | ||
75 | */ | ||
76 | struct timer_list tk_timer; /* kernel timer */ | ||
77 | unsigned long tk_timeout; /* timeout for rpc_sleep() */ | 69 | unsigned long tk_timeout; /* timeout for rpc_sleep() */ |
78 | unsigned short tk_flags; /* misc flags */ | 70 | unsigned short tk_flags; /* misc flags */ |
79 | unsigned long tk_runstate; /* Task run status */ | 71 | unsigned long tk_runstate; /* Task run status */ |
80 | struct workqueue_struct *tk_workqueue; /* Normally rpciod, but could | 72 | struct workqueue_struct *tk_workqueue; /* Normally rpciod, but could |
81 | * be any workqueue | 73 | * be any workqueue |
82 | */ | 74 | */ |
75 | struct rpc_wait_queue *tk_waitqueue; /* RPC wait queue we're on */ | ||
83 | union { | 76 | union { |
84 | struct work_struct tk_work; /* Async task work queue */ | 77 | struct work_struct tk_work; /* Async task work queue */ |
85 | struct rpc_wait tk_wait; /* RPC wait */ | 78 | struct rpc_wait tk_wait; /* RPC wait */ |
86 | struct rcu_head tk_rcu; /* for task deletion */ | ||
87 | } u; | 79 | } u; |
88 | 80 | ||
89 | unsigned short tk_timeouts; /* maj timeouts */ | 81 | unsigned short tk_timeouts; /* maj timeouts */ |
@@ -123,6 +115,7 @@ struct rpc_task_setup { | |||
123 | const struct rpc_message *rpc_message; | 115 | const struct rpc_message *rpc_message; |
124 | const struct rpc_call_ops *callback_ops; | 116 | const struct rpc_call_ops *callback_ops; |
125 | void *callback_data; | 117 | void *callback_data; |
118 | struct workqueue_struct *workqueue; | ||
126 | unsigned short flags; | 119 | unsigned short flags; |
127 | signed char priority; | 120 | signed char priority; |
128 | }; | 121 | }; |
@@ -147,9 +140,7 @@ struct rpc_task_setup { | |||
147 | 140 | ||
148 | #define RPC_TASK_RUNNING 0 | 141 | #define RPC_TASK_RUNNING 0 |
149 | #define RPC_TASK_QUEUED 1 | 142 | #define RPC_TASK_QUEUED 1 |
150 | #define RPC_TASK_WAKEUP 2 | 143 | #define RPC_TASK_ACTIVE 2 |
151 | #define RPC_TASK_HAS_TIMER 3 | ||
152 | #define RPC_TASK_ACTIVE 4 | ||
153 | 144 | ||
154 | #define RPC_IS_RUNNING(t) test_bit(RPC_TASK_RUNNING, &(t)->tk_runstate) | 145 | #define RPC_IS_RUNNING(t) test_bit(RPC_TASK_RUNNING, &(t)->tk_runstate) |
155 | #define rpc_set_running(t) set_bit(RPC_TASK_RUNNING, &(t)->tk_runstate) | 146 | #define rpc_set_running(t) set_bit(RPC_TASK_RUNNING, &(t)->tk_runstate) |
@@ -171,15 +162,6 @@ struct rpc_task_setup { | |||
171 | smp_mb__after_clear_bit(); \ | 162 | smp_mb__after_clear_bit(); \ |
172 | } while (0) | 163 | } while (0) |
173 | 164 | ||
174 | #define rpc_start_wakeup(t) \ | ||
175 | (test_and_set_bit(RPC_TASK_WAKEUP, &(t)->tk_runstate) == 0) | ||
176 | #define rpc_finish_wakeup(t) \ | ||
177 | do { \ | ||
178 | smp_mb__before_clear_bit(); \ | ||
179 | clear_bit(RPC_TASK_WAKEUP, &(t)->tk_runstate); \ | ||
180 | smp_mb__after_clear_bit(); \ | ||
181 | } while (0) | ||
182 | |||
183 | #define RPC_IS_ACTIVATED(t) test_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate) | 165 | #define RPC_IS_ACTIVATED(t) test_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate) |
184 | 166 | ||
185 | /* | 167 | /* |
@@ -192,6 +174,12 @@ struct rpc_task_setup { | |||
192 | #define RPC_PRIORITY_HIGH (1) | 174 | #define RPC_PRIORITY_HIGH (1) |
193 | #define RPC_NR_PRIORITY (1 + RPC_PRIORITY_HIGH - RPC_PRIORITY_LOW) | 175 | #define RPC_NR_PRIORITY (1 + RPC_PRIORITY_HIGH - RPC_PRIORITY_LOW) |
194 | 176 | ||
177 | struct rpc_timer { | ||
178 | struct timer_list timer; | ||
179 | struct list_head list; | ||
180 | unsigned long expires; | ||
181 | }; | ||
182 | |||
195 | /* | 183 | /* |
196 | * RPC synchronization objects | 184 | * RPC synchronization objects |
197 | */ | 185 | */ |
@@ -204,6 +192,7 @@ struct rpc_wait_queue { | |||
204 | unsigned char count; /* # task groups remaining serviced so far */ | 192 | unsigned char count; /* # task groups remaining serviced so far */ |
205 | unsigned char nr; /* # tasks remaining for cookie */ | 193 | unsigned char nr; /* # tasks remaining for cookie */ |
206 | unsigned short qlen; /* total # tasks waiting in queue */ | 194 | unsigned short qlen; /* total # tasks waiting in queue */ |
195 | struct rpc_timer timer_list; | ||
207 | #ifdef RPC_DEBUG | 196 | #ifdef RPC_DEBUG |
208 | const char * name; | 197 | const char * name; |
209 | #endif | 198 | #endif |
@@ -229,9 +218,11 @@ void rpc_killall_tasks(struct rpc_clnt *); | |||
229 | void rpc_execute(struct rpc_task *); | 218 | void rpc_execute(struct rpc_task *); |
230 | void rpc_init_priority_wait_queue(struct rpc_wait_queue *, const char *); | 219 | void rpc_init_priority_wait_queue(struct rpc_wait_queue *, const char *); |
231 | void rpc_init_wait_queue(struct rpc_wait_queue *, const char *); | 220 | void rpc_init_wait_queue(struct rpc_wait_queue *, const char *); |
221 | void rpc_destroy_wait_queue(struct rpc_wait_queue *); | ||
232 | void rpc_sleep_on(struct rpc_wait_queue *, struct rpc_task *, | 222 | void rpc_sleep_on(struct rpc_wait_queue *, struct rpc_task *, |
233 | rpc_action action, rpc_action timer); | 223 | rpc_action action); |
234 | void rpc_wake_up_task(struct rpc_task *); | 224 | void rpc_wake_up_queued_task(struct rpc_wait_queue *, |
225 | struct rpc_task *); | ||
235 | void rpc_wake_up(struct rpc_wait_queue *); | 226 | void rpc_wake_up(struct rpc_wait_queue *); |
236 | struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *); | 227 | struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *); |
237 | void rpc_wake_up_status(struct rpc_wait_queue *, int); | 228 | void rpc_wake_up_status(struct rpc_wait_queue *, int); |
diff --git a/net/sunrpc/Makefile b/net/sunrpc/Makefile index 92e1dbe50947..5369aa369b35 100644 --- a/net/sunrpc/Makefile +++ b/net/sunrpc/Makefile | |||
@@ -8,7 +8,7 @@ obj-$(CONFIG_SUNRPC_GSS) += auth_gss/ | |||
8 | obj-$(CONFIG_SUNRPC_XPRT_RDMA) += xprtrdma/ | 8 | obj-$(CONFIG_SUNRPC_XPRT_RDMA) += xprtrdma/ |
9 | 9 | ||
10 | sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ | 10 | sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ |
11 | auth.o auth_null.o auth_unix.o \ | 11 | auth.o auth_null.o auth_unix.o auth_generic.o \ |
12 | svc.o svcsock.o svcauth.o svcauth_unix.o \ | 12 | svc.o svcsock.o svcauth.o svcauth_unix.o \ |
13 | rpcb_clnt.o timer.o xdr.o \ | 13 | rpcb_clnt.o timer.o xdr.o \ |
14 | sunrpc_syms.o cache.o rpc_pipe.o \ | 14 | sunrpc_syms.o cache.o rpc_pipe.o \ |
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index eca941ce298b..0632cd0a1ad7 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/hash.h> | ||
14 | #include <linux/sunrpc/clnt.h> | 15 | #include <linux/sunrpc/clnt.h> |
15 | #include <linux/spinlock.h> | 16 | #include <linux/spinlock.h> |
16 | 17 | ||
@@ -280,10 +281,9 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred, | |||
280 | struct hlist_node *pos; | 281 | struct hlist_node *pos; |
281 | struct rpc_cred *cred = NULL, | 282 | struct rpc_cred *cred = NULL, |
282 | *entry, *new; | 283 | *entry, *new; |
283 | int nr = 0; | 284 | unsigned int nr; |
284 | 285 | ||
285 | if (!(flags & RPCAUTH_LOOKUP_ROOTCREDS)) | 286 | nr = hash_long(acred->uid, RPC_CREDCACHE_HASHBITS); |
286 | nr = acred->uid & RPC_CREDCACHE_MASK; | ||
287 | 287 | ||
288 | rcu_read_lock(); | 288 | rcu_read_lock(); |
289 | hlist_for_each_entry_rcu(entry, pos, &cache->hashtable[nr], cr_hash) { | 289 | hlist_for_each_entry_rcu(entry, pos, &cache->hashtable[nr], cr_hash) { |
@@ -356,7 +356,6 @@ rpcauth_lookupcred(struct rpc_auth *auth, int flags) | |||
356 | put_group_info(acred.group_info); | 356 | put_group_info(acred.group_info); |
357 | return ret; | 357 | return ret; |
358 | } | 358 | } |
359 | EXPORT_SYMBOL_GPL(rpcauth_lookupcred); | ||
360 | 359 | ||
361 | void | 360 | void |
362 | rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred, | 361 | rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred, |
@@ -375,41 +374,58 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred, | |||
375 | } | 374 | } |
376 | EXPORT_SYMBOL_GPL(rpcauth_init_cred); | 375 | EXPORT_SYMBOL_GPL(rpcauth_init_cred); |
377 | 376 | ||
378 | struct rpc_cred * | 377 | void |
379 | rpcauth_bindcred(struct rpc_task *task) | 378 | rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred) |
379 | { | ||
380 | task->tk_msg.rpc_cred = get_rpccred(cred); | ||
381 | dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid, | ||
382 | cred->cr_auth->au_ops->au_name, cred); | ||
383 | } | ||
384 | EXPORT_SYMBOL_GPL(rpcauth_generic_bind_cred); | ||
385 | |||
386 | static void | ||
387 | rpcauth_bind_root_cred(struct rpc_task *task) | ||
380 | { | 388 | { |
381 | struct rpc_auth *auth = task->tk_client->cl_auth; | 389 | struct rpc_auth *auth = task->tk_client->cl_auth; |
382 | struct auth_cred acred = { | 390 | struct auth_cred acred = { |
383 | .uid = current->fsuid, | 391 | .uid = 0, |
384 | .gid = current->fsgid, | 392 | .gid = 0, |
385 | .group_info = current->group_info, | ||
386 | }; | 393 | }; |
387 | struct rpc_cred *ret; | 394 | struct rpc_cred *ret; |
388 | int flags = 0; | ||
389 | 395 | ||
390 | dprintk("RPC: %5u looking up %s cred\n", | 396 | dprintk("RPC: %5u looking up %s cred\n", |
391 | task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); | 397 | task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); |
392 | get_group_info(acred.group_info); | 398 | ret = auth->au_ops->lookup_cred(auth, &acred, 0); |
393 | if (task->tk_flags & RPC_TASK_ROOTCREDS) | 399 | if (!IS_ERR(ret)) |
394 | flags |= RPCAUTH_LOOKUP_ROOTCREDS; | 400 | task->tk_msg.rpc_cred = ret; |
395 | ret = auth->au_ops->lookup_cred(auth, &acred, flags); | 401 | else |
402 | task->tk_status = PTR_ERR(ret); | ||
403 | } | ||
404 | |||
405 | static void | ||
406 | rpcauth_bind_new_cred(struct rpc_task *task) | ||
407 | { | ||
408 | struct rpc_auth *auth = task->tk_client->cl_auth; | ||
409 | struct rpc_cred *ret; | ||
410 | |||
411 | dprintk("RPC: %5u looking up %s cred\n", | ||
412 | task->tk_pid, auth->au_ops->au_name); | ||
413 | ret = rpcauth_lookupcred(auth, 0); | ||
396 | if (!IS_ERR(ret)) | 414 | if (!IS_ERR(ret)) |
397 | task->tk_msg.rpc_cred = ret; | 415 | task->tk_msg.rpc_cred = ret; |
398 | else | 416 | else |
399 | task->tk_status = PTR_ERR(ret); | 417 | task->tk_status = PTR_ERR(ret); |
400 | put_group_info(acred.group_info); | ||
401 | return ret; | ||
402 | } | 418 | } |
403 | 419 | ||
404 | void | 420 | void |
405 | rpcauth_holdcred(struct rpc_task *task) | 421 | rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) |
406 | { | 422 | { |
407 | struct rpc_cred *cred = task->tk_msg.rpc_cred; | 423 | if (cred != NULL) |
408 | if (cred != NULL) { | 424 | cred->cr_ops->crbind(task, cred); |
409 | get_rpccred(cred); | 425 | else if (flags & RPC_TASK_ROOTCREDS) |
410 | dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid, | 426 | rpcauth_bind_root_cred(task); |
411 | cred->cr_auth->au_ops->au_name, cred); | 427 | else |
412 | } | 428 | rpcauth_bind_new_cred(task); |
413 | } | 429 | } |
414 | 430 | ||
415 | void | 431 | void |
@@ -550,6 +566,7 @@ static struct shrinker rpc_cred_shrinker = { | |||
550 | void __init rpcauth_init_module(void) | 566 | void __init rpcauth_init_module(void) |
551 | { | 567 | { |
552 | rpc_init_authunix(); | 568 | rpc_init_authunix(); |
569 | rpc_init_generic_auth(); | ||
553 | register_shrinker(&rpc_cred_shrinker); | 570 | register_shrinker(&rpc_cred_shrinker); |
554 | } | 571 | } |
555 | 572 | ||
diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c new file mode 100644 index 000000000000..6a3f77c9e4d3 --- /dev/null +++ b/net/sunrpc/auth_generic.c | |||
@@ -0,0 +1,157 @@ | |||
1 | /* | ||
2 | * Generic RPC credential | ||
3 | * | ||
4 | * Copyright (C) 2008, Trond Myklebust <Trond.Myklebust@netapp.com> | ||
5 | */ | ||
6 | |||
7 | #include <linux/err.h> | ||
8 | #include <linux/types.h> | ||
9 | #include <linux/module.h> | ||
10 | #include <linux/sched.h> | ||
11 | #include <linux/sunrpc/auth.h> | ||
12 | #include <linux/sunrpc/clnt.h> | ||
13 | #include <linux/sunrpc/debug.h> | ||
14 | #include <linux/sunrpc/sched.h> | ||
15 | |||
16 | #ifdef RPC_DEBUG | ||
17 | # define RPCDBG_FACILITY RPCDBG_AUTH | ||
18 | #endif | ||
19 | |||
20 | struct generic_cred { | ||
21 | struct rpc_cred gc_base; | ||
22 | struct auth_cred acred; | ||
23 | }; | ||
24 | |||
25 | static struct rpc_auth generic_auth; | ||
26 | static struct rpc_cred_cache generic_cred_cache; | ||
27 | static const struct rpc_credops generic_credops; | ||
28 | |||
29 | /* | ||
30 | * Public call interface | ||
31 | */ | ||
32 | struct rpc_cred *rpc_lookup_cred(void) | ||
33 | { | ||
34 | return rpcauth_lookupcred(&generic_auth, 0); | ||
35 | } | ||
36 | EXPORT_SYMBOL_GPL(rpc_lookup_cred); | ||
37 | |||
38 | static void | ||
39 | generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred) | ||
40 | { | ||
41 | struct rpc_auth *auth = task->tk_client->cl_auth; | ||
42 | struct auth_cred *acred = &container_of(cred, struct generic_cred, gc_base)->acred; | ||
43 | struct rpc_cred *ret; | ||
44 | |||
45 | ret = auth->au_ops->lookup_cred(auth, acred, 0); | ||
46 | if (!IS_ERR(ret)) | ||
47 | task->tk_msg.rpc_cred = ret; | ||
48 | else | ||
49 | task->tk_status = PTR_ERR(ret); | ||
50 | } | ||
51 | |||
52 | /* | ||
53 | * Lookup generic creds for current process | ||
54 | */ | ||
55 | static struct rpc_cred * | ||
56 | generic_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) | ||
57 | { | ||
58 | return rpcauth_lookup_credcache(&generic_auth, acred, flags); | ||
59 | } | ||
60 | |||
61 | static struct rpc_cred * | ||
62 | generic_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) | ||
63 | { | ||
64 | struct generic_cred *gcred; | ||
65 | |||
66 | gcred = kmalloc(sizeof(*gcred), GFP_KERNEL); | ||
67 | if (gcred == NULL) | ||
68 | return ERR_PTR(-ENOMEM); | ||
69 | |||
70 | rpcauth_init_cred(&gcred->gc_base, acred, &generic_auth, &generic_credops); | ||
71 | gcred->gc_base.cr_flags = 1UL << RPCAUTH_CRED_UPTODATE; | ||
72 | |||
73 | gcred->acred.uid = acred->uid; | ||
74 | gcred->acred.gid = acred->gid; | ||
75 | gcred->acred.group_info = acred->group_info; | ||
76 | if (gcred->acred.group_info != NULL) | ||
77 | get_group_info(gcred->acred.group_info); | ||
78 | |||
79 | dprintk("RPC: allocated generic cred %p for uid %d gid %d\n", | ||
80 | gcred, acred->uid, acred->gid); | ||
81 | return &gcred->gc_base; | ||
82 | } | ||
83 | |||
84 | static void | ||
85 | generic_free_cred(struct rpc_cred *cred) | ||
86 | { | ||
87 | struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base); | ||
88 | |||
89 | dprintk("RPC: generic_free_cred %p\n", gcred); | ||
90 | if (gcred->acred.group_info != NULL) | ||
91 | put_group_info(gcred->acred.group_info); | ||
92 | kfree(gcred); | ||
93 | } | ||
94 | |||
95 | static void | ||
96 | generic_free_cred_callback(struct rcu_head *head) | ||
97 | { | ||
98 | struct rpc_cred *cred = container_of(head, struct rpc_cred, cr_rcu); | ||
99 | generic_free_cred(cred); | ||
100 | } | ||
101 | |||
102 | static void | ||
103 | generic_destroy_cred(struct rpc_cred *cred) | ||
104 | { | ||
105 | call_rcu(&cred->cr_rcu, generic_free_cred_callback); | ||
106 | } | ||
107 | |||
108 | /* | ||
109 | * Match credentials against current process creds. | ||
110 | */ | ||
111 | static int | ||
112 | generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags) | ||
113 | { | ||
114 | struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base); | ||
115 | |||
116 | if (gcred->acred.uid != acred->uid || | ||
117 | gcred->acred.gid != acred->gid || | ||
118 | gcred->acred.group_info != acred->group_info) | ||
119 | return 0; | ||
120 | return 1; | ||
121 | } | ||
122 | |||
123 | void __init rpc_init_generic_auth(void) | ||
124 | { | ||
125 | spin_lock_init(&generic_cred_cache.lock); | ||
126 | } | ||
127 | |||
128 | void __exit rpc_destroy_generic_auth(void) | ||
129 | { | ||
130 | rpcauth_clear_credcache(&generic_cred_cache); | ||
131 | } | ||
132 | |||
133 | static struct rpc_cred_cache generic_cred_cache = { | ||
134 | {{ NULL, },}, | ||
135 | }; | ||
136 | |||
137 | static const struct rpc_authops generic_auth_ops = { | ||
138 | .owner = THIS_MODULE, | ||
139 | #ifdef RPC_DEBUG | ||
140 | .au_name = "Generic", | ||
141 | #endif | ||
142 | .lookup_cred = generic_lookup_cred, | ||
143 | .crcreate = generic_create_cred, | ||
144 | }; | ||
145 | |||
146 | static struct rpc_auth generic_auth = { | ||
147 | .au_ops = &generic_auth_ops, | ||
148 | .au_count = ATOMIC_INIT(0), | ||
149 | .au_credcache = &generic_cred_cache, | ||
150 | }; | ||
151 | |||
152 | static const struct rpc_credops generic_credops = { | ||
153 | .cr_name = "Generic cred", | ||
154 | .crdestroy = generic_destroy_cred, | ||
155 | .crbind = generic_bind_cred, | ||
156 | .crmatch = generic_match, | ||
157 | }; | ||
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 6dac38792288..d34f6dfc7516 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
@@ -266,6 +266,7 @@ gss_release_msg(struct gss_upcall_msg *gss_msg) | |||
266 | BUG_ON(!list_empty(&gss_msg->list)); | 266 | BUG_ON(!list_empty(&gss_msg->list)); |
267 | if (gss_msg->ctx != NULL) | 267 | if (gss_msg->ctx != NULL) |
268 | gss_put_ctx(gss_msg->ctx); | 268 | gss_put_ctx(gss_msg->ctx); |
269 | rpc_destroy_wait_queue(&gss_msg->rpc_waitqueue); | ||
269 | kfree(gss_msg); | 270 | kfree(gss_msg); |
270 | } | 271 | } |
271 | 272 | ||
@@ -408,13 +409,13 @@ gss_refresh_upcall(struct rpc_task *task) | |||
408 | } | 409 | } |
409 | spin_lock(&inode->i_lock); | 410 | spin_lock(&inode->i_lock); |
410 | if (gss_cred->gc_upcall != NULL) | 411 | if (gss_cred->gc_upcall != NULL) |
411 | rpc_sleep_on(&gss_cred->gc_upcall->rpc_waitqueue, task, NULL, NULL); | 412 | rpc_sleep_on(&gss_cred->gc_upcall->rpc_waitqueue, task, NULL); |
412 | else if (gss_msg->ctx == NULL && gss_msg->msg.errno >= 0) { | 413 | else if (gss_msg->ctx == NULL && gss_msg->msg.errno >= 0) { |
413 | task->tk_timeout = 0; | 414 | task->tk_timeout = 0; |
414 | gss_cred->gc_upcall = gss_msg; | 415 | gss_cred->gc_upcall = gss_msg; |
415 | /* gss_upcall_callback will release the reference to gss_upcall_msg */ | 416 | /* gss_upcall_callback will release the reference to gss_upcall_msg */ |
416 | atomic_inc(&gss_msg->count); | 417 | atomic_inc(&gss_msg->count); |
417 | rpc_sleep_on(&gss_msg->rpc_waitqueue, task, gss_upcall_callback, NULL); | 418 | rpc_sleep_on(&gss_msg->rpc_waitqueue, task, gss_upcall_callback); |
418 | } else | 419 | } else |
419 | err = gss_msg->msg.errno; | 420 | err = gss_msg->msg.errno; |
420 | spin_unlock(&inode->i_lock); | 421 | spin_unlock(&inode->i_lock); |
@@ -1299,6 +1300,7 @@ static const struct rpc_credops gss_credops = { | |||
1299 | .cr_name = "AUTH_GSS", | 1300 | .cr_name = "AUTH_GSS", |
1300 | .crdestroy = gss_destroy_cred, | 1301 | .crdestroy = gss_destroy_cred, |
1301 | .cr_init = gss_cred_init, | 1302 | .cr_init = gss_cred_init, |
1303 | .crbind = rpcauth_generic_bind_cred, | ||
1302 | .crmatch = gss_match, | 1304 | .crmatch = gss_match, |
1303 | .crmarshal = gss_marshal, | 1305 | .crmarshal = gss_marshal, |
1304 | .crrefresh = gss_refresh, | 1306 | .crrefresh = gss_refresh, |
@@ -1310,6 +1312,7 @@ static const struct rpc_credops gss_credops = { | |||
1310 | static const struct rpc_credops gss_nullops = { | 1312 | static const struct rpc_credops gss_nullops = { |
1311 | .cr_name = "AUTH_GSS", | 1313 | .cr_name = "AUTH_GSS", |
1312 | .crdestroy = gss_destroy_cred, | 1314 | .crdestroy = gss_destroy_cred, |
1315 | .crbind = rpcauth_generic_bind_cred, | ||
1313 | .crmatch = gss_match, | 1316 | .crmatch = gss_match, |
1314 | .crmarshal = gss_marshal, | 1317 | .crmarshal = gss_marshal, |
1315 | .crrefresh = gss_refresh_null, | 1318 | .crrefresh = gss_refresh_null, |
diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c index 537d0e8589dd..3c26c18df0de 100644 --- a/net/sunrpc/auth_null.c +++ b/net/sunrpc/auth_null.c | |||
@@ -125,6 +125,7 @@ static | |||
125 | const struct rpc_credops null_credops = { | 125 | const struct rpc_credops null_credops = { |
126 | .cr_name = "AUTH_NULL", | 126 | .cr_name = "AUTH_NULL", |
127 | .crdestroy = nul_destroy_cred, | 127 | .crdestroy = nul_destroy_cred, |
128 | .crbind = rpcauth_generic_bind_cred, | ||
128 | .crmatch = nul_match, | 129 | .crmatch = nul_match, |
129 | .crmarshal = nul_marshal, | 130 | .crmarshal = nul_marshal, |
130 | .crrefresh = nul_refresh, | 131 | .crrefresh = nul_refresh, |
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index 5ed91e5bcee4..04e936a56fb2 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c | |||
@@ -60,7 +60,8 @@ static struct rpc_cred * | |||
60 | unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) | 60 | unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) |
61 | { | 61 | { |
62 | struct unx_cred *cred; | 62 | struct unx_cred *cred; |
63 | int i; | 63 | unsigned int groups = 0; |
64 | unsigned int i; | ||
64 | 65 | ||
65 | dprintk("RPC: allocating UNIX cred for uid %d gid %d\n", | 66 | dprintk("RPC: allocating UNIX cred for uid %d gid %d\n", |
66 | acred->uid, acred->gid); | 67 | acred->uid, acred->gid); |
@@ -70,21 +71,17 @@ unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) | |||
70 | 71 | ||
71 | rpcauth_init_cred(&cred->uc_base, acred, auth, &unix_credops); | 72 | rpcauth_init_cred(&cred->uc_base, acred, auth, &unix_credops); |
72 | cred->uc_base.cr_flags = 1UL << RPCAUTH_CRED_UPTODATE; | 73 | cred->uc_base.cr_flags = 1UL << RPCAUTH_CRED_UPTODATE; |
73 | if (flags & RPCAUTH_LOOKUP_ROOTCREDS) { | 74 | |
74 | cred->uc_uid = 0; | 75 | if (acred->group_info != NULL) |
75 | cred->uc_gid = 0; | 76 | groups = acred->group_info->ngroups; |
76 | cred->uc_gids[0] = NOGROUP; | 77 | if (groups > NFS_NGROUPS) |
77 | } else { | 78 | groups = NFS_NGROUPS; |
78 | int groups = acred->group_info->ngroups; | 79 | |
79 | if (groups > NFS_NGROUPS) | 80 | cred->uc_gid = acred->gid; |
80 | groups = NFS_NGROUPS; | 81 | for (i = 0; i < groups; i++) |
81 | 82 | cred->uc_gids[i] = GROUP_AT(acred->group_info, i); | |
82 | cred->uc_gid = acred->gid; | 83 | if (i < NFS_NGROUPS) |
83 | for (i = 0; i < groups; i++) | 84 | cred->uc_gids[i] = NOGROUP; |
84 | cred->uc_gids[i] = GROUP_AT(acred->group_info, i); | ||
85 | if (i < NFS_NGROUPS) | ||
86 | cred->uc_gids[i] = NOGROUP; | ||
87 | } | ||
88 | 85 | ||
89 | return &cred->uc_base; | 86 | return &cred->uc_base; |
90 | } | 87 | } |
@@ -118,26 +115,21 @@ static int | |||
118 | unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags) | 115 | unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags) |
119 | { | 116 | { |
120 | struct unx_cred *cred = container_of(rcred, struct unx_cred, uc_base); | 117 | struct unx_cred *cred = container_of(rcred, struct unx_cred, uc_base); |
121 | int i; | 118 | unsigned int groups = 0; |
119 | unsigned int i; | ||
122 | 120 | ||
123 | if (!(flags & RPCAUTH_LOOKUP_ROOTCREDS)) { | ||
124 | int groups; | ||
125 | 121 | ||
126 | if (cred->uc_uid != acred->uid | 122 | if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid) |
127 | || cred->uc_gid != acred->gid) | 123 | return 0; |
128 | return 0; | ||
129 | 124 | ||
125 | if (acred->group_info != NULL) | ||
130 | groups = acred->group_info->ngroups; | 126 | groups = acred->group_info->ngroups; |
131 | if (groups > NFS_NGROUPS) | 127 | if (groups > NFS_NGROUPS) |
132 | groups = NFS_NGROUPS; | 128 | groups = NFS_NGROUPS; |
133 | for (i = 0; i < groups ; i++) | 129 | for (i = 0; i < groups ; i++) |
134 | if (cred->uc_gids[i] != GROUP_AT(acred->group_info, i)) | 130 | if (cred->uc_gids[i] != GROUP_AT(acred->group_info, i)) |
135 | return 0; | 131 | return 0; |
136 | return 1; | 132 | return 1; |
137 | } | ||
138 | return (cred->uc_uid == 0 | ||
139 | && cred->uc_gid == 0 | ||
140 | && cred->uc_gids[0] == (gid_t) NOGROUP); | ||
141 | } | 133 | } |
142 | 134 | ||
143 | /* | 135 | /* |
@@ -245,6 +237,7 @@ static | |||
245 | const struct rpc_credops unix_credops = { | 237 | const struct rpc_credops unix_credops = { |
246 | .cr_name = "AUTH_UNIX", | 238 | .cr_name = "AUTH_UNIX", |
247 | .crdestroy = unx_destroy_cred, | 239 | .crdestroy = unx_destroy_cred, |
240 | .crbind = rpcauth_generic_bind_cred, | ||
248 | .crmatch = unx_match, | 241 | .crmatch = unx_match, |
249 | .crmarshal = unx_marshal, | 242 | .crmarshal = unx_marshal, |
250 | .crrefresh = unx_refresh, | 243 | .crrefresh = unx_refresh, |
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 8c6a7f1a25e9..ea14314331b0 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -548,7 +548,7 @@ EXPORT_SYMBOL_GPL(rpc_run_task); | |||
548 | * @msg: RPC call parameters | 548 | * @msg: RPC call parameters |
549 | * @flags: RPC call flags | 549 | * @flags: RPC call flags |
550 | */ | 550 | */ |
551 | int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) | 551 | int rpc_call_sync(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags) |
552 | { | 552 | { |
553 | struct rpc_task *task; | 553 | struct rpc_task *task; |
554 | struct rpc_task_setup task_setup_data = { | 554 | struct rpc_task_setup task_setup_data = { |
@@ -579,7 +579,7 @@ EXPORT_SYMBOL_GPL(rpc_call_sync); | |||
579 | * @data: user call data | 579 | * @data: user call data |
580 | */ | 580 | */ |
581 | int | 581 | int |
582 | rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags, | 582 | rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags, |
583 | const struct rpc_call_ops *tk_ops, void *data) | 583 | const struct rpc_call_ops *tk_ops, void *data) |
584 | { | 584 | { |
585 | struct rpc_task *task; | 585 | struct rpc_task *task; |
@@ -1066,7 +1066,7 @@ call_transmit(struct rpc_task *task) | |||
1066 | if (task->tk_msg.rpc_proc->p_decode != NULL) | 1066 | if (task->tk_msg.rpc_proc->p_decode != NULL) |
1067 | return; | 1067 | return; |
1068 | task->tk_action = rpc_exit_task; | 1068 | task->tk_action = rpc_exit_task; |
1069 | rpc_wake_up_task(task); | 1069 | rpc_wake_up_queued_task(&task->tk_xprt->pending, task); |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | /* | 1072 | /* |
@@ -1535,7 +1535,7 @@ void rpc_show_tasks(void) | |||
1535 | proc = -1; | 1535 | proc = -1; |
1536 | 1536 | ||
1537 | if (RPC_IS_QUEUED(t)) | 1537 | if (RPC_IS_QUEUED(t)) |
1538 | rpc_waitq = rpc_qname(t->u.tk_wait.rpc_waitq); | 1538 | rpc_waitq = rpc_qname(t->tk_waitqueue); |
1539 | 1539 | ||
1540 | printk("%5u %04d %04x %6d %8p %6d %8p %8ld %8s %8p %8p\n", | 1540 | printk("%5u %04d %04x %6d %8p %6d %8p %8ld %8s %8p %8p\n", |
1541 | t->tk_pid, proc, | 1541 | t->tk_pid, proc, |
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index 3164a0871cf0..f480c718b400 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c | |||
@@ -298,7 +298,7 @@ void rpcb_getport_async(struct rpc_task *task) | |||
298 | 298 | ||
299 | /* Put self on queue before sending rpcbind request, in case | 299 | /* Put self on queue before sending rpcbind request, in case |
300 | * rpcb_getport_done completes before we return from rpc_run_task */ | 300 | * rpcb_getport_done completes before we return from rpc_run_task */ |
301 | rpc_sleep_on(&xprt->binding, task, NULL, NULL); | 301 | rpc_sleep_on(&xprt->binding, task, NULL); |
302 | 302 | ||
303 | /* Someone else may have bound if we slept */ | 303 | /* Someone else may have bound if we slept */ |
304 | if (xprt_bound(xprt)) { | 304 | if (xprt_bound(xprt)) { |
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 4c669121e607..6eab9bf94baf 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
@@ -38,9 +38,9 @@ static struct kmem_cache *rpc_buffer_slabp __read_mostly; | |||
38 | static mempool_t *rpc_task_mempool __read_mostly; | 38 | static mempool_t *rpc_task_mempool __read_mostly; |
39 | static mempool_t *rpc_buffer_mempool __read_mostly; | 39 | static mempool_t *rpc_buffer_mempool __read_mostly; |
40 | 40 | ||
41 | static void __rpc_default_timer(struct rpc_task *task); | ||
42 | static void rpc_async_schedule(struct work_struct *); | 41 | static void rpc_async_schedule(struct work_struct *); |
43 | static void rpc_release_task(struct rpc_task *task); | 42 | static void rpc_release_task(struct rpc_task *task); |
43 | static void __rpc_queue_timer_fn(unsigned long ptr); | ||
44 | 44 | ||
45 | /* | 45 | /* |
46 | * RPC tasks sit here while waiting for conditions to improve. | 46 | * RPC tasks sit here while waiting for conditions to improve. |
@@ -57,41 +57,30 @@ struct workqueue_struct *rpciod_workqueue; | |||
57 | * queue->lock and bh_disabled in order to avoid races within | 57 | * queue->lock and bh_disabled in order to avoid races within |
58 | * rpc_run_timer(). | 58 | * rpc_run_timer(). |
59 | */ | 59 | */ |
60 | static inline void | 60 | static void |
61 | __rpc_disable_timer(struct rpc_task *task) | 61 | __rpc_disable_timer(struct rpc_wait_queue *queue, struct rpc_task *task) |
62 | { | 62 | { |
63 | if (task->tk_timeout == 0) | ||
64 | return; | ||
63 | dprintk("RPC: %5u disabling timer\n", task->tk_pid); | 65 | dprintk("RPC: %5u disabling timer\n", task->tk_pid); |
64 | task->tk_timeout_fn = NULL; | ||
65 | task->tk_timeout = 0; | 66 | task->tk_timeout = 0; |
67 | list_del(&task->u.tk_wait.timer_list); | ||
68 | if (list_empty(&queue->timer_list.list)) | ||
69 | del_timer(&queue->timer_list.timer); | ||
66 | } | 70 | } |
67 | 71 | ||
68 | /* | 72 | static void |
69 | * Run a timeout function. | 73 | rpc_set_queue_timer(struct rpc_wait_queue *queue, unsigned long expires) |
70 | * We use the callback in order to allow __rpc_wake_up_task() | ||
71 | * and friends to disable the timer synchronously on SMP systems | ||
72 | * without calling del_timer_sync(). The latter could cause a | ||
73 | * deadlock if called while we're holding spinlocks... | ||
74 | */ | ||
75 | static void rpc_run_timer(struct rpc_task *task) | ||
76 | { | 74 | { |
77 | void (*callback)(struct rpc_task *); | 75 | queue->timer_list.expires = expires; |
78 | 76 | mod_timer(&queue->timer_list.timer, expires); | |
79 | callback = task->tk_timeout_fn; | ||
80 | task->tk_timeout_fn = NULL; | ||
81 | if (callback && RPC_IS_QUEUED(task)) { | ||
82 | dprintk("RPC: %5u running timer\n", task->tk_pid); | ||
83 | callback(task); | ||
84 | } | ||
85 | smp_mb__before_clear_bit(); | ||
86 | clear_bit(RPC_TASK_HAS_TIMER, &task->tk_runstate); | ||
87 | smp_mb__after_clear_bit(); | ||
88 | } | 77 | } |
89 | 78 | ||
90 | /* | 79 | /* |
91 | * Set up a timer for the current task. | 80 | * Set up a timer for the current task. |
92 | */ | 81 | */ |
93 | static inline void | 82 | static void |
94 | __rpc_add_timer(struct rpc_task *task, rpc_action timer) | 83 | __rpc_add_timer(struct rpc_wait_queue *queue, struct rpc_task *task) |
95 | { | 84 | { |
96 | if (!task->tk_timeout) | 85 | if (!task->tk_timeout) |
97 | return; | 86 | return; |
@@ -99,27 +88,10 @@ __rpc_add_timer(struct rpc_task *task, rpc_action timer) | |||
99 | dprintk("RPC: %5u setting alarm for %lu ms\n", | 88 | dprintk("RPC: %5u setting alarm for %lu ms\n", |
100 | task->tk_pid, task->tk_timeout * 1000 / HZ); | 89 | task->tk_pid, task->tk_timeout * 1000 / HZ); |
101 | 90 | ||
102 | if (timer) | 91 | task->u.tk_wait.expires = jiffies + task->tk_timeout; |
103 | task->tk_timeout_fn = timer; | 92 | if (list_empty(&queue->timer_list.list) || time_before(task->u.tk_wait.expires, queue->timer_list.expires)) |
104 | else | 93 | rpc_set_queue_timer(queue, task->u.tk_wait.expires); |
105 | task->tk_timeout_fn = __rpc_default_timer; | 94 | list_add(&task->u.tk_wait.timer_list, &queue->timer_list.list); |
106 | set_bit(RPC_TASK_HAS_TIMER, &task->tk_runstate); | ||
107 | mod_timer(&task->tk_timer, jiffies + task->tk_timeout); | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | * Delete any timer for the current task. Because we use del_timer_sync(), | ||
112 | * this function should never be called while holding queue->lock. | ||
113 | */ | ||
114 | static void | ||
115 | rpc_delete_timer(struct rpc_task *task) | ||
116 | { | ||
117 | if (RPC_IS_QUEUED(task)) | ||
118 | return; | ||
119 | if (test_and_clear_bit(RPC_TASK_HAS_TIMER, &task->tk_runstate)) { | ||
120 | del_singleshot_timer_sync(&task->tk_timer); | ||
121 | dprintk("RPC: %5u deleting timer\n", task->tk_pid); | ||
122 | } | ||
123 | } | 95 | } |
124 | 96 | ||
125 | /* | 97 | /* |
@@ -161,7 +133,7 @@ static void __rpc_add_wait_queue(struct rpc_wait_queue *queue, struct rpc_task * | |||
161 | list_add(&task->u.tk_wait.list, &queue->tasks[0]); | 133 | list_add(&task->u.tk_wait.list, &queue->tasks[0]); |
162 | else | 134 | else |
163 | list_add_tail(&task->u.tk_wait.list, &queue->tasks[0]); | 135 | list_add_tail(&task->u.tk_wait.list, &queue->tasks[0]); |
164 | task->u.tk_wait.rpc_waitq = queue; | 136 | task->tk_waitqueue = queue; |
165 | queue->qlen++; | 137 | queue->qlen++; |
166 | rpc_set_queued(task); | 138 | rpc_set_queued(task); |
167 | 139 | ||
@@ -181,22 +153,18 @@ static void __rpc_remove_wait_queue_priority(struct rpc_task *task) | |||
181 | list_move(&t->u.tk_wait.list, &task->u.tk_wait.list); | 153 | list_move(&t->u.tk_wait.list, &task->u.tk_wait.list); |
182 | list_splice_init(&task->u.tk_wait.links, &t->u.tk_wait.links); | 154 | list_splice_init(&task->u.tk_wait.links, &t->u.tk_wait.links); |
183 | } | 155 | } |
184 | list_del(&task->u.tk_wait.list); | ||
185 | } | 156 | } |
186 | 157 | ||
187 | /* | 158 | /* |
188 | * Remove request from queue. | 159 | * Remove request from queue. |
189 | * Note: must be called with spin lock held. | 160 | * Note: must be called with spin lock held. |
190 | */ | 161 | */ |
191 | static void __rpc_remove_wait_queue(struct rpc_task *task) | 162 | static void __rpc_remove_wait_queue(struct rpc_wait_queue *queue, struct rpc_task *task) |
192 | { | 163 | { |
193 | struct rpc_wait_queue *queue; | 164 | __rpc_disable_timer(queue, task); |
194 | queue = task->u.tk_wait.rpc_waitq; | ||
195 | |||
196 | if (RPC_IS_PRIORITY(queue)) | 165 | if (RPC_IS_PRIORITY(queue)) |
197 | __rpc_remove_wait_queue_priority(task); | 166 | __rpc_remove_wait_queue_priority(task); |
198 | else | 167 | list_del(&task->u.tk_wait.list); |
199 | list_del(&task->u.tk_wait.list); | ||
200 | queue->qlen--; | 168 | queue->qlen--; |
201 | dprintk("RPC: %5u removed from queue %p \"%s\"\n", | 169 | dprintk("RPC: %5u removed from queue %p \"%s\"\n", |
202 | task->tk_pid, queue, rpc_qname(queue)); | 170 | task->tk_pid, queue, rpc_qname(queue)); |
@@ -229,6 +197,9 @@ static void __rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const c | |||
229 | INIT_LIST_HEAD(&queue->tasks[i]); | 197 | INIT_LIST_HEAD(&queue->tasks[i]); |
230 | queue->maxpriority = nr_queues - 1; | 198 | queue->maxpriority = nr_queues - 1; |
231 | rpc_reset_waitqueue_priority(queue); | 199 | rpc_reset_waitqueue_priority(queue); |
200 | queue->qlen = 0; | ||
201 | setup_timer(&queue->timer_list.timer, __rpc_queue_timer_fn, (unsigned long)queue); | ||
202 | INIT_LIST_HEAD(&queue->timer_list.list); | ||
232 | #ifdef RPC_DEBUG | 203 | #ifdef RPC_DEBUG |
233 | queue->name = qname; | 204 | queue->name = qname; |
234 | #endif | 205 | #endif |
@@ -245,6 +216,12 @@ void rpc_init_wait_queue(struct rpc_wait_queue *queue, const char *qname) | |||
245 | } | 216 | } |
246 | EXPORT_SYMBOL_GPL(rpc_init_wait_queue); | 217 | EXPORT_SYMBOL_GPL(rpc_init_wait_queue); |
247 | 218 | ||
219 | void rpc_destroy_wait_queue(struct rpc_wait_queue *queue) | ||
220 | { | ||
221 | del_timer_sync(&queue->timer_list.timer); | ||
222 | } | ||
223 | EXPORT_SYMBOL_GPL(rpc_destroy_wait_queue); | ||
224 | |||
248 | static int rpc_wait_bit_killable(void *word) | 225 | static int rpc_wait_bit_killable(void *word) |
249 | { | 226 | { |
250 | if (fatal_signal_pending(current)) | 227 | if (fatal_signal_pending(current)) |
@@ -313,7 +290,6 @@ EXPORT_SYMBOL_GPL(__rpc_wait_for_completion_task); | |||
313 | */ | 290 | */ |
314 | static void rpc_make_runnable(struct rpc_task *task) | 291 | static void rpc_make_runnable(struct rpc_task *task) |
315 | { | 292 | { |
316 | BUG_ON(task->tk_timeout_fn); | ||
317 | rpc_clear_queued(task); | 293 | rpc_clear_queued(task); |
318 | if (rpc_test_and_set_running(task)) | 294 | if (rpc_test_and_set_running(task)) |
319 | return; | 295 | return; |
@@ -326,7 +302,7 @@ static void rpc_make_runnable(struct rpc_task *task) | |||
326 | int status; | 302 | int status; |
327 | 303 | ||
328 | INIT_WORK(&task->u.tk_work, rpc_async_schedule); | 304 | INIT_WORK(&task->u.tk_work, rpc_async_schedule); |
329 | status = queue_work(task->tk_workqueue, &task->u.tk_work); | 305 | status = queue_work(rpciod_workqueue, &task->u.tk_work); |
330 | if (status < 0) { | 306 | if (status < 0) { |
331 | printk(KERN_WARNING "RPC: failed to add task to queue: error: %d!\n", status); | 307 | printk(KERN_WARNING "RPC: failed to add task to queue: error: %d!\n", status); |
332 | task->tk_status = status; | 308 | task->tk_status = status; |
@@ -343,7 +319,7 @@ static void rpc_make_runnable(struct rpc_task *task) | |||
343 | * as it's on a wait queue. | 319 | * as it's on a wait queue. |
344 | */ | 320 | */ |
345 | static void __rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task, | 321 | static void __rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task, |
346 | rpc_action action, rpc_action timer) | 322 | rpc_action action) |
347 | { | 323 | { |
348 | dprintk("RPC: %5u sleep_on(queue \"%s\" time %lu)\n", | 324 | dprintk("RPC: %5u sleep_on(queue \"%s\" time %lu)\n", |
349 | task->tk_pid, rpc_qname(q), jiffies); | 325 | task->tk_pid, rpc_qname(q), jiffies); |
@@ -357,11 +333,11 @@ static void __rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task, | |||
357 | 333 | ||
358 | BUG_ON(task->tk_callback != NULL); | 334 | BUG_ON(task->tk_callback != NULL); |
359 | task->tk_callback = action; | 335 | task->tk_callback = action; |
360 | __rpc_add_timer(task, timer); | 336 | __rpc_add_timer(q, task); |
361 | } | 337 | } |
362 | 338 | ||
363 | void rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task, | 339 | void rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task, |
364 | rpc_action action, rpc_action timer) | 340 | rpc_action action) |
365 | { | 341 | { |
366 | /* Mark the task as being activated if so needed */ | 342 | /* Mark the task as being activated if so needed */ |
367 | rpc_set_active(task); | 343 | rpc_set_active(task); |
@@ -370,18 +346,19 @@ void rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task, | |||
370 | * Protect the queue operations. | 346 | * Protect the queue operations. |
371 | */ | 347 | */ |
372 | spin_lock_bh(&q->lock); | 348 | spin_lock_bh(&q->lock); |
373 | __rpc_sleep_on(q, task, action, timer); | 349 | __rpc_sleep_on(q, task, action); |
374 | spin_unlock_bh(&q->lock); | 350 | spin_unlock_bh(&q->lock); |
375 | } | 351 | } |
376 | EXPORT_SYMBOL_GPL(rpc_sleep_on); | 352 | EXPORT_SYMBOL_GPL(rpc_sleep_on); |
377 | 353 | ||
378 | /** | 354 | /** |
379 | * __rpc_do_wake_up_task - wake up a single rpc_task | 355 | * __rpc_do_wake_up_task - wake up a single rpc_task |
356 | * @queue: wait queue | ||
380 | * @task: task to be woken up | 357 | * @task: task to be woken up |
381 | * | 358 | * |
382 | * Caller must hold queue->lock, and have cleared the task queued flag. | 359 | * Caller must hold queue->lock, and have cleared the task queued flag. |
383 | */ | 360 | */ |
384 | static void __rpc_do_wake_up_task(struct rpc_task *task) | 361 | static void __rpc_do_wake_up_task(struct rpc_wait_queue *queue, struct rpc_task *task) |
385 | { | 362 | { |
386 | dprintk("RPC: %5u __rpc_wake_up_task (now %lu)\n", | 363 | dprintk("RPC: %5u __rpc_wake_up_task (now %lu)\n", |
387 | task->tk_pid, jiffies); | 364 | task->tk_pid, jiffies); |
@@ -395,8 +372,7 @@ static void __rpc_do_wake_up_task(struct rpc_task *task) | |||
395 | return; | 372 | return; |
396 | } | 373 | } |
397 | 374 | ||
398 | __rpc_disable_timer(task); | 375 | __rpc_remove_wait_queue(queue, task); |
399 | __rpc_remove_wait_queue(task); | ||
400 | 376 | ||
401 | rpc_make_runnable(task); | 377 | rpc_make_runnable(task); |
402 | 378 | ||
@@ -404,48 +380,32 @@ static void __rpc_do_wake_up_task(struct rpc_task *task) | |||
404 | } | 380 | } |
405 | 381 | ||
406 | /* | 382 | /* |
407 | * Wake up the specified task | 383 | * Wake up a queued task while the queue lock is being held |
408 | */ | 384 | */ |
409 | static void __rpc_wake_up_task(struct rpc_task *task) | 385 | static void rpc_wake_up_task_queue_locked(struct rpc_wait_queue *queue, struct rpc_task *task) |
410 | { | 386 | { |
411 | if (rpc_start_wakeup(task)) { | 387 | if (RPC_IS_QUEUED(task) && task->tk_waitqueue == queue) |
412 | if (RPC_IS_QUEUED(task)) | 388 | __rpc_do_wake_up_task(queue, task); |
413 | __rpc_do_wake_up_task(task); | ||
414 | rpc_finish_wakeup(task); | ||
415 | } | ||
416 | } | 389 | } |
417 | 390 | ||
418 | /* | 391 | /* |
419 | * Default timeout handler if none specified by user | 392 | * Wake up a task on a specific queue |
420 | */ | 393 | */ |
421 | static void | 394 | void rpc_wake_up_queued_task(struct rpc_wait_queue *queue, struct rpc_task *task) |
422 | __rpc_default_timer(struct rpc_task *task) | ||
423 | { | 395 | { |
424 | dprintk("RPC: %5u timeout (default timer)\n", task->tk_pid); | 396 | spin_lock_bh(&queue->lock); |
425 | task->tk_status = -ETIMEDOUT; | 397 | rpc_wake_up_task_queue_locked(queue, task); |
426 | rpc_wake_up_task(task); | 398 | spin_unlock_bh(&queue->lock); |
427 | } | 399 | } |
400 | EXPORT_SYMBOL_GPL(rpc_wake_up_queued_task); | ||
428 | 401 | ||
429 | /* | 402 | /* |
430 | * Wake up the specified task | 403 | * Wake up the specified task |
431 | */ | 404 | */ |
432 | void rpc_wake_up_task(struct rpc_task *task) | 405 | static void rpc_wake_up_task(struct rpc_task *task) |
433 | { | 406 | { |
434 | rcu_read_lock_bh(); | 407 | rpc_wake_up_queued_task(task->tk_waitqueue, task); |
435 | if (rpc_start_wakeup(task)) { | ||
436 | if (RPC_IS_QUEUED(task)) { | ||
437 | struct rpc_wait_queue *queue = task->u.tk_wait.rpc_waitq; | ||
438 | |||
439 | /* Note: we're already in a bh-safe context */ | ||
440 | spin_lock(&queue->lock); | ||
441 | __rpc_do_wake_up_task(task); | ||
442 | spin_unlock(&queue->lock); | ||
443 | } | ||
444 | rpc_finish_wakeup(task); | ||
445 | } | ||
446 | rcu_read_unlock_bh(); | ||
447 | } | 408 | } |
448 | EXPORT_SYMBOL_GPL(rpc_wake_up_task); | ||
449 | 409 | ||
450 | /* | 410 | /* |
451 | * Wake up the next task on a priority queue. | 411 | * Wake up the next task on a priority queue. |
@@ -495,7 +455,7 @@ new_queue: | |||
495 | new_owner: | 455 | new_owner: |
496 | rpc_set_waitqueue_owner(queue, task->tk_owner); | 456 | rpc_set_waitqueue_owner(queue, task->tk_owner); |
497 | out: | 457 | out: |
498 | __rpc_wake_up_task(task); | 458 | rpc_wake_up_task_queue_locked(queue, task); |
499 | return task; | 459 | return task; |
500 | } | 460 | } |
501 | 461 | ||
@@ -508,16 +468,14 @@ struct rpc_task * rpc_wake_up_next(struct rpc_wait_queue *queue) | |||
508 | 468 | ||
509 | dprintk("RPC: wake_up_next(%p \"%s\")\n", | 469 | dprintk("RPC: wake_up_next(%p \"%s\")\n", |
510 | queue, rpc_qname(queue)); | 470 | queue, rpc_qname(queue)); |
511 | rcu_read_lock_bh(); | 471 | spin_lock_bh(&queue->lock); |
512 | spin_lock(&queue->lock); | ||
513 | if (RPC_IS_PRIORITY(queue)) | 472 | if (RPC_IS_PRIORITY(queue)) |
514 | task = __rpc_wake_up_next_priority(queue); | 473 | task = __rpc_wake_up_next_priority(queue); |
515 | else { | 474 | else { |
516 | task_for_first(task, &queue->tasks[0]) | 475 | task_for_first(task, &queue->tasks[0]) |
517 | __rpc_wake_up_task(task); | 476 | rpc_wake_up_task_queue_locked(queue, task); |
518 | } | 477 | } |
519 | spin_unlock(&queue->lock); | 478 | spin_unlock_bh(&queue->lock); |
520 | rcu_read_unlock_bh(); | ||
521 | 479 | ||
522 | return task; | 480 | return task; |
523 | } | 481 | } |
@@ -534,18 +492,16 @@ void rpc_wake_up(struct rpc_wait_queue *queue) | |||
534 | struct rpc_task *task, *next; | 492 | struct rpc_task *task, *next; |
535 | struct list_head *head; | 493 | struct list_head *head; |
536 | 494 | ||
537 | rcu_read_lock_bh(); | 495 | spin_lock_bh(&queue->lock); |
538 | spin_lock(&queue->lock); | ||
539 | head = &queue->tasks[queue->maxpriority]; | 496 | head = &queue->tasks[queue->maxpriority]; |
540 | for (;;) { | 497 | for (;;) { |
541 | list_for_each_entry_safe(task, next, head, u.tk_wait.list) | 498 | list_for_each_entry_safe(task, next, head, u.tk_wait.list) |
542 | __rpc_wake_up_task(task); | 499 | rpc_wake_up_task_queue_locked(queue, task); |
543 | if (head == &queue->tasks[0]) | 500 | if (head == &queue->tasks[0]) |
544 | break; | 501 | break; |
545 | head--; | 502 | head--; |
546 | } | 503 | } |
547 | spin_unlock(&queue->lock); | 504 | spin_unlock_bh(&queue->lock); |
548 | rcu_read_unlock_bh(); | ||
549 | } | 505 | } |
550 | EXPORT_SYMBOL_GPL(rpc_wake_up); | 506 | EXPORT_SYMBOL_GPL(rpc_wake_up); |
551 | 507 | ||
@@ -561,26 +517,48 @@ void rpc_wake_up_status(struct rpc_wait_queue *queue, int status) | |||
561 | struct rpc_task *task, *next; | 517 | struct rpc_task *task, *next; |
562 | struct list_head *head; | 518 | struct list_head *head; |
563 | 519 | ||
564 | rcu_read_lock_bh(); | 520 | spin_lock_bh(&queue->lock); |
565 | spin_lock(&queue->lock); | ||
566 | head = &queue->tasks[queue->maxpriority]; | 521 | head = &queue->tasks[queue->maxpriority]; |
567 | for (;;) { | 522 | for (;;) { |
568 | list_for_each_entry_safe(task, next, head, u.tk_wait.list) { | 523 | list_for_each_entry_safe(task, next, head, u.tk_wait.list) { |
569 | task->tk_status = status; | 524 | task->tk_status = status; |
570 | __rpc_wake_up_task(task); | 525 | rpc_wake_up_task_queue_locked(queue, task); |
571 | } | 526 | } |
572 | if (head == &queue->tasks[0]) | 527 | if (head == &queue->tasks[0]) |
573 | break; | 528 | break; |
574 | head--; | 529 | head--; |
575 | } | 530 | } |
576 | spin_unlock(&queue->lock); | 531 | spin_unlock_bh(&queue->lock); |
577 | rcu_read_unlock_bh(); | ||
578 | } | 532 | } |
579 | EXPORT_SYMBOL_GPL(rpc_wake_up_status); | 533 | EXPORT_SYMBOL_GPL(rpc_wake_up_status); |
580 | 534 | ||
535 | static void __rpc_queue_timer_fn(unsigned long ptr) | ||
536 | { | ||
537 | struct rpc_wait_queue *queue = (struct rpc_wait_queue *)ptr; | ||
538 | struct rpc_task *task, *n; | ||
539 | unsigned long expires, now, timeo; | ||
540 | |||
541 | spin_lock(&queue->lock); | ||
542 | expires = now = jiffies; | ||
543 | list_for_each_entry_safe(task, n, &queue->timer_list.list, u.tk_wait.timer_list) { | ||
544 | timeo = task->u.tk_wait.expires; | ||
545 | if (time_after_eq(now, timeo)) { | ||
546 | dprintk("RPC: %5u timeout\n", task->tk_pid); | ||
547 | task->tk_status = -ETIMEDOUT; | ||
548 | rpc_wake_up_task_queue_locked(queue, task); | ||
549 | continue; | ||
550 | } | ||
551 | if (expires == now || time_after(expires, timeo)) | ||
552 | expires = timeo; | ||
553 | } | ||
554 | if (!list_empty(&queue->timer_list.list)) | ||
555 | rpc_set_queue_timer(queue, expires); | ||
556 | spin_unlock(&queue->lock); | ||
557 | } | ||
558 | |||
581 | static void __rpc_atrun(struct rpc_task *task) | 559 | static void __rpc_atrun(struct rpc_task *task) |
582 | { | 560 | { |
583 | rpc_wake_up_task(task); | 561 | task->tk_status = 0; |
584 | } | 562 | } |
585 | 563 | ||
586 | /* | 564 | /* |
@@ -589,7 +567,7 @@ static void __rpc_atrun(struct rpc_task *task) | |||
589 | void rpc_delay(struct rpc_task *task, unsigned long delay) | 567 | void rpc_delay(struct rpc_task *task, unsigned long delay) |
590 | { | 568 | { |
591 | task->tk_timeout = delay; | 569 | task->tk_timeout = delay; |
592 | rpc_sleep_on(&delay_queue, task, NULL, __rpc_atrun); | 570 | rpc_sleep_on(&delay_queue, task, __rpc_atrun); |
593 | } | 571 | } |
594 | EXPORT_SYMBOL_GPL(rpc_delay); | 572 | EXPORT_SYMBOL_GPL(rpc_delay); |
595 | 573 | ||
@@ -644,10 +622,6 @@ static void __rpc_execute(struct rpc_task *task) | |||
644 | BUG_ON(RPC_IS_QUEUED(task)); | 622 | BUG_ON(RPC_IS_QUEUED(task)); |
645 | 623 | ||
646 | for (;;) { | 624 | for (;;) { |
647 | /* | ||
648 | * Garbage collection of pending timers... | ||
649 | */ | ||
650 | rpc_delete_timer(task); | ||
651 | 625 | ||
652 | /* | 626 | /* |
653 | * Execute any pending callback. | 627 | * Execute any pending callback. |
@@ -816,8 +790,6 @@ EXPORT_SYMBOL_GPL(rpc_free); | |||
816 | static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *task_setup_data) | 790 | static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *task_setup_data) |
817 | { | 791 | { |
818 | memset(task, 0, sizeof(*task)); | 792 | memset(task, 0, sizeof(*task)); |
819 | setup_timer(&task->tk_timer, (void (*)(unsigned long))rpc_run_timer, | ||
820 | (unsigned long)task); | ||
821 | atomic_set(&task->tk_count, 1); | 793 | atomic_set(&task->tk_count, 1); |
822 | task->tk_flags = task_setup_data->flags; | 794 | task->tk_flags = task_setup_data->flags; |
823 | task->tk_ops = task_setup_data->callback_ops; | 795 | task->tk_ops = task_setup_data->callback_ops; |
@@ -832,7 +804,7 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta | |||
832 | task->tk_owner = current->tgid; | 804 | task->tk_owner = current->tgid; |
833 | 805 | ||
834 | /* Initialize workqueue for async tasks */ | 806 | /* Initialize workqueue for async tasks */ |
835 | task->tk_workqueue = rpciod_workqueue; | 807 | task->tk_workqueue = task_setup_data->workqueue; |
836 | 808 | ||
837 | task->tk_client = task_setup_data->rpc_client; | 809 | task->tk_client = task_setup_data->rpc_client; |
838 | if (task->tk_client != NULL) { | 810 | if (task->tk_client != NULL) { |
@@ -845,12 +817,11 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta | |||
845 | task->tk_action = rpc_prepare_task; | 817 | task->tk_action = rpc_prepare_task; |
846 | 818 | ||
847 | if (task_setup_data->rpc_message != NULL) { | 819 | if (task_setup_data->rpc_message != NULL) { |
848 | memcpy(&task->tk_msg, task_setup_data->rpc_message, sizeof(task->tk_msg)); | 820 | task->tk_msg.rpc_proc = task_setup_data->rpc_message->rpc_proc; |
821 | task->tk_msg.rpc_argp = task_setup_data->rpc_message->rpc_argp; | ||
822 | task->tk_msg.rpc_resp = task_setup_data->rpc_message->rpc_resp; | ||
849 | /* Bind the user cred */ | 823 | /* Bind the user cred */ |
850 | if (task->tk_msg.rpc_cred != NULL) | 824 | rpcauth_bindcred(task, task_setup_data->rpc_message->rpc_cred, task_setup_data->flags); |
851 | rpcauth_holdcred(task); | ||
852 | else | ||
853 | rpcauth_bindcred(task); | ||
854 | if (task->tk_action == NULL) | 825 | if (task->tk_action == NULL) |
855 | rpc_call_start(task); | 826 | rpc_call_start(task); |
856 | } | 827 | } |
@@ -868,13 +839,6 @@ rpc_alloc_task(void) | |||
868 | return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_NOFS); | 839 | return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_NOFS); |
869 | } | 840 | } |
870 | 841 | ||
871 | static void rpc_free_task(struct rcu_head *rcu) | ||
872 | { | ||
873 | struct rpc_task *task = container_of(rcu, struct rpc_task, u.tk_rcu); | ||
874 | dprintk("RPC: %5u freeing task\n", task->tk_pid); | ||
875 | mempool_free(task, rpc_task_mempool); | ||
876 | } | ||
877 | |||
878 | /* | 842 | /* |
879 | * Create a new task for the specified client. | 843 | * Create a new task for the specified client. |
880 | */ | 844 | */ |
@@ -898,12 +862,25 @@ out: | |||
898 | return task; | 862 | return task; |
899 | } | 863 | } |
900 | 864 | ||
901 | 865 | static void rpc_free_task(struct rpc_task *task) | |
902 | void rpc_put_task(struct rpc_task *task) | ||
903 | { | 866 | { |
904 | const struct rpc_call_ops *tk_ops = task->tk_ops; | 867 | const struct rpc_call_ops *tk_ops = task->tk_ops; |
905 | void *calldata = task->tk_calldata; | 868 | void *calldata = task->tk_calldata; |
906 | 869 | ||
870 | if (task->tk_flags & RPC_TASK_DYNAMIC) { | ||
871 | dprintk("RPC: %5u freeing task\n", task->tk_pid); | ||
872 | mempool_free(task, rpc_task_mempool); | ||
873 | } | ||
874 | rpc_release_calldata(tk_ops, calldata); | ||
875 | } | ||
876 | |||
877 | static void rpc_async_release(struct work_struct *work) | ||
878 | { | ||
879 | rpc_free_task(container_of(work, struct rpc_task, u.tk_work)); | ||
880 | } | ||
881 | |||
882 | void rpc_put_task(struct rpc_task *task) | ||
883 | { | ||
907 | if (!atomic_dec_and_test(&task->tk_count)) | 884 | if (!atomic_dec_and_test(&task->tk_count)) |
908 | return; | 885 | return; |
909 | /* Release resources */ | 886 | /* Release resources */ |
@@ -915,9 +892,11 @@ void rpc_put_task(struct rpc_task *task) | |||
915 | rpc_release_client(task->tk_client); | 892 | rpc_release_client(task->tk_client); |
916 | task->tk_client = NULL; | 893 | task->tk_client = NULL; |
917 | } | 894 | } |
918 | if (task->tk_flags & RPC_TASK_DYNAMIC) | 895 | if (task->tk_workqueue != NULL) { |
919 | call_rcu_bh(&task->u.tk_rcu, rpc_free_task); | 896 | INIT_WORK(&task->u.tk_work, rpc_async_release); |
920 | rpc_release_calldata(tk_ops, calldata); | 897 | queue_work(task->tk_workqueue, &task->u.tk_work); |
898 | } else | ||
899 | rpc_free_task(task); | ||
921 | } | 900 | } |
922 | EXPORT_SYMBOL_GPL(rpc_put_task); | 901 | EXPORT_SYMBOL_GPL(rpc_put_task); |
923 | 902 | ||
@@ -937,9 +916,6 @@ static void rpc_release_task(struct rpc_task *task) | |||
937 | } | 916 | } |
938 | BUG_ON (RPC_IS_QUEUED(task)); | 917 | BUG_ON (RPC_IS_QUEUED(task)); |
939 | 918 | ||
940 | /* Synchronously delete any running timer */ | ||
941 | rpc_delete_timer(task); | ||
942 | |||
943 | #ifdef RPC_DEBUG | 919 | #ifdef RPC_DEBUG |
944 | task->tk_magic = 0; | 920 | task->tk_magic = 0; |
945 | #endif | 921 | #endif |
@@ -1029,11 +1005,20 @@ rpc_destroy_mempool(void) | |||
1029 | kmem_cache_destroy(rpc_task_slabp); | 1005 | kmem_cache_destroy(rpc_task_slabp); |
1030 | if (rpc_buffer_slabp) | 1006 | if (rpc_buffer_slabp) |
1031 | kmem_cache_destroy(rpc_buffer_slabp); | 1007 | kmem_cache_destroy(rpc_buffer_slabp); |
1008 | rpc_destroy_wait_queue(&delay_queue); | ||
1032 | } | 1009 | } |
1033 | 1010 | ||
1034 | int | 1011 | int |
1035 | rpc_init_mempool(void) | 1012 | rpc_init_mempool(void) |
1036 | { | 1013 | { |
1014 | /* | ||
1015 | * The following is not strictly a mempool initialisation, | ||
1016 | * but there is no harm in doing it here | ||
1017 | */ | ||
1018 | rpc_init_wait_queue(&delay_queue, "delayq"); | ||
1019 | if (!rpciod_start()) | ||
1020 | goto err_nomem; | ||
1021 | |||
1037 | rpc_task_slabp = kmem_cache_create("rpc_tasks", | 1022 | rpc_task_slabp = kmem_cache_create("rpc_tasks", |
1038 | sizeof(struct rpc_task), | 1023 | sizeof(struct rpc_task), |
1039 | 0, SLAB_HWCACHE_ALIGN, | 1024 | 0, SLAB_HWCACHE_ALIGN, |
@@ -1054,13 +1039,6 @@ rpc_init_mempool(void) | |||
1054 | rpc_buffer_slabp); | 1039 | rpc_buffer_slabp); |
1055 | if (!rpc_buffer_mempool) | 1040 | if (!rpc_buffer_mempool) |
1056 | goto err_nomem; | 1041 | goto err_nomem; |
1057 | if (!rpciod_start()) | ||
1058 | goto err_nomem; | ||
1059 | /* | ||
1060 | * The following is not strictly a mempool initialisation, | ||
1061 | * but there is no harm in doing it here | ||
1062 | */ | ||
1063 | rpc_init_wait_queue(&delay_queue, "delayq"); | ||
1064 | return 0; | 1042 | return 0; |
1065 | err_nomem: | 1043 | err_nomem: |
1066 | rpc_destroy_mempool(); | 1044 | rpc_destroy_mempool(); |
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index d5553b8179f9..85199c647022 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -188,9 +188,9 @@ out_sleep: | |||
188 | task->tk_timeout = 0; | 188 | task->tk_timeout = 0; |
189 | task->tk_status = -EAGAIN; | 189 | task->tk_status = -EAGAIN; |
190 | if (req && req->rq_ntrans) | 190 | if (req && req->rq_ntrans) |
191 | rpc_sleep_on(&xprt->resend, task, NULL, NULL); | 191 | rpc_sleep_on(&xprt->resend, task, NULL); |
192 | else | 192 | else |
193 | rpc_sleep_on(&xprt->sending, task, NULL, NULL); | 193 | rpc_sleep_on(&xprt->sending, task, NULL); |
194 | return 0; | 194 | return 0; |
195 | } | 195 | } |
196 | EXPORT_SYMBOL_GPL(xprt_reserve_xprt); | 196 | EXPORT_SYMBOL_GPL(xprt_reserve_xprt); |
@@ -238,9 +238,9 @@ out_sleep: | |||
238 | task->tk_timeout = 0; | 238 | task->tk_timeout = 0; |
239 | task->tk_status = -EAGAIN; | 239 | task->tk_status = -EAGAIN; |
240 | if (req && req->rq_ntrans) | 240 | if (req && req->rq_ntrans) |
241 | rpc_sleep_on(&xprt->resend, task, NULL, NULL); | 241 | rpc_sleep_on(&xprt->resend, task, NULL); |
242 | else | 242 | else |
243 | rpc_sleep_on(&xprt->sending, task, NULL, NULL); | 243 | rpc_sleep_on(&xprt->sending, task, NULL); |
244 | return 0; | 244 | return 0; |
245 | } | 245 | } |
246 | EXPORT_SYMBOL_GPL(xprt_reserve_xprt_cong); | 246 | EXPORT_SYMBOL_GPL(xprt_reserve_xprt_cong); |
@@ -453,7 +453,7 @@ void xprt_wait_for_buffer_space(struct rpc_task *task) | |||
453 | struct rpc_xprt *xprt = req->rq_xprt; | 453 | struct rpc_xprt *xprt = req->rq_xprt; |
454 | 454 | ||
455 | task->tk_timeout = req->rq_timeout; | 455 | task->tk_timeout = req->rq_timeout; |
456 | rpc_sleep_on(&xprt->pending, task, NULL, NULL); | 456 | rpc_sleep_on(&xprt->pending, task, NULL); |
457 | } | 457 | } |
458 | EXPORT_SYMBOL_GPL(xprt_wait_for_buffer_space); | 458 | EXPORT_SYMBOL_GPL(xprt_wait_for_buffer_space); |
459 | 459 | ||
@@ -472,7 +472,7 @@ void xprt_write_space(struct rpc_xprt *xprt) | |||
472 | if (xprt->snd_task) { | 472 | if (xprt->snd_task) { |
473 | dprintk("RPC: write space: waking waiting task on " | 473 | dprintk("RPC: write space: waking waiting task on " |
474 | "xprt %p\n", xprt); | 474 | "xprt %p\n", xprt); |
475 | rpc_wake_up_task(xprt->snd_task); | 475 | rpc_wake_up_queued_task(&xprt->pending, xprt->snd_task); |
476 | } | 476 | } |
477 | spin_unlock_bh(&xprt->transport_lock); | 477 | spin_unlock_bh(&xprt->transport_lock); |
478 | } | 478 | } |
@@ -602,8 +602,7 @@ void xprt_force_disconnect(struct rpc_xprt *xprt) | |||
602 | /* Try to schedule an autoclose RPC call */ | 602 | /* Try to schedule an autoclose RPC call */ |
603 | if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0) | 603 | if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0) |
604 | queue_work(rpciod_workqueue, &xprt->task_cleanup); | 604 | queue_work(rpciod_workqueue, &xprt->task_cleanup); |
605 | else if (xprt->snd_task != NULL) | 605 | xprt_wake_pending_tasks(xprt, -ENOTCONN); |
606 | rpc_wake_up_task(xprt->snd_task); | ||
607 | spin_unlock_bh(&xprt->transport_lock); | 606 | spin_unlock_bh(&xprt->transport_lock); |
608 | } | 607 | } |
609 | EXPORT_SYMBOL_GPL(xprt_force_disconnect); | 608 | EXPORT_SYMBOL_GPL(xprt_force_disconnect); |
@@ -653,7 +652,7 @@ void xprt_connect(struct rpc_task *task) | |||
653 | task->tk_rqstp->rq_bytes_sent = 0; | 652 | task->tk_rqstp->rq_bytes_sent = 0; |
654 | 653 | ||
655 | task->tk_timeout = xprt->connect_timeout; | 654 | task->tk_timeout = xprt->connect_timeout; |
656 | rpc_sleep_on(&xprt->pending, task, xprt_connect_status, NULL); | 655 | rpc_sleep_on(&xprt->pending, task, xprt_connect_status); |
657 | xprt->stat.connect_start = jiffies; | 656 | xprt->stat.connect_start = jiffies; |
658 | xprt->ops->connect(task); | 657 | xprt->ops->connect(task); |
659 | } | 658 | } |
@@ -749,18 +748,19 @@ EXPORT_SYMBOL_GPL(xprt_update_rtt); | |||
749 | void xprt_complete_rqst(struct rpc_task *task, int copied) | 748 | void xprt_complete_rqst(struct rpc_task *task, int copied) |
750 | { | 749 | { |
751 | struct rpc_rqst *req = task->tk_rqstp; | 750 | struct rpc_rqst *req = task->tk_rqstp; |
751 | struct rpc_xprt *xprt = req->rq_xprt; | ||
752 | 752 | ||
753 | dprintk("RPC: %5u xid %08x complete (%d bytes received)\n", | 753 | dprintk("RPC: %5u xid %08x complete (%d bytes received)\n", |
754 | task->tk_pid, ntohl(req->rq_xid), copied); | 754 | task->tk_pid, ntohl(req->rq_xid), copied); |
755 | 755 | ||
756 | task->tk_xprt->stat.recvs++; | 756 | xprt->stat.recvs++; |
757 | task->tk_rtt = (long)jiffies - req->rq_xtime; | 757 | task->tk_rtt = (long)jiffies - req->rq_xtime; |
758 | 758 | ||
759 | list_del_init(&req->rq_list); | 759 | list_del_init(&req->rq_list); |
760 | /* Ensure all writes are done before we update req->rq_received */ | 760 | /* Ensure all writes are done before we update req->rq_received */ |
761 | smp_wmb(); | 761 | smp_wmb(); |
762 | req->rq_received = req->rq_private_buf.len = copied; | 762 | req->rq_received = req->rq_private_buf.len = copied; |
763 | rpc_wake_up_task(task); | 763 | rpc_wake_up_queued_task(&xprt->pending, task); |
764 | } | 764 | } |
765 | EXPORT_SYMBOL_GPL(xprt_complete_rqst); | 765 | EXPORT_SYMBOL_GPL(xprt_complete_rqst); |
766 | 766 | ||
@@ -769,17 +769,17 @@ static void xprt_timer(struct rpc_task *task) | |||
769 | struct rpc_rqst *req = task->tk_rqstp; | 769 | struct rpc_rqst *req = task->tk_rqstp; |
770 | struct rpc_xprt *xprt = req->rq_xprt; | 770 | struct rpc_xprt *xprt = req->rq_xprt; |
771 | 771 | ||
772 | if (task->tk_status != -ETIMEDOUT) | ||
773 | return; | ||
772 | dprintk("RPC: %5u xprt_timer\n", task->tk_pid); | 774 | dprintk("RPC: %5u xprt_timer\n", task->tk_pid); |
773 | 775 | ||
774 | spin_lock(&xprt->transport_lock); | 776 | spin_lock_bh(&xprt->transport_lock); |
775 | if (!req->rq_received) { | 777 | if (!req->rq_received) { |
776 | if (xprt->ops->timer) | 778 | if (xprt->ops->timer) |
777 | xprt->ops->timer(task); | 779 | xprt->ops->timer(task); |
778 | task->tk_status = -ETIMEDOUT; | 780 | } else |
779 | } | 781 | task->tk_status = 0; |
780 | task->tk_timeout = 0; | 782 | spin_unlock_bh(&xprt->transport_lock); |
781 | rpc_wake_up_task(task); | ||
782 | spin_unlock(&xprt->transport_lock); | ||
783 | } | 783 | } |
784 | 784 | ||
785 | /** | 785 | /** |
@@ -864,7 +864,7 @@ void xprt_transmit(struct rpc_task *task) | |||
864 | if (!xprt_connected(xprt)) | 864 | if (!xprt_connected(xprt)) |
865 | task->tk_status = -ENOTCONN; | 865 | task->tk_status = -ENOTCONN; |
866 | else if (!req->rq_received) | 866 | else if (!req->rq_received) |
867 | rpc_sleep_on(&xprt->pending, task, NULL, xprt_timer); | 867 | rpc_sleep_on(&xprt->pending, task, xprt_timer); |
868 | spin_unlock_bh(&xprt->transport_lock); | 868 | spin_unlock_bh(&xprt->transport_lock); |
869 | return; | 869 | return; |
870 | } | 870 | } |
@@ -875,7 +875,7 @@ void xprt_transmit(struct rpc_task *task) | |||
875 | */ | 875 | */ |
876 | task->tk_status = status; | 876 | task->tk_status = status; |
877 | if (status == -ECONNREFUSED) | 877 | if (status == -ECONNREFUSED) |
878 | rpc_sleep_on(&xprt->sending, task, NULL, NULL); | 878 | rpc_sleep_on(&xprt->sending, task, NULL); |
879 | } | 879 | } |
880 | 880 | ||
881 | static inline void do_xprt_reserve(struct rpc_task *task) | 881 | static inline void do_xprt_reserve(struct rpc_task *task) |
@@ -895,7 +895,7 @@ static inline void do_xprt_reserve(struct rpc_task *task) | |||
895 | dprintk("RPC: waiting for request slot\n"); | 895 | dprintk("RPC: waiting for request slot\n"); |
896 | task->tk_status = -EAGAIN; | 896 | task->tk_status = -EAGAIN; |
897 | task->tk_timeout = 0; | 897 | task->tk_timeout = 0; |
898 | rpc_sleep_on(&xprt->backlog, task, NULL, NULL); | 898 | rpc_sleep_on(&xprt->backlog, task, NULL); |
899 | } | 899 | } |
900 | 900 | ||
901 | /** | 901 | /** |
@@ -1052,6 +1052,11 @@ static void xprt_destroy(struct kref *kref) | |||
1052 | xprt->shutdown = 1; | 1052 | xprt->shutdown = 1; |
1053 | del_timer_sync(&xprt->timer); | 1053 | del_timer_sync(&xprt->timer); |
1054 | 1054 | ||
1055 | rpc_destroy_wait_queue(&xprt->binding); | ||
1056 | rpc_destroy_wait_queue(&xprt->pending); | ||
1057 | rpc_destroy_wait_queue(&xprt->sending); | ||
1058 | rpc_destroy_wait_queue(&xprt->resend); | ||
1059 | rpc_destroy_wait_queue(&xprt->backlog); | ||
1055 | /* | 1060 | /* |
1056 | * Tear down transport state and free the rpc_xprt | 1061 | * Tear down transport state and free the rpc_xprt |
1057 | */ | 1062 | */ |
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 30e7ac243a90..8bd3b0f73ac0 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -1073,6 +1073,7 @@ static void xs_tcp_data_ready(struct sock *sk, int bytes) | |||
1073 | { | 1073 | { |
1074 | struct rpc_xprt *xprt; | 1074 | struct rpc_xprt *xprt; |
1075 | read_descriptor_t rd_desc; | 1075 | read_descriptor_t rd_desc; |
1076 | int read; | ||
1076 | 1077 | ||
1077 | dprintk("RPC: xs_tcp_data_ready...\n"); | 1078 | dprintk("RPC: xs_tcp_data_ready...\n"); |
1078 | 1079 | ||
@@ -1084,8 +1085,10 @@ static void xs_tcp_data_ready(struct sock *sk, int bytes) | |||
1084 | 1085 | ||
1085 | /* We use rd_desc to pass struct xprt to xs_tcp_data_recv */ | 1086 | /* We use rd_desc to pass struct xprt to xs_tcp_data_recv */ |
1086 | rd_desc.arg.data = xprt; | 1087 | rd_desc.arg.data = xprt; |
1087 | rd_desc.count = 65536; | 1088 | do { |
1088 | tcp_read_sock(sk, &rd_desc, xs_tcp_data_recv); | 1089 | rd_desc.count = 65536; |
1090 | read = tcp_read_sock(sk, &rd_desc, xs_tcp_data_recv); | ||
1091 | } while (read > 0); | ||
1089 | out: | 1092 | out: |
1090 | read_unlock(&sk->sk_callback_lock); | 1093 | read_unlock(&sk->sk_callback_lock); |
1091 | } | 1094 | } |