2007-04-26 16:49:28 -06:00
|
|
|
/* AFS Volume Location Service client
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
|
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/gfp.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/sched.h>
|
2017-11-02 09:27:47 -06:00
|
|
|
#include "afs_fs.h"
|
2005-04-16 16:20:36 -06:00
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
/*
|
2007-04-26 16:55:03 -06:00
|
|
|
* deliver reply data to a VL.GetEntryByXXX call
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
rxrpc: Don't expose skbs to in-kernel users [ver #2]
Don't expose skbs to in-kernel users, such as the AFS filesystem, but
instead provide a notification hook the indicates that a call needs
attention and another that indicates that there's a new call to be
collected.
This makes the following possibilities more achievable:
(1) Call refcounting can be made simpler if skbs don't hold refs to calls.
(2) skbs referring to non-data events will be able to be freed much sooner
rather than being queued for AFS to pick up as rxrpc_kernel_recv_data
will be able to consult the call state.
(3) We can shortcut the receive phase when a call is remotely aborted
because we don't have to go through all the packets to get to the one
cancelling the operation.
(4) It makes it easier to do encryption/decryption directly between AFS's
buffers and sk_buffs.
(5) Encryption/decryption can more easily be done in the AFS's thread
contexts - usually that of the userspace process that issued a syscall
- rather than in one of rxrpc's background threads on a workqueue.
(6) AFS will be able to wait synchronously on a call inside AF_RXRPC.
To make this work, the following interface function has been added:
int rxrpc_kernel_recv_data(
struct socket *sock, struct rxrpc_call *call,
void *buffer, size_t bufsize, size_t *_offset,
bool want_more, u32 *_abort_code);
This is the recvmsg equivalent. It allows the caller to find out about the
state of a specific call and to transfer received data into a buffer
piecemeal.
afs_extract_data() and rxrpc_kernel_recv_data() now do all the extraction
logic between them. They don't wait synchronously yet because the socket
lock needs to be dealt with.
Five interface functions have been removed:
rxrpc_kernel_is_data_last()
rxrpc_kernel_get_abort_code()
rxrpc_kernel_get_error_number()
rxrpc_kernel_free_skb()
rxrpc_kernel_data_consumed()
As a temporary hack, sk_buffs going to an in-kernel call are queued on the
rxrpc_call struct (->knlrecv_queue) rather than being handed over to the
in-kernel user. To process the queue internally, a temporary function,
temp_deliver_data() has been added. This will be replaced with common code
between the rxrpc_recvmsg() path and the kernel_rxrpc_recv_data() path in a
future patch.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-08-30 13:42:14 -06:00
|
|
|
static int afs_deliver_vl_get_entry_by_xxx(struct afs_call *call)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2007-04-26 16:55:03 -06:00
|
|
|
struct afs_cache_vlocation *entry;
|
|
|
|
__be32 *bp;
|
|
|
|
u32 tmp;
|
rxrpc: Fix races between skb free, ACK generation and replying
Inside the kafs filesystem it is possible to occasionally have a call
processed and terminated before we've had a chance to check whether we need
to clean up the rx queue for that call because afs_send_simple_reply() ends
the call when it is done, but this is done in a workqueue item that might
happen to run to completion before afs_deliver_to_call() completes.
Further, it is possible for rxrpc_kernel_send_data() to be called to send a
reply before the last request-phase data skb is released. The rxrpc skb
destructor is where the ACK processing is done and the call state is
advanced upon release of the last skb. ACK generation is also deferred to
a work item because it's possible that the skb destructor is not called in
a context where kernel_sendmsg() can be invoked.
To this end, the following changes are made:
(1) kernel_rxrpc_data_consumed() is added. This should be called whenever
an skb is emptied so as to crank the ACK and call states. This does
not release the skb, however. kernel_rxrpc_free_skb() must now be
called to achieve that. These together replace
rxrpc_kernel_data_delivered().
(2) kernel_rxrpc_data_consumed() is wrapped by afs_data_consumed().
This makes afs_deliver_to_call() easier to work as the skb can simply
be discarded unconditionally here without trying to work out what the
return value of the ->deliver() function means.
The ->deliver() functions can, via afs_data_complete(),
afs_transfer_reply() and afs_extract_data() mark that an skb has been
consumed (thereby cranking the state) without the need to
conditionally free the skb to make sure the state is correct on an
incoming call for when the call processor tries to send the reply.
(3) rxrpc_recvmsg() now has to call kernel_rxrpc_data_consumed() when it
has finished with a packet and MSG_PEEK isn't set.
(4) rxrpc_packet_destructor() no longer calls rxrpc_hard_ACK_data().
Because of this, we no longer need to clear the destructor and put the
call before we free the skb in cases where we don't want the ACK/call
state to be cranked.
(5) The ->deliver() call-type callbacks are made to return -EAGAIN rather
than 0 if they expect more data (afs_extract_data() returns -EAGAIN to
the delivery function already), and the caller is now responsible for
producing an abort if that was the last packet.
(6) There are many bits of unmarshalling code where:
ret = afs_extract_data(call, skb, last, ...);
switch (ret) {
case 0: break;
case -EAGAIN: return 0;
default: return ret;
}
is to be found. As -EAGAIN can now be passed back to the caller, we
now just return if ret < 0:
ret = afs_extract_data(call, skb, last, ...);
if (ret < 0)
return ret;
(7) Checks for trailing data and empty final data packets has been
consolidated as afs_data_complete(). So:
if (skb->len > 0)
return -EBADMSG;
if (!last)
return 0;
becomes:
ret = afs_data_complete(call, skb, last);
if (ret < 0)
return ret;
(8) afs_transfer_reply() now checks the amount of data it has against the
amount of data desired and the amount of data in the skb and returns
an error to induce an abort if we don't get exactly what we want.
Without these changes, the following oops can occasionally be observed,
particularly if some printks are inserted into the delivery path:
general protection fault: 0000 [#1] SMP
Modules linked in: kafs(E) af_rxrpc(E) [last unloaded: af_rxrpc]
CPU: 0 PID: 1305 Comm: kworker/u8:3 Tainted: G E 4.7.0-fsdevel+ #1303
Hardware name: ASUS All Series/H97-PLUS, BIOS 2306 10/09/2014
Workqueue: kafsd afs_async_workfn [kafs]
task: ffff88040be041c0 ti: ffff88040c070000 task.ti: ffff88040c070000
RIP: 0010:[<ffffffff8108fd3c>] [<ffffffff8108fd3c>] __lock_acquire+0xcf/0x15a1
RSP: 0018:ffff88040c073bc0 EFLAGS: 00010002
RAX: 6b6b6b6b6b6b6b6b RBX: 0000000000000000 RCX: ffff88040d29a710
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88040d29a710
RBP: ffff88040c073c70 R08: 0000000000000001 R09: 0000000000000001
R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: ffff88040be041c0 R15: ffffffff814c928f
FS: 0000000000000000(0000) GS:ffff88041fa00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa4595f4750 CR3: 0000000001c14000 CR4: 00000000001406f0
Stack:
0000000000000006 000000000be04930 0000000000000000 ffff880400000000
ffff880400000000 ffffffff8108f847 ffff88040be041c0 ffffffff81050446
ffff8803fc08a920 ffff8803fc08a958 ffff88040be041c0 ffff88040c073c38
Call Trace:
[<ffffffff8108f847>] ? mark_held_locks+0x5e/0x74
[<ffffffff81050446>] ? __local_bh_enable_ip+0x9b/0xa1
[<ffffffff8108f9ca>] ? trace_hardirqs_on_caller+0x16d/0x189
[<ffffffff810915f4>] lock_acquire+0x122/0x1b6
[<ffffffff810915f4>] ? lock_acquire+0x122/0x1b6
[<ffffffff814c928f>] ? skb_dequeue+0x18/0x61
[<ffffffff81609dbf>] _raw_spin_lock_irqsave+0x35/0x49
[<ffffffff814c928f>] ? skb_dequeue+0x18/0x61
[<ffffffff814c928f>] skb_dequeue+0x18/0x61
[<ffffffffa009aa92>] afs_deliver_to_call+0x344/0x39d [kafs]
[<ffffffffa009ab37>] afs_process_async_call+0x4c/0xd5 [kafs]
[<ffffffffa0099e9c>] afs_async_workfn+0xe/0x10 [kafs]
[<ffffffff81063a3a>] process_one_work+0x29d/0x57c
[<ffffffff81064ac2>] worker_thread+0x24a/0x385
[<ffffffff81064878>] ? rescuer_thread+0x2d0/0x2d0
[<ffffffff810696f5>] kthread+0xf3/0xfb
[<ffffffff8160a6ff>] ret_from_fork+0x1f/0x40
[<ffffffff81069602>] ? kthread_create_on_node+0x1cf/0x1cf
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-08-03 07:11:40 -06:00
|
|
|
int loop, ret;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
rxrpc: Don't expose skbs to in-kernel users [ver #2]
Don't expose skbs to in-kernel users, such as the AFS filesystem, but
instead provide a notification hook the indicates that a call needs
attention and another that indicates that there's a new call to be
collected.
This makes the following possibilities more achievable:
(1) Call refcounting can be made simpler if skbs don't hold refs to calls.
(2) skbs referring to non-data events will be able to be freed much sooner
rather than being queued for AFS to pick up as rxrpc_kernel_recv_data
will be able to consult the call state.
(3) We can shortcut the receive phase when a call is remotely aborted
because we don't have to go through all the packets to get to the one
cancelling the operation.
(4) It makes it easier to do encryption/decryption directly between AFS's
buffers and sk_buffs.
(5) Encryption/decryption can more easily be done in the AFS's thread
contexts - usually that of the userspace process that issued a syscall
- rather than in one of rxrpc's background threads on a workqueue.
(6) AFS will be able to wait synchronously on a call inside AF_RXRPC.
To make this work, the following interface function has been added:
int rxrpc_kernel_recv_data(
struct socket *sock, struct rxrpc_call *call,
void *buffer, size_t bufsize, size_t *_offset,
bool want_more, u32 *_abort_code);
This is the recvmsg equivalent. It allows the caller to find out about the
state of a specific call and to transfer received data into a buffer
piecemeal.
afs_extract_data() and rxrpc_kernel_recv_data() now do all the extraction
logic between them. They don't wait synchronously yet because the socket
lock needs to be dealt with.
Five interface functions have been removed:
rxrpc_kernel_is_data_last()
rxrpc_kernel_get_abort_code()
rxrpc_kernel_get_error_number()
rxrpc_kernel_free_skb()
rxrpc_kernel_data_consumed()
As a temporary hack, sk_buffs going to an in-kernel call are queued on the
rxrpc_call struct (->knlrecv_queue) rather than being handed over to the
in-kernel user. To process the queue internally, a temporary function,
temp_deliver_data() has been added. This will be replaced with common code
between the rxrpc_recvmsg() path and the kernel_rxrpc_recv_data() path in a
future patch.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-08-30 13:42:14 -06:00
|
|
|
_enter("");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
rxrpc: Don't expose skbs to in-kernel users [ver #2]
Don't expose skbs to in-kernel users, such as the AFS filesystem, but
instead provide a notification hook the indicates that a call needs
attention and another that indicates that there's a new call to be
collected.
This makes the following possibilities more achievable:
(1) Call refcounting can be made simpler if skbs don't hold refs to calls.
(2) skbs referring to non-data events will be able to be freed much sooner
rather than being queued for AFS to pick up as rxrpc_kernel_recv_data
will be able to consult the call state.
(3) We can shortcut the receive phase when a call is remotely aborted
because we don't have to go through all the packets to get to the one
cancelling the operation.
(4) It makes it easier to do encryption/decryption directly between AFS's
buffers and sk_buffs.
(5) Encryption/decryption can more easily be done in the AFS's thread
contexts - usually that of the userspace process that issued a syscall
- rather than in one of rxrpc's background threads on a workqueue.
(6) AFS will be able to wait synchronously on a call inside AF_RXRPC.
To make this work, the following interface function has been added:
int rxrpc_kernel_recv_data(
struct socket *sock, struct rxrpc_call *call,
void *buffer, size_t bufsize, size_t *_offset,
bool want_more, u32 *_abort_code);
This is the recvmsg equivalent. It allows the caller to find out about the
state of a specific call and to transfer received data into a buffer
piecemeal.
afs_extract_data() and rxrpc_kernel_recv_data() now do all the extraction
logic between them. They don't wait synchronously yet because the socket
lock needs to be dealt with.
Five interface functions have been removed:
rxrpc_kernel_is_data_last()
rxrpc_kernel_get_abort_code()
rxrpc_kernel_get_error_number()
rxrpc_kernel_free_skb()
rxrpc_kernel_data_consumed()
As a temporary hack, sk_buffs going to an in-kernel call are queued on the
rxrpc_call struct (->knlrecv_queue) rather than being handed over to the
in-kernel user. To process the queue internally, a temporary function,
temp_deliver_data() has been added. This will be replaced with common code
between the rxrpc_recvmsg() path and the kernel_rxrpc_recv_data() path in a
future patch.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-08-30 13:42:14 -06:00
|
|
|
ret = afs_transfer_reply(call);
|
rxrpc: Fix races between skb free, ACK generation and replying
Inside the kafs filesystem it is possible to occasionally have a call
processed and terminated before we've had a chance to check whether we need
to clean up the rx queue for that call because afs_send_simple_reply() ends
the call when it is done, but this is done in a workqueue item that might
happen to run to completion before afs_deliver_to_call() completes.
Further, it is possible for rxrpc_kernel_send_data() to be called to send a
reply before the last request-phase data skb is released. The rxrpc skb
destructor is where the ACK processing is done and the call state is
advanced upon release of the last skb. ACK generation is also deferred to
a work item because it's possible that the skb destructor is not called in
a context where kernel_sendmsg() can be invoked.
To this end, the following changes are made:
(1) kernel_rxrpc_data_consumed() is added. This should be called whenever
an skb is emptied so as to crank the ACK and call states. This does
not release the skb, however. kernel_rxrpc_free_skb() must now be
called to achieve that. These together replace
rxrpc_kernel_data_delivered().
(2) kernel_rxrpc_data_consumed() is wrapped by afs_data_consumed().
This makes afs_deliver_to_call() easier to work as the skb can simply
be discarded unconditionally here without trying to work out what the
return value of the ->deliver() function means.
The ->deliver() functions can, via afs_data_complete(),
afs_transfer_reply() and afs_extract_data() mark that an skb has been
consumed (thereby cranking the state) without the need to
conditionally free the skb to make sure the state is correct on an
incoming call for when the call processor tries to send the reply.
(3) rxrpc_recvmsg() now has to call kernel_rxrpc_data_consumed() when it
has finished with a packet and MSG_PEEK isn't set.
(4) rxrpc_packet_destructor() no longer calls rxrpc_hard_ACK_data().
Because of this, we no longer need to clear the destructor and put the
call before we free the skb in cases where we don't want the ACK/call
state to be cranked.
(5) The ->deliver() call-type callbacks are made to return -EAGAIN rather
than 0 if they expect more data (afs_extract_data() returns -EAGAIN to
the delivery function already), and the caller is now responsible for
producing an abort if that was the last packet.
(6) There are many bits of unmarshalling code where:
ret = afs_extract_data(call, skb, last, ...);
switch (ret) {
case 0: break;
case -EAGAIN: return 0;
default: return ret;
}
is to be found. As -EAGAIN can now be passed back to the caller, we
now just return if ret < 0:
ret = afs_extract_data(call, skb, last, ...);
if (ret < 0)
return ret;
(7) Checks for trailing data and empty final data packets has been
consolidated as afs_data_complete(). So:
if (skb->len > 0)
return -EBADMSG;
if (!last)
return 0;
becomes:
ret = afs_data_complete(call, skb, last);
if (ret < 0)
return ret;
(8) afs_transfer_reply() now checks the amount of data it has against the
amount of data desired and the amount of data in the skb and returns
an error to induce an abort if we don't get exactly what we want.
Without these changes, the following oops can occasionally be observed,
particularly if some printks are inserted into the delivery path:
general protection fault: 0000 [#1] SMP
Modules linked in: kafs(E) af_rxrpc(E) [last unloaded: af_rxrpc]
CPU: 0 PID: 1305 Comm: kworker/u8:3 Tainted: G E 4.7.0-fsdevel+ #1303
Hardware name: ASUS All Series/H97-PLUS, BIOS 2306 10/09/2014
Workqueue: kafsd afs_async_workfn [kafs]
task: ffff88040be041c0 ti: ffff88040c070000 task.ti: ffff88040c070000
RIP: 0010:[<ffffffff8108fd3c>] [<ffffffff8108fd3c>] __lock_acquire+0xcf/0x15a1
RSP: 0018:ffff88040c073bc0 EFLAGS: 00010002
RAX: 6b6b6b6b6b6b6b6b RBX: 0000000000000000 RCX: ffff88040d29a710
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88040d29a710
RBP: ffff88040c073c70 R08: 0000000000000001 R09: 0000000000000001
R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: ffff88040be041c0 R15: ffffffff814c928f
FS: 0000000000000000(0000) GS:ffff88041fa00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa4595f4750 CR3: 0000000001c14000 CR4: 00000000001406f0
Stack:
0000000000000006 000000000be04930 0000000000000000 ffff880400000000
ffff880400000000 ffffffff8108f847 ffff88040be041c0 ffffffff81050446
ffff8803fc08a920 ffff8803fc08a958 ffff88040be041c0 ffff88040c073c38
Call Trace:
[<ffffffff8108f847>] ? mark_held_locks+0x5e/0x74
[<ffffffff81050446>] ? __local_bh_enable_ip+0x9b/0xa1
[<ffffffff8108f9ca>] ? trace_hardirqs_on_caller+0x16d/0x189
[<ffffffff810915f4>] lock_acquire+0x122/0x1b6
[<ffffffff810915f4>] ? lock_acquire+0x122/0x1b6
[<ffffffff814c928f>] ? skb_dequeue+0x18/0x61
[<ffffffff81609dbf>] _raw_spin_lock_irqsave+0x35/0x49
[<ffffffff814c928f>] ? skb_dequeue+0x18/0x61
[<ffffffff814c928f>] skb_dequeue+0x18/0x61
[<ffffffffa009aa92>] afs_deliver_to_call+0x344/0x39d [kafs]
[<ffffffffa009ab37>] afs_process_async_call+0x4c/0xd5 [kafs]
[<ffffffffa0099e9c>] afs_async_workfn+0xe/0x10 [kafs]
[<ffffffff81063a3a>] process_one_work+0x29d/0x57c
[<ffffffff81064ac2>] worker_thread+0x24a/0x385
[<ffffffff81064878>] ? rescuer_thread+0x2d0/0x2d0
[<ffffffff810696f5>] kthread+0xf3/0xfb
[<ffffffff8160a6ff>] ret_from_fork+0x1f/0x40
[<ffffffff81069602>] ? kthread_create_on_node+0x1cf/0x1cf
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-08-03 07:11:40 -06:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-26 16:55:03 -06:00
|
|
|
/* unmarshall the reply once we've received all of it */
|
2017-11-02 09:27:48 -06:00
|
|
|
entry = call->reply[0];
|
2007-04-26 16:55:03 -06:00
|
|
|
bp = call->buffer;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
for (loop = 0; loop < 64; loop++)
|
|
|
|
entry->name[loop] = ntohl(*bp++);
|
2007-04-26 16:55:03 -06:00
|
|
|
entry->name[loop] = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
bp++; /* final NUL */
|
|
|
|
|
|
|
|
bp++; /* type */
|
|
|
|
entry->nservers = ntohl(*bp++);
|
|
|
|
|
2017-11-02 09:27:47 -06:00
|
|
|
for (loop = 0; loop < 8; loop++) {
|
|
|
|
entry->servers[loop].srx_family = AF_RXRPC;
|
|
|
|
entry->servers[loop].srx_service = FS_SERVICE;
|
|
|
|
entry->servers[loop].transport_type = SOCK_DGRAM;
|
2017-11-02 09:27:47 -06:00
|
|
|
entry->servers[loop].transport_len = sizeof(entry->servers[loop].transport.sin6);
|
|
|
|
entry->servers[loop].transport.sin6.sin6_family = AF_INET6;
|
|
|
|
entry->servers[loop].transport.sin6.sin6_port = htons(AFS_FS_PORT);
|
|
|
|
entry->servers[loop].transport.sin6.sin6_flowinfo = 0;
|
|
|
|
entry->servers[loop].transport.sin6.sin6_scope_id = 0;
|
|
|
|
entry->servers[loop].transport.sin6.sin6_addr.s6_addr32[0] = 0;
|
|
|
|
entry->servers[loop].transport.sin6.sin6_addr.s6_addr32[1] = 0;
|
|
|
|
entry->servers[loop].transport.sin6.sin6_addr.s6_addr32[2] = htonl(0xffff);
|
|
|
|
entry->servers[loop].transport.sin6.sin6_addr.s6_addr32[3] = *bp++;
|
2017-11-02 09:27:47 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
bp += 8; /* partition IDs */
|
|
|
|
|
|
|
|
for (loop = 0; loop < 8; loop++) {
|
|
|
|
tmp = ntohl(*bp++);
|
2007-04-26 16:55:03 -06:00
|
|
|
entry->srvtmask[loop] = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
if (tmp & AFS_VLSF_RWVOL)
|
|
|
|
entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
|
|
|
|
if (tmp & AFS_VLSF_ROVOL)
|
|
|
|
entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
|
|
|
|
if (tmp & AFS_VLSF_BACKVOL)
|
|
|
|
entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry->vid[0] = ntohl(*bp++);
|
|
|
|
entry->vid[1] = ntohl(*bp++);
|
|
|
|
entry->vid[2] = ntohl(*bp++);
|
|
|
|
|
|
|
|
bp++; /* clone ID */
|
|
|
|
|
|
|
|
tmp = ntohl(*bp++); /* flags */
|
2007-04-26 16:55:03 -06:00
|
|
|
entry->vidmask = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
if (tmp & AFS_VLF_RWEXISTS)
|
|
|
|
entry->vidmask |= AFS_VOL_VTM_RW;
|
|
|
|
if (tmp & AFS_VLF_ROEXISTS)
|
|
|
|
entry->vidmask |= AFS_VOL_VTM_RO;
|
|
|
|
if (tmp & AFS_VLF_BACKEXISTS)
|
|
|
|
entry->vidmask |= AFS_VOL_VTM_BAK;
|
|
|
|
if (!entry->vidmask)
|
2007-04-26 16:55:03 -06:00
|
|
|
return -EBADMSG;
|
|
|
|
|
|
|
|
_leave(" = 0 [done]");
|
|
|
|
return 0;
|
2007-04-26 16:49:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
2007-04-26 16:55:03 -06:00
|
|
|
* VL.GetEntryByName operation type
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2007-04-26 16:55:03 -06:00
|
|
|
static const struct afs_call_type afs_RXVLGetEntryByName = {
|
2007-04-26 16:57:07 -06:00
|
|
|
.name = "VL.GetEntryByName",
|
2007-04-26 16:55:03 -06:00
|
|
|
.deliver = afs_deliver_vl_get_entry_by_xxx,
|
|
|
|
.destructor = afs_flat_call_destructor,
|
|
|
|
};
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-26 16:55:03 -06:00
|
|
|
/*
|
|
|
|
* VL.GetEntryById operation type
|
|
|
|
*/
|
|
|
|
static const struct afs_call_type afs_RXVLGetEntryById = {
|
2007-04-26 16:57:07 -06:00
|
|
|
.name = "VL.GetEntryById",
|
2007-04-26 16:55:03 -06:00
|
|
|
.deliver = afs_deliver_vl_get_entry_by_xxx,
|
|
|
|
.destructor = afs_flat_call_destructor,
|
|
|
|
};
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
2007-04-26 16:55:03 -06:00
|
|
|
* dispatch a get volume entry by name operation
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2017-11-02 09:27:45 -06:00
|
|
|
int afs_vl_get_entry_by_name(struct afs_net *net,
|
2017-11-02 09:27:50 -06:00
|
|
|
struct afs_addr_cursor *ac,
|
2007-04-26 16:57:07 -06:00
|
|
|
struct key *key,
|
2007-04-26 16:55:03 -06:00
|
|
|
const char *volname,
|
|
|
|
struct afs_cache_vlocation *entry,
|
2017-01-05 03:38:36 -07:00
|
|
|
bool async)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2007-04-26 16:55:03 -06:00
|
|
|
struct afs_call *call;
|
|
|
|
size_t volnamesz, reqsz, padsz;
|
|
|
|
__be32 *bp;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-26 16:55:03 -06:00
|
|
|
_enter("");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-26 16:55:03 -06:00
|
|
|
volnamesz = strlen(volname);
|
|
|
|
padsz = (4 - (volnamesz & 3)) & 3;
|
|
|
|
reqsz = 8 + volnamesz + padsz;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2017-11-02 09:27:45 -06:00
|
|
|
call = afs_alloc_flat_call(net, &afs_RXVLGetEntryByName, reqsz, 384);
|
2007-04-26 16:55:03 -06:00
|
|
|
if (!call)
|
|
|
|
return -ENOMEM;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-26 16:57:07 -06:00
|
|
|
call->key = key;
|
2017-11-02 09:27:48 -06:00
|
|
|
call->reply[0] = entry;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* marshall the parameters */
|
2007-04-26 16:55:03 -06:00
|
|
|
bp = call->request;
|
|
|
|
*bp++ = htonl(VLGETENTRYBYNAME);
|
|
|
|
*bp++ = htonl(volnamesz);
|
|
|
|
memcpy(bp, volname, volnamesz);
|
|
|
|
if (padsz > 0)
|
|
|
|
memset((void *) bp + volnamesz, 0, padsz);
|
|
|
|
|
|
|
|
/* initiate the call */
|
2017-11-02 09:27:50 -06:00
|
|
|
return afs_make_call(ac, call, GFP_KERNEL, async);
|
2007-04-26 16:49:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
2007-04-26 16:55:03 -06:00
|
|
|
* dispatch a get volume entry by ID operation
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2017-11-02 09:27:45 -06:00
|
|
|
int afs_vl_get_entry_by_id(struct afs_net *net,
|
2017-11-02 09:27:50 -06:00
|
|
|
struct afs_addr_cursor *ac,
|
2007-04-26 16:57:07 -06:00
|
|
|
struct key *key,
|
2007-04-26 16:55:03 -06:00
|
|
|
afs_volid_t volid,
|
|
|
|
afs_voltype_t voltype,
|
|
|
|
struct afs_cache_vlocation *entry,
|
2017-01-05 03:38:36 -07:00
|
|
|
bool async)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2007-04-26 16:55:03 -06:00
|
|
|
struct afs_call *call;
|
2005-04-16 16:20:36 -06:00
|
|
|
__be32 *bp;
|
|
|
|
|
2007-04-26 16:55:03 -06:00
|
|
|
_enter("");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2017-11-02 09:27:45 -06:00
|
|
|
call = afs_alloc_flat_call(net, &afs_RXVLGetEntryById, 12, 384);
|
2007-04-26 16:55:03 -06:00
|
|
|
if (!call)
|
|
|
|
return -ENOMEM;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-26 16:57:07 -06:00
|
|
|
call->key = key;
|
2017-11-02 09:27:48 -06:00
|
|
|
call->reply[0] = entry;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-26 16:55:03 -06:00
|
|
|
/* marshall the parameters */
|
|
|
|
bp = call->request;
|
|
|
|
*bp++ = htonl(VLGETENTRYBYID);
|
|
|
|
*bp++ = htonl(volid);
|
|
|
|
*bp = htonl(voltype);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-26 16:55:03 -06:00
|
|
|
/* initiate the call */
|
2017-11-02 09:27:50 -06:00
|
|
|
return afs_make_call(ac, call, GFP_KERNEL, async);
|
2007-04-26 16:49:28 -06:00
|
|
|
}
|