aboutsummaryrefslogtreecommitdiffstats
path: root/fs/afs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-04-25 09:26:50 -0400
committerDavid Howells <dhowells@redhat.com>2019-04-25 09:26:50 -0400
commit0b9bf3812ad1f0d937584e300826285694f53e2b (patch)
tree9c92ffe7329d7a563c182b8c4b7beb776683888c /fs/afs
parentcd8dead0c39457e58ec1d36db93aedca811d48f1 (diff)
afs: Split wait from afs_make_call()
Split the call to afs_wait_for_call_to_complete() from afs_make_call() to make it easier to handle asynchronous calls and to make it easier to convert a synchronous call to an asynchronous one in future, for instance when someone tries to interrupt an operation by pressing Ctrl-C. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/afs')
-rw-r--r--fs/afs/fs_probe.c13
-rw-r--r--fs/afs/fsclient.c78
-rw-r--r--fs/afs/internal.h12
-rw-r--r--fs/afs/rxrpc.c33
-rw-r--r--fs/afs/vl_probe.c14
-rw-r--r--fs/afs/vlclient.c26
-rw-r--r--fs/afs/yfsclient.c54
7 files changed, 139 insertions, 91 deletions
diff --git a/fs/afs/fs_probe.c b/fs/afs/fs_probe.c
index 3a9eaec06756..5d3abde52a0f 100644
--- a/fs/afs/fs_probe.c
+++ b/fs/afs/fs_probe.c
@@ -141,8 +141,8 @@ static int afs_do_probe_fileserver(struct afs_net *net,
141 struct afs_addr_cursor ac = { 141 struct afs_addr_cursor ac = {
142 .index = 0, 142 .index = 0,
143 }; 143 };
144 struct afs_call *call;
144 bool in_progress = false; 145 bool in_progress = false;
145 int err;
146 146
147 _enter("%pU", &server->uuid); 147 _enter("%pU", &server->uuid);
148 148
@@ -156,12 +156,13 @@ static int afs_do_probe_fileserver(struct afs_net *net,
156 server->probe.rtt = UINT_MAX; 156 server->probe.rtt = UINT_MAX;
157 157
158 for (ac.index = 0; ac.index < ac.alist->nr_addrs; ac.index++) { 158 for (ac.index = 0; ac.index < ac.alist->nr_addrs; ac.index++) {
159 err = afs_fs_get_capabilities(net, server, &ac, key, server_index, 159 call = afs_fs_get_capabilities(net, server, &ac, key, server_index);
160 true); 160 if (!IS_ERR(call)) {
161 if (err == -EINPROGRESS) 161 afs_put_call(call);
162 in_progress = true; 162 in_progress = true;
163 else 163 } else {
164 afs_prioritise_error(_e, err, ac.abort_code); 164 afs_prioritise_error(_e, PTR_ERR(call), ac.abort_code);
165 }
165 } 166 }
166 167
167 if (!in_progress) 168 if (!in_progress)
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index 0b37867b5c20..5eefcf35d73d 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -468,7 +468,9 @@ int afs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsy
468 call->cb_break = fc->cb_break; 468 call->cb_break = fc->cb_break;
469 afs_use_fs_server(call, fc->cbi); 469 afs_use_fs_server(call, fc->cbi);
470 trace_afs_make_fs_call(call, &vnode->fid); 470 trace_afs_make_fs_call(call, &vnode->fid);
471 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 471
472 afs_make_call(&fc->ac, call, GFP_NOFS);
473 return afs_wait_for_call_to_complete(call, &fc->ac);
472} 474}
473 475
474/* 476/*
@@ -660,7 +662,8 @@ static int afs_fs_fetch_data64(struct afs_fs_cursor *fc, struct afs_read *req)
660 call->cb_break = fc->cb_break; 662 call->cb_break = fc->cb_break;
661 afs_use_fs_server(call, fc->cbi); 663 afs_use_fs_server(call, fc->cbi);
662 trace_afs_make_fs_call(call, &vnode->fid); 664 trace_afs_make_fs_call(call, &vnode->fid);
663 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 665 afs_make_call(&fc->ac, call, GFP_NOFS);
666 return afs_wait_for_call_to_complete(call, &fc->ac);
664} 667}
665 668
666/* 669/*
@@ -707,7 +710,8 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req)
707 call->cb_break = fc->cb_break; 710 call->cb_break = fc->cb_break;
708 afs_use_fs_server(call, fc->cbi); 711 afs_use_fs_server(call, fc->cbi);
709 trace_afs_make_fs_call(call, &vnode->fid); 712 trace_afs_make_fs_call(call, &vnode->fid);
710 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 713 afs_make_call(&fc->ac, call, GFP_NOFS);
714 return afs_wait_for_call_to_complete(call, &fc->ac);
711} 715}
712 716
713/* 717/*
@@ -827,7 +831,8 @@ int afs_fs_create(struct afs_fs_cursor *fc,
827 831
828 afs_use_fs_server(call, fc->cbi); 832 afs_use_fs_server(call, fc->cbi);
829 trace_afs_make_fs_call(call, &vnode->fid); 833 trace_afs_make_fs_call(call, &vnode->fid);
830 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 834 afs_make_call(&fc->ac, call, GFP_NOFS);
835 return afs_wait_for_call_to_complete(call, &fc->ac);
831} 836}
832 837
833/* 838/*
@@ -922,7 +927,8 @@ int afs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
922 927
923 afs_use_fs_server(call, fc->cbi); 928 afs_use_fs_server(call, fc->cbi);
924 trace_afs_make_fs_call(call, &dvnode->fid); 929 trace_afs_make_fs_call(call, &dvnode->fid);
925 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 930 afs_make_call(&fc->ac, call, GFP_NOFS);
931 return afs_wait_for_call_to_complete(call, &fc->ac);
926} 932}
927 933
928/* 934/*
@@ -1014,7 +1020,8 @@ int afs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
1014 1020
1015 afs_use_fs_server(call, fc->cbi); 1021 afs_use_fs_server(call, fc->cbi);
1016 trace_afs_make_fs_call(call, &vnode->fid); 1022 trace_afs_make_fs_call(call, &vnode->fid);
1017 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1023 afs_make_call(&fc->ac, call, GFP_NOFS);
1024 return afs_wait_for_call_to_complete(call, &fc->ac);
1018} 1025}
1019 1026
1020/* 1027/*
@@ -1128,7 +1135,8 @@ int afs_fs_symlink(struct afs_fs_cursor *fc,
1128 1135
1129 afs_use_fs_server(call, fc->cbi); 1136 afs_use_fs_server(call, fc->cbi);
1130 trace_afs_make_fs_call(call, &vnode->fid); 1137 trace_afs_make_fs_call(call, &vnode->fid);
1131 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1138 afs_make_call(&fc->ac, call, GFP_NOFS);
1139 return afs_wait_for_call_to_complete(call, &fc->ac);
1132} 1140}
1133 1141
1134/* 1142/*
@@ -1246,7 +1254,8 @@ int afs_fs_rename(struct afs_fs_cursor *fc,
1246 1254
1247 afs_use_fs_server(call, fc->cbi); 1255 afs_use_fs_server(call, fc->cbi);
1248 trace_afs_make_fs_call(call, &orig_dvnode->fid); 1256 trace_afs_make_fs_call(call, &orig_dvnode->fid);
1249 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1257 afs_make_call(&fc->ac, call, GFP_NOFS);
1258 return afs_wait_for_call_to_complete(call, &fc->ac);
1250} 1259}
1251 1260
1252/* 1261/*
@@ -1350,7 +1359,8 @@ static int afs_fs_store_data64(struct afs_fs_cursor *fc,
1350 *bp++ = htonl((u32) i_size); 1359 *bp++ = htonl((u32) i_size);
1351 1360
1352 trace_afs_make_fs_call(call, &vnode->fid); 1361 trace_afs_make_fs_call(call, &vnode->fid);
1353 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1362 afs_make_call(&fc->ac, call, GFP_NOFS);
1363 return afs_wait_for_call_to_complete(call, &fc->ac);
1354} 1364}
1355 1365
1356/* 1366/*
@@ -1426,7 +1436,8 @@ int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1426 1436
1427 afs_use_fs_server(call, fc->cbi); 1437 afs_use_fs_server(call, fc->cbi);
1428 trace_afs_make_fs_call(call, &vnode->fid); 1438 trace_afs_make_fs_call(call, &vnode->fid);
1429 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1439 afs_make_call(&fc->ac, call, GFP_NOFS);
1440 return afs_wait_for_call_to_complete(call, &fc->ac);
1430} 1441}
1431 1442
1432/* 1443/*
@@ -1524,7 +1535,8 @@ static int afs_fs_setattr_size64(struct afs_fs_cursor *fc, struct iattr *attr)
1524 1535
1525 afs_use_fs_server(call, fc->cbi); 1536 afs_use_fs_server(call, fc->cbi);
1526 trace_afs_make_fs_call(call, &vnode->fid); 1537 trace_afs_make_fs_call(call, &vnode->fid);
1527 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1538 afs_make_call(&fc->ac, call, GFP_NOFS);
1539 return afs_wait_for_call_to_complete(call, &fc->ac);
1528} 1540}
1529 1541
1530/* 1542/*
@@ -1570,7 +1582,8 @@ static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr)
1570 1582
1571 afs_use_fs_server(call, fc->cbi); 1583 afs_use_fs_server(call, fc->cbi);
1572 trace_afs_make_fs_call(call, &vnode->fid); 1584 trace_afs_make_fs_call(call, &vnode->fid);
1573 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1585 afs_make_call(&fc->ac, call, GFP_NOFS);
1586 return afs_wait_for_call_to_complete(call, &fc->ac);
1574} 1587}
1575 1588
1576/* 1589/*
@@ -1614,7 +1627,8 @@ int afs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr)
1614 1627
1615 afs_use_fs_server(call, fc->cbi); 1628 afs_use_fs_server(call, fc->cbi);
1616 trace_afs_make_fs_call(call, &vnode->fid); 1629 trace_afs_make_fs_call(call, &vnode->fid);
1617 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1630 afs_make_call(&fc->ac, call, GFP_NOFS);
1631 return afs_wait_for_call_to_complete(call, &fc->ac);
1618} 1632}
1619 1633
1620/* 1634/*
@@ -1798,7 +1812,8 @@ int afs_fs_get_volume_status(struct afs_fs_cursor *fc,
1798 1812
1799 afs_use_fs_server(call, fc->cbi); 1813 afs_use_fs_server(call, fc->cbi);
1800 trace_afs_make_fs_call(call, &vnode->fid); 1814 trace_afs_make_fs_call(call, &vnode->fid);
1801 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1815 afs_make_call(&fc->ac, call, GFP_NOFS);
1816 return afs_wait_for_call_to_complete(call, &fc->ac);
1802} 1817}
1803 1818
1804/* 1819/*
@@ -1885,7 +1900,8 @@ int afs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type)
1885 1900
1886 afs_use_fs_server(call, fc->cbi); 1901 afs_use_fs_server(call, fc->cbi);
1887 trace_afs_make_fs_call(call, &vnode->fid); 1902 trace_afs_make_fs_call(call, &vnode->fid);
1888 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1903 afs_make_call(&fc->ac, call, GFP_NOFS);
1904 return afs_wait_for_call_to_complete(call, &fc->ac);
1889} 1905}
1890 1906
1891/* 1907/*
@@ -1919,7 +1935,8 @@ int afs_fs_extend_lock(struct afs_fs_cursor *fc)
1919 1935
1920 afs_use_fs_server(call, fc->cbi); 1936 afs_use_fs_server(call, fc->cbi);
1921 trace_afs_make_fs_call(call, &vnode->fid); 1937 trace_afs_make_fs_call(call, &vnode->fid);
1922 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1938 afs_make_call(&fc->ac, call, GFP_NOFS);
1939 return afs_wait_for_call_to_complete(call, &fc->ac);
1923} 1940}
1924 1941
1925/* 1942/*
@@ -1953,7 +1970,8 @@ int afs_fs_release_lock(struct afs_fs_cursor *fc)
1953 1970
1954 afs_use_fs_server(call, fc->cbi); 1971 afs_use_fs_server(call, fc->cbi);
1955 trace_afs_make_fs_call(call, &vnode->fid); 1972 trace_afs_make_fs_call(call, &vnode->fid);
1956 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1973 afs_make_call(&fc->ac, call, GFP_NOFS);
1974 return afs_wait_for_call_to_complete(call, &fc->ac);
1957} 1975}
1958 1976
1959/* 1977/*
@@ -1998,7 +2016,8 @@ int afs_fs_give_up_all_callbacks(struct afs_net *net,
1998 *bp++ = htonl(FSGIVEUPALLCALLBACKS); 2016 *bp++ = htonl(FSGIVEUPALLCALLBACKS);
1999 2017
2000 /* Can't take a ref on server */ 2018 /* Can't take a ref on server */
2001 return afs_make_call(ac, call, GFP_NOFS, false); 2019 afs_make_call(ac, call, GFP_NOFS);
2020 return afs_wait_for_call_to_complete(call, ac);
2002} 2021}
2003 2022
2004/* 2023/*
@@ -2068,12 +2087,11 @@ static const struct afs_call_type afs_RXFSGetCapabilities = {
2068 * Probe a fileserver for the capabilities that it supports. This can 2087 * Probe a fileserver for the capabilities that it supports. This can
2069 * return up to 196 words. 2088 * return up to 196 words.
2070 */ 2089 */
2071int afs_fs_get_capabilities(struct afs_net *net, 2090struct afs_call *afs_fs_get_capabilities(struct afs_net *net,
2072 struct afs_server *server, 2091 struct afs_server *server,
2073 struct afs_addr_cursor *ac, 2092 struct afs_addr_cursor *ac,
2074 struct key *key, 2093 struct key *key,
2075 unsigned int server_index, 2094 unsigned int server_index)
2076 bool async)
2077{ 2095{
2078 struct afs_call *call; 2096 struct afs_call *call;
2079 __be32 *bp; 2097 __be32 *bp;
@@ -2082,13 +2100,14 @@ int afs_fs_get_capabilities(struct afs_net *net,
2082 2100
2083 call = afs_alloc_flat_call(net, &afs_RXFSGetCapabilities, 1 * 4, 16 * 4); 2101 call = afs_alloc_flat_call(net, &afs_RXFSGetCapabilities, 1 * 4, 16 * 4);
2084 if (!call) 2102 if (!call)
2085 return -ENOMEM; 2103 return ERR_PTR(-ENOMEM);
2086 2104
2087 call->key = key; 2105 call->key = key;
2088 call->reply[0] = afs_get_server(server); 2106 call->reply[0] = afs_get_server(server);
2089 call->reply[1] = (void *)(long)server_index; 2107 call->reply[1] = (void *)(long)server_index;
2090 call->upgrade = true; 2108 call->upgrade = true;
2091 call->want_reply_time = true; 2109 call->want_reply_time = true;
2110 call->async = true;
2092 2111
2093 /* marshall the parameters */ 2112 /* marshall the parameters */
2094 bp = call->request; 2113 bp = call->request;
@@ -2096,7 +2115,8 @@ int afs_fs_get_capabilities(struct afs_net *net,
2096 2115
2097 /* Can't take a ref on server */ 2116 /* Can't take a ref on server */
2098 trace_afs_make_fs_call(call, NULL); 2117 trace_afs_make_fs_call(call, NULL);
2099 return afs_make_call(ac, call, GFP_NOFS, async); 2118 afs_make_call(ac, call, GFP_NOFS);
2119 return call;
2100} 2120}
2101 2121
2102/* 2122/*
@@ -2183,7 +2203,8 @@ int afs_fs_fetch_status(struct afs_fs_cursor *fc,
2183 call->cb_break = fc->cb_break; 2203 call->cb_break = fc->cb_break;
2184 afs_use_fs_server(call, fc->cbi); 2204 afs_use_fs_server(call, fc->cbi);
2185 trace_afs_make_fs_call(call, fid); 2205 trace_afs_make_fs_call(call, fid);
2186 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 2206 afs_make_call(&fc->ac, call, GFP_NOFS);
2207 return afs_wait_for_call_to_complete(call, &fc->ac);
2187} 2208}
2188 2209
2189/* 2210/*
@@ -2363,5 +2384,6 @@ int afs_fs_inline_bulk_status(struct afs_fs_cursor *fc,
2363 call->cb_break = fc->cb_break; 2384 call->cb_break = fc->cb_break;
2364 afs_use_fs_server(call, fc->cbi); 2385 afs_use_fs_server(call, fc->cbi);
2365 trace_afs_make_fs_call(call, &fids[0]); 2386 trace_afs_make_fs_call(call, &fids[0]);
2366 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 2387 afs_make_call(&fc->ac, call, GFP_NOFS);
2388 return afs_wait_for_call_to_complete(call, &fc->ac);
2367} 2389}
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 3904ab0b9563..61e24551574d 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -939,8 +939,9 @@ extern int afs_fs_extend_lock(struct afs_fs_cursor *);
939extern int afs_fs_release_lock(struct afs_fs_cursor *); 939extern int afs_fs_release_lock(struct afs_fs_cursor *);
940extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *, 940extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *,
941 struct afs_addr_cursor *, struct key *); 941 struct afs_addr_cursor *, struct key *);
942extern int afs_fs_get_capabilities(struct afs_net *, struct afs_server *, 942extern struct afs_call *afs_fs_get_capabilities(struct afs_net *, struct afs_server *,
943 struct afs_addr_cursor *, struct key *, unsigned int, bool); 943 struct afs_addr_cursor *, struct key *,
944 unsigned int);
944extern int afs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *, 945extern int afs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *,
945 struct afs_fid *, struct afs_file_status *, 946 struct afs_fid *, struct afs_file_status *,
946 struct afs_callback *, unsigned int, 947 struct afs_callback *, unsigned int,
@@ -1073,7 +1074,8 @@ extern int __net_init afs_open_socket(struct afs_net *);
1073extern void __net_exit afs_close_socket(struct afs_net *); 1074extern void __net_exit afs_close_socket(struct afs_net *);
1074extern void afs_charge_preallocation(struct work_struct *); 1075extern void afs_charge_preallocation(struct work_struct *);
1075extern void afs_put_call(struct afs_call *); 1076extern void afs_put_call(struct afs_call *);
1076extern long afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t, bool); 1077extern void afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t);
1078extern long afs_wait_for_call_to_complete(struct afs_call *, struct afs_addr_cursor *);
1077extern struct afs_call *afs_alloc_flat_call(struct afs_net *, 1079extern struct afs_call *afs_alloc_flat_call(struct afs_net *,
1078 const struct afs_call_type *, 1080 const struct afs_call_type *,
1079 size_t, size_t); 1081 size_t, size_t);
@@ -1218,8 +1220,8 @@ extern void afs_fs_exit(void);
1218extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *, 1220extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *,
1219 const char *, int); 1221 const char *, int);
1220extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uuid_t *); 1222extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uuid_t *);
1221extern int afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, struct key *, 1223extern struct afs_call *afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *,
1222 struct afs_vlserver *, unsigned int, bool); 1224 struct key *, struct afs_vlserver *, unsigned int);
1223extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *); 1225extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *);
1224 1226
1225/* 1227/*
diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c
index 15c7e82d80cb..bc5aa590f348 100644
--- a/fs/afs/rxrpc.c
+++ b/fs/afs/rxrpc.c
@@ -21,7 +21,6 @@
21struct workqueue_struct *afs_async_calls; 21struct workqueue_struct *afs_async_calls;
22 22
23static void afs_wake_up_call_waiter(struct sock *, struct rxrpc_call *, unsigned long); 23static void afs_wake_up_call_waiter(struct sock *, struct rxrpc_call *, unsigned long);
24static long afs_wait_for_call_to_complete(struct afs_call *, struct afs_addr_cursor *);
25static void afs_wake_up_async_call(struct sock *, struct rxrpc_call *, unsigned long); 24static void afs_wake_up_async_call(struct sock *, struct rxrpc_call *, unsigned long);
26static void afs_delete_async_call(struct work_struct *); 25static void afs_delete_async_call(struct work_struct *);
27static void afs_process_async_call(struct work_struct *); 26static void afs_process_async_call(struct work_struct *);
@@ -361,10 +360,10 @@ static int afs_send_pages(struct afs_call *call, struct msghdr *msg)
361} 360}
362 361
363/* 362/*
364 * initiate a call 363 * Initiate a call and synchronously queue up the parameters for dispatch. Any
364 * error is stored into the call struct, which the caller must check for.
365 */ 365 */
366long afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, 366void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)
367 gfp_t gfp, bool async)
368{ 367{
369 struct sockaddr_rxrpc *srx = &ac->alist->addrs[ac->index]; 368 struct sockaddr_rxrpc *srx = &ac->alist->addrs[ac->index];
370 struct rxrpc_call *rxcall; 369 struct rxrpc_call *rxcall;
@@ -382,7 +381,6 @@ long afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call,
382 call, call->type->name, key_serial(call->key), 381 call, call->type->name, key_serial(call->key),
383 atomic_read(&call->net->nr_outstanding_calls)); 382 atomic_read(&call->net->nr_outstanding_calls));
384 383
385 call->async = async;
386 call->addr_ix = ac->index; 384 call->addr_ix = ac->index;
387 call->alist = afs_get_addrlist(ac->alist); 385 call->alist = afs_get_addrlist(ac->alist);
388 386
@@ -415,7 +413,7 @@ long afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call,
415 rxcall = rxrpc_kernel_begin_call(call->net->socket, srx, call->key, 413 rxcall = rxrpc_kernel_begin_call(call->net->socket, srx, call->key,
416 (unsigned long)call, 414 (unsigned long)call,
417 tx_total_len, gfp, 415 tx_total_len, gfp,
418 (async ? 416 (call->async ?
419 afs_wake_up_async_call : 417 afs_wake_up_async_call :
420 afs_wake_up_call_waiter), 418 afs_wake_up_call_waiter),
421 call->upgrade, 419 call->upgrade,
@@ -453,13 +451,11 @@ long afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call,
453 451
454 /* Note that at this point, we may have received the reply or an abort 452 /* Note that at this point, we may have received the reply or an abort
455 * - and an asynchronous call may already have completed. 453 * - and an asynchronous call may already have completed.
454 *
455 * afs_wait_for_call_to_complete(call, ac)
456 * must be called to synchronously clean up.
456 */ 457 */
457 if (call->async) { 458 return;
458 afs_put_call(call);
459 return -EINPROGRESS;
460 }
461
462 return afs_wait_for_call_to_complete(call, ac);
463 459
464error_do_abort: 460error_do_abort:
465 if (ret != -ECONNABORTED) { 461 if (ret != -ECONNABORTED) {
@@ -495,9 +491,7 @@ error_kill_call:
495 491
496 ac->error = ret; 492 ac->error = ret;
497 call->state = AFS_CALL_COMPLETE; 493 call->state = AFS_CALL_COMPLETE;
498 afs_put_call(call);
499 _leave(" = %d", ret); 494 _leave(" = %d", ret);
500 return ret;
501} 495}
502 496
503/* 497/*
@@ -604,10 +598,10 @@ call_complete:
604} 598}
605 599
606/* 600/*
607 * wait synchronously for a call to complete 601 * Wait synchronously for a call to complete and clean up the call struct.
608 */ 602 */
609static long afs_wait_for_call_to_complete(struct afs_call *call, 603long afs_wait_for_call_to_complete(struct afs_call *call,
610 struct afs_addr_cursor *ac) 604 struct afs_addr_cursor *ac)
611{ 605{
612 signed long rtt2, timeout; 606 signed long rtt2, timeout;
613 long ret; 607 long ret;
@@ -620,6 +614,10 @@ static long afs_wait_for_call_to_complete(struct afs_call *call,
620 614
621 _enter(""); 615 _enter("");
622 616
617 ret = call->error;
618 if (ret < 0)
619 goto out;
620
623 rtt = rxrpc_kernel_get_rtt(call->net->socket, call->rxcall); 621 rtt = rxrpc_kernel_get_rtt(call->net->socket, call->rxcall);
624 rtt2 = nsecs_to_jiffies64(rtt) * 2; 622 rtt2 = nsecs_to_jiffies64(rtt) * 2;
625 if (rtt2 < 2) 623 if (rtt2 < 2)
@@ -703,6 +701,7 @@ static long afs_wait_for_call_to_complete(struct afs_call *call,
703 break; 701 break;
704 } 702 }
705 703
704out:
706 _debug("call complete"); 705 _debug("call complete");
707 afs_put_call(call); 706 afs_put_call(call);
708 _leave(" = %p", (void *)ret); 707 _leave(" = %p", (void *)ret);
diff --git a/fs/afs/vl_probe.c b/fs/afs/vl_probe.c
index f402ee8171a1..b05e0de04f42 100644
--- a/fs/afs/vl_probe.c
+++ b/fs/afs/vl_probe.c
@@ -141,8 +141,8 @@ static bool afs_do_probe_vlserver(struct afs_net *net,
141 struct afs_addr_cursor ac = { 141 struct afs_addr_cursor ac = {
142 .index = 0, 142 .index = 0,
143 }; 143 };
144 struct afs_call *call;
144 bool in_progress = false; 145 bool in_progress = false;
145 int err;
146 146
147 _enter("%s", server->name); 147 _enter("%s", server->name);
148 148
@@ -156,12 +156,14 @@ static bool afs_do_probe_vlserver(struct afs_net *net,
156 server->probe.rtt = UINT_MAX; 156 server->probe.rtt = UINT_MAX;
157 157
158 for (ac.index = 0; ac.index < ac.alist->nr_addrs; ac.index++) { 158 for (ac.index = 0; ac.index < ac.alist->nr_addrs; ac.index++) {
159 err = afs_vl_get_capabilities(net, &ac, key, server, 159 call = afs_vl_get_capabilities(net, &ac, key, server,
160 server_index, true); 160 server_index);
161 if (err == -EINPROGRESS) 161 if (!IS_ERR(call)) {
162 afs_put_call(call);
162 in_progress = true; 163 in_progress = true;
163 else 164 } else {
164 afs_prioritise_error(_e, err, ac.abort_code); 165 afs_prioritise_error(_e, PTR_ERR(call), ac.abort_code);
166 }
165 } 167 }
166 168
167 if (!in_progress) 169 if (!in_progress)
diff --git a/fs/afs/vlclient.c b/fs/afs/vlclient.c
index c3d9e5a5f67e..e98ffe6df1c1 100644
--- a/fs/afs/vlclient.c
+++ b/fs/afs/vlclient.c
@@ -167,7 +167,8 @@ struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *vc,
167 memset((void *)bp + volnamesz, 0, padsz); 167 memset((void *)bp + volnamesz, 0, padsz);
168 168
169 trace_afs_make_vl_call(call); 169 trace_afs_make_vl_call(call);
170 return (struct afs_vldb_entry *)afs_make_call(&vc->ac, call, GFP_KERNEL, false); 170 afs_make_call(&vc->ac, call, GFP_KERNEL);
171 return (struct afs_vldb_entry *)afs_wait_for_call_to_complete(call, &vc->ac);
171} 172}
172 173
173/* 174/*
@@ -304,7 +305,8 @@ struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *vc,
304 r->uuid.node[i] = htonl(u->node[i]); 305 r->uuid.node[i] = htonl(u->node[i]);
305 306
306 trace_afs_make_vl_call(call); 307 trace_afs_make_vl_call(call);
307 return (struct afs_addr_list *)afs_make_call(&vc->ac, call, GFP_KERNEL, false); 308 afs_make_call(&vc->ac, call, GFP_KERNEL);
309 return (struct afs_addr_list *)afs_wait_for_call_to_complete(call, &vc->ac);
308} 310}
309 311
310/* 312/*
@@ -378,12 +380,11 @@ static const struct afs_call_type afs_RXVLGetCapabilities = {
378 * We use this to probe for service upgrade to determine what the server at the 380 * We use this to probe for service upgrade to determine what the server at the
379 * other end supports. 381 * other end supports.
380 */ 382 */
381int afs_vl_get_capabilities(struct afs_net *net, 383struct afs_call *afs_vl_get_capabilities(struct afs_net *net,
382 struct afs_addr_cursor *ac, 384 struct afs_addr_cursor *ac,
383 struct key *key, 385 struct key *key,
384 struct afs_vlserver *server, 386 struct afs_vlserver *server,
385 unsigned int server_index, 387 unsigned int server_index)
386 bool async)
387{ 388{
388 struct afs_call *call; 389 struct afs_call *call;
389 __be32 *bp; 390 __be32 *bp;
@@ -392,13 +393,14 @@ int afs_vl_get_capabilities(struct afs_net *net,
392 393
393 call = afs_alloc_flat_call(net, &afs_RXVLGetCapabilities, 1 * 4, 16 * 4); 394 call = afs_alloc_flat_call(net, &afs_RXVLGetCapabilities, 1 * 4, 16 * 4);
394 if (!call) 395 if (!call)
395 return -ENOMEM; 396 return ERR_PTR(-ENOMEM);
396 397
397 call->key = key; 398 call->key = key;
398 call->reply[0] = afs_get_vlserver(server); 399 call->reply[0] = afs_get_vlserver(server);
399 call->reply[1] = (void *)(long)server_index; 400 call->reply[1] = (void *)(long)server_index;
400 call->upgrade = true; 401 call->upgrade = true;
401 call->want_reply_time = true; 402 call->want_reply_time = true;
403 call->async = true;
402 404
403 /* marshall the parameters */ 405 /* marshall the parameters */
404 bp = call->request; 406 bp = call->request;
@@ -406,7 +408,8 @@ int afs_vl_get_capabilities(struct afs_net *net,
406 408
407 /* Can't take a ref on server */ 409 /* Can't take a ref on server */
408 trace_afs_make_vl_call(call); 410 trace_afs_make_vl_call(call);
409 return afs_make_call(ac, call, GFP_KERNEL, async); 411 afs_make_call(ac, call, GFP_KERNEL);
412 return call;
410} 413}
411 414
412/* 415/*
@@ -647,5 +650,6 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc,
647 memcpy(bp, uuid, sizeof(*uuid)); /* Type opr_uuid */ 650 memcpy(bp, uuid, sizeof(*uuid)); /* Type opr_uuid */
648 651
649 trace_afs_make_vl_call(call); 652 trace_afs_make_vl_call(call);
650 return (struct afs_addr_list *)afs_make_call(&vc->ac, call, GFP_KERNEL, false); 653 afs_make_call(&vc->ac, call, GFP_KERNEL);
654 return (struct afs_addr_list *)afs_wait_for_call_to_complete(call, &vc->ac);
651} 655}
diff --git a/fs/afs/yfsclient.c b/fs/afs/yfsclient.c
index 6e97a42d24d1..95b04cb76c8c 100644
--- a/fs/afs/yfsclient.c
+++ b/fs/afs/yfsclient.c
@@ -519,7 +519,8 @@ int yfs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsy
519 call->cb_break = fc->cb_break; 519 call->cb_break = fc->cb_break;
520 afs_use_fs_server(call, fc->cbi); 520 afs_use_fs_server(call, fc->cbi);
521 trace_afs_make_fs_call(call, &vnode->fid); 521 trace_afs_make_fs_call(call, &vnode->fid);
522 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 522 afs_make_call(&fc->ac, call, GFP_NOFS);
523 return afs_wait_for_call_to_complete(call, &fc->ac);
523} 524}
524 525
525/* 526/*
@@ -708,7 +709,8 @@ int yfs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req)
708 call->cb_break = fc->cb_break; 709 call->cb_break = fc->cb_break;
709 afs_use_fs_server(call, fc->cbi); 710 afs_use_fs_server(call, fc->cbi);
710 trace_afs_make_fs_call(call, &vnode->fid); 711 trace_afs_make_fs_call(call, &vnode->fid);
711 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 712 afs_make_call(&fc->ac, call, GFP_NOFS);
713 return afs_wait_for_call_to_complete(call, &fc->ac);
712} 714}
713 715
714/* 716/*
@@ -808,7 +810,8 @@ int yfs_fs_create_file(struct afs_fs_cursor *fc,
808 810
809 afs_use_fs_server(call, fc->cbi); 811 afs_use_fs_server(call, fc->cbi);
810 trace_afs_make_fs_call(call, &vnode->fid); 812 trace_afs_make_fs_call(call, &vnode->fid);
811 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 813 afs_make_call(&fc->ac, call, GFP_NOFS);
814 return afs_wait_for_call_to_complete(call, &fc->ac);
812} 815}
813 816
814static const struct afs_call_type yfs_RXFSMakeDir = { 817static const struct afs_call_type yfs_RXFSMakeDir = {
@@ -871,7 +874,8 @@ int yfs_fs_make_dir(struct afs_fs_cursor *fc,
871 874
872 afs_use_fs_server(call, fc->cbi); 875 afs_use_fs_server(call, fc->cbi);
873 trace_afs_make_fs_call(call, &vnode->fid); 876 trace_afs_make_fs_call(call, &vnode->fid);
874 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 877 afs_make_call(&fc->ac, call, GFP_NOFS);
878 return afs_wait_for_call_to_complete(call, &fc->ac);
875} 879}
876 880
877/* 881/*
@@ -961,7 +965,8 @@ int yfs_fs_remove_file2(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
961 965
962 afs_use_fs_server(call, fc->cbi); 966 afs_use_fs_server(call, fc->cbi);
963 trace_afs_make_fs_call(call, &dvnode->fid); 967 trace_afs_make_fs_call(call, &dvnode->fid);
964 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 968 afs_make_call(&fc->ac, call, GFP_NOFS);
969 return afs_wait_for_call_to_complete(call, &fc->ac);
965} 970}
966 971
967/* 972/*
@@ -1048,7 +1053,8 @@ int yfs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
1048 1053
1049 afs_use_fs_server(call, fc->cbi); 1054 afs_use_fs_server(call, fc->cbi);
1050 trace_afs_make_fs_call(call, &dvnode->fid); 1055 trace_afs_make_fs_call(call, &dvnode->fid);
1051 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1056 afs_make_call(&fc->ac, call, GFP_NOFS);
1057 return afs_wait_for_call_to_complete(call, &fc->ac);
1052} 1058}
1053 1059
1054/* 1060/*
@@ -1133,7 +1139,8 @@ int yfs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
1133 1139
1134 afs_use_fs_server(call, fc->cbi); 1140 afs_use_fs_server(call, fc->cbi);
1135 trace_afs_make_fs_call(call, &vnode->fid); 1141 trace_afs_make_fs_call(call, &vnode->fid);
1136 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1142 afs_make_call(&fc->ac, call, GFP_NOFS);
1143 return afs_wait_for_call_to_complete(call, &fc->ac);
1137} 1144}
1138 1145
1139/* 1146/*
@@ -1229,7 +1236,8 @@ int yfs_fs_symlink(struct afs_fs_cursor *fc,
1229 1236
1230 afs_use_fs_server(call, fc->cbi); 1237 afs_use_fs_server(call, fc->cbi);
1231 trace_afs_make_fs_call(call, &dvnode->fid); 1238 trace_afs_make_fs_call(call, &dvnode->fid);
1232 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1239 afs_make_call(&fc->ac, call, GFP_NOFS);
1240 return afs_wait_for_call_to_complete(call, &fc->ac);
1233} 1241}
1234 1242
1235/* 1243/*
@@ -1327,7 +1335,8 @@ int yfs_fs_rename(struct afs_fs_cursor *fc,
1327 1335
1328 afs_use_fs_server(call, fc->cbi); 1336 afs_use_fs_server(call, fc->cbi);
1329 trace_afs_make_fs_call(call, &orig_dvnode->fid); 1337 trace_afs_make_fs_call(call, &orig_dvnode->fid);
1330 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1338 afs_make_call(&fc->ac, call, GFP_NOFS);
1339 return afs_wait_for_call_to_complete(call, &fc->ac);
1331} 1340}
1332 1341
1333/* 1342/*
@@ -1433,7 +1442,8 @@ int yfs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1433 1442
1434 afs_use_fs_server(call, fc->cbi); 1443 afs_use_fs_server(call, fc->cbi);
1435 trace_afs_make_fs_call(call, &vnode->fid); 1444 trace_afs_make_fs_call(call, &vnode->fid);
1436 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1445 afs_make_call(&fc->ac, call, GFP_NOFS);
1446 return afs_wait_for_call_to_complete(call, &fc->ac);
1437} 1447}
1438 1448
1439/* 1449/*
@@ -1521,7 +1531,8 @@ static int yfs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr)
1521 1531
1522 afs_use_fs_server(call, fc->cbi); 1532 afs_use_fs_server(call, fc->cbi);
1523 trace_afs_make_fs_call(call, &vnode->fid); 1533 trace_afs_make_fs_call(call, &vnode->fid);
1524 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1534 afs_make_call(&fc->ac, call, GFP_NOFS);
1535 return afs_wait_for_call_to_complete(call, &fc->ac);
1525} 1536}
1526 1537
1527/* 1538/*
@@ -1564,7 +1575,8 @@ int yfs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr)
1564 1575
1565 afs_use_fs_server(call, fc->cbi); 1576 afs_use_fs_server(call, fc->cbi);
1566 trace_afs_make_fs_call(call, &vnode->fid); 1577 trace_afs_make_fs_call(call, &vnode->fid);
1567 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1578 afs_make_call(&fc->ac, call, GFP_NOFS);
1579 return afs_wait_for_call_to_complete(call, &fc->ac);
1568} 1580}
1569 1581
1570/* 1582/*
@@ -1751,7 +1763,8 @@ int yfs_fs_get_volume_status(struct afs_fs_cursor *fc,
1751 1763
1752 afs_use_fs_server(call, fc->cbi); 1764 afs_use_fs_server(call, fc->cbi);
1753 trace_afs_make_fs_call(call, &vnode->fid); 1765 trace_afs_make_fs_call(call, &vnode->fid);
1754 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1766 afs_make_call(&fc->ac, call, GFP_NOFS);
1767 return afs_wait_for_call_to_complete(call, &fc->ac);
1755} 1768}
1756 1769
1757/* 1770/*
@@ -1845,7 +1858,8 @@ int yfs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type)
1845 1858
1846 afs_use_fs_server(call, fc->cbi); 1859 afs_use_fs_server(call, fc->cbi);
1847 trace_afs_make_fs_call(call, &vnode->fid); 1860 trace_afs_make_fs_call(call, &vnode->fid);
1848 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1861 afs_make_call(&fc->ac, call, GFP_NOFS);
1862 return afs_wait_for_call_to_complete(call, &fc->ac);
1849} 1863}
1850 1864
1851/* 1865/*
@@ -1880,7 +1894,8 @@ int yfs_fs_extend_lock(struct afs_fs_cursor *fc)
1880 1894
1881 afs_use_fs_server(call, fc->cbi); 1895 afs_use_fs_server(call, fc->cbi);
1882 trace_afs_make_fs_call(call, &vnode->fid); 1896 trace_afs_make_fs_call(call, &vnode->fid);
1883 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1897 afs_make_call(&fc->ac, call, GFP_NOFS);
1898 return afs_wait_for_call_to_complete(call, &fc->ac);
1884} 1899}
1885 1900
1886/* 1901/*
@@ -1915,7 +1930,8 @@ int yfs_fs_release_lock(struct afs_fs_cursor *fc)
1915 1930
1916 afs_use_fs_server(call, fc->cbi); 1931 afs_use_fs_server(call, fc->cbi);
1917 trace_afs_make_fs_call(call, &vnode->fid); 1932 trace_afs_make_fs_call(call, &vnode->fid);
1918 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 1933 afs_make_call(&fc->ac, call, GFP_NOFS);
1934 return afs_wait_for_call_to_complete(call, &fc->ac);
1919} 1935}
1920 1936
1921/* 1937/*
@@ -2003,7 +2019,8 @@ int yfs_fs_fetch_status(struct afs_fs_cursor *fc,
2003 call->cb_break = fc->cb_break; 2019 call->cb_break = fc->cb_break;
2004 afs_use_fs_server(call, fc->cbi); 2020 afs_use_fs_server(call, fc->cbi);
2005 trace_afs_make_fs_call(call, fid); 2021 trace_afs_make_fs_call(call, fid);
2006 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 2022 afs_make_call(&fc->ac, call, GFP_NOFS);
2023 return afs_wait_for_call_to_complete(call, &fc->ac);
2007} 2024}
2008 2025
2009/* 2026/*
@@ -2180,5 +2197,6 @@ int yfs_fs_inline_bulk_status(struct afs_fs_cursor *fc,
2180 call->cb_break = fc->cb_break; 2197 call->cb_break = fc->cb_break;
2181 afs_use_fs_server(call, fc->cbi); 2198 afs_use_fs_server(call, fc->cbi);
2182 trace_afs_make_fs_call(call, &fids[0]); 2199 trace_afs_make_fs_call(call, &fids[0]);
2183 return afs_make_call(&fc->ac, call, GFP_NOFS, false); 2200 afs_make_call(&fc->ac, call, GFP_NOFS);
2201 return afs_wait_for_call_to_complete(call, &fc->ac);
2184} 2202}