Commit ffba718e authored by David Howells's avatar David Howells

afs: Get rid of afs_call::reply[]

Replace the afs_call::reply[] array with a bunch of typed members so that
the compiler can use type-checking on them.  It's also easier for the eye
to see what's going on.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent fefb2483
......@@ -213,7 +213,7 @@ static int afs_find_cm_server_by_peer(struct afs_call *call)
return 0;
}
call->cm_server = server;
call->server = server;
return afs_record_cm_probe(call, server);
}
......@@ -234,7 +234,7 @@ static int afs_find_cm_server_by_uuid(struct afs_call *call,
return 0;
}
call->cm_server = server;
call->server = server;
return afs_record_cm_probe(call, server);
}
......@@ -260,8 +260,8 @@ static void SRXAFSCB_CallBack(struct work_struct *work)
* server holds up change visibility till it receives our reply so as
* to maintain cache coherency.
*/
if (call->cm_server)
afs_break_callbacks(call->cm_server, call->count, call->request);
if (call->server)
afs_break_callbacks(call->server, call->count, call->request);
afs_send_empty_reply(call);
afs_put_call(call);
......@@ -376,10 +376,10 @@ static void SRXAFSCB_InitCallBackState(struct work_struct *work)
{
struct afs_call *call = container_of(work, struct afs_call, work);
_enter("{%p}", call->cm_server);
_enter("{%p}", call->server);
if (call->cm_server)
afs_init_callback_state(call->cm_server);
if (call->server)
afs_init_callback_state(call->server);
afs_send_empty_reply(call);
afs_put_call(call);
_leave("");
......
......@@ -408,7 +408,7 @@ static int afs_readpage(struct file *file, struct page *page)
static void afs_readpages_page_done(struct afs_call *call, struct afs_read *req)
{
#ifdef CONFIG_AFS_FSCACHE
struct afs_vnode *vnode = call->reply[0];
struct afs_vnode *vnode = call->xvnode;
#endif
struct page *page = req->pages[req->index];
......
......@@ -74,7 +74,7 @@ static void afs_schedule_lock_extension(struct afs_vnode *vnode)
*/
void afs_lock_op_done(struct afs_call *call)
{
struct afs_vnode *vnode = call->reply[0];
struct afs_vnode *vnode = call->xvnode;
if (call->error == 0) {
spin_lock(&vnode->lock);
......
......@@ -33,8 +33,8 @@ static bool afs_fs_probe_done(struct afs_server *server)
void afs_fileserver_probe_result(struct afs_call *call)
{
struct afs_addr_list *alist = call->alist;
struct afs_server *server = call->reply[0];
unsigned int server_index = (long)call->reply[1];
struct afs_server *server = call->server;
unsigned int server_index = call->server_index;
unsigned int index = call->addr_ix;
unsigned int rtt = UINT_MAX;
bool have_result = false;
......
This diff is collapsed.
......@@ -111,8 +111,13 @@ struct afs_call {
struct rxrpc_call *rxcall; /* RxRPC call handle */
struct key *key; /* security for this call */
struct afs_net *net; /* The network namespace */
struct afs_server *cm_server; /* Server affected by incoming CM call */
union {
struct afs_server *server;
struct afs_vlserver *vlserver;
};
struct afs_cb_interest *cbi; /* Callback interest for server used */
struct afs_vnode *dvnode; /* Directory vnode of call */
struct afs_vnode *xvnode; /* Other vnode of call */
void *request; /* request data (first part) */
struct address_space *mapping; /* Pages being written from */
struct iov_iter iter; /* Buffer iterator */
......@@ -122,7 +127,21 @@ struct afs_call {
struct bio_vec bvec[1];
};
void *buffer; /* reply receive buffer */
void *reply[4]; /* Where to put the reply */
union {
long ret0; /* Value to reply with instead of 0 */
struct afs_addr_list *ret_alist;
struct afs_vldb_entry *ret_vldb;
struct afs_acl *ret_acl;
};
struct afs_fid *out_fid;
struct afs_file_status *out_vnode_status;
struct afs_file_status *out_extra_status;
struct afs_callback *out_cb;
struct yfs_acl *out_yacl;
struct afs_volsync *out_volsync;
struct afs_volume_status *out_volstatus;
struct afs_read *read_request;
unsigned int server_index;
pgoff_t first; /* first page in mapping to deal with */
pgoff_t last; /* last page in mapping to deal with */
atomic_t usage;
......@@ -146,7 +165,6 @@ struct afs_call {
bool send_pages; /* T if data from mapping should be sent */
bool need_attention; /* T if RxRPC poked us */
bool async; /* T if asynchronous */
bool ret_reply0; /* T if should return reply[0] on success */
bool upgrade; /* T to request service upgrade */
bool want_reply_time; /* T if want reply_time */
bool intr; /* T if interruptible */
......
......@@ -188,7 +188,7 @@ void afs_put_call(struct afs_call *call)
if (call->type->destructor)
call->type->destructor(call);
afs_put_server(call->net, call->cm_server);
afs_put_server(call->net, call->server);
afs_put_cb_interest(call->net, call->cbi);
afs_put_addrlist(call->alist);
kfree(call->request);
......@@ -696,10 +696,9 @@ long afs_wait_for_call_to_complete(struct afs_call *call,
ret = ac->error;
switch (ret) {
case 0:
if (call->ret_reply0) {
ret = (long)call->reply[0];
call->reply[0] = NULL;
}
ret = call->ret0;
call->ret0 = 0;
/* Fall through */
case -ECONNABORTED:
ac->responded = true;
......
......@@ -33,8 +33,8 @@ static bool afs_vl_probe_done(struct afs_vlserver *server)
void afs_vlserver_probe_result(struct afs_call *call)
{
struct afs_addr_list *alist = call->alist;
struct afs_vlserver *server = call->reply[0];
unsigned int server_index = (long)call->reply[1];
struct afs_vlserver *server = call->vlserver;
unsigned int server_index = call->server_index;
unsigned int index = call->addr_ix;
unsigned int rtt = UINT_MAX;
bool have_result = false;
......
......@@ -34,7 +34,7 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call)
/* unmarshall the reply once we've received all of it */
uvldb = call->buffer;
entry = call->reply[0];
entry = call->ret_vldb;
nr_servers = ntohl(uvldb->nServers);
if (nr_servers > AFS_NMAXNSERVERS)
......@@ -110,7 +110,7 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call)
static void afs_destroy_vl_get_entry_by_name_u(struct afs_call *call)
{
kfree(call->reply[0]);
kfree(call->ret_vldb);
afs_flat_call_destructor(call);
}
......@@ -155,8 +155,7 @@ struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *vc,
}
call->key = vc->key;
call->reply[0] = entry;
call->ret_reply0 = true;
call->ret_vldb = entry;
call->max_lifespan = AFS_VL_MAX_LIFESPAN;
/* Marshall the parameters */
......@@ -215,7 +214,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
if (!alist)
return -ENOMEM;
alist->version = uniquifier;
call->reply[0] = alist;
call->ret_alist = alist;
call->count = count;
call->count2 = nentries;
call->unmarshall++;
......@@ -230,7 +229,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
if (ret < 0)
return ret;
alist = call->reply[0];
alist = call->ret_alist;
bp = call->buffer;
count = min(call->count, 4U);
for (i = 0; i < count; i++)
......@@ -250,8 +249,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
static void afs_vl_get_addrs_u_destructor(struct afs_call *call)
{
afs_put_server(call->net, (struct afs_server *)call->reply[0]);
kfree(call->reply[1]);
afs_put_addrlist(call->ret_alist);
return afs_flat_call_destructor(call);
}
......@@ -288,8 +286,7 @@ struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *vc,
return ERR_PTR(-ENOMEM);
call->key = vc->key;
call->reply[0] = NULL;
call->ret_reply0 = true;
call->ret_alist = NULL;
call->max_lifespan = AFS_VL_MAX_LIFESPAN;
/* Marshall the parameters */
......@@ -360,9 +357,7 @@ static int afs_deliver_vl_get_capabilities(struct afs_call *call)
static void afs_destroy_vl_get_capabilities(struct afs_call *call)
{
struct afs_vlserver *server = call->reply[0];
afs_put_vlserver(call->net, server);
afs_put_vlserver(call->net, call->vlserver);
afs_flat_call_destructor(call);
}
......@@ -400,8 +395,8 @@ struct afs_call *afs_vl_get_capabilities(struct afs_net *net,
return ERR_PTR(-ENOMEM);
call->key = key;
call->reply[0] = afs_get_vlserver(server);
call->reply[1] = (void *)(long)server_index;
call->vlserver = afs_get_vlserver(server);
call->server_index = server_index;
call->upgrade = true;
call->want_reply_time = true;
call->async = true;
......@@ -463,7 +458,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
if (!alist)
return -ENOMEM;
alist->version = uniquifier;
call->reply[0] = alist;
call->ret_alist = alist;
if (call->count == 0)
goto extract_volendpoints;
......@@ -491,7 +486,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
if (ret < 0)
return ret;
alist = call->reply[0];
alist = call->ret_alist;
bp = call->buffer;
switch (call->count2) {
case YFS_ENDPOINT_IPV4:
......@@ -612,7 +607,6 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
break;
}
alist = call->reply[0];
_leave(" = 0 [done]");
return 0;
}
......@@ -647,8 +641,7 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc,
return ERR_PTR(-ENOMEM);
call->key = vc->key;
call->reply[0] = NULL;
call->ret_reply0 = true;
call->ret_alist = NULL;
call->max_lifespan = AFS_VL_MAX_LIFESPAN;
/* Marshall the parameters */
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment