diff options
author | David Howells <dhowells@redhat.com> | 2019-04-25 16:26:50 +0300 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2019-04-25 16:26:50 +0300 |
commit | 0b9bf3812ad1f0d937584e300826285694f53e2b (patch) | |
tree | 9c92ffe7329d7a563c182b8c4b7beb776683888c /fs/afs/fsclient.c | |
parent | cd8dead0c39457e58ec1d36db93aedca811d48f1 (diff) | |
download | linux-0b9bf3812ad1f0d937584e300826285694f53e2b.tar.xz |
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/fsclient.c')
-rw-r--r-- | fs/afs/fsclient.c | 78 |
1 files changed, 50 insertions, 28 deletions
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 call->cb_break = fc->cb_break; afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -660,7 +662,8 @@ static int afs_fs_fetch_data64(struct afs_fs_cursor *fc, struct afs_read *req) call->cb_break = fc->cb_break; afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -707,7 +710,8 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req) call->cb_break = fc->cb_break; afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -827,7 +831,8 @@ int afs_fs_create(struct afs_fs_cursor *fc, afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -922,7 +927,8 @@ int afs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode, afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &dvnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1014,7 +1020,8 @@ int afs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode, afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1128,7 +1135,8 @@ int afs_fs_symlink(struct afs_fs_cursor *fc, afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1246,7 +1254,8 @@ int afs_fs_rename(struct afs_fs_cursor *fc, afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &orig_dvnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1350,7 +1359,8 @@ static int afs_fs_store_data64(struct afs_fs_cursor *fc, *bp++ = htonl((u32) i_size); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1426,7 +1436,8 @@ int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping, afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1524,7 +1535,8 @@ static int afs_fs_setattr_size64(struct afs_fs_cursor *fc, struct iattr *attr) afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1570,7 +1582,8 @@ static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr) afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1614,7 +1627,8 @@ int afs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr) afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1798,7 +1812,8 @@ int afs_fs_get_volume_status(struct afs_fs_cursor *fc, afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1885,7 +1900,8 @@ int afs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type) afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1919,7 +1935,8 @@ int afs_fs_extend_lock(struct afs_fs_cursor *fc) afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1953,7 +1970,8 @@ int afs_fs_release_lock(struct afs_fs_cursor *fc) afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -1998,7 +2016,8 @@ int afs_fs_give_up_all_callbacks(struct afs_net *net, *bp++ = htonl(FSGIVEUPALLCALLBACKS); /* Can't take a ref on server */ - return afs_make_call(ac, call, GFP_NOFS, false); + afs_make_call(ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, ac); } /* @@ -2068,12 +2087,11 @@ static const struct afs_call_type afs_RXFSGetCapabilities = { * Probe a fileserver for the capabilities that it supports. This can * return up to 196 words. */ -int afs_fs_get_capabilities(struct afs_net *net, - struct afs_server *server, - struct afs_addr_cursor *ac, - struct key *key, - unsigned int server_index, - bool async) +struct afs_call *afs_fs_get_capabilities(struct afs_net *net, + struct afs_server *server, + struct afs_addr_cursor *ac, + struct key *key, + unsigned int server_index) { struct afs_call *call; __be32 *bp; @@ -2082,13 +2100,14 @@ int afs_fs_get_capabilities(struct afs_net *net, call = afs_alloc_flat_call(net, &afs_RXFSGetCapabilities, 1 * 4, 16 * 4); if (!call) - return -ENOMEM; + return ERR_PTR(-ENOMEM); call->key = key; call->reply[0] = afs_get_server(server); call->reply[1] = (void *)(long)server_index; call->upgrade = true; call->want_reply_time = true; + call->async = true; /* marshall the parameters */ bp = call->request; @@ -2096,7 +2115,8 @@ int afs_fs_get_capabilities(struct afs_net *net, /* Can't take a ref on server */ trace_afs_make_fs_call(call, NULL); - return afs_make_call(ac, call, GFP_NOFS, async); + afs_make_call(ac, call, GFP_NOFS); + return call; } /* @@ -2183,7 +2203,8 @@ int afs_fs_fetch_status(struct afs_fs_cursor *fc, call->cb_break = fc->cb_break; afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, fid); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } /* @@ -2363,5 +2384,6 @@ int afs_fs_inline_bulk_status(struct afs_fs_cursor *fc, call->cb_break = fc->cb_break; afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &fids[0]); - return afs_make_call(&fc->ac, call, GFP_NOFS, false); + afs_make_call(&fc->ac, call, GFP_NOFS); + return afs_wait_for_call_to_complete(call, &fc->ac); } |