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) ...@@ -213,7 +213,7 @@ static int afs_find_cm_server_by_peer(struct afs_call *call)
return 0; return 0;
} }
call->cm_server = server; call->server = server;
return afs_record_cm_probe(call, server); return afs_record_cm_probe(call, server);
} }
...@@ -234,7 +234,7 @@ static int afs_find_cm_server_by_uuid(struct afs_call *call, ...@@ -234,7 +234,7 @@ static int afs_find_cm_server_by_uuid(struct afs_call *call,
return 0; return 0;
} }
call->cm_server = server; call->server = server;
return afs_record_cm_probe(call, server); return afs_record_cm_probe(call, server);
} }
...@@ -260,8 +260,8 @@ static void SRXAFSCB_CallBack(struct work_struct *work) ...@@ -260,8 +260,8 @@ static void SRXAFSCB_CallBack(struct work_struct *work)
* server holds up change visibility till it receives our reply so as * server holds up change visibility till it receives our reply so as
* to maintain cache coherency. * to maintain cache coherency.
*/ */
if (call->cm_server) if (call->server)
afs_break_callbacks(call->cm_server, call->count, call->request); afs_break_callbacks(call->server, call->count, call->request);
afs_send_empty_reply(call); afs_send_empty_reply(call);
afs_put_call(call); afs_put_call(call);
...@@ -376,10 +376,10 @@ static void SRXAFSCB_InitCallBackState(struct work_struct *work) ...@@ -376,10 +376,10 @@ static void SRXAFSCB_InitCallBackState(struct work_struct *work)
{ {
struct afs_call *call = container_of(work, struct afs_call, 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) if (call->server)
afs_init_callback_state(call->cm_server); afs_init_callback_state(call->server);
afs_send_empty_reply(call); afs_send_empty_reply(call);
afs_put_call(call); afs_put_call(call);
_leave(""); _leave("");
......
...@@ -408,7 +408,7 @@ static int afs_readpage(struct file *file, struct page *page) ...@@ -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) static void afs_readpages_page_done(struct afs_call *call, struct afs_read *req)
{ {
#ifdef CONFIG_AFS_FSCACHE #ifdef CONFIG_AFS_FSCACHE
struct afs_vnode *vnode = call->reply[0]; struct afs_vnode *vnode = call->xvnode;
#endif #endif
struct page *page = req->pages[req->index]; struct page *page = req->pages[req->index];
......
...@@ -74,7 +74,7 @@ static void afs_schedule_lock_extension(struct afs_vnode *vnode) ...@@ -74,7 +74,7 @@ static void afs_schedule_lock_extension(struct afs_vnode *vnode)
*/ */
void afs_lock_op_done(struct afs_call *call) 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) { if (call->error == 0) {
spin_lock(&vnode->lock); spin_lock(&vnode->lock);
......
...@@ -33,8 +33,8 @@ static bool afs_fs_probe_done(struct afs_server *server) ...@@ -33,8 +33,8 @@ static bool afs_fs_probe_done(struct afs_server *server)
void afs_fileserver_probe_result(struct afs_call *call) void afs_fileserver_probe_result(struct afs_call *call)
{ {
struct afs_addr_list *alist = call->alist; struct afs_addr_list *alist = call->alist;
struct afs_server *server = call->reply[0]; struct afs_server *server = call->server;
unsigned int server_index = (long)call->reply[1]; unsigned int server_index = call->server_index;
unsigned int index = call->addr_ix; unsigned int index = call->addr_ix;
unsigned int rtt = UINT_MAX; unsigned int rtt = UINT_MAX;
bool have_result = false; bool have_result = false;
......
This diff is collapsed.
...@@ -111,8 +111,13 @@ struct afs_call { ...@@ -111,8 +111,13 @@ struct afs_call {
struct rxrpc_call *rxcall; /* RxRPC call handle */ struct rxrpc_call *rxcall; /* RxRPC call handle */
struct key *key; /* security for this call */ struct key *key; /* security for this call */
struct afs_net *net; /* The network namespace */ 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_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) */ void *request; /* request data (first part) */
struct address_space *mapping; /* Pages being written from */ struct address_space *mapping; /* Pages being written from */
struct iov_iter iter; /* Buffer iterator */ struct iov_iter iter; /* Buffer iterator */
...@@ -122,7 +127,21 @@ struct afs_call { ...@@ -122,7 +127,21 @@ struct afs_call {
struct bio_vec bvec[1]; struct bio_vec bvec[1];
}; };
void *buffer; /* reply receive buffer */ 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 first; /* first page in mapping to deal with */
pgoff_t last; /* last page in mapping to deal with */ pgoff_t last; /* last page in mapping to deal with */
atomic_t usage; atomic_t usage;
...@@ -146,7 +165,6 @@ struct afs_call { ...@@ -146,7 +165,6 @@ struct afs_call {
bool send_pages; /* T if data from mapping should be sent */ bool send_pages; /* T if data from mapping should be sent */
bool need_attention; /* T if RxRPC poked us */ bool need_attention; /* T if RxRPC poked us */
bool async; /* T if asynchronous */ bool async; /* T if asynchronous */
bool ret_reply0; /* T if should return reply[0] on success */
bool upgrade; /* T to request service upgrade */ bool upgrade; /* T to request service upgrade */
bool want_reply_time; /* T if want reply_time */ bool want_reply_time; /* T if want reply_time */
bool intr; /* T if interruptible */ bool intr; /* T if interruptible */
......
...@@ -188,7 +188,7 @@ void afs_put_call(struct afs_call *call) ...@@ -188,7 +188,7 @@ void afs_put_call(struct afs_call *call)
if (call->type->destructor) if (call->type->destructor)
call->type->destructor(call); 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_cb_interest(call->net, call->cbi);
afs_put_addrlist(call->alist); afs_put_addrlist(call->alist);
kfree(call->request); kfree(call->request);
...@@ -696,10 +696,9 @@ long afs_wait_for_call_to_complete(struct afs_call *call, ...@@ -696,10 +696,9 @@ long afs_wait_for_call_to_complete(struct afs_call *call,
ret = ac->error; ret = ac->error;
switch (ret) { switch (ret) {
case 0: case 0:
if (call->ret_reply0) { ret = call->ret0;
ret = (long)call->reply[0]; call->ret0 = 0;
call->reply[0] = NULL;
}
/* Fall through */ /* Fall through */
case -ECONNABORTED: case -ECONNABORTED:
ac->responded = true; ac->responded = true;
......
...@@ -33,8 +33,8 @@ static bool afs_vl_probe_done(struct afs_vlserver *server) ...@@ -33,8 +33,8 @@ static bool afs_vl_probe_done(struct afs_vlserver *server)
void afs_vlserver_probe_result(struct afs_call *call) void afs_vlserver_probe_result(struct afs_call *call)
{ {
struct afs_addr_list *alist = call->alist; struct afs_addr_list *alist = call->alist;
struct afs_vlserver *server = call->reply[0]; struct afs_vlserver *server = call->vlserver;
unsigned int server_index = (long)call->reply[1]; unsigned int server_index = call->server_index;
unsigned int index = call->addr_ix; unsigned int index = call->addr_ix;
unsigned int rtt = UINT_MAX; unsigned int rtt = UINT_MAX;
bool have_result = false; bool have_result = false;
......
...@@ -34,7 +34,7 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call) ...@@ -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 */ /* unmarshall the reply once we've received all of it */
uvldb = call->buffer; uvldb = call->buffer;
entry = call->reply[0]; entry = call->ret_vldb;
nr_servers = ntohl(uvldb->nServers); nr_servers = ntohl(uvldb->nServers);
if (nr_servers > AFS_NMAXNSERVERS) if (nr_servers > AFS_NMAXNSERVERS)
...@@ -110,7 +110,7 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call) ...@@ -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) 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); 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, ...@@ -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->key = vc->key;
call->reply[0] = entry; call->ret_vldb = entry;
call->ret_reply0 = true;
call->max_lifespan = AFS_VL_MAX_LIFESPAN; call->max_lifespan = AFS_VL_MAX_LIFESPAN;
/* Marshall the parameters */ /* Marshall the parameters */
...@@ -215,7 +214,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call) ...@@ -215,7 +214,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
if (!alist) if (!alist)
return -ENOMEM; return -ENOMEM;
alist->version = uniquifier; alist->version = uniquifier;
call->reply[0] = alist; call->ret_alist = alist;
call->count = count; call->count = count;
call->count2 = nentries; call->count2 = nentries;
call->unmarshall++; call->unmarshall++;
...@@ -230,7 +229,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call) ...@@ -230,7 +229,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
if (ret < 0) if (ret < 0)
return ret; return ret;
alist = call->reply[0]; alist = call->ret_alist;
bp = call->buffer; bp = call->buffer;
count = min(call->count, 4U); count = min(call->count, 4U);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
...@@ -250,8 +249,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call) ...@@ -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) static void afs_vl_get_addrs_u_destructor(struct afs_call *call)
{ {
afs_put_server(call->net, (struct afs_server *)call->reply[0]); afs_put_addrlist(call->ret_alist);
kfree(call->reply[1]);
return afs_flat_call_destructor(call); return afs_flat_call_destructor(call);
} }
...@@ -288,8 +286,7 @@ struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *vc, ...@@ -288,8 +286,7 @@ struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *vc,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
call->key = vc->key; call->key = vc->key;
call->reply[0] = NULL; call->ret_alist = NULL;
call->ret_reply0 = true;
call->max_lifespan = AFS_VL_MAX_LIFESPAN; call->max_lifespan = AFS_VL_MAX_LIFESPAN;
/* Marshall the parameters */ /* Marshall the parameters */
...@@ -360,9 +357,7 @@ static int afs_deliver_vl_get_capabilities(struct afs_call *call) ...@@ -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) static void afs_destroy_vl_get_capabilities(struct afs_call *call)
{ {
struct afs_vlserver *server = call->reply[0]; afs_put_vlserver(call->net, call->vlserver);
afs_put_vlserver(call->net, server);
afs_flat_call_destructor(call); afs_flat_call_destructor(call);
} }
...@@ -400,8 +395,8 @@ struct afs_call *afs_vl_get_capabilities(struct afs_net *net, ...@@ -400,8 +395,8 @@ struct afs_call *afs_vl_get_capabilities(struct afs_net *net,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
call->key = key; call->key = key;
call->reply[0] = afs_get_vlserver(server); call->vlserver = afs_get_vlserver(server);
call->reply[1] = (void *)(long)server_index; call->server_index = server_index;
call->upgrade = true; call->upgrade = true;
call->want_reply_time = true; call->want_reply_time = true;
call->async = true; call->async = true;
...@@ -463,7 +458,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call) ...@@ -463,7 +458,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
if (!alist) if (!alist)
return -ENOMEM; return -ENOMEM;
alist->version = uniquifier; alist->version = uniquifier;
call->reply[0] = alist; call->ret_alist = alist;
if (call->count == 0) if (call->count == 0)
goto extract_volendpoints; goto extract_volendpoints;
...@@ -491,7 +486,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call) ...@@ -491,7 +486,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
if (ret < 0) if (ret < 0)
return ret; return ret;
alist = call->reply[0]; alist = call->ret_alist;
bp = call->buffer; bp = call->buffer;
switch (call->count2) { switch (call->count2) {
case YFS_ENDPOINT_IPV4: case YFS_ENDPOINT_IPV4:
...@@ -612,7 +607,6 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call) ...@@ -612,7 +607,6 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
break; break;
} }
alist = call->reply[0];
_leave(" = 0 [done]"); _leave(" = 0 [done]");
return 0; return 0;
} }
...@@ -647,8 +641,7 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc, ...@@ -647,8 +641,7 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
call->key = vc->key; call->key = vc->key;
call->reply[0] = NULL; call->ret_alist = NULL;
call->ret_reply0 = true;
call->max_lifespan = AFS_VL_MAX_LIFESPAN; call->max_lifespan = AFS_VL_MAX_LIFESPAN;
/* Marshall the parameters */ /* 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