afs: Fix probe handling, server rotation and RO volume callback handling
Subsystems (6)
David Howells
maintainercover afs: Fix probe handling, server rotation and RO volume callback handling
Hi Marc,
Here are a set of patches to make some substantial fixes to the afs filesystem including:
(1) Fix fileserver probe handling so that the next round of probes doesn't break ongoing server/address rotation by clearing all the probe result tracking. Instead, detach the probe results into a separate struct and allocate a new one each time we start probing and update the pointer to it. Probes are also sent in order of address preference to try and improve the chance that the preferred one will complete first.
(2) Fix server rotation so that it uses configurable address preferences across on the probes that have completed so far than ranking them by RTT as the latter doesn't necessarily give the best route. The preference list can be altered by echoing commands into /proc/net/afs/addr_prefs.
(3) Fix the handling of Read-Only (and Backup) volume callbacks as there is one per volume, not one per file, so if someone performs a command that, say, offlines the volume but doesn't change it, when it comes back online we don't spam the server with a status fetch for every vnode we're using. Instead, check the Creation timestamp in the VolSync record when prompted by a callback break.
(4) Handle volume regression (ie. a RW volume being restored from a backup) by scrubbing all cache data for that volume. This is detected from the VolSync creation timestamp.
(5) Adjust abort handling and abort -> error mapping to match better with what other AFS clients do.
(6) Handle file locking locally on RO volumes rather than trying to get them on the server. Exclusive locks aren't really handled in a RO volume.
(7) Set RO volumes to be RO superblocks.
(8) Fix offline and busy volume state handling as they only apply to individual server instances and not entire volumes and the rotation algorithm should go and look at other servers if available. Also make it sleep briefly before each retry if all the volume instances are unavailable.
In addition there are a number of small fixes in rxrpc and afs included here so that those problems don't affect testing.
The patches can be found here:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=afs-fixes
Thanks,
David
---
%(shortlog)s
%(diffstat)s
David Howells (41):
rxrpc: Fix RTT determination to use PING ACKs as a source
rxrpc: Fix two connection reaping bugs
rxrpc: Fix some minor issues with bundle tracing
afs: Fix afs_server_list to be cleaned up with RCU
afs: Make error on cell lookup failure consistent with OpenAFS
afs: Remove whitespace before most ')' from the trace header
afs: Automatically generate trace tag enums
afs: Add comments on abort handling
afs: Turn the afs_addr_list address array into an array of structs rxrpc, afs: Allow afs to pin rxrpc_peer objects
afs: Don't skip server addresses for which we didn't get an RTT
reading
afs: Rename addr_list::failed to probe_failed
afs: Handle the VIO abort explicitly
afs: Use op->nr_iterations=-1 to indicate to begin fileserver
iteration
afs: Return ENOENT if no cell DNS record can be found
afs: Wrap most op->error accesses with inline funcs
afs: Don't put afs_call in afs_wait_for_call_to_complete()
afs: Simplify error handling
afs: Add a tracepoint for struct afs_addr_list
afs: Rename some fields
afs: Use peer + service_id as call address
afs: Fold the afs_addr_cursor struct in
rxrpc: Create a procfile to display outstanding clien conn bundles
afs: Add some more info to /proc/net/afs/servers
afs: Remove the unimplemented afs_cmp_addr_list()
afs: Provide a way to configure address priorities
afs: Mark address lists with configured priorities
afs: Dispatch fileserver probes in priority order
afs: Dispatch vlserver probes in priority order
afs: Keep a record of the current fileserver endpoint state
afs: Combine the endpoint state bools into a bitmask
afs: Fix file locking on R/O volumes to operate in local mode
afs: Mark a superblock for an R/O or Backup volume as SB_RDONLY
afs: Make it possible to find the volumes that are using a server
afs: Defer volume record destruction to a workqueue
afs: Move the vnode/volume validity checking code into its own file
afs: Apply server breaks to mmap'd files in the call processor
afs: Parse the VolSync record in the reply of a number of RPC ops
afs: Overhaul invalidation handling to better support RO volumes
afs: Fix fileserver rotation
afs: Fix offline and busy handling
fs/afs/Makefile | 2 + fs/afs/addr_list.c | 224 +++++------ fs/afs/addr_prefs.c | 531 +++++++++++++++++++++++++ fs/afs/afs.h | 4 + fs/afs/callback.c | 138 ++++--- fs/afs/cell.c | 5 +- fs/afs/cmservice.c | 5 +- fs/afs/dir.c | 55 +-- fs/afs/dir_silly.c | 2 +- fs/afs/dynroot.c | 4 +- fs/afs/file.c | 20 +- fs/afs/fs_operation.c | 86 ++-- fs/afs/fs_probe.c | 323 ++++++++------- fs/afs/fsclient.c | 56 ++- fs/afs/inode.c | 198 +--------- fs/afs/internal.h | 355 +++++++++++------ fs/afs/main.c | 1 + fs/afs/misc.c | 10 +- fs/afs/proc.c | 102 ++++- fs/afs/rotate.c | 495 ++++++++++++++++------- fs/afs/rxrpc.c | 107 ++--- fs/afs/server.c | 130 +++--- fs/afs/server_list.c | 126 +++++- fs/afs/super.c | 11 +- fs/afs/validation.c | 376 ++++++++++++++++++ fs/afs/vl_alias.c | 69 +--- fs/afs/vl_list.c | 29 +- fs/afs/vl_probe.c | 60 ++- fs/afs/vl_rotate.c | 223 +++++++---- fs/afs/vlclient.c | 124 ++++-- fs/afs/volume.c | 66 +++- fs/afs/write.c | 6 +- fs/afs/yfsclient.c | 6 +- include/net/af_rxrpc.h | 15 +- include/trace/events/afs.h | 742 +++++++++++++++++++---------------- include/trace/events/rxrpc.h | 3 + net/rxrpc/af_rxrpc.c | 62 ++- net/rxrpc/ar-internal.h | 6 +- net/rxrpc/call_object.c | 17 +- net/rxrpc/conn_client.c | 17 +- net/rxrpc/conn_object.c | 2 +- net/rxrpc/input.c | 4 + net/rxrpc/local_object.c | 2 +- net/rxrpc/net_ns.c | 4 + net/rxrpc/peer_object.c | 56 ++- net/rxrpc/proc.c | 76 ++++ net/rxrpc/sendmsg.c | 11 +- 47 files changed, 3304 insertions(+), 1662 deletions(-) create mode 100644 fs/afs/addr_prefs.c create mode 100644 fs/afs/validation.c
David Howells
maintainerPATCH 1/41 rxrpc: Fix RTT determination to use PING ACKs as a source
Fix RTT determination to use a PING ACK that is in marked as being in response to a DATA packet as the response from which RTT can be calculated from in lieu of a REQUESTED ACK. The server may send the latter instead of the former.
--- net/rxrpc/input.c | 4 ++++ 1 file changed, 4 insertions(+)
net/rxrpc/input.c +4 -0
@@ -806,6 +806,10 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb)rxrpc_complete_rtt_probe (call, skb->tstamp, acked_serial, ack_serial, rxrpc_rtt_rx_ping_response);break ; +case RXRPC_ACK_PING : +if (acked_serial ==0 ) +break ; + fallthrough;case RXRPC_ACK_REQUESTED :rxrpc_complete_rtt_probe (call, skb->tstamp, acked_serial, ack_serial, rxrpc_rtt_rx_requested_ack);
Re: [PATCH 01/41] rxrpc: Fix RTT determination to use PING ACKs as a source
Quoted 18 lines · David Howells
Fix RTT determination to use a PING ACK that is in marked as being in response to a DATA packet as the response from which RTT can be calculated from in lieu of a REQUESTED ACK. The server may send the latter instead of the former.
Fixes 4700c4d80b7b ("rxrpc: Fix loss of RTT samples due to interposed ACK")Signed-off-by David Howells <[email protected]>cc Marc Dionne <[email protected]>--- net/rxrpc/input.c | 4 ++++ 1 file changed, 4 insertions(+)net/rxrpc/input.c +0
-0
net/rxrpc/input.c static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb) · line 815
Quoted 10 lines
net/rxrpc/input.c +4
-0@@ -806,6 +806,10 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb)rxrpc_complete_rtt_probe (call, skb->tstamp, acked_serial, ack_serial, rxrpc_rtt_rx_ping_response);break ; +case RXRPC_ACK_PING : +if (acked_serial ==0 ) +break ; + fallthrough;case RXRPC_ACK_REQUESTED :rxrpc_complete_rtt_probe (call, skb->tstamp, acked_serial, ack_serial, rxrpc_rtt_rx_requested_ack);
David,
I do not believe the ack_reason matters within rxrpc_input_ack(). As long as the acked_serial is non-zero, rxrpc_complete_rtt_probe() can be called to attempt to compute an RTT. If there is an exact match for the acked_serial then an RTT can be computed and if acked_serial is later than the pending rtt probe, the probe can be abandoned with the following caveats.
1. Receiving an acked_serial that is later than the serial of the transmitted probe indicates that a packet
transmitted after the probe was received first. Or that reordering of the transmitted packets occurred.
Or that the probe was never received by the peer; or that the peer's response to the probe was lost in
transit.
2. The serial number namespace is unsigned 32-bit shared across all of the call channels of the associated
rx connection. As the serial numbers will wrap the use of after() within rxrpc_complete_rtt_probe to
compare their values is questionable. If serial numbers will be compared in this manner then they
need to be locally tracked and compared as unsigned 64-bit values where only the low 32-bits are
transmitted on the wire and any wire serial number equal to zero is ignored.
Jeffrey Altman
David Howells
maintainerRe: [PATCH 01/41] rxrpc: Fix RTT determination to use PING ACKs as a source
I'm going to drop this patch from this series for now and send it separately.
Quoted 17 lines
I do not believe the
ack_reasonmatters withinrxrpc_input_ack(). As long as theacked_serialis non-zero,rxrpc_complete_rtt_probe()can be called to attempt to compute an RTT. If
there is an exact match for theacked_serialthen an RTT can be computed and ifacked_serialis later than the pending rtt probe, the probe
can be abandoned with the following caveats.1. Receiving an
acked_serialthat is later than the serial of the transmitted probe indicates that a packet
transmitted after the probe was received first. Or that reordering of the transmitted packets occurred.
Or that the probe was never received by the peer; or that the peer's response to the probe was lost in
transit.
2. The serial number namespace is unsigned 32-bit shared across all of the call channels of the associated
Quoted 8 lines
rx connection. As the serial numbers will wrap the use of
after()withinrxrpc_complete_rtt_probeto
compare their values is questionable. If serial numbers will be
compared in this manner then they
need to be locally tracked and compared as unsigned 64-bit values where only the low 32-bits are
transmitted on the wire and any wire serial number equal to zero is ignored.
I do ignore ack.serial == 0 for this purpose.
I'm not sure how expanding it internally to 64-bits actually helps since the upper 32 bits is not visible to the peer.
David
Re: [PATCH 01/41] rxrpc: Fix RTT determination to use PING ACKs as a source
Quoted 25 lines · David Howells
I do not believe the
ack_reasonmatters withinrxrpc_input_ack(). As long asQuoted 16 lines
the
acked_serialis non-zero,rxrpc_complete_rtt_probe()can be called to attempt to compute an RTT. If
there is an exact match for theacked_serialthen an RTT can be computed and ifacked_serialis later than the pending rtt probe, the probe
can be abandoned with the following caveats.1. Receiving an
acked_serialthat is later than the serial of the transmitted probe indicates that a packet
transmitted after the probe was received first. Or that reordering of the transmitted packets occurred.
Or that the probe was never received by the peer; or that the peer's response to the probe was lost in
transit.
2. The serial number namespace is unsigned 32-bit shared across all of the call channels of the associatedQuoted 8 lines
rx connection. As the serial numbers will wrap the use of
after()withinrxrpc_complete_rtt_probeto
compare their values is questionable. If serial numbers will be
compared in this manner then they
need to be locally tracked and compared as unsigned 64-bit values where only the low 32-bits are
transmitted on the wire and any wire serial number equal to zero is ignored.
Quoted 1 line
I do ignore ack.serial == 0 for this purpose.
Zero has the special meaning - this ACK is not explicitly in response to a received packet.
However, as mentioned, the serial number counter wraps frequently and most RxRPC implementations do not transition from serial 0xffffffff -> 0x00000001 when wrapping.
Quoted 2 lines
I'm not sure how expanding it internally to 64-bits actually helps since the upper 32 bits is not visible to the peer.
rxrpc_complete_rtt_probe contains the following logic that relies on after() being able to detect a serial number wrap.
/* If a later serial is being acked, then mark this slot as
* being available.
*/
if (after(acked_serial, orig_serial)) { trace_rxrpc_rtt_rx(call, rxrpc_rtt_rx_obsolete, i, orig_serial, acked_serial, 0, 0); clear_bit(i + RXRPC_CALL_RTT_PEND_SHIFT, &call->rtt_avail); smp_wmb();
set_bit(i, &call->rtt_avail);
}
Otherwise, acked_serial = 0x01 will be considered smaller than orig_serial = 0xfffffffe and the slot will not be marked available.
I will note that there is a similar problem with rxrpc_seq_t values which are u32 on the wire but which will wrap for calls that transmit more than approximately 5.5TB of data. Calls of this size are unlikely for a cache manager but are common for any service transmitting volume dumps.
Jeffrey Altman
Re: [PATCH 01/41] rxrpc: Fix RTT determination to use PING ACKs as a source
Quoted 18 lines · Jeffrey E Altman
Quoted 3 lines
I'm not sure how expanding it internally to 64-bits actually helps since the upper 32 bits is not visible to the peer.
rxrpc_complete_rtt_probecontains the following logic that relies onafter()being able to detect a serial number wrap./* If a later serial is being acked, then mark this slot as
* being available.
*/if (
after(acked_serial, orig_serial)) {trace_rxrpc_rtt_rx(call, rxrpc_rtt_rx_obsolete, i, orig_serial, acked_serial, 0, 0);clear_bit(i + RXRPC_CALL_RTT_PEND_SHIFT, &call->rtt_avail);smp_wmb();
set_bit(i, &call->rtt_avail);
}
Quoted 3 lines
Otherwise,
acked_serial=0x01will be considered smaller thanorig_serial=0xfffffffeand the slot will not be marked available.I will note that there is a similar problem with
rxrpc_seq_tvalues which are u32 on the wire but which will wrap for calls that transmit more than approximately 5.5TB of data. Calls of this size are unlikely for a cache manager but are common for any service transmitting volume dumps.
I misread the definition of after() which is
static inline bool after(u32 seq1, u32 seq2)
{
return (s32)(seq1 - seq2) > 0;
}
This is sufficient to detect the serial number and sequence number wrapping.
What it doesn't provide is a method for rxrpc tracing and /proc file to report on the total number of packets that have been sent or received on a call or connection which might or might not be important depending upon the use case.
Jeffrey Altman
David Howells
maintainerRe: [PATCH 01/41] rxrpc: Fix RTT determination to use PING ACKs as a source
In reply to Jeffrey E AltmanQuoted 8 lines · Jeffrey E Altman
Quoted 1 line
I do ignore ack.serial == 0 for this purpose.
Zero has the special meaning - this ACK is not explicitly in response to a received packet.
However, as mentioned, the serial number counter wraps frequently and most RxRPC implementations
do not transition from serial0xffffffff->0x00000001when wrapping.
I don't skip zero serial numbers either. I'm not sure whether it would be better to do so.
Quoted 2 lines
Otherwise,
acked_serial=0x01will be considered smaller thanorig_serial=0xfffffffeand the slot will not be marked available.
As you mentioned in your follow up email, after() deals with that by casting to signed, subtracting and then examining the result.
David
Re: [PATCH 01/41] rxrpc: Fix RTT determination to use PING ACKs as a source
Quoted 11 lines · David Howells
Quoted 7 lines · Jeffrey E Altman
Quoted 1 line
I do ignore ack.serial == 0 for this purpose.
Zero has the special meaning - this ACK is not explicitly in response to a received packet.
However, as mentioned, the serial number counter wraps frequently and most RxRPC implementations
do not transition from serial0xffffffff->0x00000001when wrapping.I don't skip zero serial numbers either. I'm not sure whether it would be better to do so.
If a DATA packet is sent with serial number zero and an ACK packet is sent in response to it with the ack.serial field set to the DATA packet serial number (zero), then the receiver of the ACK will be unable to compute an RTT from that DATA packet. It will happen rarely but it will happen.
Jeffrey
Re: [PATCH 01/41] rxrpc: Fix RTT determination to use PING ACKs as a source
In reply to David HowellsQuoted 11 lines · David Howells
Quoted 7 lines · Jeffrey E Altman
Quoted 1 line
I do ignore ack.serial == 0 for this purpose.
Zero has the special meaning - this ACK is not explicitly in response to a received packet.
However, as mentioned, the serial number counter wraps frequently and most RxRPC implementations
do not transition from serial0xffffffff->0x00000001when wrapping.I don't skip zero serial numbers either. I'm not sure whether it would be better to do so.
If a DATA packet is sent with serial number zero and an ACK packet is sent in response to it with the ack.serial field set to the DATA packet serial number (zero), then the receiver of the ACK will be unable to compute an RTT from that DATA packet. It will happen rarely but it will happen.
Jeffrey
David Howells
maintainerPATCH 2/41 rxrpc: Fix two connection reaping bugs
In reply to David HowellsFix two connection reaping bugs:
(1) rxrpc_connection_expiry is in units of seconds, so rxrpc_disconnect_call() needs to multiply it by HZ when adding it to jiffies.
(2) rxrpc_client_conn_reap_timeout() should set RXRPC_CLIENT_REAP_TIMER if local->kill_all_client_conns is clear, not if it is set (in which case we don't need the timer). Without this, old client connections don't get cleaned up until the local endpoint is cleaned up.
--- net/rxrpc/conn_object.c | 2 +- net/rxrpc/local_object.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/rxrpc/conn_object.c +1 -1
@@ -212,7 +212,7 @@ void rxrpc_disconnect_call(struct rxrpc_call *call) conn->idle_timestamp = jiffies;if (atomic_dec_and_test (&conn->active))rxrpc_set_service_reap_timer (conn->rxnet, - jiffies + rxrpc_connection_expiry); + jiffies + rxrpc_connection_expiry *HZ ); }rxrpc_put_call (call, rxrpc_call_put_io_thread);
net/rxrpc/local_object.c +1 -1
@@ -87,7 +87,7 @@ static void rxrpc_client_conn_reap_timeout(struct timer_list *timer)struct rxrpc_local *local = container_of(timer, struct rxrpc_local, client_conn_reap_timer); -if (local->kill_all_client_conns && +if (!local->kill_all_client_conns &&test_and_set_bit (RXRPC_CLIENT_CONN_REAP_TIMER , &local->client_conn_flags))rxrpc_wake_up_io_thread (local); }
Re: [PATCH 02/41] rxrpc: Fix two connection reaping bugs
Quoted 21 lines · David Howells
Fix two connection reaping bugs:
(1)
rxrpc_connection_expiryis in units of seconds, sorxrpc_disconnect_call()needs to multiply it by HZ when adding it to jiffies.(2)
rxrpc_client_conn_reap_timeout()should setRXRPC_CLIENT_REAP_TIMERiflocal->kill_all_client_connsis clear, not if it is set (in which case we don't need the timer). Without this, old client connections don't get cleaned up until the local endpoint is cleaned up.Fixes 5040011d073d ("rxrpc: Make the local endpoint hold a ref on a connected call")Fixes 0d6bf319bc5a ("rxrpc: Move the client conn cache management to the I/O thread")Signed-off-by David Howells <[email protected]>cc Marc Dionne <[email protected]>cc "David S. Miller" <[email protected]>cc Eric Dumazet <[email protected]>cc Jakub Kicinski <[email protected]>cc Paolo Abeni <[email protected]>
Quoted 1 line
---
Re: [PATCH 02/41] rxrpc: Fix two connection reaping bugs
In reply to David HowellsThis patch was applied to bpf/bpf.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Thu, 9 Nov 2023 15:39:25 +0000 you wrote:
Fix two connection reaping bugs:
(1)
rxrpc_connection_expiryis in units of seconds, sorxrpc_disconnect_call()needs to multiply it by HZ when adding it to jiffies.
Quoted 6 lines
(2)
rxrpc_client_conn_reap_timeout()should setRXRPC_CLIENT_REAP_TIMERiflocal->kill_all_client_connsis clear, not if it is set (in which case we don't need the timer). Without this, old client connections don't get cleaned up until the local endpoint is cleaned up.[...]
Here is the summary with links:
- [02/41] rxrpc: Fix two connection reaping bugs
https://git.kernel.org/bpf/bpf/c/61e4a8660002
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
David Howells
maintainerPATCH 3/41 rxrpc: Fix some minor issues with bundle tracing
In reply to David HowellsFix some superficial issues with the tracing of rxrpc_bundle structs, including:
(1) Set the debug_id when the bundle is allocated rather than when it is set up so that the "NEW" trace line displays the correct bundle ID.
(2) Show the refcount when emitting the "FREE" traceline.
--- net/rxrpc/conn_client.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/rxrpc/conn_client.c +4 -3
@@ -73,6 +73,7 @@ static void rxrpc_destroy_client_conn_ids(struct rxrpc_local *local)static struct rxrpc_bundle *rxrpc_alloc_bundle (struct rxrpc_call *call,gfp_t gfp) { +static atomic_t rxrpc_bundle_id;struct rxrpc_bundle *bundle; bundle =kzalloc (sizeof (*bundle), gfp);
@@ -85,6 +86,7 @@ static struct rxrpc_bundle *rxrpc_alloc_bundle(struct rxrpc_call *call, bundle->upgrade =test_bit (RXRPC_CALL_UPGRADE , &call->flags); bundle->service_id = call->dest_srx.srx_service; bundle->security_level = call->security_level; + bundle->debug_id =atomic_inc_return (&rxrpc_bundle_id);refcount_set (&bundle->ref,1 );atomic_set (&bundle->active,1 );INIT_LIST_HEAD (&bundle->waiting_calls);
@@ -105,7 +107,8 @@ struct rxrpc_bundle *rxrpc_get_bundle(struct rxrpc_bundle *bundle,static void rxrpc_free_bundle (struct rxrpc_bundle *bundle) { -trace_rxrpc_bundle (bundle->debug_id,1 , rxrpc_bundle_free); +trace_rxrpc_bundle (bundle->debug_id,refcount_read (&bundle->ref), + rxrpc_bundle_free);rxrpc_put_peer (bundle->peer, rxrpc_peer_put_bundle);key_put (bundle->key);kfree (bundle);
@@ -239,7 +242,6 @@ static bool rxrpc_may_reuse_conn(struct rxrpc_connection *conn)*/ int rxrpc_look_up_bundle (struct rxrpc_call *call,gfp_t gfp) { -static atomic_t rxrpc_bundle_id;struct rxrpc_bundle *bundle, *candidate;struct rxrpc_local *local = call->local;struct rb_node *p, **pp, *parent;
@@ -306,7 +308,6 @@ int rxrpc_look_up_bundle(struct rxrpc_call *call, gfp_t gfp) }_debug ("new bundle" ); - candidate->debug_id =atomic_inc_return (&rxrpc_bundle_id);rb_link_node (&candidate->local_node, parent, pp);rb_insert_color (&candidate->local_node, &local->client_bundles); call->bundle =rxrpc_get_bundle (candidate, rxrpc_bundle_get_client_call);
David Howells
maintainerPATCH 4/41 afs: Fix afs_server_list to be cleaned up with RCU
In reply to David Howellsafs_server_list is accessed with the rcu_read_lock() held from volume->servers, so it needs to be cleaned up correctly.
Fix this by using kfree_rcu() instead of kfree().
--- fs/afs/internal.h | 1 + fs/afs/server_list.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
fs/afs/internal.h +1 -0
@@ -553,6 +553,7 @@ struct afs_server_entry { };struct afs_server_list { +struct rcu_head rcu;afs_volid_t vids[AFS_MAXTYPES ];/* Volume IDs */ refcount_t usage;unsigned char nr_servers;
fs/afs/server_list.c +1 -1
@@ -17,7 +17,7 @@ void afs_put_serverlist(struct afs_net *net, struct afs_server_list *slist)for (i =0 ; i < slist->nr_servers; i++)afs_unuse_server (net, slist->servers[i].server, afs_server_trace_put_slist); -kfree (slist); +kfree_rcu (slist, rcu); } }
David Howells
maintainerPATCH 5/41 afs: Make error on cell lookup failure consistent with OpenAFS
In reply to David HowellsWhen kafs tries to look up a cell in the DNS or the local config, it will translate a lookup failure into EDESTADDRREQ whereas OpenAFS translates it into ENOENT. Applications such as West expect the latter behaviour and fail if they see the former.
This can be seen by trying to mount an unknown cell:
# mount -t afs %example.com:cell.root /mnt mount: /mnt: mount(2) system call failed: Destination address required.
--- fs/afs/dynroot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/afs/dynroot.c +2 -2
@@ -132,8 +132,8 @@ static int afs_probe_cell_name(struct dentry *dentry) ret =dns_query (net->net,"afsdb" , name, len,"srv=1" ,NULL ,NULL , false); -if (ret == -ENODATA ) - ret = -EDESTADDRREQ ; +if (ret == -ENODATA || ret == -ENOKEY ) + ret = -ENOENT ;return ret; }
David Howells
maintainerPATCH 6/41 afs: Remove whitespace before most ')' from the trace header
In reply to David Howellscheckpatch objects to whitespace before ')', so remove most of it from the afs trace header.
--- include/trace/events/afs.h | 242 ++++++++++++++++++------------------- 1 file changed, 121 insertions(+), 121 deletions(-)
include/trace/events/afs.h +121 -121
@@ -654,12 +654,12 @@ TRACE_EVENT(afs_receive_data, TP_ARGS(call, iter, want_more, ret),TP_STRUCT__entry ( -__field (loff_t ,remain ) - __field(unsigned int, call ) - __field(enum afs_call_state, state ) - __field(unsigned short, unmarshall ) -__field (bool, want_more ) -__field (int, ret ) +__field (loff_t ,remain ) + __field(unsigned int, call) + __field(enum afs_call_state, state) + __field(unsigned short, unmarshall) +__field (bool, want_more) +__field (int, ret) ), TP_fast_assign(
@@ -686,9 +686,9 @@ TRACE_EVENT(afs_notify_call,TP_ARGS (rxcall, call),TP_STRUCT__entry ( - __field(unsigned int, call ) - __field(enum afs_call_state, state ) - __field(unsigned short, unmarshall ) + __field(unsigned int, call) + __field(enum afs_call_state, state) + __field(unsigned short, unmarshall) ), TP_fast_assign(
@@ -708,9 +708,9 @@ TRACE_EVENT(afs_cb_call,TP_ARGS (call),TP_STRUCT__entry ( - __field(unsigned int, call ) -__field (u32 ,op ) -__field (u16, service_id ) + __field(unsigned int, call) +__field (u32 ,op ) +__field (u16, service_id) ), TP_fast_assign(
@@ -733,11 +733,11 @@ TRACE_EVENT(afs_call, TP_ARGS(call_debug_id, op, ref, outstanding, where),TP_STRUCT__entry ( -__field (unsigned int ,call ) -__field (int, op ) -__field (int, ref ) -__field (int, outstanding ) - __field(const void *, where ) +__field (unsigned int ,call ) +__field (int, op) +__field (int, ref) +__field (int, outstanding) + __field(const void *, where) ), TP_fast_assign(
@@ -762,9 +762,9 @@ TRACE_EVENT(afs_make_fs_call,TP_ARGS (call, fid),TP_STRUCT__entry ( - __field(unsigned int, call ) - __field(enum afs_fs_operation, op ) - __field_struct(struct afs_fid, fid ) + __field(unsigned int, call) + __field(enum afs_fs_operation, op) + __field_struct(struct afs_fid, fid) ), TP_fast_assign(
@@ -794,10 +794,10 @@ TRACE_EVENT(afs_make_fs_calli,TP_ARGS (call, fid, i),TP_STRUCT__entry ( - __field(unsigned int, call ) - __field(unsigned int, i ) - __field(enum afs_fs_operation, op ) - __field_struct(struct afs_fid, fid ) + __field(unsigned int, call) + __field(unsigned int, i) + __field(enum afs_fs_operation, op) + __field_struct(struct afs_fid, fid) ), TP_fast_assign(
@@ -829,10 +829,10 @@ TRACE_EVENT(afs_make_fs_call1,TP_ARGS (call, fid, name),TP_STRUCT__entry ( - __field(unsigned int, call ) - __field(enum afs_fs_operation, op ) - __field_struct(struct afs_fid, fid ) -__array (char, name,24 ) + __field(unsigned int, call) + __field(enum afs_fs_operation, op) + __field_struct(struct afs_fid, fid) +__array (char, name,24 ) ), TP_fast_assign(
@@ -866,11 +866,11 @@ TRACE_EVENT(afs_make_fs_call2, TP_ARGS(call, fid, name, name2),TP_STRUCT__entry ( -__field (unsigned int ,call ) - __field(enum afs_fs_operation, op ) - __field_struct(struct afs_fid, fid ) -__array (char, name,24 ) -__array (char, name2,24 ) +__field (unsigned int ,call ) + __field(enum afs_fs_operation, op) + __field_struct(struct afs_fid, fid) +__array (char, name,24 ) +__array (char, name2,24 ) ), TP_fast_assign(
@@ -907,8 +907,8 @@ TRACE_EVENT(afs_make_vl_call,TP_ARGS (call),TP_STRUCT__entry ( - __field(unsigned int, call ) -__field (enum afs_vl_operation ,op ) + __field(unsigned int, call) +__field (enum afs_vl_operation ,op ) ), TP_fast_assign(
@@ -927,10 +927,10 @@ TRACE_EVENT(afs_call_done,TP_ARGS (call),TP_STRUCT__entry ( - __field(unsigned int, call ) -__field (struct rxrpc_call *,rx_call ) -__field (int, ret ) -__field (u32, abort_code ) + __field(unsigned int, call) +__field (struct rxrpc_call *,rx_call ) +__field (int, ret) +__field (u32, abort_code) ), TP_fast_assign(
@@ -953,10 +953,10 @@ TRACE_EVENT(afs_send_data, TP_ARGS(call, msg),TP_STRUCT__entry ( -__field (unsigned int ,call ) - __field(unsigned int, flags ) -__field (loff_t, offset ) -__field (loff_t, count ) +__field (unsigned int ,call ) + __field(unsigned int, flags) +__field (loff_t, offset) +__field (loff_t, count) ), TP_fast_assign(
@@ -977,10 +977,10 @@ TRACE_EVENT(afs_sent_data, TP_ARGS(call, msg, ret),TP_STRUCT__entry ( -__field (unsigned int ,call ) -__field (int, ret ) -__field (loff_t, offset ) -__field (loff_t, count ) +__field (unsigned int ,call ) +__field (int, ret) +__field (loff_t, offset) +__field (loff_t, count) ), TP_fast_assign(
@@ -1001,9 +1001,9 @@ TRACE_EVENT(afs_dir_check_failed, TP_ARGS(vnode, off, i_size),TP_STRUCT__entry ( -__field (struct afs_vnode *,vnode ) -__field (loff_t, off ) -__field (loff_t, i_size ) +__field (struct afs_vnode *,vnode ) +__field (loff_t, off) +__field (loff_t, i_size) ), TP_fast_assign(
@@ -1022,11 +1022,11 @@ TRACE_EVENT(afs_folio_dirty, TP_ARGS(vnode, where, folio),TP_STRUCT__entry ( -__field (struct afs_vnode *,vnode ) - __field(const char *, where ) -__field (pgoff_t, index ) - __field(unsigned long, from ) - __field(unsigned long, to ) +__field (struct afs_vnode *,vnode ) + __field(const char *, where) +__field (pgoff_t, index) + __field(unsigned long, from) + __field(unsigned long, to) ), TP_fast_assign(
@@ -1056,11 +1056,11 @@ TRACE_EVENT(afs_call_state, TP_ARGS(call, from, to, ret, remote_abort),TP_STRUCT__entry ( -__field (unsigned int ,call ) - __field(enum afs_call_state, from ) - __field(enum afs_call_state, to ) -__field (int, ret ) -__field (u32, abort ) +__field (unsigned int ,call ) + __field(enum afs_call_state, from) + __field(enum afs_call_state, to) +__field (int, ret) +__field (u32, abort) ), TP_fast_assign(
@@ -1084,9 +1084,9 @@ TRACE_EVENT(afs_lookup,TP_ARGS (dvnode, name, fid),TP_STRUCT__entry ( - __field_struct(struct afs_fid, dfid ) - __field_struct(struct afs_fid, fid ) -__array (char, name,24 ) + __field_struct(struct afs_fid, dfid) + __field_struct(struct afs_fid, fid) +__array (char, name,24 ) ), TP_fast_assign(
@@ -1116,15 +1116,15 @@ TRACE_EVENT(afs_edit_dir,TP_ARGS (dvnode, why, op, block, slot, f_vnode, f_unique, name),TP_STRUCT__entry ( - __field(unsigned int, vnode ) - __field(unsigned int, unique ) - __field(enum afs_edit_dir_reason, why ) - __field(enum afs_edit_dir_op, op ) - __field(unsigned int, block ) - __field(unsigned short, slot ) - __field(unsigned int, f_vnode ) - __field(unsigned int, f_unique ) -__array (char, name,24 ) + __field(unsigned int, vnode) + __field(unsigned int, unique) + __field(enum afs_edit_dir_reason, why) + __field(enum afs_edit_dir_op, op) + __field(unsigned int, block) + __field(unsigned short, slot) + __field(unsigned int, f_vnode) + __field(unsigned int, f_unique) +__array (char, name,24 ) ), TP_fast_assign(
@@ -1157,8 +1157,8 @@ TRACE_EVENT(afs_protocol_error,TP_ARGS (call, cause),TP_STRUCT__entry ( - __field(unsigned int, call ) - __field(enum afs_eproto_cause, cause ) + __field(unsigned int, call) + __field(enum afs_eproto_cause, cause) ), TP_fast_assign(
@@ -1177,9 +1177,9 @@ TRACE_EVENT(afs_io_error, TP_ARGS(call, error, where),TP_STRUCT__entry ( -__field (unsigned int ,call ) -__field (int, error ) - __field(enum afs_io_error, where ) +__field (unsigned int ,call ) +__field (int, error) + __field(enum afs_io_error, where) ), TP_fast_assign(
@@ -1199,9 +1199,9 @@ TRACE_EVENT(afs_file_error, TP_ARGS(vnode, error, where),TP_STRUCT__entry ( -__field_struct (struct afs_fid ,fid ) -__field (int, error ) - __field(enum afs_file_error, where ) +__field_struct (struct afs_fid ,fid ) +__field (int, error) + __field(enum afs_file_error, where) ), TP_fast_assign(
@@ -1222,9 +1222,9 @@ TRACE_EVENT(afs_cm_no_server,TP_ARGS (call, srx),TP_STRUCT__entry ( - __field(unsigned int, call ) - __field(unsigned int, op_id ) - __field_struct(struct sockaddr_rxrpc, srx ) + __field(unsigned int, call) + __field(unsigned int, op_id) + __field_struct(struct sockaddr_rxrpc, srx) ), TP_fast_assign(
@@ -1243,9 +1243,9 @@ TRACE_EVENT(afs_cm_no_server_u,TP_ARGS (call, uuid),TP_STRUCT__entry ( - __field(unsigned int, call ) - __field(unsigned int, op_id ) -__field_struct (uuid_t, uuid ) + __field(unsigned int, call) + __field(unsigned int, op_id) +__field_struct (uuid_t, uuid) ), TP_fast_assign(
@@ -1265,11 +1265,11 @@ TRACE_EVENT(afs_flock_ev, TP_ARGS(vnode, fl, event, error),TP_STRUCT__entry ( -__field_struct (struct afs_fid ,fid ) - __field(enum afs_flock_event, event ) - __field(enum afs_lock_state, state ) -__field (int, error ) - __field(unsigned int, debug_id ) +__field_struct (struct afs_fid ,fid ) + __field(enum afs_flock_event, event) + __field(enum afs_lock_state, state) +__field (int, error) + __field(unsigned int, debug_id) ), TP_fast_assign(
@@ -1295,13 +1295,13 @@ TRACE_EVENT(afs_flock_op, TP_ARGS(vnode, fl, op),TP_STRUCT__entry ( -__field_struct (struct afs_fid ,fid ) -__field (loff_t, from ) -__field (loff_t, len ) - __field(enum afs_flock_operation, op ) - __field(unsigned char, type ) - __field(unsigned int, flags ) - __field(unsigned int, debug_id ) +__field_struct (struct afs_fid ,fid ) +__field (loff_t, from) +__field (loff_t, len) + __field(enum afs_flock_operation, op) + __field(unsigned char, type) + __field(unsigned int, flags) + __field(unsigned int, debug_id) ), TP_fast_assign(
@@ -1328,7 +1328,7 @@ TRACE_EVENT(afs_reload_dir,TP_ARGS (vnode),TP_STRUCT__entry ( -__field_struct (struct afs_fid ,fid ) +__field_struct (struct afs_fid ,fid ) ), TP_fast_assign(
@@ -1345,8 +1345,8 @@ TRACE_EVENT(afs_silly_rename,TP_ARGS (vnode, done),TP_STRUCT__entry ( - __field_struct(struct afs_fid, fid ) -__field (bool, done ) + __field_struct(struct afs_fid, fid) +__field (bool, done) ), TP_fast_assign(
@@ -1365,9 +1365,9 @@ TRACE_EVENT(afs_get_tree, TP_ARGS(cell, volume),TP_STRUCT__entry ( -__field (u64 ,vid ) -__array (char, cell,24 ) -__array (char, volume,24 ) +__field (u64 ,vid ) +__array (char, cell,24 ) +__array (char, volume,24 ) ), TP_fast_assign(
@@ -1392,10 +1392,10 @@ TRACE_EVENT(afs_cb_break,TP_ARGS (fid, cb_break, reason, skipped),TP_STRUCT__entry ( - __field_struct(struct afs_fid, fid ) - __field(unsigned int, cb_break ) - __field(enum afs_cb_break_reason, reason ) -__field (bool, skipped ) + __field_struct(struct afs_fid, fid) + __field(unsigned int, cb_break) + __field(enum afs_cb_break_reason, reason) +__field (bool, skipped) ), TP_fast_assign(
@@ -1418,8 +1418,8 @@ TRACE_EVENT(afs_cb_miss,TP_ARGS (fid, reason),TP_STRUCT__entry ( - __field_struct(struct afs_fid, fid ) - __field(enum afs_cb_break_reason, reason ) + __field_struct(struct afs_fid, fid) + __field(enum afs_cb_break_reason, reason) ), TP_fast_assign(
@@ -1439,10 +1439,10 @@ TRACE_EVENT(afs_server, TP_ARGS(server_debug_id, ref, active, reason),TP_STRUCT__entry ( -__field (unsigned int ,server ) -__field (int, ref ) -__field (int, active ) -__field (int, reason ) +__field (unsigned int ,server ) +__field (int, ref) +__field (int, active) +__field (int, reason) ), TP_fast_assign(
@@ -1465,9 +1465,9 @@ TRACE_EVENT(afs_volume, TP_ARGS(vid, ref, reason),TP_STRUCT__entry ( -__field (afs_volid_t ,vid ) -__field (int, ref ) - __field(enum afs_volume_trace, reason ) +__field (afs_volid_t ,vid ) +__field (int, ref) + __field(enum afs_volume_trace, reason) ), TP_fast_assign(
@@ -1489,10 +1489,10 @@ TRACE_EVENT(afs_cell, TP_ARGS(cell_debug_id, ref, active, reason),TP_STRUCT__entry ( -__field (unsigned int ,cell ) -__field (int, ref ) -__field (int, active ) -__field (int, reason ) +__field (unsigned int ,cell ) +__field (int, ref) +__field (int, active) +__field (int, reason) ), TP_fast_assign(
David Howells
maintainerPATCH 7/41 afs: Automatically generate trace tag enums
In reply to David HowellsAutomatically generate trace tag enums from the symbol -> string mapping tables rather than having the enums as well, thereby reducing duplicated data.
--- include/trace/events/afs.h | 233 +++++-------------------------------- 1 file changed, 27 insertions(+), 206 deletions(-)
include/trace/events/afs.h +27 -206
@@ -18,97 +18,6 @@#ifndef __AFS_DECLARE_TRACE_ENUMS_ONCE_ONLY#define __AFS_DECLARE_TRACE_ENUMS_ONCE_ONLY -enum afs_call_trace { - afs_call_trace_alloc, - afs_call_trace_free, - afs_call_trace_get, - afs_call_trace_put, - afs_call_trace_wake, - afs_call_trace_work, -}; - -enum afs_server_trace { - afs_server_trace_alloc, - afs_server_trace_callback, - afs_server_trace_destroy, - afs_server_trace_free, - afs_server_trace_gc, - afs_server_trace_get_by_addr, - afs_server_trace_get_by_uuid, - afs_server_trace_get_caps, - afs_server_trace_get_install, - afs_server_trace_get_new_cbi, - afs_server_trace_get_probe, - afs_server_trace_give_up_cb, - afs_server_trace_purging, - afs_server_trace_put_call, - afs_server_trace_put_cbi, - afs_server_trace_put_find_rsq, - afs_server_trace_put_probe, - afs_server_trace_put_slist, - afs_server_trace_put_slist_isort, - afs_server_trace_put_uuid_rsq, - afs_server_trace_update, -}; - - -enum afs_volume_trace { - afs_volume_trace_alloc, - afs_volume_trace_free, - afs_volume_trace_get_alloc_sbi, - afs_volume_trace_get_cell_insert, - afs_volume_trace_get_new_op, - afs_volume_trace_get_query_alias, - afs_volume_trace_put_cell_dup, - afs_volume_trace_put_cell_root, - afs_volume_trace_put_destroy_sbi, - afs_volume_trace_put_free_fc, - afs_volume_trace_put_put_op, - afs_volume_trace_put_query_alias, - afs_volume_trace_put_validate_fc, - afs_volume_trace_remove, -}; - -enum afs_cell_trace { - afs_cell_trace_alloc, - afs_cell_trace_free, - afs_cell_trace_get_queue_dns, - afs_cell_trace_get_queue_manage, - afs_cell_trace_get_queue_new, - afs_cell_trace_get_vol, - afs_cell_trace_insert, - afs_cell_trace_manage, - afs_cell_trace_put_candidate, - afs_cell_trace_put_destroy, - afs_cell_trace_put_queue_fail, - afs_cell_trace_put_queue_work, - afs_cell_trace_put_vol, - afs_cell_trace_see_source, - afs_cell_trace_see_ws, - afs_cell_trace_unuse_alias, - afs_cell_trace_unuse_check_alias, - afs_cell_trace_unuse_delete, - afs_cell_trace_unuse_fc, - afs_cell_trace_unuse_lookup, - afs_cell_trace_unuse_mntpt, - afs_cell_trace_unuse_no_pin, - afs_cell_trace_unuse_parse, - afs_cell_trace_unuse_pin, - afs_cell_trace_unuse_probe, - afs_cell_trace_unuse_sbi, - afs_cell_trace_unuse_ws, - afs_cell_trace_use_alias, - afs_cell_trace_use_check_alias, - afs_cell_trace_use_fc, - afs_cell_trace_use_fc_alias, - afs_cell_trace_use_lookup, - afs_cell_trace_use_mntpt, - afs_cell_trace_use_pin, - afs_cell_trace_use_probe, - afs_cell_trace_use_sbi, - afs_cell_trace_wait, -}; -enum afs_fs_operation { afs_FS_FetchData =130 ,/* AFS Fetch file data */ afs_FS_FetchACL = 131, /* AFS Fetch file ACL */
@@ -202,121 +111,6 @@ enum yfs_cm_operation { yfs_CB_CallBack = 64204, }; -enum afs_edit_dir_op { - afs_edit_dir_create, - afs_edit_dir_create_error, - afs_edit_dir_create_inval, - afs_edit_dir_create_nospc, - afs_edit_dir_delete, - afs_edit_dir_delete_error, - afs_edit_dir_delete_inval, - afs_edit_dir_delete_noent, -}; - -enum afs_edit_dir_reason { - afs_edit_dir_for_create, - afs_edit_dir_for_link, - afs_edit_dir_for_mkdir, - afs_edit_dir_for_rename_0, - afs_edit_dir_for_rename_1, - afs_edit_dir_for_rename_2, - afs_edit_dir_for_rmdir, - afs_edit_dir_for_silly_0, - afs_edit_dir_for_silly_1, - afs_edit_dir_for_symlink, - afs_edit_dir_for_unlink, -}; - -enum afs_eproto_cause { - afs_eproto_bad_status, - afs_eproto_cb_count, - afs_eproto_cb_fid_count, - afs_eproto_cellname_len, - afs_eproto_file_type, - afs_eproto_ibulkst_cb_count, - afs_eproto_ibulkst_count, - afs_eproto_motd_len, - afs_eproto_offline_msg_len, - afs_eproto_volname_len, - afs_eproto_yvl_fsendpt4_len, - afs_eproto_yvl_fsendpt6_len, - afs_eproto_yvl_fsendpt_num, - afs_eproto_yvl_fsendpt_type, - afs_eproto_yvl_vlendpt4_len, - afs_eproto_yvl_vlendpt6_len, - afs_eproto_yvl_vlendpt_type, -}; - -enum afs_io_error { - afs_io_error_cm_reply, - afs_io_error_extract, - afs_io_error_fs_probe_fail, - afs_io_error_vl_lookup_fail, - afs_io_error_vl_probe_fail, -}; - -enum afs_file_error { - afs_file_error_dir_bad_magic, - afs_file_error_dir_big, - afs_file_error_dir_missing_page, - afs_file_error_dir_name_too_long, - afs_file_error_dir_over_end, - afs_file_error_dir_small, - afs_file_error_dir_unmarked_ext, - afs_file_error_mntpt, - afs_file_error_writeback_fail, -}; - -enum afs_flock_event { - afs_flock_acquired, - afs_flock_callback_break, - afs_flock_defer_unlock, - afs_flock_extend_fail, - afs_flock_fail_other, - afs_flock_fail_perm, - afs_flock_no_lockers, - afs_flock_release_fail, - afs_flock_silly_delete, - afs_flock_timestamp, - afs_flock_try_to_lock, - afs_flock_vfs_lock, - afs_flock_vfs_locking, - afs_flock_waited, - afs_flock_waiting, - afs_flock_work_extending, - afs_flock_work_retry, - afs_flock_work_unlocking, - afs_flock_would_block, -}; - -enum afs_flock_operation { - afs_flock_op_copy_lock, - afs_flock_op_flock, - afs_flock_op_grant, - afs_flock_op_lock, - afs_flock_op_release_lock, - afs_flock_op_return_ok, - afs_flock_op_return_eagain, - afs_flock_op_return_edeadlk, - afs_flock_op_return_error, - afs_flock_op_set_lock, - afs_flock_op_unlock, - afs_flock_op_wake, -}; - -enum afs_cb_break_reason { - afs_cb_break_no_break, - afs_cb_break_no_promise, - afs_cb_break_for_callback, - afs_cb_break_for_deleted, - afs_cb_break_for_lapsed, - afs_cb_break_for_s_reinit, - afs_cb_break_for_unlink, - afs_cb_break_for_v_break, - afs_cb_break_for_volume_callback, - afs_cb_break_for_zap, -}; -#endif /* end __AFS_DECLARE_TRACE_ENUMS_ONCE_ONLY */ /*
@@ -391,6 +185,7 @@ enum afs_cb_break_reason { EM(afs_cell_trace_unuse_fc, "UNU fc ") \ EM(afs_cell_trace_unuse_lookup, "UNU lookup") \ EM(afs_cell_trace_unuse_mntpt, "UNU mntpt ") \ + EM(afs_cell_trace_unuse_no_pin, "UNU no-pin") \ EM(afs_cell_trace_unuse_parse, "UNU parse ") \ EM(afs_cell_trace_unuse_pin, "UNU pin ") \EM (afs_cell_trace_unuse_probe,"UNU probe " ) \
@@ -614,6 +409,32 @@ enum afs_cb_break_reason { EM(afs_cb_break_for_volume_callback, "break-v-cb") \E_ (afs_cb_break_for_zap,"break-zap" ) +/* +* Generate enums for tracing information. + */ +#ifndef __AFS_GENERATE_TRACE_ENUMS_ONCE_ONLY +#define __AFS_GENERATE_TRACE_ENUMS_ONCE_ONLY + +#undef EM +#undef E_ +#define EM (a, b) a, +#define E_ (a, b) a + +enum afs_call_trace { afs_call_traces }__mode (byte ); +enum afs_cb_break_reason { afs_cb_break_reasons }__mode (byte ); +enum afs_cell_trace { afs_cell_traces }__mode (byte ); +enum afs_edit_dir_op { afs_edit_dir_ops }__mode (byte ); +enum afs_edit_dir_reason { afs_edit_dir_reasons }__mode (byte ); +enum afs_eproto_cause { afs_eproto_causes }__mode (byte ); +enum afs_file_error { afs_file_errors }__mode (byte ); +enum afs_flock_event { afs_flock_events }__mode (byte ); +enum afs_flock_operation { afs_flock_operations }__mode (byte ); +enum afs_io_error { afs_io_errors }__mode (byte ); +enum afs_server_trace { afs_server_traces }__mode (byte ); +enum afs_volume_trace { afs_volume_traces }__mode (byte ); + +#endif /* end __AFS_GENERATE_TRACE_ENUMS_ONCE_ONLY */ +/* * Export enum symbols via userspace. */
David Howells
maintainerPATCH 8/41 afs: Add comments on abort handling
In reply to David HowellsAdd some comments on AFS abort code handling in the rotation algorithm and adjust the errors produced to match.
--- fs/afs/rotate.c | 100 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 89 insertions(+), 11 deletions(-)
fs/afs/rotate.c +89 -11
@@ -13,6 +13,7 @@#include <linux/sched/signal.h> #include "internal.h" #include "afs_fs.h" +#include "protocol_uae.h" /* * Begin iteration through a server list, starting with the vnode's last used
@@ -143,6 +144,11 @@ bool afs_select_fileserver(struct afs_operation *op)case -ECONNABORTED :/* The far side rejected the operation on some grounds. This * might involve the server being busy or the volume having been moved. +* +* Note that various V* errors should not be sent to a cache manager +* by a fileserver as they should be translated to more modern UAE* +* errors instead. IBM AFS and OpenAFS fileservers, however, do leak +* these abort codes. */ switch (op->ac.abort_code) {case VNOVOL :
@@ -150,6 +156,11 @@ bool afs_select_fileserver(struct afs_operation *op)* - May indicate that the VL is wrong - retry once and compare * the results. * - May indicate that the fileserver couldn't attach to the vol. +* - The volume might have been temporarily removed so that it can +* be replaced by a volume restore. "vos" might have ended one +* transaction and has yet to create the next. +* - The volume might not be blessed or might not be in-service +* (administrative action). */ if (op->flags &AFS_OPERATION_VNOVOL ) { op->error = -EREMOTEIO ;
@@ -183,16 +194,56 @@ bool afs_select_fileserver(struct afs_operation *op)_leave (" = t [vnovol]" );return true; -case VSALVAGE :/* TODO: Should this return an error or iterate? */ case VVOLEXISTS : -case VNOSERVICE :case VONLINE : -case VDISKFULL : -case VOVERQUOTA : - op->error =afs_abort_to_error (op->ac.abort_code); +/* These should not be returned from the fileserver. */ +pr_warn ("Fileserver returned unexpected abort %d\n" , + op->ac.abort_code); + op->error = -EREMOTEIO ; + goto next_server; + +case VNOSERVICE : +/* Prior to AFS 3.2 VNOSERVICE was returned from the fileserver +* if the volume was neither in-service nor administratively +* blessed. All usage was replaced by VNOVOL because AFS 3.1 and +* earlier cache managers did not handle VNOSERVICE and assumed +* it was the client OSes errno 105. +* +* Starting with OpenAFS 1.4.8 VNOSERVICE was repurposed as the +* fileserver idle dead time error which was sent in place of +* RX_CALL_TIMEOUT (-3). The error was intended to be sent if the +* fileserver took too long to send a reply to the client. +* RX_CALL_TIMEOUT would have caused the cache manager to mark the +* server down whereas VNOSERVICE since AFS 3.2 would cause cache +* manager to temporarily (up to 15 minutes) mark the volume +* instance as unusable. +* +* The idle dead logic resulted in cache inconsistency since a +* state changing call that the cache manager assumed was dead +* could still be processed to completion by the fileserver. This +* logic was removed in OpenAFS 1.8.0 and VNOSERVICE is no longer +* returned. However, many 1.4.8 through 1.6.24 fileservers are +* still in existence. +* +* AuriStorFS fileservers have never returned VNOSERVICE. +* +* VNOSERVICE should be treated as an alias for RX_CALL_TIMEOUT.. +*/ +case RX_CALL_TIMEOUT : + op->error = -ETIMEDOUT ; goto next_server; +case VSALVAGING :/* This error should not be leaked to cache managers +* but is from OpenAFS demand attach fileservers. +* It should be treated as an alias for VOFFLINE. +*/ +case VSALVAGE :/* VSALVAGE should be treated as a synonym of VOFFLINE */ case VOFFLINE : +/* The volume is in use by the volserver or another volume utility +* for an operation that might alter the contents. The volume is +* expected to come back but it might take a long time (could be +* days). +*/ if (!test_and_set_bit (AFS_VOLUME_OFFLINE , &op->volume->flags)) {afs_busy (op->volume, op->ac.abort_code);clear_bit (AFS_VOLUME_BUSY , &op->volume->flags);
@@ -207,11 +258,19 @@ bool afs_select_fileserver(struct afs_operation *op) } goto busy; -case VSALVAGING : -case VRESTARTING : +case VRESTARTING :/* The fileserver is either shutting down or starting up. */ case VBUSY : -/* Retry after going round all the servers unless we -* have a file lock we need to maintain. +/* The volume is in use by the volserver or another volume utility +* for an operation that is not expected to alter the contents of +* the volume. VBUSY should not be returned for a ROVOL or +* BACKVOL (but many OpenAFS fileserver versions are broken). The +* fileserver is supposed to continue serving content from ROVOLs +* and BACKVOLs during an ITBusy transaction because the content +* cannot change. The volume is expected to come back but it +* might take awhile. +* +* Retry after going round all the servers unless we have a file +* lock we need to maintain. */ if (op->flags &AFS_OPERATION_NO_VSLEEP ) { op->error = -EBUSY ;
@@ -226,7 +285,7 @@ bool afs_select_fileserver(struct afs_operation *op)if (!afs_sleep_and_retry (op)) goto failed; -/* Retry with same server & address */ +/* Retry with same server & address */ _leave (" = t [vbusy]" );return true; }
@@ -270,10 +329,29 @@ bool afs_select_fileserver(struct afs_operation *op) goto restart_from_beginning; +case VDISKFULL : +case UAENOSPC : +/* The partition is full. Only applies to RWVOLs. +* Translate locally and return ENOSPC. +* No replicas to failover to. +*/ + op->error = -ENOSPC ; + goto failed_but_online; + +case VOVERQUOTA : +case UAEDQUOT : +/* Volume is full. Only applies to RWVOLs. +* Translate locally and return EDQUOT. +* No replicas to failover to. +*/ + op->error = -EDQUOT ; + goto failed_but_online; +default : + op->error =afs_abort_to_error (op->ac.abort_code); + failed_but_online:clear_bit (AFS_VOLUME_OFFLINE , &op->volume->flags);clear_bit (AFS_VOLUME_BUSY , &op->volume->flags); - op->error =afs_abort_to_error (op->ac.abort_code); goto failed; }
Re: [PATCH 08/41] afs: Add comments on abort handling
Quoted 8 lines · David Howells
Add some comments on AFS abort code handling in the rotation algorithm and adjust the errors produced to match.
Reported-by Jeffrey E Altman <[email protected]>Signed-off-by David Howells <[email protected]>cc Marc Dionne <[email protected]>---
David Howells
maintainerPATCH 9/41 afs: Turn the afs_addr_list address array into an array of structs
In reply to David HowellsTurn the afs_addr_list address array into an array of structs, thereby allowing per-address (such as RTT) info to be added.
--- fs/afs/addr_list.c | 10 +++++----- fs/afs/fs_probe.c | 6 +++--- fs/afs/internal.h | 6 +++++- fs/afs/proc.c | 4 ++-- fs/afs/rotate.c | 2 +- fs/afs/rxrpc.c | 4 ++-- fs/afs/server.c | 4 ++-- fs/afs/vl_alias.c | 4 ++-- fs/afs/vl_probe.c | 6 +++--- fs/afs/vl_rotate.c | 2 +- 10 files changed, 26 insertions(+), 22 deletions(-)
fs/afs/addr_list.c +5 -5
@@ -45,7 +45,7 @@ struct afs_addr_list *afs_alloc_addrlist(unsigned int nr, alist->max_addrs = nr;for (i =0 ; i < nr; i++) { -struct sockaddr_rxrpc *srx = &alist->addrs[i]; +struct sockaddr_rxrpc *srx = &alist->addrs[i].srx; srx->srx_family =AF_RXRPC ; srx->srx_service = service; srx->transport_type =SOCK_DGRAM ;
@@ -281,7 +281,7 @@ void afs_merge_fs_addr4(struct afs_addr_list *alist, __be32 xdr, u16 port)return ;for (i =0 ; i < alist->nr_ipv4; i++) { -struct sockaddr_in *a = &alist->addrs[i].transport.sin; +struct sockaddr_in *a = &alist->addrs[i].srx.transport.sin;u32 a_addr =ntohl (a->sin_addr.s_addr);u16 a_port =ntohs (a->sin_port);
@@ -298,7 +298,7 @@ void afs_merge_fs_addr4(struct afs_addr_list *alist, __be32 xdr, u16 port) alist->addrs + i, sizeof(alist->addrs[0]) * (alist->nr_addrs - i)); - srx = &alist->addrs[i]; + srx = &alist->addrs[i].srx; srx->srx_family =AF_RXRPC ; srx->transport_type =SOCK_DGRAM ; srx->transport_len =sizeof (srx->transport.sin);
@@ -321,7 +321,7 @@ void afs_merge_fs_addr6(struct afs_addr_list *alist, __be32 *xdr, u16 port)return ;for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) { -struct sockaddr_in6 *a = &alist->addrs[i].transport.sin6; +struct sockaddr_in6 *a = &alist->addrs[i].srx.transport.sin6;u16 a_port =ntohs (a->sin6_port); diff =memcmp (xdr, &a->sin6_addr,16 );
@@ -338,7 +338,7 @@ void afs_merge_fs_addr6(struct afs_addr_list *alist, __be32 *xdr, u16 port) alist->addrs + i, sizeof(alist->addrs[0]) * (alist->nr_addrs - i)); - srx = &alist->addrs[i]; + srx = &alist->addrs[i].srx; srx->srx_family =AF_RXRPC ; srx->transport_type =SOCK_DGRAM ; srx->transport_len =sizeof (srx->transport.sin6);
fs/afs/fs_probe.c +3 -3
@@ -153,12 +153,12 @@ void afs_fileserver_probe_result(struct afs_call *call)if (call->service_id ==YFS_FS_SERVICE ) { server->probe.is_yfs = true;set_bit (AFS_SERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx_service = call->service_id; + alist->addrs[index].srx.srx_service = call->service_id; }else { server->probe.not_yfs = true;if (!server->probe.is_yfs) {clear_bit (AFS_SERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx_service = call->service_id; + alist->addrs[index].srx.srx_service = call->service_id; } cap0 =ntohl (call->tmp);if (cap0 &AFS3_VICED_CAPABILITY_64BITFILES )
@@ -182,7 +182,7 @@ void afs_fileserver_probe_result(struct afs_call *call)spin_unlock (&server->probe_lock);_debug ("probe %pU [%u] %pISpc rtt=%u ret=%d" , - &server->uuid, index, &alist->addrs[index].transport, + &server->uuid, index, &alist->addrs[index].srx.transport, rtt_us, ret);return afs_done_one_fs_probe (call->net, server);
fs/afs/internal.h +5 -1
@@ -87,7 +87,9 @@ struct afs_addr_list { enum dns_lookup_status status:8;unsigned long failed;/* Mask of addrs that failed locally/ICMP */ unsigned long responded;/* Mask of addrs that responded */ -struct sockaddr_rxrpc addrs[]; +struct { +struct sockaddr_rxrpc srx; + } addrs[] __counted_by(max_addrs);#define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8)) };
@@ -968,6 +970,8 @@ extern void afs_put_addrlist(struct afs_addr_list *);extern struct afs_vlserver_list *afs_parse_text_addrs (struct afs_net *,const char *,size_t ,char ,unsigned short ,unsigned short ); +bool afs_addr_list_same (const struct afs_addr_list *a, +const struct afs_addr_list *b);extern struct afs_vlserver_list *afs_dns_query (struct afs_cell *,time64_t *);extern bool afs_iterate_addresses (struct afs_addr_cursor *);extern int afs_end_cursor (struct afs_addr_cursor *);
fs/afs/proc.c +2 -2
@@ -307,7 +307,7 @@ static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v)for (i =0 ; i < alist->nr_addrs; i++)seq_printf (m," %c %pISpc\n" , alist->preferred == i ?'>' :'-' , - &alist->addrs[i].transport); + &alist->addrs[i].srx.transport); }seq_printf (m," info: fl=%lx rtt=%d\n" , vlserver->flags, vlserver->rtt); seq_printf(m, " probe: fl=%x e=%d ac=%d out=%d\n",
@@ -399,7 +399,7 @@ static int afs_proc_servers_show(struct seq_file *m, void *v) alist->version, alist->responded, alist->failed);for (i =0 ; i < alist->nr_addrs; i++)seq_printf (m," [%x] %pISpc%s\n" , - i, &alist->addrs[i].transport, + i, &alist->addrs[i].srx.transport, alist->preferred == i ?"*" :"" );return 0 ; }
fs/afs/rotate.c +1 -1
@@ -487,7 +487,7 @@ bool afs_select_fileserver(struct afs_operation *op)_debug ("address [%u] %u/%u %pISp" , op->index, op->ac.index, op->ac.alist->nr_addrs, - &op->ac.alist->addrs[op->ac.index].transport); + &op->ac.alist->addrs[op->ac.index].srx.transport);_leave (" = t" );return true;
fs/afs/rxrpc.c +2 -2
@@ -296,7 +296,7 @@ static void afs_notify_end_request_tx(struct sock *sock,*/ void afs_make_call (struct afs_addr_cursor *ac,struct afs_call *call,gfp_t gfp) { -struct sockaddr_rxrpc *srx = &ac->alist->addrs[ac->index]; +struct sockaddr_rxrpc *srx = &ac->alist->addrs[ac->index].srx;struct rxrpc_call *rxcall;struct msghdr msg;struct kvec iov[1 ];
@@ -461,7 +461,7 @@ static void afs_log_error(struct afs_call *call, s32 remote_abort) max = m +1 ;pr_notice ("kAFS: Peer reported %s failure on %s [%pISp]\n" , msg, call->type->name, - &call->alist->addrs[call->addr_ix].transport); + &call->alist->addrs[call->addr_ix].srx.transport); } }
fs/afs/server.c +2 -2
@@ -42,7 +42,7 @@ struct afs_server *afs_find_server(struct afs_net *net,hlist_for_each_entry_rcu (server, &net->fs_addresses6, addr6_link) { alist =rcu_dereference (server->addresses);for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) { - b = &alist->addrs[i].transport.sin6; + b = &alist->addrs[i].srx.transport.sin6; diff = ((u16 __force )a->sin6_port - (u16 __force )b->sin6_port);if (diff ==0 )
@@ -58,7 +58,7 @@ struct afs_server *afs_find_server(struct afs_net *net,hlist_for_each_entry_rcu (server, &net->fs_addresses4, addr4_link) { alist =rcu_dereference (server->addresses);for (i =0 ; i < alist->nr_ipv4; i++) { - b = &alist->addrs[i].transport.sin; + b = &alist->addrs[i].srx.transport.sin; diff = ((u16 __force )a->sin_port - (u16 __force )b->sin_port);if (diff ==0 )
fs/afs/vl_alias.c +2 -2
@@ -94,8 +94,8 @@ static int afs_compare_fs_alists(const struct afs_server *server_a, lb =rcu_dereference (server_b->addresses);while (a < la->nr_addrs && b < lb->nr_addrs) { -const struct sockaddr_rxrpc *srx_a = &la->addrs[a]; -const struct sockaddr_rxrpc *srx_b = &lb->addrs[b]; +const struct sockaddr_rxrpc *srx_a = &la->addrs[a].srx; +const struct sockaddr_rxrpc *srx_b = &lb->addrs[b].srx;int diff =afs_compare_addrs (srx_a, srx_b);if (diff <0 ) {
fs/afs/vl_probe.c +3 -3
@@ -106,12 +106,12 @@ void afs_vlserver_probe_result(struct afs_call *call)if (call->service_id ==YFS_VL_SERVICE ) { server->probe.flags |=AFS_VLSERVER_PROBE_IS_YFS ;set_bit (AFS_VLSERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx_service = call->service_id; + alist->addrs[index].srx.srx_service = call->service_id; }else { server->probe.flags |=AFS_VLSERVER_PROBE_NOT_YFS ;if (!(server->probe.flags &AFS_VLSERVER_PROBE_IS_YFS )) {clear_bit (AFS_VLSERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx_service = call->service_id; + alist->addrs[index].srx.srx_service = call->service_id; } }
@@ -131,7 +131,7 @@ void afs_vlserver_probe_result(struct afs_call *call)spin_unlock (&server->probe_lock);_debug ("probe [%u][%u] %pISpc rtt=%u ret=%d" , - server_index, index, &alist->addrs[index].transport, rtt_us, ret); + server_index, index, &alist->addrs[index].srx.transport, rtt_us, ret);afs_done_one_vl_probe (server, have_result); }
fs/afs/vl_rotate.c +1 -1
@@ -243,7 +243,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)_debug ("VL address %d/%d" , vc->ac.index, vc->ac.alist->nr_addrs); -_leave (" = t %pISpc" , &vc->ac.alist->addrs[vc->ac.index].transport); +_leave (" = t %pISpc" , &vc->ac.alist->addrs[vc->ac.index].srx.transport);return true; next_server:
David Howells
maintainerPATCH 10/41 rxrpc, afs: Allow afs to pin rxrpc_peer objects
In reply to David HowellsChange rxrpc's API such that:
(1) A new function, rxrpc_kernel_lookup_peer(), is provided to look up an rxrpc_peer record for a remote address and a corresponding function, rxrpc_kernel_put_peer(), is provided to dispose of it again.
(2) When setting up a call, the rxrpc_peer object used during a call is now passed in rather than being set up by rxrpc_connect_call(). For afs, this meenat passing it to rxrpc_kernel_begin_call() rather than the full address (the service ID then has to be passed in as a separate parameter).
(3) A new function, rxrpc_kernel_remote_addr(), is added so that afs can get a pointer to the transport address for display purposed, and another, rxrpc_kernel_remote_srx(), to gain a pointer to the full rxrpc address.
(4) The function to retrieve the RTT from a call, rxrpc_kernel_get_srtt(), is then altered to take a peer. This now returns the RTT or -1 if there are insufficient samples.
(5) Rename rxrpc_kernel_get_peer() to rxrpc_kernel_call_get_peer().
(6) Provide a new function, rxrpc_kernel_get_peer(), to get a ref on a peer the caller already has.
This allows the afs filesystem to pin the rxrpc_peer records that it is using, allowing faster lookups and pointer comparisons rather than comparing sockaddr_rxrpc contents. It also makes it easier to get hold of the RTT. The following changes are made to afs:
(1) The addr_list struct's addrs[] elements now hold a peer struct pointer and a service ID rather than a sockaddr_rxrpc.
(2) When displaying the transport address, rxrpc_kernel_remote_addr() is used.
(3) The port arg is removed from afs_alloc_addrlist() since it's always overridden.
(4) afs_merge_fs_addr4() and afs_merge_fs_addr6() do peer lookup and may now return an error that must be handled.
(5) afs_find_server() now takes a peer pointer to specify the address.
(6) afs_find_server(), afs_compare_fs_alists() and afs_merge_fs_addr[46]{} now do peer pointer comparison rather than address comparison.
--- fs/afs/addr_list.c | 125 ++++++++++++++++++----------------- fs/afs/cmservice.c | 5 +- fs/afs/fs_probe.c | 11 +-- fs/afs/internal.h | 26 ++++---- fs/afs/proc.c | 9 +-- fs/afs/rotate.c | 6 +- fs/afs/rxrpc.c | 10 +-- fs/afs/server.c | 41 ++---------- fs/afs/vl_alias.c | 55 +-------------- fs/afs/vl_list.c | 15 +++-- fs/afs/vl_probe.c | 12 ++-- fs/afs/vl_rotate.c | 6 +- fs/afs/vlclient.c | 22 ++++-- include/net/af_rxrpc.h | 15 +++-- include/trace/events/rxrpc.h | 3 + net/rxrpc/af_rxrpc.c | 62 ++++++++++++++--- net/rxrpc/ar-internal.h | 2 +- net/rxrpc/call_object.c | 17 ++--- net/rxrpc/peer_object.c | 56 ++++++++++------ net/rxrpc/sendmsg.c | 11 ++- 20 files changed, 271 insertions(+), 238 deletions(-)
fs/afs/addr_list.c +66 -59
@@ -13,26 +13,33 @@#include "internal.h" #include "afs_fs.h" +static void afs_free_addrlist (struct rcu_head *rcu) +{ + struct afs_addr_list *alist = container_of(rcu, struct afs_addr_list, rcu); +unsigned int i; + +for (i =0 ; i < alist->nr_addrs; i++) +rxrpc_kernel_put_peer (alist->addrs[i].peer); +} +/* * Release an address list. */ void afs_put_addrlist (struct afs_addr_list *alist) {if (alist &&refcount_dec_and_test (&alist->usage)) -kfree_rcu (alist, rcu); +call_rcu (&alist->rcu, afs_free_addrlist); }/* * Allocate an address list. */ -struct afs_addr_list *afs_alloc_addrlist (unsigned int nr, -unsigned short service, -unsigned short port) +struct afs_addr_list *afs_alloc_addrlist (unsigned int nr,u16 service_id) {struct afs_addr_list *alist;unsigned int i; -_enter ("%u,%u,%u" , nr, service, port); +_enter ("%u,%u" , nr, service_id);if (nr >AFS_MAX_ADDRESSES ) nr =AFS_MAX_ADDRESSES ;
@@ -44,16 +51,8 @@ struct afs_addr_list *afs_alloc_addrlist(unsigned int nr,refcount_set (&alist->usage,1 ); alist->max_addrs = nr; -for (i =0 ; i < nr; i++) { -struct sockaddr_rxrpc *srx = &alist->addrs[i].srx; - srx->srx_family =AF_RXRPC ; - srx->srx_service = service; - srx->transport_type =SOCK_DGRAM ; - srx->transport_len =sizeof (srx->transport.sin6); - srx->transport.sin6.sin6_family =AF_INET6 ; - srx->transport.sin6.sin6_port =htons (port); - } - +for (i =0 ; i < nr; i++) + alist->addrs[i].service_id = service_id;return alist; }
@@ -126,7 +125,7 @@ struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *net,if (!vllist->servers[0 ].server) goto error_vl; - alist =afs_alloc_addrlist (nr, service,AFS_VL_PORT ); + alist =afs_alloc_addrlist (nr, service);if (!alist) goto error;
@@ -197,9 +196,11 @@ struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *net, }if (family ==AF_INET ) -afs_merge_fs_addr4 (alist, x[0 ], xport); + ret =afs_merge_fs_addr4 (net, alist, x[0 ], xport);else -afs_merge_fs_addr6 (alist, x, xport); + ret =afs_merge_fs_addr6 (net, alist, x, xport); +if (ret <0 ) + goto error; }while (p < end);
@@ -271,25 +272,33 @@ struct afs_vlserver_list *afs_dns_query(struct afs_cell *cell, time64_t *_expiry/* * Merge an IPv4 entry into a fileserver address list. */ -void afs_merge_fs_addr4 (struct afs_addr_list *alist,__be32 xdr,u16 port) +int afs_merge_fs_addr4 (struct afs_net *net,struct afs_addr_list *alist, +__be32 xdr,u16 port) { -struct sockaddr_rxrpc *srx; -u32 addr =ntohl (xdr); +struct sockaddr_rxrpc srx; +struct rxrpc_peer *peer;int i;if (alist->nr_addrs >= alist->max_addrs) -return ; +return 0 ; -for (i =0 ; i < alist->nr_ipv4; i++) { -struct sockaddr_in *a = &alist->addrs[i].srx.transport.sin; -u32 a_addr =ntohl (a->sin_addr.s_addr); -u16 a_port =ntohs (a->sin_port); + srx.srx_family =AF_RXRPC ; + srx.transport_type =SOCK_DGRAM ; + srx.transport_len =sizeof (srx.transport.sin); + srx.transport.sin.sin_family =AF_INET ; + srx.transport.sin.sin_port =htons (port); + srx.transport.sin.sin_addr.s_addr = xdr; -if (addr == a_addr && port == a_port) -return ; -if (addr == a_addr && port < a_port) -break ; -if (addr < a_addr) + peer =rxrpc_kernel_lookup_peer (net->socket, &srx,GFP_KERNEL ); +if (!peer) +return -ENOMEM ; + +for (i =0 ; i < alist->nr_ipv4; i++) { +if (peer == alist->addrs[i].peer) { +rxrpc_kernel_put_peer (peer); +return 0 ; + } +if (peer <= alist->addrs[i].peer)break ; }
@@ -298,38 +307,42 @@ void afs_merge_fs_addr4(struct afs_addr_list *alist, __be32 xdr, u16 port) alist->addrs + i, sizeof(alist->addrs[0]) * (alist->nr_addrs - i)); - srx = &alist->addrs[i].srx; - srx->srx_family =AF_RXRPC ; - srx->transport_type =SOCK_DGRAM ; - srx->transport_len =sizeof (srx->transport.sin); - srx->transport.sin.sin_family =AF_INET ; - srx->transport.sin.sin_port =htons (port); - srx->transport.sin.sin_addr.s_addr = xdr; + alist->addrs[i].peer = peer; alist->nr_ipv4++; alist->nr_addrs++; +return 0 ; }/* * Merge an IPv6 entry into a fileserver address list. */ -void afs_merge_fs_addr6 (struct afs_addr_list *alist,__be32 *xdr,u16 port) +int afs_merge_fs_addr6 (struct afs_net *net,struct afs_addr_list *alist, +__be32 *xdr,u16 port) { -struct sockaddr_rxrpc *srx; -int i, diff; +struct sockaddr_rxrpc srx; +struct rxrpc_peer *peer; +int i;if (alist->nr_addrs >= alist->max_addrs) -return ; +return 0 ; -for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) { -struct sockaddr_in6 *a = &alist->addrs[i].srx.transport.sin6; -u16 a_port =ntohs (a->sin6_port); + srx.srx_family =AF_RXRPC ; + srx.transport_type =SOCK_DGRAM ; + srx.transport_len =sizeof (srx.transport.sin6); + srx.transport.sin6.sin6_family =AF_INET6 ; + srx.transport.sin6.sin6_port =htons (port); +memcpy (&srx.transport.sin6.sin6_addr, xdr,16 ); - diff =memcmp (xdr, &a->sin6_addr,16 ); -if (diff ==0 && port == a_port) -return ; -if (diff ==0 && port < a_port) -break ; -if (diff <0 ) + peer =rxrpc_kernel_lookup_peer (net->socket, &srx,GFP_KERNEL ); +if (!peer) +return -ENOMEM ; + +for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) { +if (peer == alist->addrs[i].peer) { +rxrpc_kernel_put_peer (peer); +return 0 ; + } +if (peer <= alist->addrs[i].peer)break ; }
@@ -337,15 +350,9 @@ void afs_merge_fs_addr6(struct afs_addr_list *alist, __be32 *xdr, u16 port)memmove (alist->addrs + i +1 , alist->addrs + i,sizeof (alist->addrs[0 ]) * (alist->nr_addrs - i)); - - srx = &alist->addrs[i].srx; - srx->srx_family =AF_RXRPC ; - srx->transport_type =SOCK_DGRAM ; - srx->transport_len =sizeof (srx->transport.sin6); - srx->transport.sin6.sin6_family =AF_INET6 ; - srx->transport.sin6.sin6_port =htons (port); -memcpy (&srx->transport.sin6.sin6_addr, xdr,16 ); + alist->addrs[i].peer = peer; alist->nr_addrs++; +return 0 ; }/*
fs/afs/cmservice.c +3 -2
@@ -146,10 +146,11 @@ static int afs_find_cm_server_by_peer(struct afs_call *call) {struct sockaddr_rxrpc srx;struct afs_server *server; +struct rxrpc_peer *peer; -rxrpc_kernel_get_peer (call->net->socket, call->rxcall, &srx); + peer =rxrpc_kernel_get_call_peer (call->net->socket, call->rxcall); - server =afs_find_server (call->net, &srx); + server =afs_find_server (call->net, peer);if (!server) {trace_afs_cm_no_server (call, &srx);return 0 ;
fs/afs/fs_probe.c +6 -5
@@ -101,6 +101,7 @@ static void afs_fs_probe_not_done(struct afs_net *net,void afs_fileserver_probe_result (struct afs_call *call) {struct afs_addr_list *alist = call->alist; +struct afs_address *addr = &alist->addrs[call->addr_ix];struct afs_server *server = call->server;unsigned int index = call->addr_ix;unsigned int rtt_us =0 , cap0;
@@ -153,12 +154,12 @@ void afs_fileserver_probe_result(struct afs_call *call)if (call->service_id ==YFS_FS_SERVICE ) { server->probe.is_yfs = true;set_bit (AFS_SERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx.srx_service = call->service_id; + addr->service_id = call->service_id; }else { server->probe.not_yfs = true;if (!server->probe.is_yfs) {clear_bit (AFS_SERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx.srx_service = call->service_id; + addr->service_id = call->service_id; } cap0 =ntohl (call->tmp);if (cap0 &AFS3_VICED_CAPABILITY_64BITFILES )
@@ -167,7 +168,7 @@ void afs_fileserver_probe_result(struct afs_call *call)clear_bit (AFS_SERVER_FL_HAS_FS64 , &server->flags); } -rxrpc_kernel_get_srtt (call->net->socket, call->rxcall, &rtt_us); + rtt_us =rxrpc_kernel_get_srtt (addr->peer);if (rtt_us < server->probe.rtt) { server->probe.rtt = rtt_us; server->rtt = rtt_us;
@@ -181,8 +182,8 @@ void afs_fileserver_probe_result(struct afs_call *call) out:spin_unlock (&server->probe_lock); -_debug ("probe %pU [%u] %pISpc rtt=%u ret=%d" , - &server->uuid, index, &alist->addrs[index].srx.transport, +_debug ("probe %pU [%u] %pISpc rtt=%d ret=%d" , + &server->uuid, index,rxrpc_kernel_remote_addr (alist->addrs[index].peer), rtt_us, ret);return afs_done_one_fs_probe (call->net, server);
fs/afs/internal.h +14 -12
@@ -72,6 +72,11 @@ enum afs_call_state { AFS_CALL_COMPLETE, /* Completed or failed */ }; +struct afs_address { +struct rxrpc_peer *peer; +u16 service_id; +}; +/* * List of server addresses. */
@@ -87,9 +92,7 @@ struct afs_addr_list { enum dns_lookup_status status:8;unsigned long failed;/* Mask of addrs that failed locally/ICMP */ unsigned long responded;/* Mask of addrs that responded */ -struct { -struct sockaddr_rxrpc srx; - } addrs[] __counted_by(max_addrs); + struct afs_address addrs[] __counted_by(max_addrs);#define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8)) };
@@ -420,7 +423,7 @@ struct afs_vlserver {atomic_t probe_outstanding;spinlock_t probe_lock;struct { -unsigned int rtt;/* RTT in uS */ +unsigned int rtt;/* Best RTT in uS (or UINT_MAX) */ u32 abort_code;short error;unsigned short flags;
@@ -537,7 +540,7 @@ struct afs_server {atomic_t probe_outstanding;spinlock_t probe_lock;struct { -unsigned int rtt;/* RTT in uS */ +unsigned int rtt;/* Best RTT in uS (or UINT_MAX) */ u32 abort_code;short error;bool responded:1 ;
@@ -963,9 +966,7 @@ static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alistrefcount_inc (&alist->usage);return alist; } -extern struct afs_addr_list *afs_alloc_addrlist (unsigned int , -unsigned short , -unsigned short ); +extern struct afs_addr_list *afs_alloc_addrlist (unsigned int nr,u16 service_id);extern void afs_put_addrlist (struct afs_addr_list *); extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *, const char *, size_t, char,
@@ -976,8 +977,10 @@ extern struct afs_vlserver_list *afs_dns_query(struct afs_cell *, time64_t *);extern bool afs_iterate_addresses (struct afs_addr_cursor *);extern int afs_end_cursor (struct afs_addr_cursor *); -extern void afs_merge_fs_addr4 (struct afs_addr_list *,__be32 ,u16 ); -extern void afs_merge_fs_addr6 (struct afs_addr_list *,__be32 *,u16 ); +extern int afs_merge_fs_addr4 (struct afs_net *net,struct afs_addr_list *addr, +__be32 xdr,u16 port); +extern int afs_merge_fs_addr6 (struct afs_net *net,struct afs_addr_list *addr, +__be32 *xdr,u16 port);/* * callback.c
@@ -1404,8 +1407,7 @@ extern void __exit afs_clean_up_permit_cache(void);*/ extern spinlock_t afs_server_peer_lock; -extern struct afs_server *afs_find_server (struct afs_net *, -const struct sockaddr_rxrpc *); +extern struct afs_server *afs_find_server (struct afs_net *,const struct rxrpc_peer *);extern struct afs_server *afs_find_server_by_uuid (struct afs_net *,const uuid_t *);extern struct afs_server *afs_lookup_server (struct afs_cell *,struct key *,const uuid_t *,u32 );extern struct afs_server *afs_get_server (struct afs_server *,enum afs_server_trace );
fs/afs/proc.c +5 -4
@@ -307,7 +307,7 @@ static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v)for (i =0 ; i < alist->nr_addrs; i++)seq_printf (m," %c %pISpc\n" , alist->preferred == i ?'>' :'-' , - &alist->addrs[i].srx.transport); +rxrpc_kernel_remote_addr (alist->addrs[i].peer)); }seq_printf (m," info: fl=%lx rtt=%d\n" , vlserver->flags, vlserver->rtt); seq_printf(m, " probe: fl=%x e=%d ac=%d out=%d\n",
@@ -398,9 +398,10 @@ static int afs_proc_servers_show(struct seq_file *m, void *v)seq_printf (m," - ALIST v=%u rsp=%lx f=%lx\n" , alist->version, alist->responded, alist->failed);for (i =0 ; i < alist->nr_addrs; i++) -seq_printf (m," [%x] %pISpc%s\n" , - i, &alist->addrs[i].srx.transport, - alist->preferred == i ?"*" :"" ); +seq_printf (m," [%x] %pISpc%s rtt=%d\n" , + i,rxrpc_kernel_remote_addr (alist->addrs[i].peer), + alist->preferred == i ?"*" :"" , +rxrpc_kernel_get_srtt (alist->addrs[i].peer));return 0 ; }
fs/afs/rotate.c +3 -3
@@ -113,7 +113,7 @@ bool afs_select_fileserver(struct afs_operation *op)struct afs_server *server;struct afs_vnode *vnode = op->file[0 ].vnode;struct afs_error e; -u32 rtt; +unsigned int rtt;int error = op->ac.error, i; _enter("%lx[%d],%lx[%d],%d,%d",
@@ -419,7 +419,7 @@ bool afs_select_fileserver(struct afs_operation *op) } op->index =-1 ; - rtt =U32_MAX ; + rtt =UINT_MAX ;for (i =0 ; i < op->server_list->nr_servers; i++) {struct afs_server *s = op->server_list->servers[i].server;
@@ -487,7 +487,7 @@ bool afs_select_fileserver(struct afs_operation *op)_debug ("address [%u] %u/%u %pISp" , op->index, op->ac.index, op->ac.alist->nr_addrs, - &op->ac.alist->addrs[op->ac.index].srx.transport); +rxrpc_kernel_remote_addr (op->ac.alist->addrs[op->ac.index].peer));_leave (" = t" );return true;
fs/afs/rxrpc.c +6 -4
@@ -296,7 +296,8 @@ static void afs_notify_end_request_tx(struct sock *sock,*/ void afs_make_call (struct afs_addr_cursor *ac,struct afs_call *call,gfp_t gfp) { -struct sockaddr_rxrpc *srx = &ac->alist->addrs[ac->index].srx; +struct afs_address *addr = &ac->alist->addrs[ac->index]; +struct rxrpc_peer *peer = addr->peer;struct rxrpc_call *rxcall;struct msghdr msg;struct kvec iov[1 ];
@@ -304,7 +305,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)s64 tx_total_len;int ret; -_enter (",{%pISp}," , &srx->transport); +_enter (",{%pISp}," ,rxrpc_kernel_remote_addr (addr->peer));ASSERT (call->type !=NULL );ASSERT (call->type->name !=NULL );
@@ -333,7 +334,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) }/* create a call */ - rxcall = rxrpc_kernel_begin_call(call->net->socket, srx, call->key, + rxcall = rxrpc_kernel_begin_call(call->net->socket, peer, call->key, (unsigned long)call, tx_total_len, call->max_lifespan,
@@ -341,6 +342,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) (call->async ? afs_wake_up_async_call : afs_wake_up_call_waiter), + addr->service_id, call->upgrade, (call->intr ?RXRPC_PREINTERRUPTIBLE : RXRPC_UNINTERRUPTIBLE),
@@ -461,7 +463,7 @@ static void afs_log_error(struct afs_call *call, s32 remote_abort) max = m +1 ;pr_notice ("kAFS: Peer reported %s failure on %s [%pISp]\n" , msg, call->type->name, - &call->alist->addrs[call->addr_ix].srx.transport); +rxrpc_kernel_remote_addr (call->alist->addrs[call->addr_ix].peer)); } }
fs/afs/server.c +7 -34
57 lines not on this page · raw message
fs/afs/vl_alias.c +3 -52
67 lines not on this page · raw message
fs/afs/vl_list.c +10 -5
@@ -83,14 +83,15 @@ static u16 afs_extract_le16(const u8 **_b)/* * Build a VL server address list from a DNS queried server list. */ -static struct afs_addr_list *afs_extract_vl_addrs (const u8 **_b,const u8 *end, +static struct afs_addr_list *afs_extract_vl_addrs (struct afs_net *net, +const u8 **_b,const u8 *end,u8 nr_addrs,u16 port) {struct afs_addr_list *alist;const u8 *b = *_b;int ret = -EINVAL ; - alist =afs_alloc_addrlist (nr_addrs,VL_SERVICE , port); + alist =afs_alloc_addrlist (nr_addrs,VL_SERVICE );if (!alist)return ERR_PTR (-ENOMEM );if (nr_addrs ==0 )
@@ -109,7 +110,9 @@ static struct afs_addr_list *afs_extract_vl_addrs(const u8 **_b, const u8 *end, goto error; }memcpy (x, b,4 ); -afs_merge_fs_addr4 (alist, x[0 ], port); + ret =afs_merge_fs_addr4 (net, alist, x[0 ], port); +if (ret <0 ) + goto error; b +=4 ;break ;
@@ -119,7 +122,9 @@ static struct afs_addr_list *afs_extract_vl_addrs(const u8 **_b, const u8 *end, goto error; }memcpy (x, b,16 ); -afs_merge_fs_addr6 (alist, x, port); + ret =afs_merge_fs_addr6 (net, alist, x, port); +if (ret <0 ) + goto error; b +=16 ;break ;
@@ -247,7 +252,7 @@ struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *cell,/* Extract the addresses - note that we can't skip this as we * have to advance the payload pointer. */ - addrs =afs_extract_vl_addrs (&b, end, bs.nr_addrs, bs.port); + addrs =afs_extract_vl_addrs (cell->net, &b, end, bs.nr_addrs, bs.port);if (IS_ERR (addrs)) { ret =PTR_ERR (addrs); goto error_2;
fs/afs/vl_probe.c +7 -5
@@ -48,6 +48,7 @@ void afs_vlserver_probe_result(struct afs_call *call) {struct afs_addr_list *alist = call->alist;struct afs_vlserver *server = call->vlserver; +struct afs_address *addr = &alist->addrs[call->addr_ix];unsigned int server_index = call->server_index;unsigned int rtt_us =0 ;unsigned int index = call->addr_ix;
@@ -106,16 +107,16 @@ void afs_vlserver_probe_result(struct afs_call *call)if (call->service_id ==YFS_VL_SERVICE ) { server->probe.flags |=AFS_VLSERVER_PROBE_IS_YFS ;set_bit (AFS_VLSERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx.srx_service = call->service_id; + addr->service_id = call->service_id; }else { server->probe.flags |=AFS_VLSERVER_PROBE_NOT_YFS ;if (!(server->probe.flags &AFS_VLSERVER_PROBE_IS_YFS )) {clear_bit (AFS_VLSERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx.srx_service = call->service_id; + addr->service_id = call->service_id; } } -rxrpc_kernel_get_srtt (call->net->socket, call->rxcall, &rtt_us); + rtt_us =rxrpc_kernel_get_srtt (addr->peer);if (rtt_us < server->probe.rtt) { server->probe.rtt = rtt_us; server->rtt = rtt_us;
@@ -130,8 +131,9 @@ void afs_vlserver_probe_result(struct afs_call *call) out:spin_unlock (&server->probe_lock); -_debug ("probe [%u][%u] %pISpc rtt=%u ret=%d" , - server_index, index, &alist->addrs[index].srx.transport, rtt_us, ret); +_debug ("probe [%u][%u] %pISpc rtt=%d ret=%d" , + server_index, index,rxrpc_kernel_remote_addr (addr->peer), + rtt_us, ret);afs_done_one_vl_probe (server, have_result); }
fs/afs/vl_rotate.c +3 -3
@@ -86,7 +86,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)struct afs_addr_list *alist;struct afs_vlserver *vlserver;struct afs_error e; -u32 rtt; +unsigned int rtt;int error = vc->ac.error, i; _enter("%lx[%d],%lx[%d],%d,%d",
@@ -188,7 +188,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc) goto selected_server; vc->index =-1 ; - rtt =U32_MAX ; + rtt =UINT_MAX ;for (i =0 ; i < vc->server_list->nr_servers; i++) {struct afs_vlserver *s = vc->server_list->servers[i].server;
@@ -243,7 +243,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)_debug ("VL address %d/%d" , vc->ac.index, vc->ac.alist->nr_addrs); -_leave (" = t %pISpc" , &vc->ac.alist->addrs[vc->ac.index].srx.transport); +_leave (" = t %pISpc" ,rxrpc_kernel_remote_addr (vc->ac.alist->addrs[vc->ac.index].peer));return true; next_server:
fs/afs/vlclient.c +15 -7
@@ -208,7 +208,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call) count =ntohl (*bp); nentries =min (nentries, count); - alist =afs_alloc_addrlist (nentries,FS_SERVICE ,AFS_FS_PORT ); + alist =afs_alloc_addrlist (nentries,FS_SERVICE );if (!alist)return -ENOMEM ; alist->version = uniquifier;
@@ -230,9 +230,13 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call) alist = call->ret_alist; bp = call->buffer; count =min (call->count,4U ); -for (i =0 ; i < count; i++) -if (alist->nr_addrs < call->count2) -afs_merge_fs_addr4 (alist, *bp++,AFS_FS_PORT ); +for (i =0 ; i < count; i++) { +if (alist->nr_addrs < call->count2) { + ret =afs_merge_fs_addr4 (call->net, alist, *bp++,AFS_FS_PORT ); +if (ret <0 ) +return ret; + } + } call->count -= count;if (call->count >0 )
@@ -450,7 +454,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)if (call->count >YFS_MAXENDPOINTS )return afs_protocol_error (call, afs_eproto_yvl_fsendpt_num); - alist =afs_alloc_addrlist (call->count,FS_SERVICE ,AFS_FS_PORT ); + alist =afs_alloc_addrlist (call->count,FS_SERVICE );if (!alist)return -ENOMEM ; alist->version = uniquifier;
@@ -488,14 +492,18 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)if (ntohl (bp[0 ]) !=sizeof (__be32) *2 )return afs_protocol_error ( call, afs_eproto_yvl_fsendpt4_len); -afs_merge_fs_addr4 (alist, bp[1 ],ntohl (bp[2 ])); + ret =afs_merge_fs_addr4 (call->net, alist, bp[1 ],ntohl (bp[2 ])); +if (ret <0 ) +return ret; bp +=3 ;break ;case YFS_ENDPOINT_IPV6 :if (ntohl (bp[0 ]) !=sizeof (__be32) *5 )return afs_protocol_error ( call, afs_eproto_yvl_fsendpt6_len); -afs_merge_fs_addr6 (alist, bp +1 ,ntohl (bp[5 ])); + ret =afs_merge_fs_addr6 (call->net, alist, bp +1 ,ntohl (bp[5 ])); +if (ret <0 ) +return ret; bp +=6 ;break ;default :
include/net/af_rxrpc.h +11 -4
@@ -15,6 +15,7 @@ struct key;struct sock ;struct socket ;struct rxrpc_call ; +struct rxrpc_peer ;enum rxrpc_abort_reason ;enum rxrpc_interruptibility {
@@ -41,13 +42,14 @@ void rxrpc_kernel_new_call_notification(struct socket *, rxrpc_notify_new_call_t, rxrpc_discard_new_call_t);struct rxrpc_call *rxrpc_kernel_begin_call (struct socket *sock, -struct sockaddr_rxrpc *srx, +struct rxrpc_peer *peer,struct key *key,unsigned long user_call_ID,s64 tx_total_len,u32 hard_timeout,gfp_t gfp,rxrpc_notify_rx_t notify_rx, +u16 service_id,bool upgrade,enum rxrpc_interruptibility interruptibility,unsigned int debug_id);
@@ -60,9 +62,14 @@ bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *, u32, int, enum rxrpc_abort_reason);void rxrpc_kernel_shutdown_call (struct socket *sock,struct rxrpc_call *call);void rxrpc_kernel_put_call (struct socket *sock,struct rxrpc_call *call); -void rxrpc_kernel_get_peer (struct socket *,struct rxrpc_call *, -struct sockaddr_rxrpc *); -bool rxrpc_kernel_get_srtt (struct socket *,struct rxrpc_call *,u32 *); +struct rxrpc_peer *rxrpc_kernel_lookup_peer (struct socket *sock, +struct sockaddr_rxrpc *srx,gfp_t gfp); +void rxrpc_kernel_put_peer (struct rxrpc_peer *peer); +struct rxrpc_peer *rxrpc_kernel_get_peer (struct rxrpc_peer *peer); +struct rxrpc_peer *rxrpc_kernel_get_call_peer (struct socket *sock,struct rxrpc_call *call); +const struct sockaddr_rxrpc *rxrpc_kernel_remote_srx (const struct rxrpc_peer *peer); +const struct sockaddr *rxrpc_kernel_remote_addr (const struct rxrpc_peer *peer); +unsigned int rxrpc_kernel_get_srtt (const struct rxrpc_peer *);int rxrpc_kernel_charge_accept (struct socket *,rxrpc_notify_rx_t ,rxrpc_user_attach_call_t ,unsigned long ,gfp_t ,unsigned int );
include/trace/events/rxrpc.h +3 -0
@@ -178,7 +178,9 @@#define rxrpc_peer_traces \ EM(rxrpc_peer_free, "FREE ") \ EM(rxrpc_peer_get_accept, "GET accept ") \ + EM(rxrpc_peer_get_application, "GET app ") \ EM(rxrpc_peer_get_bundle, "GET bundle ") \ + EM(rxrpc_peer_get_call, "GET call ") \ EM(rxrpc_peer_get_client_conn, "GET cln-conn") \ EM(rxrpc_peer_get_input, "GET input ") \ EM(rxrpc_peer_get_input_error, "GET inpt-err") \
@@ -187,6 +189,7 @@ EM(rxrpc_peer_get_service_conn, "GET srv-conn") \ EM(rxrpc_peer_new_client, "NEW client ") \ EM(rxrpc_peer_new_prealloc, "NEW prealloc") \ + EM(rxrpc_peer_put_application, "PUT app ") \ EM(rxrpc_peer_put_bundle, "PUT bundle ") \ EM(rxrpc_peer_put_call, "PUT call ") \EM (rxrpc_peer_put_conn,"PUT conn " ) \
net/rxrpc/af_rxrpc.c +54 -8
108 lines not on this page · raw message
net/rxrpc/ar-internal.h +1 -1
@@ -364,6 +364,7 @@ struct rxrpc_conn_proto {struct rxrpc_conn_parameters {struct rxrpc_local *local;/* Representation of local endpoint */ +struct rxrpc_peer *peer;/* Representation of remote endpoint */ struct key *key;/* Security details */ bool exclusive;/* T if conn is exclusive */ bool upgrade;/* T if service ID can be upgraded */
@@ -867,7 +868,6 @@ struct rxrpc_call *rxrpc_find_call_by_user_ID(struct rxrpc_sock *, unsigned longstruct rxrpc_call *rxrpc_alloc_call (struct rxrpc_sock *,gfp_t ,unsigned int );struct rxrpc_call *rxrpc_new_client_call (struct rxrpc_sock *,struct rxrpc_conn_parameters *, -struct sockaddr_rxrpc *,struct rxrpc_call_params *,gfp_t ,unsigned int );void rxrpc_start_call_timer (struct rxrpc_call *call);
net/rxrpc/call_object.c +9 -8
@@ -193,7 +193,6 @@ struct rxrpc_call *rxrpc_alloc_call(struct rxrpc_sock *rx, gfp_t gfp,* Allocate a new client call. */ static struct rxrpc_call *rxrpc_alloc_client_call(struct rxrpc_sock *rx, - struct sockaddr_rxrpc *srx, struct rxrpc_conn_parameters *cp, struct rxrpc_call_params *p, gfp_t gfp,
@@ -211,10 +210,12 @@ static struct rxrpc_call *rxrpc_alloc_client_call(struct rxrpc_sock *rx, now =ktime_get_real (); call->acks_latest_ts = now; call->cong_tstamp = now; - call->dest_srx = *srx; + call->dest_srx = cp->peer->srx; + call->dest_srx.srx_service = cp->service_id; call->interruptibility = p->interruptibility; call->tx_total_len = p->tx_total_len; call->key =key_get (cp->key); + call->peer =rxrpc_get_peer (cp->peer, rxrpc_peer_get_call); call->local =rxrpc_get_local (cp->local, rxrpc_local_get_call); call->security_level = cp->security_level;if (p->kernel)
@@ -306,10 +307,6 @@ static int rxrpc_connect_call(struct rxrpc_call *call, gfp_t gfp)_enter ("{%d,%lx}," , call->debug_id, call->user_call_ID); - call->peer =rxrpc_lookup_peer (local, &call->dest_srx, gfp); -if (!call->peer) - goto error; - ret =rxrpc_look_up_bundle (call, gfp);if (ret <0 ) goto error;
@@ -334,7 +331,6 @@ static int rxrpc_connect_call(struct rxrpc_call *call, gfp_t gfp)*/ struct rxrpc_call *rxrpc_new_client_call (struct rxrpc_sock *rx,struct rxrpc_conn_parameters *cp, -struct sockaddr_rxrpc *srx,struct rxrpc_call_params *p,gfp_t gfp,unsigned int debug_id)
@@ -349,13 +345,18 @@ struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,_enter ("%p,%lx" , rx, p->user_call_ID); +if (WARN_ON_ONCE (!cp->peer)) { +release_sock (&rx->sk); +return ERR_PTR (-EIO ); + } + limiter =rxrpc_get_call_slot (p, gfp);if (!limiter) {release_sock (&rx->sk);return ERR_PTR (-ERESTARTSYS ); } - call =rxrpc_alloc_client_call (rx, srx, cp, p, gfp, debug_id); + call =rxrpc_alloc_client_call (rx, cp, p, gfp, debug_id);if (IS_ERR (call)) {release_sock (&rx->sk);up (limiter);
net/rxrpc/peer_object.c +35 -21
80 lines not on this page · raw message
net/rxrpc/sendmsg.c +10 -1
@@ -572,6 +572,7 @@ rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, __acquires(&call->user_mutex) {struct rxrpc_conn_parameters cp; +struct rxrpc_peer *peer;struct rxrpc_call *call;struct key *key;
@@ -584,21 +585,29 @@ rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg,return ERR_PTR (-EDESTADDRREQ ); } + peer =rxrpc_lookup_peer (rx->local, srx,GFP_KERNEL ); +if (!peer) { +release_sock (&rx->sk); +return ERR_PTR (-ENOMEM ); + } + key = rx->key;if (key && !rx->key->payload.data[0 ]) key =NULL ;memset (&cp,0 ,sizeof (cp)); cp.local = rx->local; + cp.peer = peer; cp.key = rx->key; cp.security_level = rx->min_sec_level; cp.exclusive = rx->exclusive | p->exclusive; cp.upgrade = p->upgrade; cp.service_id = srx->srx_service; - call =rxrpc_new_client_call (rx, &cp, srx, &p->call,GFP_KERNEL , + call =rxrpc_new_client_call (rx, &cp, &p->call,GFP_KERNEL ,atomic_inc_return (&rxrpc_debug_id));/* The socket is now unlocked */ +rxrpc_put_peer (peer, rxrpc_peer_put_application);_leave (" = %p\n" , call);return call; }
Marc Dionne
maintainerRe: [PATCH 10/41] rxrpc, afs: Allow afs to pin rxrpc_peer objects
Quoted 1,251 lines · David Howells
Change rxrpc's API such that:
(1) A new function,
rxrpc_kernel_lookup_peer(), is provided to look up anrxrpc_peerrecord for a remote address and a corresponding function,rxrpc_kernel_put_peer(), is provided to dispose of it again.(2) When setting up a call, the
rxrpc_peerobject used during a call is now passed in rather than being set up byrxrpc_connect_call(). For afs, this meenat passing it torxrpc_kernel_begin_call()rather than the full address (the service ID then has to be passed in as a separate parameter).(3) A new function,
rxrpc_kernel_remote_addr(), is added so that afs can get a pointer to the transport address for display purposed, and another,rxrpc_kernel_remote_srx(), to gain a pointer to the full rxrpc address.(4) The function to retrieve the RTT from a call,
rxrpc_kernel_get_srtt(), is then altered to take a peer. This now returns the RTT or -1 if there are insufficient samples.(5) Rename
rxrpc_kernel_get_peer()torxrpc_kernel_call_get_peer().(6) Provide a new function,
rxrpc_kernel_get_peer(), to get a ref on a peer the caller already has.This allows the afs filesystem to pin the
rxrpc_peerrecords that it is using, allowing faster lookups and pointer comparisons rather than comparingsockaddr_rxrpccontents. It also makes it easier to get hold of the RTT. The following changes are made to afs:(1) The
addr_liststruct's addrs[] elements now hold a peer struct pointer and a service ID rather than asockaddr_rxrpc.(2) When displaying the transport address,
rxrpc_kernel_remote_addr()is used.(3) The port arg is removed from
afs_alloc_addrlist()since it's always overridden.(4)
afs_merge_fs_addr4()andafs_merge_fs_addr6()do peer lookup and may now return an error that must be handled.(5)
afs_find_server()now takes a peer pointer to specify the address.(6)
afs_find_server(),afs_compare_fs_alists()and afs_merge_fs_addr[46]{} now do peer pointer comparison rather than address comparison.Signed-off-by David Howells <[email protected]>cc Marc Dionne <[email protected]>--- fs/afs/addr_list.c | 125 ++++++++++++++++++----------------- fs/afs/cmservice.c | 5 +- fs/afs/fs_probe.c | 11 +-- fs/afs/internal.h | 26 ++++---- fs/afs/proc.c | 9 +-- fs/afs/rotate.c | 6 +- fs/afs/rxrpc.c | 10 +-- fs/afs/server.c | 41 ++---------- fs/afs/vl_alias.c | 55 +-------------- fs/afs/vl_list.c | 15 +++-- fs/afs/vl_probe.c | 12 ++-- fs/afs/vl_rotate.c | 6 +- fs/afs/vlclient.c | 22 ++++-- include/net/af_rxrpc.h | 15 +++-- include/trace/events/rxrpc.h | 3 + net/rxrpc/af_rxrpc.c | 62 ++++++++++++++--- net/rxrpc/ar-internal.h | 2 +- net/rxrpc/call_object.c | 17 ++--- net/rxrpc/peer_object.c | 56 ++++++++++------ net/rxrpc/sendmsg.c | 11 ++- 20 files changed, 271 insertions(+), 238 deletions(-)fs/afs/addr_list.c +66
-59@@ -13,26 +13,33 @@#include "internal.h" #include "afs_fs.h" +static void afs_free_addrlist (struct rcu_head *rcu) +{ + struct afs_addr_list *alist = container_of(rcu, struct afs_addr_list, rcu); +unsigned int i; + +for (i =0 ; i < alist->nr_addrs; i++) +rxrpc_kernel_put_peer (alist->addrs[i].peer); +} +/* * Release an address list. */ void afs_put_addrlist (struct afs_addr_list *alist) {if (alist &&refcount_dec_and_test (&alist->usage)) -kfree_rcu (alist, rcu); +call_rcu (&alist->rcu, afs_free_addrlist); }/* * Allocate an address list. */ -struct afs_addr_list *afs_alloc_addrlist (unsigned int nr, -unsigned short service, -unsigned short port) +struct afs_addr_list *afs_alloc_addrlist (unsigned int nr,u16 service_id) {struct afs_addr_list *alist;unsigned int i; -_enter ("%u,%u,%u" , nr, service, port); +_enter ("%u,%u" , nr, service_id);if (nr >AFS_MAX_ADDRESSES ) nr =AFS_MAX_ADDRESSES ;@@ -44,16 +51,8 @@ struct afs_addr_list *afs_alloc_addrlist(unsigned int nr,refcount_set (&alist->usage,1 ); alist->max_addrs = nr; -for (i =0 ; i < nr; i++) { -struct sockaddr_rxrpc *srx = &alist->addrs[i].srx; - srx->srx_family =AF_RXRPC ; - srx->srx_service = service; - srx->transport_type =SOCK_DGRAM ; - srx->transport_len =sizeof (srx->transport.sin6); - srx->transport.sin6.sin6_family =AF_INET6 ; - srx->transport.sin6.sin6_port =htons (port); - } - +for (i =0 ; i < nr; i++) + alist->addrs[i].service_id = service_id;return alist; }@@ -126,7 +125,7 @@ struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *net,if (!vllist->servers[0 ].server) goto error_vl; - alist =afs_alloc_addrlist (nr, service,AFS_VL_PORT ); + alist =afs_alloc_addrlist (nr, service);if (!alist) goto error;@@ -197,9 +196,11 @@ struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *net, }if (family ==AF_INET ) -afs_merge_fs_addr4 (alist, x[0 ], xport); + ret =afs_merge_fs_addr4 (net, alist, x[0 ], xport);else -afs_merge_fs_addr6 (alist, x, xport); + ret =afs_merge_fs_addr6 (net, alist, x, xport); +if (ret <0 ) + goto error; }while (p < end);@@ -271,25 +272,33 @@ struct afs_vlserver_list *afs_dns_query(struct afs_cell *cell, time64_t *_expiry/* * Merge an IPv4 entry into a fileserver address list. */ -void afs_merge_fs_addr4 (struct afs_addr_list *alist,__be32 xdr,u16 port) +int afs_merge_fs_addr4 (struct afs_net *net,struct afs_addr_list *alist, +__be32 xdr,u16 port) { -struct sockaddr_rxrpc *srx; -u32 addr =ntohl (xdr); +struct sockaddr_rxrpc srx; +struct rxrpc_peer *peer;int i;if (alist->nr_addrs >= alist->max_addrs) -return ; +return 0 ; -for (i =0 ; i < alist->nr_ipv4; i++) { -struct sockaddr_in *a = &alist->addrs[i].srx.transport.sin; -u32 a_addr =ntohl (a->sin_addr.s_addr); -u16 a_port =ntohs (a->sin_port); + srx.srx_family =AF_RXRPC ; + srx.transport_type =SOCK_DGRAM ; + srx.transport_len =sizeof (srx.transport.sin); + srx.transport.sin.sin_family =AF_INET ; + srx.transport.sin.sin_port =htons (port); + srx.transport.sin.sin_addr.s_addr = xdr; -if (addr == a_addr && port == a_port) -return ; -if (addr == a_addr && port < a_port) -break ; -if (addr < a_addr) + peer =rxrpc_kernel_lookup_peer (net->socket, &srx,GFP_KERNEL ); +if (!peer) +return -ENOMEM ; + +for (i =0 ; i < alist->nr_ipv4; i++) { +if (peer == alist->addrs[i].peer) { +rxrpc_kernel_put_peer (peer); +return 0 ; + } +if (peer <= alist->addrs[i].peer)break ; }@@ -298,38 +307,42 @@ void afs_merge_fs_addr4(struct afs_addr_list *alist, __be32 xdr, u16 port) alist->addrs + i, sizeof(alist->addrs[0]) * (alist->nr_addrs - i)); - srx = &alist->addrs[i].srx; - srx->srx_family =AF_RXRPC ; - srx->transport_type =SOCK_DGRAM ; - srx->transport_len =sizeof (srx->transport.sin); - srx->transport.sin.sin_family =AF_INET ; - srx->transport.sin.sin_port =htons (port); - srx->transport.sin.sin_addr.s_addr = xdr; + alist->addrs[i].peer = peer; alist->nr_ipv4++; alist->nr_addrs++; +return 0 ; }/* * Merge an IPv6 entry into a fileserver address list. */ -void afs_merge_fs_addr6 (struct afs_addr_list *alist,__be32 *xdr,u16 port) +int afs_merge_fs_addr6 (struct afs_net *net,struct afs_addr_list *alist, +__be32 *xdr,u16 port) { -struct sockaddr_rxrpc *srx; -int i, diff; +struct sockaddr_rxrpc srx; +struct rxrpc_peer *peer; +int i;if (alist->nr_addrs >= alist->max_addrs) -return ; +return 0 ; -for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) { -struct sockaddr_in6 *a = &alist->addrs[i].srx.transport.sin6; -u16 a_port =ntohs (a->sin6_port); + srx.srx_family =AF_RXRPC ; + srx.transport_type =SOCK_DGRAM ; + srx.transport_len =sizeof (srx.transport.sin6); + srx.transport.sin6.sin6_family =AF_INET6 ; + srx.transport.sin6.sin6_port =htons (port); +memcpy (&srx.transport.sin6.sin6_addr, xdr,16 ); - diff =memcmp (xdr, &a->sin6_addr,16 ); -if (diff ==0 && port == a_port) -return ; -if (diff ==0 && port < a_port) -break ; -if (diff <0 ) + peer =rxrpc_kernel_lookup_peer (net->socket, &srx,GFP_KERNEL ); +if (!peer) +return -ENOMEM ; + +for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) { +if (peer == alist->addrs[i].peer) { +rxrpc_kernel_put_peer (peer); +return 0 ; + } +if (peer <= alist->addrs[i].peer)break ; }@@ -337,15 +350,9 @@ void afs_merge_fs_addr6(struct afs_addr_list *alist, __be32 *xdr, u16 port)memmove (alist->addrs + i +1 , alist->addrs + i,sizeof (alist->addrs[0 ]) * (alist->nr_addrs - i)); - - srx = &alist->addrs[i].srx; - srx->srx_family =AF_RXRPC ; - srx->transport_type =SOCK_DGRAM ; - srx->transport_len =sizeof (srx->transport.sin6); - srx->transport.sin6.sin6_family =AF_INET6 ; - srx->transport.sin6.sin6_port =htons (port); -memcpy (&srx->transport.sin6.sin6_addr, xdr,16 ); + alist->addrs[i].peer = peer; alist->nr_addrs++; +return 0 ; }/* fs/afs/cmservice.c +3
-2@@ -146,10 +146,11 @@ static int afs_find_cm_server_by_peer(struct afs_call *call) {struct sockaddr_rxrpc srx;struct afs_server *server; +struct rxrpc_peer *peer; -rxrpc_kernel_get_peer (call->net->socket, call->rxcall, &srx); + peer =rxrpc_kernel_get_call_peer (call->net->socket, call->rxcall); - server =afs_find_server (call->net, &srx); + server =afs_find_server (call->net, peer);if (!server) {trace_afs_cm_no_server (call, &srx);return 0 ;fs/afs/fs_probe.c +6
-5@@ -101,6 +101,7 @@ static void afs_fs_probe_not_done(struct afs_net *net,void afs_fileserver_probe_result (struct afs_call *call) {struct afs_addr_list *alist = call->alist; +struct afs_address *addr = &alist->addrs[call->addr_ix];struct afs_server *server = call->server;unsigned int index = call->addr_ix;unsigned int rtt_us =0 , cap0;@@ -153,12 +154,12 @@ void afs_fileserver_probe_result(struct afs_call *call)if (call->service_id ==YFS_FS_SERVICE ) { server->probe.is_yfs = true;set_bit (AFS_SERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx.srx_service = call->service_id; + addr->service_id = call->service_id; }else { server->probe.not_yfs = true;if (!server->probe.is_yfs) {clear_bit (AFS_SERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx.srx_service = call->service_id; + addr->service_id = call->service_id; } cap0 =ntohl (call->tmp);if (cap0 &AFS3_VICED_CAPABILITY_64BITFILES )@@ -167,7 +168,7 @@ void afs_fileserver_probe_result(struct afs_call *call)clear_bit (AFS_SERVER_FL_HAS_FS64 , &server->flags); } -rxrpc_kernel_get_srtt (call->net->socket, call->rxcall, &rtt_us); + rtt_us =rxrpc_kernel_get_srtt (addr->peer);if (rtt_us < server->probe.rtt) { server->probe.rtt = rtt_us; server->rtt = rtt_us;@@ -181,8 +182,8 @@ void afs_fileserver_probe_result(struct afs_call *call) out:spin_unlock (&server->probe_lock); -_debug ("probe %pU [%u] %pISpc rtt=%u ret=%d" , - &server->uuid, index, &alist->addrs[index].srx.transport, +_debug ("probe %pU [%u] %pISpc rtt=%d ret=%d" , + &server->uuid, index,rxrpc_kernel_remote_addr (alist->addrs[index].peer), rtt_us, ret);return afs_done_one_fs_probe (call->net, server);fs/afs/internal.h +14
-12@@ -72,6 +72,11 @@ enum afs_call_state { AFS_CALL_COMPLETE, /* Completed or failed */ }; +struct afs_address { +struct rxrpc_peer *peer; +u16 service_id; +}; +/* * List of server addresses. */ @@ -87,9 +92,7 @@ struct afs_addr_list { enum dns_lookup_status status:8;unsigned long failed;/* Mask of addrs that failed locally/ICMP */ unsigned long responded;/* Mask of addrs that responded */ -struct { -struct sockaddr_rxrpc srx; - } addrs[] __counted_by(max_addrs); + struct afs_address addrs[] __counted_by(max_addrs);#define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8)) };@@ -420,7 +423,7 @@ struct afs_vlserver {atomic_t probe_outstanding;spinlock_t probe_lock;struct { -unsigned int rtt;/* RTT in uS */ +unsigned int rtt;/* Best RTT in uS (or UINT_MAX) */ u32 abort_code;short error;unsigned short flags;@@ -537,7 +540,7 @@ struct afs_server {atomic_t probe_outstanding;spinlock_t probe_lock;struct { -unsigned int rtt;/* RTT in uS */ +unsigned int rtt;/* Best RTT in uS (or UINT_MAX) */ u32 abort_code;short error;bool responded:1 ;@@ -963,9 +966,7 @@ static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alistrefcount_inc (&alist->usage);return alist; } -extern struct afs_addr_list *afs_alloc_addrlist (unsigned int , -unsigned short , -unsigned short ); +extern struct afs_addr_list *afs_alloc_addrlist (unsigned int nr,u16 service_id);extern void afs_put_addrlist (struct afs_addr_list *); extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *, const char *, size_t, char,@@ -976,8 +977,10 @@ extern struct afs_vlserver_list *afs_dns_query(struct afs_cell *, time64_t *);extern bool afs_iterate_addresses (struct afs_addr_cursor *);extern int afs_end_cursor (struct afs_addr_cursor *); -extern void afs_merge_fs_addr4 (struct afs_addr_list *,__be32 ,u16 ); -extern void afs_merge_fs_addr6 (struct afs_addr_list *,__be32 *,u16 ); +extern int afs_merge_fs_addr4 (struct afs_net *net,struct afs_addr_list *addr, +__be32 xdr,u16 port); +extern int afs_merge_fs_addr6 (struct afs_net *net,struct afs_addr_list *addr, +__be32 *xdr,u16 port);/* * callback.c @@ -1404,8 +1407,7 @@ extern void __exit afs_clean_up_permit_cache(void);*/ extern spinlock_t afs_server_peer_lock; -extern struct afs_server *afs_find_server (struct afs_net *, -const struct sockaddr_rxrpc *); +extern struct afs_server *afs_find_server (struct afs_net *,const struct rxrpc_peer *);extern struct afs_server *afs_find_server_by_uuid (struct afs_net *,const uuid_t *);extern struct afs_server *afs_lookup_server (struct afs_cell *,struct key *,const uuid_t *,u32 );extern struct afs_server *afs_get_server (struct afs_server *,enum afs_server_trace );fs/afs/proc.c +5
-4@@ -307,7 +307,7 @@ static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v)for (i =0 ; i < alist->nr_addrs; i++)seq_printf (m," %c %pISpc\n" , alist->preferred == i ?'>' :'-' , - &alist->addrs[i].srx.transport); +rxrpc_kernel_remote_addr (alist->addrs[i].peer)); }seq_printf (m," info: fl=%lx rtt=%d\n" , vlserver->flags, vlserver->rtt); seq_printf(m, " probe: fl=%x e=%d ac=%d out=%d\n",@@ -398,9 +398,10 @@ static int afs_proc_servers_show(struct seq_file *m, void *v)seq_printf (m," - ALIST v=%u rsp=%lx f=%lx\n" , alist->version, alist->responded, alist->failed);for (i =0 ; i < alist->nr_addrs; i++) -seq_printf (m," [%x] %pISpc%s\n" , - i, &alist->addrs[i].srx.transport, - alist->preferred == i ?"*" :"" ); +seq_printf (m," [%x] %pISpc%s rtt=%d\n" , + i,rxrpc_kernel_remote_addr (alist->addrs[i].peer), + alist->preferred == i ?"*" :"" , +rxrpc_kernel_get_srtt (alist->addrs[i].peer));return 0 ; }fs/afs/rotate.c +3
-3@@ -113,7 +113,7 @@ bool afs_select_fileserver(struct afs_operation *op)struct afs_server *server;struct afs_vnode *vnode = op->file[0 ].vnode;struct afs_error e; -u32 rtt; +unsigned int rtt;int error = op->ac.error, i; _enter("%lx[%d],%lx[%d],%d,%d",@@ -419,7 +419,7 @@ bool afs_select_fileserver(struct afs_operation *op) } op->index =-1 ; - rtt =U32_MAX ; + rtt =UINT_MAX ;for (i =0 ; i < op->server_list->nr_servers; i++) {struct afs_server *s = op->server_list->servers[i].server;@@ -487,7 +487,7 @@ bool afs_select_fileserver(struct afs_operation *op)_debug ("address [%u] %u/%u %pISp" , op->index, op->ac.index, op->ac.alist->nr_addrs, - &op->ac.alist->addrs[op->ac.index].srx.transport); +rxrpc_kernel_remote_addr (op->ac.alist->addrs[op->ac.index].peer));_leave (" = t" );return true;fs/afs/rxrpc.c +6
-4@@ -296,7 +296,8 @@ static void afs_notify_end_request_tx(struct sock *sock,*/ void afs_make_call (struct afs_addr_cursor *ac,struct afs_call *call,gfp_t gfp) { -struct sockaddr_rxrpc *srx = &ac->alist->addrs[ac->index].srx; +struct afs_address *addr = &ac->alist->addrs[ac->index]; +struct rxrpc_peer *peer = addr->peer;struct rxrpc_call *rxcall;struct msghdr msg;struct kvec iov[1 ];@@ -304,7 +305,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)s64 tx_total_len;int ret; -_enter (",{%pISp}," , &srx->transport); +_enter (",{%pISp}," ,rxrpc_kernel_remote_addr (addr->peer));ASSERT (call->type !=NULL );ASSERT (call->type->name !=NULL );@@ -333,7 +334,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) }/* create a call */ - rxcall = rxrpc_kernel_begin_call(call->net->socket, srx, call->key, + rxcall = rxrpc_kernel_begin_call(call->net->socket, peer, call->key, (unsigned long)call, tx_total_len, call->max_lifespan,@@ -341,6 +342,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) (call->async ? afs_wake_up_async_call : afs_wake_up_call_waiter), + addr->service_id, call->upgrade, (call->intr ?RXRPC_PREINTERRUPTIBLE : RXRPC_UNINTERRUPTIBLE),@@ -461,7 +463,7 @@ static void afs_log_error(struct afs_call *call, s32 remote_abort) max = m +1 ;pr_notice ("kAFS: Peer reported %s failure on %s [%pISp]\n" , msg, call->type->name, - &call->alist->addrs[call->addr_ix].srx.transport); +rxrpc_kernel_remote_addr (call->alist->addrs[call->addr_ix].peer)); } }fs/afs/server.c +7
-34@@ -21,13 +21,12 @@ static void __afs_put_server(struct afs_net *, struct afs_server *);/* * Find a server by one of its addresses. */ -struct afs_server *afs_find_server (struct afs_net *net, -const struct sockaddr_rxrpc *srx) +struct afs_server *afs_find_server (struct afs_net *net,const struct rxrpc_peer *peer) {const struct afs_addr_list *alist;struct afs_server *server =NULL ;unsigned int i; -int seq =0 , diff; +int seq =0 ;rcu_read_lock ();@@ -37,37 +36,11 @@ struct afs_server *afs_find_server(struct afs_net *net, server =NULL ;read_seqbegin_or_lock (&net->fs_addr_lock, &seq); -if (srx->transport.family ==AF_INET6 ) { -const struct sockaddr_in6 *a = &srx->transport.sin6, *b; -hlist_for_each_entry_rcu (server, &net->fs_addresses6, addr6_link) { - alist =rcu_dereference (server->addresses); -for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) { - b = &alist->addrs[i].srx.transport.sin6; - diff = ((u16 __force )a->sin6_port - - (u16 __force )b->sin6_port); -if (diff ==0 ) - diff =memcmp (&a->sin6_addr, - &b->sin6_addr, -sizeof (struct in6_addr )); -if (diff ==0 ) - goto found; - } - } - }else { -const struct sockaddr_in *a = &srx->transport.sin, *b; -hlist_for_each_entry_rcu (server, &net->fs_addresses4, addr4_link) { - alist =rcu_dereference (server->addresses); -for (i =0 ; i < alist->nr_ipv4; i++) { - b = &alist->addrs[i].srx.transport.sin; - diff = ((u16 __force )a->sin_port - - (u16 __force )b->sin_port); -if (diff ==0 ) - diff = ((u32 __force )a->sin_addr.s_addr - - (u32 __force )b->sin_addr.s_addr); -if (diff ==0 ) - goto found; - } - } +hlist_for_each_entry_rcu (server, &net->fs_addresses6, addr6_link) { + alist =rcu_dereference (server->addresses); +for (i =0 ; i < alist->nr_addrs; i++) +if (alist->addrs[i].peer == peer) + goto found; } server =NULL ;fs/afs/vl_alias.c +3
-52@@ -32,55 +32,6 @@ static struct afs_volume *afs_sample_volume(struct afs_cell *cell, struct key *kreturn volume; } -/* -* Compare two addresses. -*/ -static int afs_compare_addrs (const struct sockaddr_rxrpc *srx_a, -const struct sockaddr_rxrpc *srx_b) -{ -short port_a, port_b; -int addr_a, addr_b, diff; - - diff = (short )srx_a->transport_type - (short )srx_b->transport_type; -if (diff) - goto out; - -switch (srx_a->transport_type) { -case AF_INET : { -const struct sockaddr_in *a = &srx_a->transport.sin; -const struct sockaddr_in *b = &srx_b->transport.sin; - addr_a =ntohl (a->sin_addr.s_addr); - addr_b =ntohl (b->sin_addr.s_addr); - diff = addr_a - addr_b; -if (diff ==0 ) { - port_a =ntohs (a->sin_port); - port_b =ntohs (b->sin_port); - diff = port_a - port_b; - } -break ; - } - -case AF_INET6 : { -const struct sockaddr_in6 *a = &srx_a->transport.sin6; -const struct sockaddr_in6 *b = &srx_b->transport.sin6; - diff =memcmp (&a->sin6_addr, &b->sin6_addr,16 ); -if (diff ==0 ) { - port_a =ntohs (a->sin6_port); - port_b =ntohs (b->sin6_port); - diff = port_a - port_b; - } -break ; - } - -default : -WARN_ON (1 ); - diff =1 ; - } - -out: -return diff; -} -/* * Compare the address lists of a pair of fileservers. */ @@ -94,9 +45,9 @@ static int afs_compare_fs_alists(const struct afs_server *server_a, lb =rcu_dereference (server_b->addresses);while (a < la->nr_addrs && b < lb->nr_addrs) { -const struct sockaddr_rxrpc *srx_a = &la->addrs[a].srx; -const struct sockaddr_rxrpc *srx_b = &lb->addrs[b].srx; -int diff =afs_compare_addrs (srx_a, srx_b); +unsigned long pa = (unsigned long )la->addrs[a].peer; +unsigned long pb = (unsigned long )lb->addrs[b].peer; +long diff = pa - pb;if (diff <0 ) { a++;fs/afs/vl_list.c +10
-5@@ -83,14 +83,15 @@ static u16 afs_extract_le16(const u8 **_b)/* * Build a VL server address list from a DNS queried server list. */ -static struct afs_addr_list *afs_extract_vl_addrs (const u8 **_b,const u8 *end, +static struct afs_addr_list *afs_extract_vl_addrs (struct afs_net *net, +const u8 **_b,const u8 *end,u8 nr_addrs,u16 port) {struct afs_addr_list *alist;const u8 *b = *_b;int ret = -EINVAL ; - alist =afs_alloc_addrlist (nr_addrs,VL_SERVICE , port); + alist =afs_alloc_addrlist (nr_addrs,VL_SERVICE );if (!alist)return ERR_PTR (-ENOMEM );if (nr_addrs ==0 )@@ -109,7 +110,9 @@ static struct afs_addr_list *afs_extract_vl_addrs(const u8 **_b, const u8 *end, goto error; }memcpy (x, b,4 ); -afs_merge_fs_addr4 (alist, x[0 ], port); + ret =afs_merge_fs_addr4 (net, alist, x[0 ], port); +if (ret <0 ) + goto error; b +=4 ;break ;@@ -119,7 +122,9 @@ static struct afs_addr_list *afs_extract_vl_addrs(const u8 **_b, const u8 *end, goto error; }memcpy (x, b,16 ); -afs_merge_fs_addr6 (alist, x, port); + ret =afs_merge_fs_addr6 (net, alist, x, port); +if (ret <0 ) + goto error; b +=16 ;break ;@@ -247,7 +252,7 @@ struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *cell,/* Extract the addresses - note that we can't skip this as we * have to advance the payload pointer. */ - addrs =afs_extract_vl_addrs (&b, end, bs.nr_addrs, bs.port); + addrs =afs_extract_vl_addrs (cell->net, &b, end, bs.nr_addrs, bs.port);if (IS_ERR (addrs)) { ret =PTR_ERR (addrs); goto error_2;fs/afs/vl_probe.c +7
-5@@ -48,6 +48,7 @@ void afs_vlserver_probe_result(struct afs_call *call) {struct afs_addr_list *alist = call->alist;struct afs_vlserver *server = call->vlserver; +struct afs_address *addr = &alist->addrs[call->addr_ix];unsigned int server_index = call->server_index;unsigned int rtt_us =0 ;unsigned int index = call->addr_ix;@@ -106,16 +107,16 @@ void afs_vlserver_probe_result(struct afs_call *call)if (call->service_id ==YFS_VL_SERVICE ) { server->probe.flags |=AFS_VLSERVER_PROBE_IS_YFS ;set_bit (AFS_VLSERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx.srx_service = call->service_id; + addr->service_id = call->service_id; }else { server->probe.flags |=AFS_VLSERVER_PROBE_NOT_YFS ;if (!(server->probe.flags &AFS_VLSERVER_PROBE_IS_YFS )) {clear_bit (AFS_VLSERVER_FL_IS_YFS , &server->flags); - alist->addrs[index].srx.srx_service = call->service_id; + addr->service_id = call->service_id; } } -rxrpc_kernel_get_srtt (call->net->socket, call->rxcall, &rtt_us); + rtt_us =rxrpc_kernel_get_srtt (addr->peer);if (rtt_us < server->probe.rtt) { server->probe.rtt = rtt_us; server->rtt = rtt_us;@@ -130,8 +131,9 @@ void afs_vlserver_probe_result(struct afs_call *call) out:spin_unlock (&server->probe_lock); -_debug ("probe [%u][%u] %pISpc rtt=%u ret=%d" , - server_index, index, &alist->addrs[index].srx.transport, rtt_us, ret); +_debug ("probe [%u][%u] %pISpc rtt=%d ret=%d" , + server_index, index,rxrpc_kernel_remote_addr (addr->peer), + rtt_us, ret);afs_done_one_vl_probe (server, have_result); }fs/afs/vl_rotate.c +3
-3@@ -86,7 +86,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)struct afs_addr_list *alist;struct afs_vlserver *vlserver;struct afs_error e; -u32 rtt; +unsigned int rtt;int error = vc->ac.error, i; _enter("%lx[%d],%lx[%d],%d,%d",@@ -188,7 +188,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc) goto selected_server; vc->index =-1 ; - rtt =U32_MAX ; + rtt =UINT_MAX ;for (i =0 ; i < vc->server_list->nr_servers; i++) {struct afs_vlserver *s = vc->server_list->servers[i].server;@@ -243,7 +243,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)_debug ("VL address %d/%d" , vc->ac.index, vc->ac.alist->nr_addrs); -_leave (" = t %pISpc" , &vc->ac.alist->addrs[vc->ac.index].srx.transport); +_leave (" = t %pISpc" ,rxrpc_kernel_remote_addr (vc->ac.alist->addrs[vc->ac.index].peer));return true; next_server:fs/afs/vlclient.c +15
-7@@ -208,7 +208,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call) count =ntohl (*bp); nentries =min (nentries, count); - alist =afs_alloc_addrlist (nentries,FS_SERVICE ,AFS_FS_PORT ); + alist =afs_alloc_addrlist (nentries,FS_SERVICE );if (!alist)return -ENOMEM ; alist->version = uniquifier;@@ -230,9 +230,13 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call) alist = call->ret_alist; bp = call->buffer; count =min (call->count,4U ); -for (i =0 ; i < count; i++) -if (alist->nr_addrs < call->count2) -afs_merge_fs_addr4 (alist, *bp++,AFS_FS_PORT ); +for (i =0 ; i < count; i++) { +if (alist->nr_addrs < call->count2) { + ret =afs_merge_fs_addr4 (call->net, alist, *bp++,AFS_FS_PORT ); +if (ret <0 ) +return ret; + } + } call->count -= count;if (call->count >0 )@@ -450,7 +454,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)if (call->count >YFS_MAXENDPOINTS )return afs_protocol_error (call, afs_eproto_yvl_fsendpt_num); - alist =afs_alloc_addrlist (call->count,FS_SERVICE ,AFS_FS_PORT ); + alist =afs_alloc_addrlist (call->count,FS_SERVICE );if (!alist)return -ENOMEM ; alist->version = uniquifier;@@ -488,14 +492,18 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)if (ntohl (bp[0 ]) !=sizeof (__be32) *2 )return afs_protocol_error ( call, afs_eproto_yvl_fsendpt4_len); -afs_merge_fs_addr4 (alist, bp[1 ],ntohl (bp[2 ])); + ret =afs_merge_fs_addr4 (call->net, alist, bp[1 ],ntohl (bp[2 ])); +if (ret <0 ) +return ret; bp +=3 ;break ;case YFS_ENDPOINT_IPV6 :if (ntohl (bp[0 ]) !=sizeof (__be32) *5 )return afs_protocol_error ( call, afs_eproto_yvl_fsendpt6_len); -afs_merge_fs_addr6 (alist, bp +1 ,ntohl (bp[5 ])); + ret =afs_merge_fs_addr6 (call->net, alist, bp +1 ,ntohl (bp[5 ])); +if (ret <0 ) +return ret; bp +=6 ;break ;default :include/net/af_rxrpc.h +11
-4@@ -15,6 +15,7 @@ struct key;struct sock ;struct socket ;struct rxrpc_call ; +struct rxrpc_peer ;enum rxrpc_abort_reason ;enum rxrpc_interruptibility {@@ -41,13 +42,14 @@ void rxrpc_kernel_new_call_notification(struct socket *, rxrpc_notify_new_call_t, rxrpc_discard_new_call_t);struct rxrpc_call *rxrpc_kernel_begin_call (struct socket *sock, -struct sockaddr_rxrpc *srx, +struct rxrpc_peer *peer,struct key *key,unsigned long user_call_ID,s64 tx_total_len,u32 hard_timeout,gfp_t gfp,rxrpc_notify_rx_t notify_rx, +u16 service_id,bool upgrade,enum rxrpc_interruptibility interruptibility,unsigned int debug_id);@@ -60,9 +62,14 @@ bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *, u32, int, enum rxrpc_abort_reason);void rxrpc_kernel_shutdown_call (struct socket *sock,struct rxrpc_call *call);void rxrpc_kernel_put_call (struct socket *sock,struct rxrpc_call *call); -void rxrpc_kernel_get_peer (struct socket *,struct rxrpc_call *, -struct sockaddr_rxrpc *); -bool rxrpc_kernel_get_srtt (struct socket *,struct rxrpc_call *,u32 *); +struct rxrpc_peer *rxrpc_kernel_lookup_peer (struct socket *sock, +struct sockaddr_rxrpc *srx,gfp_t gfp); +void rxrpc_kernel_put_peer (struct rxrpc_peer *peer); +struct rxrpc_peer *rxrpc_kernel_get_peer (struct rxrpc_peer *peer); +struct rxrpc_peer *rxrpc_kernel_get_call_peer (struct socket *sock,struct rxrpc_call *call); +const struct sockaddr_rxrpc *rxrpc_kernel_remote_srx (const struct rxrpc_peer *peer); +const struct sockaddr *rxrpc_kernel_remote_addr (const struct rxrpc_peer *peer); +unsigned int rxrpc_kernel_get_srtt (const struct rxrpc_peer *);int rxrpc_kernel_charge_accept (struct socket *,rxrpc_notify_rx_t ,rxrpc_user_attach_call_t ,unsigned long ,gfp_t ,unsigned int );include/trace/events/rxrpc.h +3
-0@@ -178,7 +178,9 @@#define rxrpc_peer_traces \ EM(rxrpc_peer_free, "FREE ") \ EM(rxrpc_peer_get_accept, "GET accept ") \ + EM(rxrpc_peer_get_application, "GET app ") \ EM(rxrpc_peer_get_bundle, "GET bundle ") \ + EM(rxrpc_peer_get_call, "GET call ") \ EM(rxrpc_peer_get_client_conn, "GET cln-conn") \ EM(rxrpc_peer_get_input, "GET input ") \ EM(rxrpc_peer_get_input_error, "GET inpt-err") \@@ -187,6 +189,7 @@ EM(rxrpc_peer_get_service_conn, "GET srv-conn") \ EM(rxrpc_peer_new_client, "NEW client ") \ EM(rxrpc_peer_new_prealloc, "NEW prealloc") \ + EM(rxrpc_peer_put_application, "PUT app ") \ EM(rxrpc_peer_put_bundle, "PUT bundle ") \ EM(rxrpc_peer_put_call, "PUT call ") \EM (rxrpc_peer_put_conn,"PUT conn " ) \net/rxrpc/af_rxrpc.c +54
-8@@ -258,16 +258,62 @@ static int rxrpc_listen(struct socket *sock, int backlog)return ret; } +/** +* rxrpc_kernel_lookup_peer - Obtain remote transport endpoint for an address +* @sock: The socket through which it will be accessed +* @srx: The network address +* @gfp: Allocation flags +* +* Lookup or create a remote transport endpoint record for the specified +* address and return it with a ref held. +*/ +struct rxrpc_peer *rxrpc_kernel_lookup_peer (struct socket *sock, +struct sockaddr_rxrpc *srx,gfp_t gfp) +{ +struct rxrpc_sock *rx =rxrpc_sk (sock->sk); +int ret; + + ret =rxrpc_validate_address (rx, srx,sizeof (*srx)); +if (ret <0 ) +return ERR_PTR (ret); + +return rxrpc_lookup_peer (rx->local, srx, gfp); +} +EXPORT_SYMBOL (rxrpc_kernel_lookup_peer); + +/** +* rxrpc_kernel_get_peer - Get a reference on a peer +* @peer: The peer to get a reference on. +* +* Get a record for the remote peer in a call. +*/ +struct rxrpc_peer *rxrpc_kernel_get_peer (struct rxrpc_peer *peer) +{ +return peer ?rxrpc_get_peer (peer, rxrpc_peer_get_application) :NULL ; +} +EXPORT_SYMBOL (rxrpc_kernel_get_peer); + +/** +* rxrpc_kernel_put_peer - Allow a kernel app to drop a peer reference +* @peer: The peer to drop a ref on +*/ +void rxrpc_kernel_put_peer (struct rxrpc_peer *peer) +{ +rxrpc_put_peer (peer, rxrpc_peer_put_application); +} +EXPORT_SYMBOL (rxrpc_kernel_put_peer); +/** * rxrpc_kernel_begin_call - Allow a kernel service to begin a call * @sock: The socket on which to make the call -* @srx: The address of the peer to contact +* @peer: The peer to contact * @key: The security context to use (defaults to socket setting) * @user_call_ID: The ID to use * @tx_total_len: Total length of data to transmit during the call (or -1) * @hard_timeout: The maximum lifespan of the call in sec * @gfp: The allocation constraints * @notify_rx: Where to send notifications instead of socket queue +* @service_id: The ID of the service to contact * @upgrade: Request service upgrade for call * @interruptibility: The call is interruptible, or can be canceled. * @debug_id: The debug ID for tracing to be assigned to the call @@ -280,13 +326,14 @@ static int rxrpc_listen(struct socket *sock, int backlog)* supplying @srx and @key. */ struct rxrpc_call *rxrpc_kernel_begin_call (struct socket *sock, -struct sockaddr_rxrpc *srx, +struct rxrpc_peer *peer,struct key *key,unsigned long user_call_ID,s64 tx_total_len,u32 hard_timeout,gfp_t gfp,rxrpc_notify_rx_t notify_rx, +u16 service_id,bool upgrade,enum rxrpc_interruptibility interruptibility,unsigned int debug_id)@@ -295,13 +342,11 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,struct rxrpc_call_params p;struct rxrpc_call *call;struct rxrpc_sock *rx =rxrpc_sk (sock->sk); -int ret;_enter (",,%x,%lx" ,key_serial (key), user_call_ID); - ret =rxrpc_validate_address (rx, srx,sizeof (*srx)); -if (ret <0 ) -return ERR_PTR (ret); +if (WARN_ON_ONCE (peer->local != rx->local)) +return ERR_PTR (-EIO );lock_sock (&rx->sk);@@ -319,12 +364,13 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,memset (&cp,0 ,sizeof (cp)); cp.local = rx->local; + cp.peer = peer; cp.key = key; cp.security_level = rx->min_sec_level; cp.exclusive = false; cp.upgrade = upgrade; - cp.service_id = srx->srx_service; - call =rxrpc_new_client_call (rx, &cp, srx, &p, gfp, debug_id); + cp.service_id = service_id; + call =rxrpc_new_client_call (rx, &cp, &p, gfp, debug_id);/* The socket has been unlocked. */ if (!IS_ERR (call)) { call->notify_rx = notify_rx;net/rxrpc/ar-internal.h +1
-1@@ -364,6 +364,7 @@ struct rxrpc_conn_proto {struct rxrpc_conn_parameters {struct rxrpc_local *local;/* Representation of local endpoint */ +struct rxrpc_peer *peer;/* Representation of remote endpoint */ struct key *key;/* Security details */ bool exclusive;/* T if conn is exclusive */ bool upgrade;/* T if service ID can be upgraded */ @@ -867,7 +868,6 @@ struct rxrpc_call *rxrpc_find_call_by_user_ID(struct rxrpc_sock *, unsigned longstruct rxrpc_call *rxrpc_alloc_call (struct rxrpc_sock *,gfp_t ,unsigned int );struct rxrpc_call *rxrpc_new_client_call (struct rxrpc_sock *,struct rxrpc_conn_parameters *, -struct sockaddr_rxrpc *,struct rxrpc_call_params *,gfp_t ,unsigned int );void rxrpc_start_call_timer (struct rxrpc_call *call);net/rxrpc/call_object.c +9
-8@@ -193,7 +193,6 @@ struct rxrpc_call *rxrpc_alloc_call(struct rxrpc_sock *rx, gfp_t gfp,* Allocate a new client call. */ static struct rxrpc_call *rxrpc_alloc_client_call(struct rxrpc_sock *rx, - struct sockaddr_rxrpc *srx, struct rxrpc_conn_parameters *cp, struct rxrpc_call_params *p, gfp_t gfp,@@ -211,10 +210,12 @@ static struct rxrpc_call *rxrpc_alloc_client_call(struct rxrpc_sock *rx, now =ktime_get_real (); call->acks_latest_ts = now; call->cong_tstamp = now; - call->dest_srx = *srx; + call->dest_srx = cp->peer->srx; + call->dest_srx.srx_service = cp->service_id; call->interruptibility = p->interruptibility; call->tx_total_len = p->tx_total_len; call->key =key_get (cp->key); + call->peer =rxrpc_get_peer (cp->peer, rxrpc_peer_get_call); call->local =rxrpc_get_local (cp->local, rxrpc_local_get_call); call->security_level = cp->security_level;if (p->kernel)@@ -306,10 +307,6 @@ static int rxrpc_connect_call(struct rxrpc_call *call, gfp_t gfp)_enter ("{%d,%lx}," , call->debug_id, call->user_call_ID); - call->peer =rxrpc_lookup_peer (local, &call->dest_srx, gfp); -if (!call->peer) - goto error; - ret =rxrpc_look_up_bundle (call, gfp);if (ret <0 ) goto error;@@ -334,7 +331,6 @@ static int rxrpc_connect_call(struct rxrpc_call *call, gfp_t gfp)*/ struct rxrpc_call *rxrpc_new_client_call (struct rxrpc_sock *rx,struct rxrpc_conn_parameters *cp, -struct sockaddr_rxrpc *srx,struct rxrpc_call_params *p,gfp_t gfp,unsigned int debug_id)@@ -349,13 +345,18 @@ struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,_enter ("%p,%lx" , rx, p->user_call_ID); +if (WARN_ON_ONCE (!cp->peer)) { +release_sock (&rx->sk); +return ERR_PTR (-EIO ); + } + limiter =rxrpc_get_call_slot (p, gfp);if (!limiter) {release_sock (&rx->sk);return ERR_PTR (-ERESTARTSYS ); } - call =rxrpc_alloc_client_call (rx, srx, cp, p, gfp, debug_id); + call =rxrpc_alloc_client_call (rx, cp, p, gfp, debug_id);if (IS_ERR (call)) {release_sock (&rx->sk);up (limiter);net/rxrpc/peer_object.c +35
-21@@ -22,6 +22,8 @@#include <net/ip6_route.h> #include "ar-internal.h" +static const struct sockaddr_rxrpc rxrpc_null_addr; +/* * Hash a peer key. */ @@ -457,39 +459,51 @@ void rxrpc_destroy_all_peers(struct rxrpc_net *rxnet) }/** -* rxrpc_kernel_get_peer - Get the peer address of a call +* rxrpc_kernel_get_call_peer - Get the peer address of a call * @sock: The socket on which the call is in progress. * @call: The call to query -* @_srx: Where to place the result * -* Get the address of the remote peer in a call. +* Get a record for the remote peer in a call. */ -void rxrpc_kernel_get_peer (struct socket *sock,struct rxrpc_call *call, -struct sockaddr_rxrpc *_srx) +struct rxrpc_peer *rxrpc_kernel_get_call_peer (struct socket *sock,struct rxrpc_call *call) { - *_srx = call->peer->srx; +return call->peer; } -EXPORT_SYMBOL (rxrpc_kernel_get_peer); +EXPORT_SYMBOL (rxrpc_kernel_get_call_peer);/** * rxrpc_kernel_get_srtt - Get a call's peer smoothed RTT -* @sock: The socket on which the call is in progress. -* @call: The call to query -* @_srtt: Where to store the SRTT value. +* @peer: The peer to query * -* Get the call's peer smoothed RTT in uS. +* Get the call's peer smoothed RTT in uS or UINT_MAX if we have no samples. */ -bool rxrpc_kernel_get_srtt (struct socket *sock,struct rxrpc_call *call, -u32 *_srtt) +unsigned int rxrpc_kernel_get_srtt (const struct rxrpc_peer *peer) { -struct rxrpc_peer *peer = call->peer; +return peer->rtt_count >0 ? peer->srtt_us >>3 :UINT_MAX ; +} +EXPORT_SYMBOL (rxrpc_kernel_get_srtt); -if (peer->rtt_count ==0 ) { - *_srtt =1000000 ;/* 1S */ -return false; - } +/** +* rxrpc_kernel_remote_srx - Get the address of a peer +* @peer: The peer to query +* +* Get a pointer to the address from a peer record. The caller is responsible +* for making sure that the address is not deallocated. +*/ +const struct sockaddr_rxrpc *rxrpc_kernel_remote_srx (const struct rxrpc_peer *peer) +{ +return peer ? &peer->srx : &rxrpc_null_addr; +} - *_srtt = call->peer->srtt_us >>3 ; -return true; +/** +* rxrpc_kernel_remote_addr - Get the peer transport address of a call +* @peer: The peer to query +* +* Get a pointer to the transport address from a peer record. The caller is +* responsible for making sure that the address is not deallocated. +*/ +const struct sockaddr *rxrpc_kernel_remote_addr (const struct rxrpc_peer *peer) +{ +return (const struct sockaddr *) + (peer ? &peer->srx.transport : &rxrpc_null_addr.transport); } -EXPORT_SYMBOL (rxrpc_kernel_get_srtt);net/rxrpc/sendmsg.c +8
-0@@ -572,6 +572,7 @@ rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, __acquires(&call->user_mutex) {struct rxrpc_conn_parameters cp; +struct rxrpc_peer *peer;struct rxrpc_call *call;struct key *key;@@ -584,21 +585,29 @@ rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg,return ERR_PTR (-EDESTADDRREQ ); } + peer =rxrpc_lookup_peer (rx->local, srx,GFP_KERNEL ); +if (!peer) { +release_sock (&rx->sk); +return ERR_PTR (-ENOMEM ); + } + key = rx->key;if (key && !rx->key->payload.data[0 ]) key =NULL ;memset (&cp,0 ,sizeof (cp)); cp.local = rx->local; + cp.peer = peer; cp.key = rx->key; cp.security_level = rx->min_sec_level; cp.exclusive = rx->exclusive | p->exclusive; cp.upgrade = p->upgrade;
net/rxrpc/sendmsg.c rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, · line 613
Quoted 10 lines
net/rxrpc/sendmsg.c +2
-1cp.service_id = srx->srx_service; - call =rxrpc_new_client_call (rx, &cp, srx, &p->call,GFP_KERNEL , + call =rxrpc_new_client_call (rx, &cp, &p->call,GFP_KERNEL ,atomic_inc_return (&rxrpc_debug_id));/* The socket is now unlocked */ +rxrpc_put_peer (peer, rxrpc_peer_put_application);_leave (" = %p\n" , call);return call; }
rxrpc_kernel_remote_srx and rxrpc_kernel_remote_addr need an EXPORT_SYMBOL to be available to fs/afs when built as a module.
Marc
David Howells
maintainerPATCH 11/41 afs: Don't skip server addresses for which we didn't get an RTT reading
In reply to David HowellsIn the rotation algorithms for iterating over volume location servers and file servers, don't skip servers from which we got a valid response to a probe (either a reply DATA packet or an ABORT) even if we didn't manage to get an RTT reading.
--- fs/afs/rotate.c | 2 +- fs/afs/vl_rotate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/afs/rotate.c +1 -1
@@ -426,7 +426,7 @@ bool afs_select_fileserver(struct afs_operation *op)if (!test_bit (i, &op->untried) || !test_bit (AFS_SERVER_FL_RESPONDING , &s->flags))continue ; -if (s->probe.rtt < rtt) { +if (s->probe.rtt <= rtt) { op->index = i; rtt = s->probe.rtt; }
fs/afs/vl_rotate.c +1 -1
@@ -195,7 +195,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)if (!test_bit (i, &vc->untried) || !test_bit (AFS_VLSERVER_FL_RESPONDING , &s->flags))continue ; -if (s->probe.rtt < rtt) { +if (s->probe.rtt <= rtt) { vc->index = i; rtt = s->probe.rtt; }
David Howells
maintainerPATCH 12/41 afs: Rename addr_list::failed to probe_failed
In reply to David HowellsRename the failed member of struct addr_list to probe_failed as it's specifically related to probe failures.
--- fs/afs/addr_list.c | 2 +- fs/afs/fs_probe.c | 6 +++--- fs/afs/internal.h | 2 +- fs/afs/proc.c | 2 +- fs/afs/rotate.c | 2 +- fs/afs/vl_probe.c | 4 ++-- fs/afs/vl_rotate.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-)
fs/afs/addr_list.c +1 -1
@@ -367,7 +367,7 @@ bool afs_iterate_addresses(struct afs_addr_cursor *ac)return false; set = ac->alist->responded; - failed = ac->alist->failed; + failed = ac->alist->probe_failed;_enter ("%lx-%lx-%lx,%d" , set, failed, ac->tried, ac->index); ac->nr_iterations++;
fs/afs/fs_probe.c +3 -3
@@ -88,7 +88,7 @@ static void afs_fs_probe_not_done(struct afs_net *net,if (server->probe.error ==0 ) server->probe.error = -ENOMEM ; -set_bit (index, &alist->failed); +set_bit (index, &alist->probe_failed);spin_unlock (&server->probe_lock);return afs_done_one_fs_probe (net, server);
@@ -138,7 +138,7 @@ void afs_fileserver_probe_result(struct afs_call *call)case -ETIME :default :clear_bit (index, &alist->responded); -set_bit (index, &alist->failed); +set_bit (index, &alist->probe_failed); if (!server->probe.responded && (server->probe.error == 0 || server->probe.error == -ETIMEDOUT ||
@@ -149,7 +149,7 @@ void afs_fileserver_probe_result(struct afs_call *call) } responded: -clear_bit (index, &alist->failed); +clear_bit (index, &alist->probe_failed);if (call->service_id ==YFS_FS_SERVICE ) { server->probe.is_yfs = true;
fs/afs/internal.h +1 -1
@@ -90,7 +90,7 @@ struct afs_addr_list {unsigned char nr_ipv4;/* Number of IPv4 addresses */ enum dns_record_source source:8; enum dns_lookup_status status:8; -unsigned long failed;/* Mask of addrs that failed locally/ICMP */ +unsigned long probe_failed;/* Mask of addrs that failed locally/ICMP */ unsigned long responded;/* Mask of addrs that responded */ struct afs_address addrs[] __counted_by(max_addrs);#define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8))
fs/afs/proc.c +1 -1
@@ -396,7 +396,7 @@ static int afs_proc_servers_show(struct seq_file *m, void *v) (int )(jiffies - server->probed_at) /HZ , atomic_read(&server->probe_outstanding));seq_printf (m," - ALIST v=%u rsp=%lx f=%lx\n" , - alist->version, alist->responded, alist->failed); + alist->version, alist->responded, alist->probe_failed);for (i =0 ; i < alist->nr_addrs; i++) seq_printf(m, " [%x] %pISpc%s rtt=%d\n", i, rxrpc_kernel_remote_addr(alist->addrs[i].peer),
fs/afs/rotate.c +1 -1
@@ -582,7 +582,7 @@ void afs_dump_edestaddrreq(const struct afs_operation *op) a->nr_ipv4, a->nr_addrs, a->max_addrs, a->preferred);pr_notice ("FC: - R=%lx F=%lx\n" , - a->responded, a->failed); + a->responded, a->probe_failed);if (a == op->ac.alist)pr_notice ("FC: - current\n" ); }
fs/afs/vl_probe.c +2 -2
@@ -90,7 +90,7 @@ void afs_vlserver_probe_result(struct afs_call *call)case -ETIME :default :clear_bit (index, &alist->responded); -set_bit (index, &alist->failed); +set_bit (index, &alist->probe_failed); if (!(server->probe.flags & AFS_VLSERVER_PROBE_RESPONDED) && (server->probe.error == 0 || server->probe.error == -ETIMEDOUT ||
@@ -102,7 +102,7 @@ void afs_vlserver_probe_result(struct afs_call *call) responded:set_bit (index, &alist->responded); -clear_bit (index, &alist->failed); +clear_bit (index, &alist->probe_failed);if (call->service_id ==YFS_VL_SERVICE ) { server->probe.flags |=AFS_VLSERVER_PROBE_IS_YFS ;
fs/afs/vl_rotate.c +1 -1
@@ -312,7 +312,7 @@ static void afs_vl_dump_edestaddrreq(const struct afs_vl_cursor *vc) a->nr_ipv4, a->nr_addrs, a->max_addrs, a->preferred);pr_notice ("VC: - R=%lx F=%lx\n" , - a->responded, a->failed); + a->responded, a->probe_failed);if (a == vc->ac.alist)pr_notice ("VC: - current\n" ); }
David Howells
maintainerPATCH 13/41 afs: Handle the VIO abort explicitly
In reply to David HowellsWhen processing the result of a call, handle the VIO abort specifically rather than leaving it to a default case. Rather than erroring out unconditionally, see if there's another server if the volume has more than one server available, otherwise return -EREMOTEIO.
--- fs/afs/rotate.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/afs/rotate.c +6 -0
@@ -329,6 +329,12 @@ bool afs_select_fileserver(struct afs_operation *op) goto restart_from_beginning; +case VIO : + op->error = -EREMOTEIO ; +if (op->volume->type !=AFSVL_RWVOL ) + goto next_server; + goto failed; +case VDISKFULL :case UAENOSPC :/* The partition is full. Only applies to RWVOLs.
Re: [PATCH 13/41] afs: Handle the VIO abort explicitly
Quoted 11 lines · David Howells
When processing the result of a call, handle the VIO abort specifically rather than leaving it to a default case. Rather than erroring out unconditionally, see if there's another server if the volume has more than one server available, otherwise return
-EREMOTEIO.Signed-off-by David Howells <[email protected]>cc Marc Dionne <[email protected]>--- fs/afs/rotate.c | 6 ++++++ 1 file changed, 6 insertions(+)
OpenAFS fileservers can return VIO (112) either during an attempt to load a vnode or to store a vnode. However, most IBM AFS derived cache managers do not explicitly handle VIO errors and pass them to the vfs to be interpreted as a local operating system error. For Linux that means EHOSTDOWN. Therefore, AuriStorFS fileservers return UAEIO instead.
Please modify this patch to handle UAEIO the same as VIO.
Thank you.
Jeffrey Altman
David Howells
maintainerPATCH 14/41 afs: Use op->nr_iterations=-1 to indicate to begin fileserver iteration
In reply to David HowellsSet op->nr_iterations to -1 to indicate that we need to begin fileserver iteration rather than setting error to SHRT_MAX. This makes it easier to eliminate the address cursor.
--- fs/afs/fs_operation.c | 2 +- fs/afs/internal.h | 2 +- fs/afs/rotate.c | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-)
fs/afs/fs_operation.c +1 -1
@@ -41,7 +41,7 @@ struct afs_operation *afs_alloc_operation(struct key *key, struct afs_volume *vo op->cb_v_break = volume->cb_v_break; op->debug_id =atomic_inc_return (&afs_operation_debug_counter); op->error = -EDESTADDRREQ ; - op->ac.error =SHRT_MAX ; + op->nr_iterations =-1 ;_leave (" = [op=%08x]" , op->debug_id);return op;
fs/afs/internal.h +1 -1
@@ -858,7 +858,7 @@ struct afs_operation {struct afs_call *call;unsigned long untried;/* Bitmask of untried servers */ short index;/* Current server */ -unsigned short nr_iterations;/* Number of server iterations */ +short nr_iterations;/* Number of server iterations */ unsigned int flags;#define AFS_OPERATION_STOP 0x0001/* Set to cease iteration */
fs/afs/rotate.c +6 -5
@@ -116,7 +116,10 @@ bool afs_select_fileserver(struct afs_operation *op)unsigned int rtt;int error = op->ac.error, i; -_enter ("%lx[%d],%lx[%d],%d,%d" , + op->nr_iterations++; + +_enter ("OP=%x+%x,%llx,%lx[%d],%lx[%d],%d,%d" , + op->debug_id, op->nr_iterations, op->volume->vid, op->untried, op->index, op->ac.tried, op->ac.index, error, op->ac.abort_code);
@@ -126,13 +129,11 @@ bool afs_select_fileserver(struct afs_operation *op)return false; } - op->nr_iterations++; +if (op->nr_iterations ==0 ) + goto start;/* Evaluate the result of the previous operation, if there was one. */ switch (error) { -case SHRT_MAX : - goto start; -case 0 :default :/* Success or local failure. Stop. */
David Howells
maintainerPATCH 15/41 afs: Return ENOENT if no cell DNS record can be found
In reply to David HowellsMake AFS return error ENOENT if no cell SRV or AFSDB DNS record (or cellservdb config file record) can be found rather than returning EDESTADDRREQ.
Also add cell name lookup info to the cursor dump.
--- fs/afs/vl_rotate.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/afs/vl_rotate.c +10 -0
@@ -58,6 +58,12 @@ static bool afs_start_vl_iteration(struct afs_vl_cursor *vc) }/* Status load is ordered after lookup counter load */ +if (cell->dns_status ==DNS_LOOKUP_GOT_NOT_FOUND ) { +pr_warn ("No record of cell %s\n" , cell->name); + vc->error = -ENOENT ; +return false; + } +if (cell->dns_source ==DNS_RECORD_UNAVAILABLE ) { vc->error = -EDESTADDRREQ ;return false;
@@ -285,6 +291,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)*/ static void afs_vl_dump_edestaddrreq (const struct afs_vl_cursor *vc) { +struct afs_cell *cell = vc->cell;static int count;int i;
@@ -294,6 +301,9 @@ static void afs_vl_dump_edestaddrreq(const struct afs_vl_cursor *vc)rcu_read_lock ();pr_notice ("EDESTADDR occurred\n" ); +pr_notice ("CELL: %s err=%d\n" , cell->name, cell->error); +pr_notice ("DNS: src=%u st=%u lc=%x\n" , + cell->dns_source, cell->dns_status, cell->dns_lookup_count);pr_notice ("VC: ut=%lx ix=%u ni=%hu fl=%hx err=%hd\n" , vc->untried, vc->index, vc->nr_iterations, vc->flags, vc->error);
David Howells
maintainerPATCH 16/41 afs: Wrap most op->error accesses with inline funcs
In reply to David HowellsWrap most op->error accesses with inline funcs which will make it easier for a subsequent patch to replace op->error with something else. Two functions are added to this end:
(1) afs_op_error() - Get the error code.
(2) afs_op_set_error() - Set the error code.
--- fs/afs/dir.c | 38 +++++++++++++++--------------- fs/afs/file.c | 4 ++-- fs/afs/fs_operation.c | 21 ++++++++++------- fs/afs/fsclient.c | 2 +- fs/afs/inode.c | 2 +- fs/afs/internal.h | 20 ++++++++++++---- fs/afs/rotate.c | 55 ++++++++++++++++++++++++------------------- fs/afs/server.c | 6 ++--- fs/afs/write.c | 6 ++--- 9 files changed, 87 insertions(+), 67 deletions(-)
fs/afs/dir.c +19 -19
@@ -878,14 +878,14 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,* lookups contained therein are stored in the reply without aborting * the whole operation. */ - op->error = -ENOTSUPP ; +afs_op_set_error (op, -ENOTSUPP );if (!cookie->one_only) { op->ops = &afs_inline_bulk_status_operation;afs_begin_vnode_operation (op);afs_wait_for_operation (op); } -if (op->error == -ENOTSUPP ) { +if (afs_op_error (op) == -ENOTSUPP ) {/* We could try FS.BulkStatus next, but this aborts the entire * op if any of the lookups fails - so, for the moment, revert * to FS.FetchStatus for op->file[1].
@@ -895,10 +895,10 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,afs_begin_vnode_operation (op);afs_wait_for_operation (op); } - inode =ERR_PTR (op->error); + inode =ERR_PTR (afs_op_error (op)); out_op: -if (op->error ==0 ) { +if (!afs_op_error (op)) { inode = &op->file[1 ].vnode->netfs.inode; op->file[1 ].vnode =NULL ; }
@@ -1273,7 +1273,7 @@ static void afs_vnode_new_inode(struct afs_operation *op)_enter ("" ); - ASSERTCMP(op->error, ==, 0); + ASSERTCMP(afs_op_error(op), ==, 0); inode =afs_iget (op, vp);if (IS_ERR (inode)) {
@@ -1286,7 +1286,7 @@ static void afs_vnode_new_inode(struct afs_operation *op) vnode =AFS_FS_I (inode);set_bit (AFS_VNODE_NEW_CONTENT , &vnode->flags); -if (!op->error) +if (!afs_op_error (op))afs_cache_permit (vnode, op->key, vnode->cb_break, &vp->scb);d_instantiate (op->dentry, inode); }
@@ -1320,7 +1320,7 @@ static void afs_create_put(struct afs_operation *op) {_enter ("op=%08x" , op->debug_id); -if (op->error) +if (afs_op_error (op))d_drop (op->dentry); }
@@ -1480,7 +1480,7 @@ static void afs_dir_remove_link(struct afs_operation *op)struct dentry *dentry = op->dentry;int ret; -if (op->error !=0 || +if (afs_op_error (op) || (op->file[1 ].scb.have_status && op->file[1 ].scb.have_error))return ;if (d_really_is_positive (dentry))
@@ -1504,10 +1504,10 @@ static void afs_dir_remove_link(struct afs_operation *op) ret =afs_validate (vnode, op->key);if (ret != -ESTALE ) - op->error = ret; +afs_op_set_error (op, ret); } -_debug ("nlink %d [val %d]" , vnode->netfs.inode.i_nlink, op->error); +_debug ("nlink %d [val %d]" , vnode->netfs.inode.i_nlink,afs_op_error (op)); }static void afs_unlink_success (struct afs_operation *op)
@@ -1538,7 +1538,7 @@ static void afs_unlink_edit_dir(struct afs_operation *op)static void afs_unlink_put (struct afs_operation *op) {_enter ("op=%08x" , op->debug_id); -if (op->unlink.need_rehash && op->error <0 && op->error != -ENOENT ) +if (op->unlink.need_rehash &&afs_op_error (op) <0 &&afs_op_error (op) != -ENOENT )d_rehash (op->dentry); }
@@ -1579,7 +1579,7 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)/* Try to make sure we have a callback promise on the victim. */ ret =afs_validate (vnode, op->key);if (ret <0 ) { - op->error = ret; +afs_op_set_error (op, ret); goto error; }
@@ -1588,7 +1588,7 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)spin_unlock (&dentry->d_lock);/* Start asynchronous writeout of the inode */ write_inode_now (d_inode (dentry),0 ); - op->error =afs_sillyrename (dvnode, vnode, dentry, op->key); +afs_op_set_error (op,afs_sillyrename (dvnode, vnode, dentry, op->key)); goto error; }if (!d_unhashed (dentry)) {
@@ -1609,7 +1609,7 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)/* If there was a conflict with a third party, check the status of the * unlinked vnode. */ -if (op->error ==0 && (op->flags &AFS_OPERATION_DIR_CONFLICT )) { +if (afs_op_error (op) ==0 && (op->flags &AFS_OPERATION_DIR_CONFLICT )) { op->file[1 ].update_ctime = false; op->fetch_status.which =1 ; op->ops = &afs_fetch_status_operation;
@@ -1691,7 +1691,7 @@ static void afs_link_success(struct afs_operation *op)static void afs_link_put (struct afs_operation *op) {_enter ("op=%08x" , op->debug_id); -if (op->error) +if (afs_op_error (op))d_drop (op->dentry); }
@@ -1889,7 +1889,7 @@ static void afs_rename_put(struct afs_operation *op)if (op->rename.rehash)d_rehash (op->rename.rehash);dput (op->rename.tmp); -if (op->error) +if (afs_op_error (op))d_rehash (op->dentry); }
@@ -1934,7 +1934,7 @@ static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,return PTR_ERR (op); ret =afs_validate (vnode, op->key); - op->error = ret; +afs_op_set_error (op, ret);if (ret <0 ) goto error;
@@ -1971,7 +1971,7 @@ static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir, op->rename.tmp =d_alloc (new_dentry->d_parent, &new_dentry->d_name);if (!op->rename.tmp) { - op->error = -ENOMEM ; +afs_op_nomem (op); goto error; }
@@ -1979,7 +1979,7 @@ static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,AFS_FS_I (d_inode (new_dentry)), new_dentry, op->key);if (ret) { - op->error = ret; +afs_op_set_error (op, ret); goto error; }
fs/afs/file.c +2 -2
@@ -243,7 +243,7 @@ static void afs_fetch_data_notify(struct afs_operation *op) {struct afs_read *req = op->fetch.req;struct netfs_io_subrequest *subreq = req->subreq; -int error = op->error; +int error =afs_op_error (op);if (error == -ECONNABORTED ) error =afs_abort_to_error (op->ac.abort_code);
@@ -271,7 +271,7 @@ static void afs_fetch_data_success(struct afs_operation *op)static void afs_fetch_data_put (struct afs_operation *op) { - op->fetch.req->error = op->error; + op->fetch.req->error =afs_op_error (op);afs_put_read (op->fetch.req); }
fs/afs/fs_operation.c +12 -9
@@ -40,8 +40,8 @@ struct afs_operation *afs_alloc_operation(struct key *key, struct afs_volume *vo op->net = volume->cell->net; op->cb_v_break = volume->cb_v_break; op->debug_id =atomic_inc_return (&afs_operation_debug_counter); - op->error = -EDESTADDRREQ ; op->nr_iterations =-1 ; +afs_op_set_error (op, -EDESTADDRREQ );_leave (" = [op=%08x]" , op->debug_id);return op;
@@ -71,7 +71,7 @@ static bool afs_get_io_locks(struct afs_operation *op)swap (vnode, vnode2);if (mutex_lock_interruptible (&vnode->io_lock) <0 ) { - op->error = -ERESTARTSYS ; +afs_op_set_error (op, -ERESTARTSYS ); op->flags |=AFS_OPERATION_STOP ;_leave (" = f [I 0]" );return false;
@@ -80,7 +80,7 @@ static bool afs_get_io_locks(struct afs_operation *op)if (vnode2) {if (mutex_lock_interruptible_nested (&vnode2->io_lock,1 ) <0 ) { - op->error = -ERESTARTSYS ; +afs_op_set_error (op, -ERESTARTSYS ); op->flags |=AFS_OPERATION_STOP ;mutex_unlock (&vnode->io_lock); op->flags &= ~AFS_OPERATION_LOCK_0 ;
@@ -159,11 +159,14 @@ static void afs_end_vnode_operation(struct afs_operation *op) {_enter ("" ); -if (op->error == -EDESTADDRREQ || - op->error == -EADDRNOTAVAIL || - op->error == -ENETUNREACH || - op->error == -EHOSTUNREACH ) +switch (afs_op_error (op)) { +case -EDESTADDRREQ : +case -EADDRNOTAVAIL : +case -ENETUNREACH : +case -EHOSTUNREACH :afs_dump_edestaddrreq (op); +break ; + }afs_drop_io_locks (op);
@@ -209,7 +212,7 @@ void afs_wait_for_operation(struct afs_operation *op)afs_end_vnode_operation (op); -if (op->error ==0 && op->ops->edit_dir) { +if (!afs_op_error (op) && op->ops->edit_dir) {_debug ("edit_dir" ); op->ops->edit_dir (op); }
@@ -221,7 +224,7 @@ void afs_wait_for_operation(struct afs_operation *op)*/ int afs_put_operation (struct afs_operation *op) { -int i, ret = op->error; +int i, ret =afs_op_error (op);_enter ("op=%08x,%d" , op->debug_id, ret);
fs/afs/fsclient.c +1 -1
@@ -1899,7 +1899,7 @@ void afs_fs_inline_bulk_status(struct afs_operation *op)int i;if (test_bit (AFS_SERVER_FL_NO_IBULK , &op->server->flags)) { - op->error = -ENOTSUPP ; +afs_op_set_error (op, -ENOTSUPP );return ; }
fs/afs/inode.c +1 -1
@@ -331,7 +331,7 @@ static void afs_fetch_status_success(struct afs_operation *op)if (vnode->netfs.inode.i_state &I_NEW ) { ret =afs_inode_init_from_status (op, vp, vnode); - op->error = ret; +afs_op_set_error (op, ret);if (ret ==0 )afs_cache_permit (vnode, op->key, vp->cb_break_before, &vp->scb); }else {
fs/afs/internal.h +15 -5
@@ -1139,11 +1139,6 @@ extern bool afs_begin_vnode_operation(struct afs_operation *);extern void afs_wait_for_operation (struct afs_operation *);extern int afs_do_sync_operation (struct afs_operation *); -static inline void afs_op_nomem (struct afs_operation *op) -{ - op->error = -ENOMEM ; -} -static inline void afs_op_set_vnode (struct afs_operation *op,unsigned int n,struct afs_vnode *vnode) {
@@ -1237,6 +1232,21 @@ static inline void __afs_stat(atomic_t *s)extern int afs_abort_to_error (u32 );extern void afs_prioritise_error (struct afs_error *,int ,u32 ); +static inline void afs_op_nomem (struct afs_operation *op) +{ + op->error = -ENOMEM ; +} + +static inline int afs_op_error (const struct afs_operation *op) +{ +return op->error; +} + +static inline int afs_op_set_error (struct afs_operation *op,int error) +{ +return op->error = error; +} +/* * mntpt.c */
fs/afs/rotate.c +31 -24
160 lines not on this page · raw message
fs/afs/server.c +3 -3
@@ -628,8 +628,8 @@ static noinline bool afs_update_server_record(struct afs_operation *op,_leave (" = t [intr]" );return true; } - op->error =PTR_ERR (alist); -_leave (" = f [%d]" , op->error); +afs_op_set_error (op,PTR_ERR (alist)); +_leave (" = f [%d]" ,afs_op_error (op));return false; }
@@ -683,7 +683,7 @@ bool afs_check_server_record(struct afs_operation *op, struct afs_server *server (op->flags &AFS_OPERATION_UNINTR ) ? TASK_UNINTERRUPTIBLE : TASK_INTERRUPTIBLE);if (ret == -ERESTARTSYS ) { - op->error = ret; +afs_op_set_error (op, ret);_leave (" = f [intr]" );return false; }
fs/afs/write.c +3 -3
@@ -366,7 +366,7 @@ static void afs_store_data_success(struct afs_operation *op) op->ctime = op->file[0 ].scb.status.mtime_client;afs_vnode_commit_status (op, &op->file[0 ]); -if (op->error ==0 ) { +if (!afs_op_error (op)) {if (!op->store.laundering)afs_pages_written_back (vnode, op->store.pos, op->store.size);afs_stat_v (vnode, n_stores);
@@ -428,7 +428,7 @@ static int afs_store_data(struct afs_vnode *vnode, struct iov_iter *iter, loff_tafs_wait_for_operation (op); -switch (op->error) { +switch (afs_op_error (op)) {case -EACCES :case -EPERM :case -ENOKEY :
@@ -447,7 +447,7 @@ static int afs_store_data(struct afs_vnode *vnode, struct iov_iter *iter, loff_t }afs_put_wb_key (wbk); -_leave (" = %d" , op->error); +_leave (" = %d" ,afs_op_error (op));return afs_put_operation (op); }
David Howells
maintainerPATCH 17/41 afs: Don't put afs_call in afs_wait_for_call_to_complete()
In reply to David HowellsDon't put the afs_call struct in afs_wait_for_call_to_complete() but rather have the caller do it. This will allow the caller to fish stuff out of the afs_call struct rather than the afs_addr_cursor struct, thereby allowing a subsequent patch to subsume it.
--- fs/afs/fs_operation.c | 7 +++-- fs/afs/fsclient.c | 5 ++- fs/afs/internal.h | 2 +- fs/afs/rxrpc.c | 73 ++++++++++++++++--------------------------- fs/afs/vlclient.c | 64 ++++++++++++++++++++++--------------- 5 files changed, 75 insertions(+), 76 deletions(-)
fs/afs/fs_operation.c +5 -2
@@ -191,8 +191,11 @@ void afs_wait_for_operation(struct afs_operation *op)else op->ac.error = -ENOTSUPP ; -if (op->call) - op->error =afs_wait_for_call_to_complete (op->call, &op->ac); +if (op->call) { +afs_wait_for_call_to_complete (op->call, &op->ac); + op->error = op->ac.error; +afs_put_call (op->call); + } }switch (op->error) {
fs/afs/fsclient.c +4 -1
@@ -1612,6 +1612,7 @@ int afs_fs_give_up_all_callbacks(struct afs_net *net, {struct afs_call *call;__be32 *bp; +int ret;_enter ("" );
@@ -1627,7 +1628,9 @@ int afs_fs_give_up_all_callbacks(struct afs_net *net, call->server =afs_use_server (server, afs_server_trace_give_up_cb);afs_make_call (ac, call,GFP_NOFS ); -return afs_wait_for_call_to_complete (call, ac); +afs_wait_for_call_to_complete (call, ac); +afs_put_call (call); +return ret; }/*
fs/afs/internal.h +1 -1
@@ -1290,7 +1290,7 @@ extern void __net_exit afs_close_socket(struct afs_net *);extern void afs_charge_preallocation (struct work_struct *);extern void afs_put_call (struct afs_call *);extern void afs_make_call (struct afs_addr_cursor *,struct afs_call *,gfp_t ); -extern long afs_wait_for_call_to_complete (struct afs_call *,struct afs_addr_cursor *); +void afs_wait_for_call_to_complete (struct afs_call *call,struct afs_addr_cursor *ac);extern struct afs_call *afs_alloc_flat_call (struct afs_net *,const struct afs_call_type *,size_t ,size_t );
fs/afs/rxrpc.c +27 -46
98 lines not on this page · raw message
fs/afs/vlclient.c +38 -26
146 lines not on this page · raw message
David Howells
maintainerPATCH 18/41 afs: Simplify error handling
In reply to David HowellsSimplify error handling a bit by moving it from the afs_addr_cursor struct to the afs_operation and afs_vl_cursor structs and using the error prioritisation function for accumulating errors from multiple sources (AFS tries to rotate between multiple fileservers, some of which may be inaccessible or in some state of offlinedness).
--- fs/afs/addr_list.c | 8 ++-- fs/afs/dir.c | 14 ++++--- fs/afs/dir_silly.c | 2 +- fs/afs/file.c | 3 -- fs/afs/fs_operation.c | 24 +++++------ fs/afs/fsclient.c | 1 + fs/afs/internal.h | 44 +++++++++++++++------ fs/afs/misc.c | 10 ++++- fs/afs/rotate.c | 58 ++++++++++++++------------- fs/afs/rxrpc.c | 17 ++++---- fs/afs/server.c | 1 - fs/afs/vl_alias.c | 2 +- fs/afs/vl_probe.c | 7 ++-- fs/afs/vl_rotate.c | 92 +++++++++++++++++++++---------------------- fs/afs/vlclient.c | 34 ++++++++++------ 15 files changed, 174 insertions(+), 143 deletions(-)
fs/afs/addr_list.c +3 -5
@@ -386,26 +386,24 @@ bool afs_iterate_addresses(struct afs_addr_cursor *ac) selected: ac->index = index;set_bit (index, &ac->tried); - ac->responded = false; + ac->call_responded = false;return true; }/* * Release an address list cursor. */ -int afs_end_cursor (struct afs_addr_cursor *ac) +void afs_end_cursor (struct afs_addr_cursor *ac) {struct afs_addr_list *alist; alist = ac->alist;if (alist) { -if (ac->responded && +if (ac->call_responded && ac->index != alist->preferred &&test_bit (ac->alist->preferred, &ac->tried))WRITE_ONCE (alist->preferred, ac->index);afs_put_addrlist (alist); ac->alist =NULL ; } - -return ac->error; }
fs/afs/dir.c +8 -6
@@ -693,8 +693,9 @@ static void afs_do_lookup_success(struct afs_operation *op) vp = &op->file[0 ]; abort_code = vp->scb.status.abort_code;if (abort_code !=0 ) { - op->ac.abort_code = abort_code; - op->error =afs_abort_to_error (abort_code); + op->call_abort_code = abort_code; +afs_op_set_error (op,afs_abort_to_error (abort_code)); + op->cumul_error.abort_code = abort_code; }break ;
@@ -846,13 +847,14 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,_debug ("nr_files %u" , op->nr_files);/* Need space for examining all the selected files */ - op->error = -ENOMEM ;if (op->nr_files >2 ) { op->more_files =kvcalloc (op->nr_files -2 ,sizeof (struct afs_vnode_param ),GFP_KERNEL ); -if (!op->more_files) +if (!op->more_files) { +afs_op_nomem (op); goto out_op; + }for (i =2 ; i < op->nr_files; i++) { vp = &op->more_files[i -2 ];
@@ -1255,7 +1257,7 @@ void afs_check_for_remote_deletion(struct afs_operation *op) {struct afs_vnode *vnode = op->file[0 ].vnode; -switch (op->ac.abort_code) { +switch (afs_op_abort_code (op)) {case VNOVNODE :set_bit (AFS_VNODE_DELETED , &vnode->flags);afs_break_callback (vnode, afs_cb_break_for_deleted);
@@ -1280,7 +1282,7 @@ static void afs_vnode_new_inode(struct afs_operation *op)/* ENOMEM or EINTR at a really inconvenient time - just abandon * the new directory on the server. */ - op->error =PTR_ERR (inode); +afs_op_accumulate_error (op,PTR_ERR (inode),0 );return ; }
fs/afs/dir_silly.c +1 -1
@@ -218,7 +218,7 @@ static int afs_do_silly_unlink(struct afs_vnode *dvnode, struct afs_vnode *vnode/* If there was a conflict with a third party, check the status of the * unlinked vnode. */ -if (op->error ==0 && (op->flags &AFS_OPERATION_DIR_CONFLICT )) { +if (op->cumul_error.error ==0 && (op->flags &AFS_OPERATION_DIR_CONFLICT )) { op->file[1 ].update_ctime = false; op->fetch_status.which =1 ; op->ops = &afs_fetch_status_operation;
fs/afs/file.c +0 -3
@@ -245,10 +245,7 @@ static void afs_fetch_data_notify(struct afs_operation *op)struct netfs_io_subrequest *subreq = req->subreq;int error =afs_op_error (op); -if (error == -ECONNABORTED ) - error =afs_abort_to_error (op->ac.abort_code); req->error = error; -if (subreq) {__set_bit (NETFS_SREQ_CLEAR_TAIL , &subreq->flags);netfs_subreq_terminated (subreq, error ?: req->actual_len, false);
fs/afs/fs_operation.c +12 -12
@@ -169,9 +169,6 @@ static void afs_end_vnode_operation(struct afs_operation *op) }afs_drop_io_locks (op); - -if (op->error == -ECONNABORTED ) - op->error =afs_abort_to_error (op->ac.abort_code); }/*
@@ -182,6 +179,8 @@ void afs_wait_for_operation(struct afs_operation *op)_enter ("" );while (afs_select_fileserver (op)) { + op->call_error =0 ; + op->call_abort_code =0 ; op->cb_s_break = op->server->cb_s_break;if (test_bit (AFS_SERVER_FL_IS_YFS , &op->server->flags) && op->ops->issue_yfs_rpc)
@@ -189,28 +188,29 @@ void afs_wait_for_operation(struct afs_operation *op)else if (op->ops->issue_afs_rpc) op->ops->issue_afs_rpc (op);else - op->ac.error = -ENOTSUPP ; + op->call_error = -ENOTSUPP ;if (op->call) {afs_wait_for_call_to_complete (op->call, &op->ac); - op->error = op->ac.error; + op->call_abort_code = op->call->abort_code; + op->call_error = op->call->error; + op->call_responded = op->call->responded; + op->ac.call_responded = true; +WRITE_ONCE (op->ac.alist->addrs[op->ac.index].last_error, + op->call_error);afs_put_call (op->call); } } -switch (op->error) { -case 0 : +if (!afs_op_error (op)) {_debug ("success" ); op->ops->success (op); -break ; -case -ECONNABORTED : + }else if (op->cumul_error.aborted) {if (op->ops->aborted) op->ops->aborted (op); - fallthrough; -default : + }else {if (op->ops->failed) op->ops->failed (op); -break ; }afs_end_vnode_operation (op);
fs/afs/fsclient.c +1 -0
@@ -1629,6 +1629,7 @@ int afs_fs_give_up_all_callbacks(struct afs_net *net, call->server =afs_use_server (server, afs_server_trace_give_up_cb);afs_make_call (ac, call,GFP_NOFS );afs_wait_for_call_to_complete (call, ac); + ret = call->error;afs_put_call (call);return ret; }
fs/afs/internal.h +31 -13
126 lines not on this page · raw message
fs/afs/misc.c +8 -2
@@ -116,6 +116,8 @@ void afs_prioritise_error(struct afs_error *e, int error, u32 abort_code) {switch (error) {case 0 : + e->aborted = false; + e->error =0 ;return ;default : if (e->error == -ETIMEDOUT ||
@@ -161,12 +163,16 @@ void afs_prioritise_error(struct afs_error *e, int error, u32 abort_code)if (e->responded)return ; e->error = error; + e->aborted = false;return ;case -ECONNABORTED : - error =afs_abort_to_error (abort_code); - fallthrough; + e->error =afs_abort_to_error (abort_code); + e->aborted = true; + e->responded = true; +return ;case -ENETRESET :/* Responded, but we seem to have changed address */ + e->aborted = false; e->responded = true; e->error = error;return ;
fs/afs/rotate.c +30 -28
174 lines not on this page · raw message
fs/afs/rxrpc.c +7 -10
@@ -408,8 +408,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)rxrpc_kernel_recv_data (call->net->socket, rxcall, &msg.msg_iter, &len, false, &call->abort_code, &call->service_id); - ac->abort_code = call->abort_code; - ac->responded = true; + call->responded = true; } call->error = ret;trace_afs_call_done (call);
@@ -429,7 +428,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)afs_put_call (call); } - ac->error = ret; + call->error = ret; call->state =AFS_CALL_COMPLETE ;_leave (" = %d" , ret); }
@@ -510,6 +509,7 @@ static void afs_deliver_to_call(struct afs_call *call) ret = -EBADMSG ;switch (ret) {case 0 : + call->responded = true;afs_queue_call_work (call);if (state ==AFS_CALL_CL_PROC_REPLY ) {if (call->op)
@@ -524,9 +524,11 @@ static void afs_deliver_to_call(struct afs_call *call) goto out;case -ECONNABORTED : ASSERTCMP(state, ==, AFS_CALL_COMPLETE); + call->responded = true;afs_log_error (call, call->abort_code); goto done;case -ENOTSUPP : + call->responded = true; abort_code =RXGEN_OPCODE ; rxrpc_kernel_abort_call(call->net->socket, call->rxcall, abort_code, ret,
@@ -573,7 +575,7 @@ static void afs_deliver_to_call(struct afs_call *call) }/* -* Wait synchronously for a call to complete and clean up the call struct. +* Wait synchronously for a call to complete. */ void afs_wait_for_call_to_complete (struct afs_call *call,struct afs_addr_cursor *ac) {
@@ -626,13 +628,8 @@ void afs_wait_for_call_to_complete(struct afs_call *call, struct afs_addr_cursor } } -spin_lock_bh (&call->state_lock); - ac->abort_code = call->abort_code; - ac->error = call->error; -spin_unlock_bh (&call->state_lock); -if (call->error ==0 || call->error == -ECONNABORTED ) - ac->responded = true; + call->responded = true; }/*
fs/afs/server.c +0 -1
@@ -436,7 +436,6 @@ static void afs_give_up_callbacks(struct afs_net *net, struct afs_server *serverstruct afs_addr_cursor ac = { .alist = alist, .index = alist->preferred, - .error =0 , };afs_fs_give_up_all_callbacks (net, server, &ac,NULL );
fs/afs/vl_alias.c +1 -1
@@ -236,7 +236,7 @@ static char *afs_vl_get_cell_name(struct afs_cell *cell, struct key *key)while (afs_select_vlserver (&vc)) {if (!test_bit (AFS_VLSERVER_FL_IS_YFS , &vc.server->flags)) { - vc.ac.error = -EOPNOTSUPP ; + vc.call_error = -EOPNOTSUPP ; skipped = true;continue ; }
fs/afs/vl_probe.c +3 -4
@@ -169,10 +169,11 @@ static bool afs_do_probe_vlserver(struct afs_net *net, call =afs_vl_get_capabilities (net, &ac, key, server, server_index);if (!IS_ERR (call)) { +afs_prioritise_error (_e, call->error, call->abort_code);afs_put_call (call); in_progress = true; }else { -afs_prioritise_error (_e,PTR_ERR (call), ac.abort_code); +afs_prioritise_error (_e,PTR_ERR (call),0 );afs_done_one_vl_probe (server, false); } }
@@ -187,12 +188,10 @@ int afs_send_vl_probes(struct afs_net *net, struct key *key, struct afs_vlserver_list *vllist) {struct afs_vlserver *server; -struct afs_error e; +struct afs_error e = {};bool in_progress = false;int i; - e.error =0 ; - e.responded = false;for (i =0 ; i < vllist->nr_servers; i++) { server = vllist->servers[i].server;if (test_bit (AFS_VLSERVER_FL_PROBED , &server->flags))
fs/afs/vl_rotate.c +46 -46
219 lines not on this page · raw message
fs/afs/vlclient.c +23 -11
@@ -161,10 +161,13 @@ struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *vc,trace_afs_make_vl_call (call);afs_make_call (&vc->ac, call,GFP_KERNEL );afs_wait_for_call_to_complete (call, &vc->ac); + vc->call_abort_code = call->abort_code; + vc->call_error = call->error; + vc->call_responded = call->responded;afs_put_call (call); -if (vc->ac.error) { +if (vc->call_error) {kfree (entry); -return ERR_PTR (vc->ac.error); +return ERR_PTR (vc->call_error); }return entry; }
@@ -305,11 +308,14 @@ struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *vc,trace_afs_make_vl_call (call);afs_make_call (&vc->ac, call,GFP_KERNEL );afs_wait_for_call_to_complete (call, &vc->ac); - alist = call->ret_alist; + vc->call_abort_code = call->abort_code; + vc->call_error = call->error; + vc->call_responded = call->responded; + alist = call->ret_alist;afs_put_call (call); -if (vc->ac.error) { +if (vc->call_error) {afs_put_addrlist (alist); -return ERR_PTR (vc->ac.error); +return ERR_PTR (vc->call_error); }return alist; }
@@ -656,11 +662,14 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc,trace_afs_make_vl_call (call);afs_make_call (&vc->ac, call,GFP_KERNEL );afs_wait_for_call_to_complete (call, &vc->ac); - alist = call->ret_alist; + vc->call_abort_code = call->abort_code; + vc->call_error = call->error; + vc->call_responded = call->responded; + alist = call->ret_alist;afs_put_call (call); -if (vc->ac.error) { +if (vc->call_error) {afs_put_addrlist (alist); -return ERR_PTR (vc->ac.error); +return ERR_PTR (vc->call_error); }return alist; }
@@ -769,11 +778,14 @@ char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *vc)trace_afs_make_vl_call (call);afs_make_call (&vc->ac, call,GFP_KERNEL );afs_wait_for_call_to_complete (call, &vc->ac); - cellname = call->ret_str; + vc->call_abort_code = call->abort_code; + vc->call_error = call->error; + vc->call_responded = call->responded; + cellname = call->ret_str;afs_put_call (call); -if (vc->ac.error) { +if (vc->call_error) {kfree (cellname); -return ERR_PTR (vc->ac.error); +return ERR_PTR (vc->call_error); }return cellname; }
David Howells
maintainerPATCH 19/41 afs: Add a tracepoint for struct afs_addr_list
In reply to David HowellsAdd a tracepoint to track the lifetime of the afs_addr_list struct.
--- fs/afs/addr_list.c | 33 ++++++++++++++++++++++---- fs/afs/fs_probe.c | 4 ++-- fs/afs/internal.h | 10 +++----- fs/afs/rotate.c | 4 ++-- fs/afs/rxrpc.c | 4 ++-- fs/afs/server.c | 9 ++++---- fs/afs/vl_list.c | 11 +++++---- fs/afs/vl_rotate.c | 9 ++------ fs/afs/vlclient.c | 4 ++-- include/trace/events/afs.h | 47 ++++++++++++++++++++++++++++++++++++++ 10 files changed, 100 insertions(+), 35 deletions(-)
fs/afs/addr_list.c +29 -4
@@ -20,17 +20,39 @@ static void afs_free_addrlist(struct rcu_head *rcu)for (i =0 ; i < alist->nr_addrs; i++)rxrpc_kernel_put_peer (alist->addrs[i].peer); +trace_afs_alist (alist->debug_id,refcount_read (&alist->usage), afs_alist_trace_free); +kfree (alist); }/* * Release an address list. */ -void afs_put_addrlist (struct afs_addr_list *alist) +void afs_put_addrlist (struct afs_addr_list *alist,enum afs_alist_trace reason) { -if (alist &&refcount_dec_and_test (&alist->usage)) +unsigned int debug_id; +bool dead; +int r; + +if (!alist) +return ; + debug_id = alist->debug_id; + dead =__refcount_dec_and_test (&alist->usage, &r); +trace_afs_alist (debug_id, r -1 , reason); +if (dead)call_rcu (&alist->rcu, afs_free_addrlist); } +struct afs_addr_list *afs_get_addrlist (struct afs_addr_list *alist,enum afs_alist_trace reason) +{ +int r; + +if (alist) { +__refcount_inc (&alist->usage, &r); +trace_afs_alist (alist->debug_id, r +1 , reason); + } +return alist; +} +/* * Allocate an address list. */
@@ -38,6 +60,7 @@ struct afs_addr_list *afs_alloc_addrlist(unsigned int nr, u16 service_id) {struct afs_addr_list *alist;unsigned int i; +static atomic_t debug_id;_enter ("%u,%u" , nr, service_id);
@@ -50,9 +73,11 @@ struct afs_addr_list *afs_alloc_addrlist(unsigned int nr, u16 service_id)refcount_set (&alist->usage,1 ); alist->max_addrs = nr; + alist->debug_id =atomic_inc_return (&debug_id);for (i =0 ; i < nr; i++) alist->addrs[i].service_id = service_id; +trace_afs_alist (alist->debug_id,1 , afs_alist_trace_alloc);return alist; }
@@ -217,7 +242,7 @@ struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *net, problem, p - text, (int)len, (int)len, text); ret = -EINVAL ; error: -afs_put_addrlist (alist); +afs_put_addrlist (alist, afs_alist_trace_put_parse_error); error_vl:afs_put_vlserverlist (net, vllist);return ERR_PTR (ret);
@@ -403,7 +428,7 @@ void afs_end_cursor(struct afs_addr_cursor *ac) ac->index != alist->preferred && test_bit(ac->alist->preferred, &ac->tried))WRITE_ONCE (alist->preferred, ac->index); -afs_put_addrlist (alist); +afs_put_addrlist (alist, afs_alist_trace_put_end_cursor); ac->alist =NULL ; } }
fs/afs/fs_probe.c +2 -2
@@ -205,7 +205,7 @@ void afs_fs_probe_fileserver(struct afs_net *net, struct afs_server *server,read_lock (&server->fs_lock); ac.alist =rcu_dereference_protected (server->addresses,lockdep_is_held (&server->fs_lock)); -afs_get_addrlist (ac.alist); +afs_get_addrlist (ac.alist, afs_alist_trace_get_probe);read_unlock (&server->fs_lock); server->probed_at = jiffies;
@@ -226,7 +226,7 @@ void afs_fs_probe_fileserver(struct afs_net *net, struct afs_server *server,afs_fs_probe_not_done (net, server, &ac); } -afs_put_addrlist (ac.alist); +afs_put_addrlist (ac.alist, afs_alist_trace_put_probe); }/*
fs/afs/internal.h +3 -7
@@ -85,6 +85,7 @@ struct afs_addr_list {struct rcu_head rcu;refcount_t usage;u32 version;/* Version */ +unsigned int debug_id;unsigned char max_addrs;unsigned char nr_addrs;unsigned char preferred;/* Preferred address */
@@ -968,14 +969,9 @@ static inline bool afs_is_folio_dirty_mmapped(unsigned long priv)/* * addr_list.c */ -static inline struct afs_addr_list *afs_get_addrlist (struct afs_addr_list *alist) -{ -if (alist) -refcount_inc (&alist->usage); -return alist; -} +struct afs_addr_list *afs_get_addrlist (struct afs_addr_list *alist,enum afs_alist_trace reason);extern struct afs_addr_list *afs_alloc_addrlist (unsigned int nr,u16 service_id); -extern void afs_put_addrlist (struct afs_addr_list *); +extern void afs_put_addrlist (struct afs_addr_list *alist,enum afs_alist_trace reason);extern struct afs_vlserver_list *afs_parse_text_addrs (struct afs_net *,const char *,size_t ,char ,unsigned short ,unsigned short );
fs/afs/rotate.c +2 -2
@@ -482,7 +482,7 @@ bool afs_select_fileserver(struct afs_operation *op)read_lock (&server->fs_lock); alist =rcu_dereference_protected (server->addresses,lockdep_is_held (&server->fs_lock)); -afs_get_addrlist (alist); +afs_get_addrlist (alist, afs_alist_trace_get_fsrotate_set);read_unlock (&server->fs_lock); retry_server:
@@ -491,7 +491,7 @@ bool afs_select_fileserver(struct afs_operation *op)if (!op->ac.alist) op->ac.alist = alist;else -afs_put_addrlist (alist); +afs_put_addrlist (alist, afs_alist_trace_put_retry_server); op->ac.index =-1 ;
fs/afs/rxrpc.c +2 -2
@@ -187,7 +187,7 @@ void afs_put_call(struct afs_call *call) call->type->destructor (call);afs_unuse_server_notime (call->net, call->server, afs_server_trace_put_call); -afs_put_addrlist (call->alist); +afs_put_addrlist (call->alist, afs_alist_trace_put_call);kfree (call->request); trace_afs_call(call->debug_id, afs_call_trace_free, 0, o,
@@ -315,7 +315,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) atomic_read(&call->net->nr_outstanding_calls)); call->addr_ix = ac->index; - call->alist =afs_get_addrlist (ac->alist); + call->alist =afs_get_addrlist (ac->alist, afs_alist_trace_get_make_call);/* Work out the length we're going to transmit. This is awkward for * calls such as FS.StoreData where there's an extra injection of data
fs/afs/server.c +5 -4
@@ -274,13 +274,13 @@ struct afs_server *afs_lookup_server(struct afs_cell *cell, struct key *key, candidate =afs_alloc_server (cell, uuid, alist);if (!candidate) { -afs_put_addrlist (alist); +afs_put_addrlist (alist, afs_alist_trace_put_server_oom);return ERR_PTR (-ENOMEM ); } server =afs_install_server (cell, candidate);if (server != candidate) { -afs_put_addrlist (alist); +afs_put_addrlist (alist, afs_alist_trace_put_server_dup);kfree (candidate); }else {/* Immediately dispatch an asynchronous probe to each interface
@@ -420,7 +420,8 @@ static void afs_server_rcu(struct rcu_head *rcu)trace_afs_server (server->debug_id,refcount_read (&server->ref),atomic_read (&server->active), afs_server_trace_free); -afs_put_addrlist (rcu_access_pointer (server->addresses)); +afs_put_addrlist (rcu_access_pointer (server->addresses), + afs_alist_trace_put_server);kfree (server); }
@@ -642,7 +643,7 @@ static noinline bool afs_update_server_record(struct afs_operation *op,write_unlock (&server->fs_lock); } -afs_put_addrlist (discard); +afs_put_addrlist (discard, afs_alist_trace_put_server_update);_leave (" = t" );return true; }
fs/afs/vl_list.c +6 -5
@@ -33,7 +33,8 @@ static void afs_vlserver_rcu(struct rcu_head *rcu) { struct afs_vlserver *vlserver = container_of(rcu, struct afs_vlserver, rcu); -afs_put_addrlist (rcu_access_pointer (vlserver->addresses)); +afs_put_addrlist (rcu_access_pointer (vlserver->addresses), + afs_alist_trace_put_vlserver);kfree_rcu (vlserver, rcu); }
@@ -145,7 +146,7 @@ static struct afs_addr_list *afs_extract_vl_addrs(struct afs_net *net, error: *_b = b; -afs_put_addrlist (alist); +afs_put_addrlist (alist, afs_alist_trace_put_parse_error);return ERR_PTR (ret); }
@@ -260,7 +261,7 @@ struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *cell,if (vllist->nr_servers >= nr_servers) {_debug ("skip %u >= %u" , vllist->nr_servers, nr_servers); -afs_put_addrlist (addrs); +afs_put_addrlist (addrs, afs_alist_trace_put_parse_empty);afs_put_vlserver (cell->net, server);continue ; }
@@ -269,7 +270,7 @@ struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *cell, addrs->status = bs.status;if (addrs->nr_addrs ==0 ) { -afs_put_addrlist (addrs); +afs_put_addrlist (addrs, afs_alist_trace_put_parse_empty);if (!rcu_access_pointer (server->addresses)) {afs_put_vlserver (cell->net, server);continue ;
@@ -281,7 +282,7 @@ struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *cell, old =rcu_replace_pointer (server->addresses, old,lockdep_is_held (&server->lock));write_unlock (&server->lock); -afs_put_addrlist (old); +afs_put_addrlist (old, afs_alist_trace_put_vlserver_old); }
fs/afs/vl_rotate.c +2 -7
@@ -231,16 +231,11 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)read_lock (&vlserver->lock); alist =rcu_dereference_protected (vlserver->addresses,lockdep_is_held (&vlserver->lock)); -afs_get_addrlist (alist); +afs_get_addrlist (alist, afs_alist_trace_get_vlrotate_set);read_unlock (&vlserver->lock);memset (&vc->ac,0 ,sizeof (vc->ac)); - -if (!vc->ac.alist) - vc->ac.alist = alist; -else -afs_put_addrlist (alist); - + vc->ac.alist = alist; vc->ac.index =-1 ; iterate_address:
fs/afs/vlclient.c +2 -2
@@ -314,7 +314,7 @@ struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *vc, alist = call->ret_alist;afs_put_call (call);if (vc->call_error) { -afs_put_addrlist (alist); +afs_put_addrlist (alist, afs_alist_trace_put_getaddru);return ERR_PTR (vc->call_error); }return alist;
@@ -668,7 +668,7 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc, alist = call->ret_alist;afs_put_call (call);if (vc->call_error) { -afs_put_addrlist (alist); +afs_put_addrlist (alist, afs_alist_trace_put_getaddru);return ERR_PTR (vc->call_error); }return alist;
include/trace/events/afs.h +47 -0
71 lines not on this page · raw message
David Howells
maintainerPATCH 20/41 afs: Rename some fields
In reply to David HowellsRename the ->index and ->untried fields of the afs_vl_cursor and afs_operation struct to ->server_index and ->untried_servers to avoid confusion with address iteration fields when those get folded in.
--- fs/afs/internal.h | 8 ++++---- fs/afs/rotate.c | 36 ++++++++++++++++++------------------ fs/afs/vl_rotate.c | 32 ++++++++++++++++---------------- 3 files changed, 38 insertions(+), 38 deletions(-)
fs/afs/internal.h +4 -4
@@ -746,11 +746,11 @@ struct afs_vl_cursor {struct afs_vlserver_list *server_list;/* Current server list (pins ref) */ struct afs_vlserver *server;/* Server on which this resides */ struct key *key;/* Key for the server */ -unsigned long untried;/* Bitmask of untried servers */ +unsigned long untried_servers;/* Bitmask of untried servers */ struct afs_error cumul_error;/* Cumulative error */ s32 call_abort_code; -short index;/* Current server */ short call_error;/* Error from single call */ +short server_index;/* Current server */ unsigned short flags;#define AFS_VL_CURSOR_STOP 0x0001/* Set to cease iteration */ #define AFS_VL_CURSOR_RETRY 0x0002/* Set to do a retry */
@@ -863,8 +863,8 @@ struct afs_operation {struct afs_server_list *server_list;/* Current server list (pins ref) */ struct afs_server *server;/* Server we're using (ref pinned by server_list) */ struct afs_call *call; -unsigned long untried;/* Bitmask of untried servers */ -short index;/* Current server */ +unsigned long untried_servers;/* Bitmask of untried servers */ +short server_index;/* Current server */ short nr_iterations;/* Number of server iterations */ bool call_responded;/* T if the current address responded */
fs/afs/rotate.c +18 -18
@@ -32,8 +32,8 @@ static bool afs_start_fs_iteration(struct afs_operation *op, lockdep_is_held(&op->volume->servers_lock)));read_unlock (&op->volume->servers_lock); - op->untried = (1UL << op->server_list->nr_servers) -1 ; - op->index =READ_ONCE (op->server_list->preferred); + op->untried_servers = (1UL << op->server_list->nr_servers) -1 ; + op->server_index =READ_ONCE (op->server_list->preferred); cb_server = vnode->cb_server;if (cb_server) {
@@ -41,7 +41,7 @@ static bool afs_start_fs_iteration(struct afs_operation *op,for (i =0 ; i < op->server_list->nr_servers; i++) { server = op->server_list->servers[i].server;if (server == cb_server) { - op->index = i; + op->server_index = i; goto found_interest; } }
@@ -120,7 +120,7 @@ bool afs_select_fileserver(struct afs_operation *op)_enter ("OP=%x+%x,%llx,%lx[%d],%lx[%d],%d,%d" , op->debug_id, op->nr_iterations, op->volume->vid, - op->untried, op->index, + op->untried_servers, op->server_index, op->ac.tried, op->ac.index, error, abort_code);
@@ -172,7 +172,7 @@ bool afs_select_fileserver(struct afs_operation *op) }write_lock (&op->volume->servers_lock); - op->server_list->vnovol_mask |=1 << op->index; + op->server_list->vnovol_mask |=1 << op->server_index;write_unlock (&op->volume->servers_lock);set_bit (AFS_VOLUME_NEEDS_UPDATE , &op->volume->flags);
@@ -417,9 +417,9 @@ bool afs_select_fileserver(struct afs_operation *op)_debug ("__ VOL %llx __" , op->volume->vid); pick_server: -_debug ("pick [%lx]" , op->untried); +_debug ("pick [%lx]" , op->untried_servers); - error =afs_wait_for_fs_probes (op->server_list, op->untried); + error =afs_wait_for_fs_probes (op->server_list, op->untried_servers);if (error <0 ) {afs_op_set_error (op, error); goto failed;
@@ -429,40 +429,40 @@ bool afs_select_fileserver(struct afs_operation *op)* callbacks, we stick with the server we're already using if we can. */ if (op->server) { -_debug ("server %u" , op->index); -if (test_bit (op->index, &op->untried)) +_debug ("server %u" , op->server_index); +if (test_bit (op->server_index, &op->untried_servers)) goto selected_server; op->server =NULL ;_debug ("no server" ); } - op->index =-1 ; + op->server_index =-1 ; rtt =UINT_MAX ;for (i =0 ; i < op->server_list->nr_servers; i++) {struct afs_server *s = op->server_list->servers[i].server; -if (!test_bit (i, &op->untried) || +if (!test_bit (i, &op->untried_servers) || !test_bit (AFS_SERVER_FL_RESPONDING , &s->flags))continue ;if (s->probe.rtt <= rtt) { - op->index = i; + op->server_index = i; rtt = s->probe.rtt; } } -if (op->index ==-1 ) +if (op->server_index ==-1 ) goto no_more_servers; selected_server: -_debug ("use %d" , op->index); -__clear_bit (op->index, &op->untried); +_debug ("use %d" , op->server_index); +__clear_bit (op->server_index, &op->untried_servers);/* We're starting on a different fileserver from the list. We need to * check it, create a callback intercept, find its address list and * probe its capabilities before we use it. */ ASSERTCMP(op->ac.alist, ==, NULL); - server = op->server_list->servers[op->index].server; + server = op->server_list->servers[op->server_index].server;if (!afs_check_server_record (op, server)) goto failed;
@@ -504,7 +504,7 @@ bool afs_select_fileserver(struct afs_operation *op) goto out_of_addresses;_debug ("address [%u] %u/%u %pISp" , - op->index, op->ac.index, op->ac.alist->nr_addrs, + op->server_index, op->ac.index, op->ac.alist->nr_addrs,rxrpc_kernel_remote_addr (op->ac.alist->addrs[op->ac.index].peer)); op->call_responded = false;
@@ -579,7 +579,7 @@ void afs_dump_edestaddrreq(const struct afs_operation *op) op->file[0 ].cb_break_before, op->file[1].cb_break_before, op->flags, op->cumul_error.error);pr_notice ("OP: ut=%lx ix=%d ni=%u\n" , - op->untried, op->index, op->nr_iterations); + op->untried_servers, op->server_index, op->nr_iterations);pr_notice ("OP: call er=%d ac=%d r=%u\n" , op->call_error, op->call_abort_code, op->call_responded);
fs/afs/vl_rotate.c +16 -16
@@ -78,8 +78,8 @@ static bool afs_start_vl_iteration(struct afs_vl_cursor *vc)if (!vc->server_list->nr_servers)return false; - vc->untried = (1UL << vc->server_list->nr_servers) -1 ; - vc->index =-1 ; + vc->untried_servers = (1UL << vc->server_list->nr_servers) -1 ; + vc->server_index =-1 ;return true; }
@@ -98,7 +98,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc) vc->nr_iterations++;_enter ("%lx[%d],%lx[%d],%d,%d" , - vc->untried, vc->index, + vc->untried_servers, vc->server_index, vc->ac.tried, vc->ac.index, error, abort_code);
@@ -131,7 +131,7 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)/* The server went weird. */ afs_prioritise_error (&vc->cumul_error, -EREMOTEIO , abort_code);//write_lock(&vc->cell->vl_servers_lock); -//vc->server_list->weird_mask |= 1 << vc->index; +//vc->server_list->weird_mask |= 1 << vc->server_index; //write_unlock(&vc->cell->vl_servers_lock); goto next_server;
@@ -184,46 +184,46 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc) } pick_server: -_debug ("pick [%lx]" , vc->untried); +_debug ("pick [%lx]" , vc->untried_servers); - error =afs_wait_for_vl_probes (vc->server_list, vc->untried); + error =afs_wait_for_vl_probes (vc->server_list, vc->untried_servers);if (error <0 ) {afs_prioritise_error (&vc->cumul_error, error,0 ); goto failed; }/* Pick the untried server with the lowest RTT. */ - vc->index = vc->server_list->preferred; -if (test_bit (vc->index, &vc->untried)) + vc->server_index = vc->server_list->preferred; +if (test_bit (vc->server_index, &vc->untried_servers)) goto selected_server; - vc->index =-1 ; + vc->server_index =-1 ; rtt =UINT_MAX ;for (i =0 ; i < vc->server_list->nr_servers; i++) {struct afs_vlserver *s = vc->server_list->servers[i].server; -if (!test_bit (i, &vc->untried) || +if (!test_bit (i, &vc->untried_servers) || !test_bit (AFS_VLSERVER_FL_RESPONDING , &s->flags))continue ;if (s->probe.rtt <= rtt) { - vc->index = i; + vc->server_index = i; rtt = s->probe.rtt; } } -if (vc->index ==-1 ) +if (vc->server_index ==-1 ) goto no_more_servers; selected_server: -_debug ("use %d" , vc->index); -__clear_bit (vc->index, &vc->untried); +_debug ("use %d" , vc->server_index); +__clear_bit (vc->server_index, &vc->untried_servers);/* We're starting on a different vlserver from the list. We need to * check it, find its address list and probe its capabilities before we * use it. */ ASSERTCMP(vc->ac.alist, ==, NULL); - vlserver = vc->server_list->servers[vc->index].server; + vlserver = vc->server_list->servers[vc->server_index].server; vc->server = vlserver;_debug ("USING VLSERVER: %s" , vlserver->name);
@@ -299,7 +299,7 @@ static void afs_vl_dump_edestaddrreq(const struct afs_vl_cursor *vc)pr_notice ("DNS: src=%u st=%u lc=%x\n" , cell->dns_source, cell->dns_status, cell->dns_lookup_count);pr_notice ("VC: ut=%lx ix=%u ni=%hu fl=%hx err=%hd\n" , - vc->untried, vc->index, vc->nr_iterations, vc->flags, + vc->untried_servers, vc->server_index, vc->nr_iterations, vc->flags, vc->cumul_error.error);pr_notice ("VC: call er=%d ac=%d r=%u\n" , vc->call_error, vc->call_abort_code, vc->call_responded);
David Howells
maintainerPATCH 21/41 afs: Use peer + service_id as call address
In reply to David HowellsUse the rxrpc_peer plus the service ID as the call address instead of passing in a sockaddr_srx down to rxrpc. The peer record is obtained by using rxrpc_kernel_get_peer(). This avoids the need to repeatedly look up the peer and allows rxrpc to hold on to resources for it.
--- fs/afs/addr_list.c | 10 +++------- fs/afs/fs_probe.c | 4 ++-- fs/afs/fsclient.c | 14 +++++++++----- fs/afs/internal.h | 18 +++++++++++------- fs/afs/rxrpc.c | 12 ++++++------ fs/afs/server.c | 1 + fs/afs/vl_list.c | 3 ++- fs/afs/vl_probe.c | 4 ++-- fs/afs/vlclient.c | 14 ++++++++++++-- 9 files changed, 48 insertions(+), 32 deletions(-)
fs/afs/addr_list.c +3 -7
@@ -56,13 +56,12 @@ struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist, enum afs_ali/* * Allocate an address list. */ -struct afs_addr_list *afs_alloc_addrlist (unsigned int nr,u16 service_id) +struct afs_addr_list *afs_alloc_addrlist (unsigned int nr) {struct afs_addr_list *alist; -unsigned int i;static atomic_t debug_id; -_enter ("%u,%u" , nr, service_id); +_enter ("%u" , nr);if (nr >AFS_MAX_ADDRESSES ) nr =AFS_MAX_ADDRESSES ;
@@ -74,9 +73,6 @@ struct afs_addr_list *afs_alloc_addrlist(unsigned int nr, u16 service_id)refcount_set (&alist->usage,1 ); alist->max_addrs = nr; alist->debug_id =atomic_inc_return (&debug_id); - -for (i =0 ; i < nr; i++) - alist->addrs[i].service_id = service_id;trace_afs_alist (alist->debug_id,1 , afs_alist_trace_alloc);return alist; }
@@ -150,7 +146,7 @@ struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *net,if (!vllist->servers[0 ].server) goto error_vl; - alist =afs_alloc_addrlist (nr, service); + alist =afs_alloc_addrlist (nr);if (!alist) goto error;
fs/afs/fs_probe.c +2 -2
@@ -154,12 +154,12 @@ void afs_fileserver_probe_result(struct afs_call *call)if (call->service_id ==YFS_FS_SERVICE ) { server->probe.is_yfs = true;set_bit (AFS_SERVER_FL_IS_YFS , &server->flags); - addr->service_id = call->service_id; + server->service_id = call->service_id; }else { server->probe.not_yfs = true;if (!server->probe.is_yfs) {clear_bit (AFS_SERVER_FL_IS_YFS , &server->flags); - addr->service_id = call->service_id; + server->service_id = call->service_id; } cap0 =ntohl (call->tmp);if (cap0 &AFS3_VICED_CAPABILITY_64BITFILES )
fs/afs/fsclient.c +9 -5
@@ -1620,7 +1620,9 @@ int afs_fs_give_up_all_callbacks(struct afs_net *net,if (!call)return -ENOMEM ; - call->key = key; + call->key = key; + call->peer =rxrpc_kernel_get_peer (ac->alist->addrs[ac->index].peer); + call->service_id = server->service_id;/* marshall the parameters */ bp = call->request;
@@ -1722,10 +1724,12 @@ bool afs_fs_get_capabilities(struct afs_net *net, struct afs_server *server,if (!call)return false; - call->key = key; - call->server =afs_use_server (server, afs_server_trace_get_caps); - call->upgrade = true; - call->async = true; + call->key = key; + call->server =afs_use_server (server, afs_server_trace_get_caps); + call->peer =rxrpc_kernel_get_peer (ac->alist->addrs[ac->index].peer); + call->service_id = server->service_id; + call->upgrade = true; + call->async = true; call->max_lifespan =AFS_PROBE_MAX_LIFESPAN ;/* marshall the parameters */
fs/afs/internal.h +11 -7
@@ -74,7 +74,6 @@ enum afs_call_state {struct afs_address {struct rxrpc_peer *peer; -u16 service_id;short last_error;/* Last error from this address */ };
@@ -108,6 +107,7 @@ struct afs_call {struct work_struct async_work;/* async I/O processor */ struct work_struct work;/* actual work processor */ struct rxrpc_call *rxcall;/* RxRPC call handle */ +struct rxrpc_peer *peer;/* Remote endpoint */ struct key *key;/* security for this call */ struct afs_net *net;/* The network namespace */ struct afs_server *server;/* The fileserver record if fs op (pins ref) */
@@ -435,6 +435,7 @@ struct afs_vlserver {#define AFS_VLSERVER_PROBE_LOCAL_FAILURE 0x08/* A local failure prevented a probe */ } probe; +u16 service_id;/* Service ID we're using */ u16 port;u16 name_len;/* Length of name */ char name[];/* Server name, case-flattened */
@@ -527,6 +528,7 @@ struct afs_server {refcount_t ref;/* Object refcount */ atomic_t active;/* Active user count */ u32 addr_version;/* Address list version */ +u16 service_id;/* Service ID we're using. */ unsigned int rtt;/* Server's current RTT in uS */ unsigned int debug_id;/* Debugging ID for traces */
@@ -970,7 +972,7 @@ static inline bool afs_is_folio_dirty_mmapped(unsigned long priv)* addr_list.c */ struct afs_addr_list *afs_get_addrlist (struct afs_addr_list *alist,enum afs_alist_trace reason); -extern struct afs_addr_list *afs_alloc_addrlist (unsigned int nr,u16 service_id); +extern struct afs_addr_list *afs_alloc_addrlist (unsigned int nr);extern void afs_put_addrlist (struct afs_addr_list *alist,enum afs_alist_trace reason); extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *, const char *, size_t, char,
@@ -1317,11 +1319,13 @@ extern int afs_protocol_error(struct afs_call *, enum afs_eproto_cause);static inline void afs_make_op_call (struct afs_operation *op,struct afs_call *call,gfp_t gfp) { - op->call = call; - op->type = call->type; - call->op = op; - call->key = op->key; - call->intr = !(op->flags &AFS_OPERATION_UNINTR ); + op->call = call; + op->type = call->type; + call->op = op; + call->key = op->key; + call->intr = !(op->flags &AFS_OPERATION_UNINTR ); + call->peer =rxrpc_kernel_get_peer (op->ac.alist->addrs[op->ac.index].peer); + call->service_id = op->server->service_id;afs_make_call (&op->ac, call, gfp); }
fs/afs/rxrpc.c +6 -6
@@ -178,6 +178,8 @@ void afs_put_call(struct afs_call *call)ASSERT (!work_pending (&call->async_work));ASSERT (call->type->name !=NULL ); +rxrpc_kernel_put_peer (call->peer); +if (call->rxcall) {rxrpc_kernel_shutdown_call (net->socket, call->rxcall);rxrpc_kernel_put_call (net->socket, call->rxcall);
@@ -296,8 +298,6 @@ static void afs_notify_end_request_tx(struct sock *sock,*/ void afs_make_call (struct afs_addr_cursor *ac,struct afs_call *call,gfp_t gfp) { -struct afs_address *addr = &ac->alist->addrs[ac->index]; -struct rxrpc_peer *peer = addr->peer;struct rxrpc_call *rxcall;struct msghdr msg;struct kvec iov[1 ];
@@ -305,7 +305,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)s64 tx_total_len;int ret; -_enter (",{%pISp}," ,rxrpc_kernel_remote_addr (addr->peer)); +_enter (",{%pISp+%u}," ,rxrpc_kernel_remote_addr (call->peer), call->service_id);ASSERT (call->type !=NULL );ASSERT (call->type->name !=NULL );
@@ -334,7 +334,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) }/* create a call */ - rxcall = rxrpc_kernel_begin_call(call->net->socket, peer, call->key, + rxcall = rxrpc_kernel_begin_call(call->net->socket, call->peer, call->key, (unsigned long)call, tx_total_len, call->max_lifespan,
@@ -342,7 +342,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) (call->async ? afs_wake_up_async_call : afs_wake_up_call_waiter), - addr->service_id, + call->service_id, call->upgrade, (call->intr ?RXRPC_PREINTERRUPTIBLE : RXRPC_UNINTERRUPTIBLE),
@@ -462,7 +462,7 @@ static void afs_log_error(struct afs_call *call, s32 remote_abort) max = m +1 ;pr_notice ("kAFS: Peer reported %s failure on %s [%pISp]\n" , msg, call->type->name, -rxrpc_kernel_remote_addr (call->alist->addrs[call->addr_ix].peer)); +rxrpc_kernel_remote_addr (call->peer)); } }
fs/afs/server.c +1 -0
@@ -214,6 +214,7 @@ static struct afs_server *afs_alloc_server(struct afs_cell *cell,spin_lock_init (&server->probe_lock); server->cell = cell; server->rtt =UINT_MAX ; + server->service_id =FS_SERVICE ;afs_inc_servers_outstanding (net);trace_afs_server (server->debug_id,1 ,1 , afs_server_trace_alloc);
fs/afs/vl_list.c +2 -1
@@ -23,6 +23,7 @@ struct afs_vlserver *afs_alloc_vlserver(const char *name, size_t name_len,spin_lock_init (&vlserver->probe_lock); vlserver->rtt =UINT_MAX ; vlserver->name_len = name_len; + vlserver->service_id =VL_SERVICE ; vlserver->port = port;memcpy (vlserver->name, name, name_len); }
@@ -92,7 +93,7 @@ static struct afs_addr_list *afs_extract_vl_addrs(struct afs_net *net,const u8 *b = *_b;int ret = -EINVAL ; - alist =afs_alloc_addrlist (nr_addrs,VL_SERVICE ); + alist =afs_alloc_addrlist (nr_addrs);if (!alist)return ERR_PTR (-ENOMEM );if (nr_addrs ==0 )
fs/afs/vl_probe.c +2 -2
@@ -107,12 +107,12 @@ void afs_vlserver_probe_result(struct afs_call *call)if (call->service_id ==YFS_VL_SERVICE ) { server->probe.flags |=AFS_VLSERVER_PROBE_IS_YFS ;set_bit (AFS_VLSERVER_FL_IS_YFS , &server->flags); - addr->service_id = call->service_id; + server->service_id = call->service_id; }else { server->probe.flags |=AFS_VLSERVER_PROBE_NOT_YFS ;if (!(server->probe.flags &AFS_VLSERVER_PROBE_IS_YFS )) {clear_bit (AFS_VLSERVER_FL_IS_YFS , &server->flags); - addr->service_id = call->service_id; + server->service_id = call->service_id; } }
fs/afs/vlclient.c +12 -2
@@ -149,6 +149,8 @@ struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *vc, call->key = vc->key; call->ret_vldb = entry; call->max_lifespan =AFS_VL_MAX_LIFESPAN ; + call->peer =rxrpc_kernel_get_peer (vc->ac.alist->addrs[vc->ac.index].peer); + call->service_id = vc->server->service_id;/* Marshall the parameters */ bp = call->request;
@@ -211,7 +213,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call) count =ntohl (*bp); nentries =min (nentries, count); - alist =afs_alloc_addrlist (nentries,FS_SERVICE ); + alist =afs_alloc_addrlist (nentries);if (!alist)return -ENOMEM ; alist->version = uniquifier;
@@ -288,6 +290,8 @@ struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *vc, call->key = vc->key; call->ret_alist =NULL ; call->max_lifespan =AFS_VL_MAX_LIFESPAN ; + call->peer =rxrpc_kernel_get_peer (vc->ac.alist->addrs[vc->ac.index].peer); + call->service_id = vc->server->service_id;/* Marshall the parameters */ bp = call->request;
@@ -407,6 +411,8 @@ struct afs_call *afs_vl_get_capabilities(struct afs_net *net, call->key = key; call->vlserver =afs_get_vlserver (server); call->server_index = server_index; + call->peer =rxrpc_kernel_get_peer (ac->alist->addrs[ac->index].peer); + call->service_id = server->service_id; call->upgrade = true; call->async = true; call->max_lifespan =AFS_PROBE_MAX_LIFESPAN ;
@@ -462,7 +468,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)if (call->count >YFS_MAXENDPOINTS )return afs_protocol_error (call, afs_eproto_yvl_fsendpt_num); - alist =afs_alloc_addrlist (call->count,FS_SERVICE ); + alist =afs_alloc_addrlist (call->count);if (!alist)return -ENOMEM ; alist->version = uniquifier;
@@ -652,6 +658,8 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc, call->key = vc->key; call->ret_alist =NULL ; call->max_lifespan =AFS_VL_MAX_LIFESPAN ; + call->peer =rxrpc_kernel_get_peer (vc->ac.alist->addrs[vc->ac.index].peer); + call->service_id = vc->server->service_id;/* Marshall the parameters */ bp = call->request;
@@ -769,6 +777,8 @@ char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *vc) call->key = vc->key; call->ret_str =NULL ; call->max_lifespan =AFS_VL_MAX_LIFESPAN ; + call->peer =rxrpc_kernel_get_peer (vc->ac.alist->addrs[vc->ac.index].peer); + call->service_id = vc->server->service_id;/* marshall the parameters */ bp = call->request;
David Howells
maintainerPATCH 22/41 afs: Fold the afs_addr_cursor struct in
In reply to David HowellsFold the afs_addr_cursor struct into the afs_operation struct and the afs_vl_cursor struct and fold its operations into their callers also.
--- fs/afs/addr_list.c | 53 ----------------------- fs/afs/fs_operation.c | 21 +++++++-- fs/afs/fs_probe.c | 41 ++++++++---------- fs/afs/fsclient.c | 31 +++++++++----- fs/afs/internal.h | 58 ++++++++++++------------- fs/afs/rotate.c | 71 ++++++++++++++++++------------ fs/afs/rxrpc.c | 13 ++---- fs/afs/server.c | 6 +-- fs/afs/vl_probe.c | 23 +++++----- fs/afs/vl_rotate.c | 88 ++++++++++++++++++++++++++++---------- fs/afs/vlclient.c | 34 ++++++++------- include/trace/events/afs.h | 18 ++++++-- 12 files changed, 243 insertions(+), 214 deletions(-)
fs/afs/addr_list.c +0 -53
@@ -375,56 +375,3 @@ int afs_merge_fs_addr6(struct afs_net *net, struct afs_addr_list *alist, alist->nr_addrs++;return 0 ; } - -/* -* Get an address to try. -*/ -bool afs_iterate_addresses (struct afs_addr_cursor *ac) -{ -unsigned long set, failed; -int index; - -if (!ac->alist) -return false; - - set = ac->alist->responded; - failed = ac->alist->probe_failed; -_enter ("%lx-%lx-%lx,%d" , set, failed, ac->tried, ac->index); - - ac->nr_iterations++; - - set &= ~(failed | ac->tried); - -if (!set) -return false; - - index =READ_ONCE (ac->alist->preferred); -if (test_bit (index, &set)) - goto selected; - - index =__ffs (set); - -selected: - ac->index = index; -set_bit (index, &ac->tried); - ac->call_responded = false; -return true; -} - -/* -* Release an address list cursor. -*/ -void afs_end_cursor (struct afs_addr_cursor *ac) -{ -struct afs_addr_list *alist; - - alist = ac->alist; -if (alist) { -if (ac->call_responded && - ac->index != alist->preferred && -test_bit (ac->alist->preferred, &ac->tried)) -WRITE_ONCE (alist->preferred, ac->index); -afs_put_addrlist (alist, afs_alist_trace_put_end_cursor); - ac->alist =NULL ; - } -}
fs/afs/fs_operation.c +17 -4
@@ -179,6 +179,7 @@ void afs_wait_for_operation(struct afs_operation *op)_enter ("" );while (afs_select_fileserver (op)) { + op->call_responded = false; op->call_error =0 ; op->call_abort_code =0 ; op->cb_s_break = op->server->cb_s_break;
@@ -191,17 +192,19 @@ void afs_wait_for_operation(struct afs_operation *op) op->call_error = -ENOTSUPP ;if (op->call) { -afs_wait_for_call_to_complete (op->call, &op->ac); +afs_wait_for_call_to_complete (op->call); op->call_abort_code = op->call->abort_code; op->call_error = op->call->error; op->call_responded = op->call->responded; - op->ac.call_responded = true; -WRITE_ONCE (op->ac.alist->addrs[op->ac.index].last_error, +WRITE_ONCE (op->alist->addrs[op->addr_index].last_error, op->call_error);afs_put_call (op->call); } } +if (op->call_responded) +set_bit (AFS_SERVER_FL_RESPONDING , &op->server->flags); +if (!afs_op_error (op)) {_debug ("success" ); op->ops->success (op);
@@ -227,6 +230,7 @@ void afs_wait_for_operation(struct afs_operation *op)*/ int afs_put_operation (struct afs_operation *op) { +struct afs_addr_list *alist;int i, ret =afs_op_error (op);_enter ("op=%08x,%d" , op->debug_id, ret);
@@ -249,7 +253,16 @@ int afs_put_operation(struct afs_operation *op)kfree (op->more_files); } -afs_end_cursor (&op->ac); + alist = op->alist; +if (alist) { +if (op->call_responded && + op->addr_index != alist->preferred && +test_bit (alist->preferred, &op->addr_tried)) +WRITE_ONCE (alist->preferred, op->addr_index); +afs_put_addrlist (alist, afs_alist_trace_put_operation); + op->alist =NULL ; + } +afs_put_serverlist (op->net, op->server_list);afs_put_volume (op->net, op->volume, afs_volume_trace_put_put_op);key_put (op->key);
fs/afs/fs_probe.c +19 -22
77 lines not on this page · raw message
fs/afs/fsclient.c +20 -11
@@ -1605,10 +1605,8 @@ static const struct afs_call_type afs_RXFSGiveUpAllCallBacks = {/* * Flush all the callbacks we have on a server. */ -int afs_fs_give_up_all_callbacks (struct afs_net *net, -struct afs_server *server, -struct afs_addr_cursor *ac, -struct key *key) +int afs_fs_give_up_all_callbacks (struct afs_net *net,struct afs_server *server, +struct afs_address *addr,struct key *key) {struct afs_call *call;__be32 *bp;
@@ -1621,7 +1619,7 @@ int afs_fs_give_up_all_callbacks(struct afs_net *net,return -ENOMEM ; call->key = key; - call->peer =rxrpc_kernel_get_peer (ac->alist->addrs[ac->index].peer); + call->peer =rxrpc_kernel_get_peer (addr->peer); call->service_id = server->service_id;/* marshall the parameters */
@@ -1629,9 +1627,11 @@ int afs_fs_give_up_all_callbacks(struct afs_net *net, *bp++ =htonl (FSGIVEUPALLCALLBACKS ); call->server =afs_use_server (server, afs_server_trace_give_up_cb); -afs_make_call (ac, call,GFP_NOFS ); -afs_wait_for_call_to_complete (call, ac); +afs_make_call (call,GFP_NOFS ); +afs_wait_for_call_to_complete (call); ret = call->error; +if (call->responded) +set_bit (AFS_SERVER_FL_RESPONDING , &server->flags);afs_put_call (call);return ret; }
@@ -1695,6 +1695,12 @@ static int afs_deliver_fs_get_capabilities(struct afs_call *call)return 0 ; } +static void afs_fs_get_capabilities_destructor (struct afs_call *call) +{ +afs_put_addrlist (call->probe_alist, afs_alist_trace_put_getcaps); +afs_flat_call_destructor (call); +} +/* * FS.GetCapabilities operation type */
@@ -1703,7 +1709,7 @@ static const struct afs_call_type afs_RXFSGetCapabilities = { .op = afs_FS_GetCapabilities, .deliver = afs_deliver_fs_get_capabilities, .done = afs_fileserver_probe_result, - .destructor = afs_flat_call_destructor, + .destructor = afs_fs_get_capabilities_destructor, };/*
@@ -1713,7 +1719,8 @@ static const struct afs_call_type afs_RXFSGetCapabilities = {* ->done() - otherwise we return false to indicate we didn't even try. */ bool afs_fs_get_capabilities (struct afs_net *net,struct afs_server *server, -struct afs_addr_cursor *ac,struct key *key) +struct afs_addr_list *alist,unsigned int addr_index, +struct key *key) {struct afs_call *call;__be32 *bp;
@@ -1726,7 +1733,9 @@ bool afs_fs_get_capabilities(struct afs_net *net, struct afs_server *server, call->key = key; call->server =afs_use_server (server, afs_server_trace_get_caps); - call->peer =rxrpc_kernel_get_peer (ac->alist->addrs[ac->index].peer); + call->peer =rxrpc_kernel_get_peer (alist->addrs[addr_index].peer); + call->probe_alist =afs_get_addrlist (alist, afs_alist_trace_get_getcaps); + call->probe_index = addr_index; call->service_id = server->service_id; call->upgrade = true; call->async = true;
@@ -1737,7 +1746,7 @@ bool afs_fs_get_capabilities(struct afs_net *net, struct afs_server *server, *bp++ =htonl (FSGETCAPABILITIES );trace_afs_make_fs_call (call,NULL ); -afs_make_call (ac, call,GFP_NOFS ); +afs_make_call (call,GFP_NOFS );afs_put_call (call);return true; }
fs/afs/internal.h +28 -30
146 lines not on this page · raw message
fs/afs/rotate.c +44 -27
154 lines not on this page · raw message
fs/afs/rxrpc.c +3 -10
@@ -189,7 +189,6 @@ void afs_put_call(struct afs_call *call) call->type->destructor (call);afs_unuse_server_notime (call->net, call->server, afs_server_trace_put_call); -afs_put_addrlist (call->alist, afs_alist_trace_put_call);kfree (call->request); trace_afs_call(call->debug_id, afs_call_trace_free, 0, o,
@@ -296,7 +295,7 @@ static void afs_notify_end_request_tx(struct sock *sock,* Initiate a call and synchronously queue up the parameters for dispatch. Any * error is stored into the call struct, which the caller must check for. */ -void afs_make_call (struct afs_addr_cursor *ac,struct afs_call *call,gfp_t gfp) +void afs_make_call (struct afs_call *call,gfp_t gfp) {struct rxrpc_call *rxcall;struct msghdr msg;
@@ -314,9 +313,6 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) call, call->type->name,key_serial (call->key), atomic_read(&call->net->nr_outstanding_calls)); - call->addr_ix = ac->index; - call->alist =afs_get_addrlist (ac->alist, afs_alist_trace_get_make_call); -/* Work out the length we're going to transmit. This is awkward for * calls such as FS.StoreData where there's an extra injection of data * after the initial fixed part.
@@ -392,7 +388,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)/* Note that at this point, we may have received the reply or an abort * - and an asynchronous call may already have completed. * -* afs_wait_for_call_to_complete(call, ac) +* afs_wait_for_call_to_complete(call) * must be called to synchronously clean up. */ return ;
@@ -577,7 +573,7 @@ static void afs_deliver_to_call(struct afs_call *call)/* * Wait synchronously for a call to complete. */ -void afs_wait_for_call_to_complete (struct afs_call *call,struct afs_addr_cursor *ac) +void afs_wait_for_call_to_complete (struct afs_call *call) {bool rxrpc_complete = false;
@@ -627,9 +623,6 @@ void afs_wait_for_call_to_complete(struct afs_call *call, struct afs_addr_cursorafs_set_call_complete (call, -EINTR ,0 ); } } - -if (call->error ==0 || call->error == -ECONNABORTED ) - call->responded = true; }/*
fs/afs/server.c +1 -5
@@ -435,12 +435,8 @@ static void __afs_put_server(struct afs_net *net, struct afs_server *server)static void afs_give_up_callbacks (struct afs_net *net,struct afs_server *server) {struct afs_addr_list *alist =rcu_access_pointer (server->addresses); -struct afs_addr_cursor ac = { - .alist = alist, - .index = alist->preferred, - }; -afs_fs_give_up_all_callbacks (net, server, &ac,NULL ); +afs_fs_give_up_all_callbacks (net, server, &alist->addrs[alist->preferred],NULL ); }/*
fs/afs/vl_probe.c +12 -11
@@ -46,12 +46,12 @@ static void afs_done_one_vl_probe(struct afs_vlserver *server, bool wake_up)*/ void afs_vlserver_probe_result (struct afs_call *call) { -struct afs_addr_list *alist = call->alist; +struct afs_addr_list *alist = call->probe_alist;struct afs_vlserver *server = call->vlserver; -struct afs_address *addr = &alist->addrs[call->addr_ix]; +struct afs_address *addr = &alist->addrs[call->probe_index];unsigned int server_index = call->server_index;unsigned int rtt_us =0 ; -unsigned int index = call->addr_ix; +unsigned int index = call->probe_index;bool have_result = false;int ret = call->error;
@@ -148,25 +148,25 @@ static bool afs_do_probe_vlserver(struct afs_net *net,unsigned int server_index, struct afs_error *_e) { - struct afs_addr_cursor ac = { - .index =0 , - }; + struct afs_addr_list *alist;struct afs_call *call; +unsigned int index;bool in_progress = false;_enter ("%s" , server->name);read_lock (&server->lock); - ac.alist =rcu_dereference_protected (server->addresses, -lockdep_is_held (&server->lock)); + alist =rcu_dereference_protected (server->addresses, +lockdep_is_held (&server->lock)); +afs_get_addrlist (alist, afs_alist_trace_get_vlprobe);read_unlock (&server->lock); -atomic_set (&server->probe_outstanding, ac.alist->nr_addrs); +atomic_set (&server->probe_outstanding, alist->nr_addrs);memset (&server->probe,0 ,sizeof (server->probe)); server->probe.rtt =UINT_MAX ; -for (ac.index =0 ; ac.index < ac.alist->nr_addrs; ac.index++) { - call =afs_vl_get_capabilities (net, &ac, key, server, +for (index =0 ; index < alist->nr_addrs; index++) { + call =afs_vl_get_capabilities (net, alist, index, key, server, server_index);if (!IS_ERR (call)) {afs_prioritise_error (_e, call->error, call->abort_code);
@@ -178,6 +178,7 @@ static bool afs_do_probe_vlserver(struct afs_net *net, } } +afs_put_addrlist (alist, afs_alist_trace_put_vlprobe);return in_progress; }
fs/afs/vl_rotate.c +66 -22
194 lines not on this page · raw message
fs/afs/vlclient.c +19 -15
@@ -149,7 +149,7 @@ struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *vc, call->key = vc->key; call->ret_vldb = entry; call->max_lifespan =AFS_VL_MAX_LIFESPAN ; - call->peer =rxrpc_kernel_get_peer (vc->ac.alist->addrs[vc->ac.index].peer); + call->peer =rxrpc_kernel_get_peer (vc->alist->addrs[vc->addr_index].peer); call->service_id = vc->server->service_id;/* Marshall the parameters */
@@ -161,8 +161,8 @@ struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *vc,memset ((void *)bp + volnamesz,0 , padsz);trace_afs_make_vl_call (call); -afs_make_call (&vc->ac, call,GFP_KERNEL ); -afs_wait_for_call_to_complete (call, &vc->ac); +afs_make_call (call,GFP_KERNEL ); +afs_wait_for_call_to_complete (call); vc->call_abort_code = call->abort_code; vc->call_error = call->error; vc->call_responded = call->responded;
@@ -290,7 +290,7 @@ struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *vc, call->key = vc->key; call->ret_alist =NULL ; call->max_lifespan =AFS_VL_MAX_LIFESPAN ; - call->peer =rxrpc_kernel_get_peer (vc->ac.alist->addrs[vc->ac.index].peer); + call->peer =rxrpc_kernel_get_peer (vc->alist->addrs[vc->addr_index].peer); call->service_id = vc->server->service_id;/* Marshall the parameters */
@@ -310,8 +310,8 @@ struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *vc, r->uuid.node[i] =htonl (u->node[i]);trace_afs_make_vl_call (call); -afs_make_call (&vc->ac, call,GFP_KERNEL ); -afs_wait_for_call_to_complete (call, &vc->ac); +afs_make_call (call,GFP_KERNEL ); +afs_wait_for_call_to_complete (call); vc->call_abort_code = call->abort_code; vc->call_error = call->error; vc->call_responded = call->responded;
@@ -371,6 +371,7 @@ static int afs_deliver_vl_get_capabilities(struct afs_call *call)static void afs_destroy_vl_get_capabilities (struct afs_call *call) { +afs_put_addrlist (call->probe_alist, afs_alist_trace_put_vlgetcaps);afs_put_vlserver (call->net, call->vlserver);afs_flat_call_destructor (call); }
@@ -394,7 +395,8 @@ static const struct afs_call_type afs_RXVLGetCapabilities = {* other end supports. */ struct afs_call *afs_vl_get_capabilities (struct afs_net *net, -struct afs_addr_cursor *ac, +struct afs_addr_list *alist, +unsigned int addr_index,struct key *key,struct afs_vlserver *server,unsigned int server_index)
@@ -411,7 +413,9 @@ struct afs_call *afs_vl_get_capabilities(struct afs_net *net, call->key = key; call->vlserver =afs_get_vlserver (server); call->server_index = server_index; - call->peer =rxrpc_kernel_get_peer (ac->alist->addrs[ac->index].peer); + call->peer =rxrpc_kernel_get_peer (alist->addrs[addr_index].peer); + call->probe_alist =afs_get_addrlist (alist, afs_alist_trace_get_vlgetcaps); + call->probe_index = addr_index; call->service_id = server->service_id; call->upgrade = true; call->async = true;
@@ -423,7 +427,7 @@ struct afs_call *afs_vl_get_capabilities(struct afs_net *net,/* Can't take a ref on server */ trace_afs_make_vl_call (call); -afs_make_call (ac, call,GFP_KERNEL ); +afs_make_call (call,GFP_KERNEL );return call; }
@@ -658,7 +662,7 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc, call->key = vc->key; call->ret_alist =NULL ; call->max_lifespan =AFS_VL_MAX_LIFESPAN ; - call->peer =rxrpc_kernel_get_peer (vc->ac.alist->addrs[vc->ac.index].peer); + call->peer =rxrpc_kernel_get_peer (vc->alist->addrs[vc->addr_index].peer); call->service_id = vc->server->service_id;/* Marshall the parameters */
@@ -668,8 +672,8 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc,memcpy (bp, uuid,sizeof (*uuid));/* Type opr_uuid */ trace_afs_make_vl_call (call); -afs_make_call (&vc->ac, call,GFP_KERNEL ); -afs_wait_for_call_to_complete (call, &vc->ac); +afs_make_call (call,GFP_KERNEL ); +afs_wait_for_call_to_complete (call); vc->call_abort_code = call->abort_code; vc->call_error = call->error; vc->call_responded = call->responded;
@@ -777,7 +781,7 @@ char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *vc) call->key = vc->key; call->ret_str =NULL ; call->max_lifespan =AFS_VL_MAX_LIFESPAN ; - call->peer =rxrpc_kernel_get_peer (vc->ac.alist->addrs[vc->ac.index].peer); + call->peer =rxrpc_kernel_get_peer (vc->alist->addrs[vc->addr_index].peer); call->service_id = vc->server->service_id;/* marshall the parameters */
@@ -786,8 +790,8 @@ char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *vc)/* Can't take a ref on server */ trace_afs_make_vl_call (call); -afs_make_call (&vc->ac, call,GFP_KERNEL ); -afs_wait_for_call_to_complete (call, &vc->ac); +afs_make_call (call,GFP_KERNEL ); +afs_wait_for_call_to_complete (call); vc->call_abort_code = call->abort_code; vc->call_error = call->error; vc->call_responded = call->responded;
include/trace/events/afs.h +14 -4
@@ -204,21 +204,31 @@ enum yfs_cm_operation {#define afs_alist_traces \ EM(afs_alist_trace_alloc, "ALLOC ") \ + EM(afs_alist_trace_get_getcaps, "GET getcap") \ EM(afs_alist_trace_get_fsrotate_set, "GET fs-rot") \ - EM(afs_alist_trace_get_make_call, "GET mkcall") \ EM(afs_alist_trace_get_probe, "GET probe ") \ + EM(afs_alist_trace_get_vlgetcaps, "GET vgtcap") \ + EM(afs_alist_trace_get_vlprobe, "GET vprobe") \ EM(afs_alist_trace_get_vlrotate_set, "GET vl-rot") \ - EM(afs_alist_trace_put_call, "PUT call ") \ - EM(afs_alist_trace_put_end_cursor, "PUT endcur") \ EM(afs_alist_trace_put_getaddru, "PUT GtAdrU") \ + EM(afs_alist_trace_put_getcaps, "PUT getcap") \ + EM(afs_alist_trace_put_next_server, "PUT nx-srv") \ + EM(afs_alist_trace_put_op_failed, "PUT op-fai") \ + EM(afs_alist_trace_put_operation, "PUT op ") \ EM(afs_alist_trace_put_parse_empty, "PUT p-empt") \ EM(afs_alist_trace_put_parse_error, "PUT p-err ") \ EM(afs_alist_trace_put_probe, "PUT probe ") \ - EM(afs_alist_trace_put_retry_server, "PUT retry ") \ + EM(afs_alist_trace_put_restart_rotate, "PUT rstrot") \ EM(afs_alist_trace_put_server, "PUT server") \ EM(afs_alist_trace_put_server_dup, "PUT sv-dup") \ EM(afs_alist_trace_put_server_oom, "PUT sv-oom") \ EM(afs_alist_trace_put_server_update, "PUT sv-upd") \ + EM(afs_alist_trace_put_vlgetcaps, "PUT vgtcap") \ + EM(afs_alist_trace_put_vlprobe, "PUT vprobe") \ + EM(afs_alist_trace_put_vlrotate_end, "PUT vr-end") \ + EM(afs_alist_trace_put_vlrotate_fail, "PUT vr-fai") \ + EM(afs_alist_trace_put_vlrotate_next, "PUT vr-nxt") \ + EM(afs_alist_trace_put_vlrotate_restart,"PUT vr-rst") \ EM(afs_alist_trace_put_vlserver, "PUT vlsrvr") \ EM(afs_alist_trace_put_vlserver_old, "PUT vs-old") \ E_(afs_alist_trace_free, "FREE ")
David Howells
maintainerPATCH 23/41 rxrpc: Create a procfile to display outstanding clien conn bundles
In reply to David HowellsCreate /proc/net/rxrpc/bundles to display outstanding rxrpc client connection bundles.
--- net/rxrpc/ar-internal.h | 4 +++ net/rxrpc/conn_client.c | 10 ++++++ net/rxrpc/net_ns.c | 4 +++ net/rxrpc/proc.c | 76 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+)
net/rxrpc/ar-internal.h +4 -0
@@ -68,6 +68,7 @@ struct rxrpc_net {atomic_t nr_calls;/* Count of allocated calls */ atomic_t nr_conns; +struct list_head bundle_proc_list;/* List of bundles for proc */ struct list_head conn_proc_list;/* List of conns in this namespace for proc */ struct list_head service_conns;/* Service conns in this namespace */ rwlock_t conn_lock;/* Lock for ->conn_proc_list, ->service_conns */
@@ -432,6 +433,7 @@ struct rxrpc_bundle {struct rxrpc_local *local;/* Representation of local endpoint */ struct rxrpc_peer *peer;/* Remote endpoint */ struct key *key;/* Security details */ +struct list_head proc_link;/* Link in net->bundle_proc_list */ const struct rxrpc_security *security;/* applied security module */ refcount_t ref;atomic_t active;/* Number of active users */
@@ -445,6 +447,7 @@ struct rxrpc_bundle {struct rb_node local_node;/* Node in local->client_conns */ struct list_head waiting_calls;/* Calls waiting for channels */ unsigned long avail_chans;/* Mask of available channels */ +unsigned int conn_ids[4 ];/* Connection IDs. */ struct rxrpc_connection *conns[4 ];/* The connections in the bundle (max 4) */ };
@@ -1167,6 +1170,7 @@ void rxrpc_put_peer(struct rxrpc_peer *, enum rxrpc_peer_trace);*/ extern const struct seq_operations rxrpc_call_seq_ops;extern const struct seq_operations rxrpc_connection_seq_ops; +extern const struct seq_operations rxrpc_bundle_seq_ops;extern const struct seq_operations rxrpc_peer_seq_ops;extern const struct seq_operations rxrpc_local_seq_ops;
net/rxrpc/conn_client.c +10 -0
@@ -91,6 +91,10 @@ static struct rxrpc_bundle *rxrpc_alloc_bundle(struct rxrpc_call *call,atomic_set (&bundle->active,1 );INIT_LIST_HEAD (&bundle->waiting_calls);trace_rxrpc_bundle (bundle->debug_id,1 , rxrpc_bundle_new); + +write_lock (&bundle->local->rxnet->conn_lock); +list_add_tail (&bundle->proc_link, &bundle->local->rxnet->bundle_proc_list); +write_unlock (&bundle->local->rxnet->conn_lock); }return bundle; }
@@ -109,6 +113,9 @@ static void rxrpc_free_bundle(struct rxrpc_bundle *bundle) {trace_rxrpc_bundle (bundle->debug_id,refcount_read (&bundle->ref), rxrpc_bundle_free); +write_lock (&bundle->local->rxnet->conn_lock); +list_del (&bundle->proc_link); +write_unlock (&bundle->local->rxnet->conn_lock);rxrpc_put_peer (bundle->peer, rxrpc_peer_put_bundle);key_put (bundle->key);kfree (bundle);
@@ -338,6 +345,7 @@ static bool rxrpc_add_conn_to_bundle(struct rxrpc_bundle *bundle, old = bundle->conns[slot];if (old) { bundle->conns[slot] =NULL ; + bundle->conn_ids[slot] =0 ;trace_rxrpc_client (old,-1 , rxrpc_client_replace);rxrpc_put_connection (old, rxrpc_conn_put_noreuse); }
@@ -351,6 +359,7 @@ static bool rxrpc_add_conn_to_bundle(struct rxrpc_bundle *bundle,rxrpc_activate_bundle (bundle); conn->bundle_shift = shift; bundle->conns[slot] = conn; + bundle->conn_ids[slot] = conn->debug_id;for (i =0 ; i <RXRPC_MAXCALLS ; i++)set_bit (shift + i, &bundle->avail_chans);return true;
@@ -671,6 +680,7 @@ static void rxrpc_unbundle_conn(struct rxrpc_connection *conn)if (bundle->conns[bindex] == conn) {_debug ("clear slot %u" , bindex); bundle->conns[bindex] =NULL ; + bundle->conn_ids[bindex] =0 ;for (i =0 ; i <RXRPC_MAXCALLS ; i++)clear_bit (conn->bundle_shift + i, &bundle->avail_chans);rxrpc_put_client_connection_id (bundle->local, conn);
net/rxrpc/net_ns.c +4 -0
@@ -45,6 +45,7 @@ static __net_init int rxrpc_init_net(struct net *net)atomic_set (&rxnet->nr_calls,1 );atomic_set (&rxnet->nr_conns,1 ); +INIT_LIST_HEAD (&rxnet->bundle_proc_list);INIT_LIST_HEAD (&rxnet->conn_proc_list);INIT_LIST_HEAD (&rxnet->service_conns);rwlock_init (&rxnet->conn_lock);
@@ -78,6 +79,9 @@ static __net_init int rxrpc_init_net(struct net *net)proc_create_net ("conns" ,0444 , rxnet->proc_net, &rxrpc_connection_seq_ops,sizeof (struct seq_net_private )); +proc_create_net ("bundles" ,0444 , rxnet->proc_net, + &rxrpc_bundle_seq_ops, +sizeof (struct seq_net_private ));proc_create_net ("peers" ,0444 , rxnet->proc_net, &rxrpc_peer_seq_ops,sizeof (struct seq_net_private ));
net/rxrpc/proc.c +76 -0
82 lines not on this page · raw message
Re: [PATCH 23/41] rxrpc: Create a procfile to display outstanding clien conn bundles
Quoted 2 lines · David Howells
Create
/proc/net/rxrpc/bundlesto display outstanding rxrpc client connection bundles.
There is a typo in the subject
s/clien/client/
David Howells
maintainerPATCH 24/41 afs: Add some more info to /proc/net/afs/servers
In reply to David HowellsIn /proc/net/afs/servers, show the cell name and the last error for each address in the server's list.
--- fs/afs/fs_operation.c | 2 -- fs/afs/fs_probe.c | 2 ++ fs/afs/proc.c | 24 ++++++++++++++++-------- fs/afs/rotate.c | 2 ++ fs/afs/vl_rotate.c | 2 ++ 5 files changed, 22 insertions(+), 10 deletions(-)
fs/afs/fs_operation.c +0 -2
@@ -196,8 +196,6 @@ void afs_wait_for_operation(struct afs_operation *op) op->call_abort_code = op->call->abort_code; op->call_error = op->call->error; op->call_responded = op->call->responded; -WRITE_ONCE (op->alist->addrs[op->addr_index].last_error, - op->call_error);afs_put_call (op->call); } }
fs/afs/fs_probe.c +2 -0
@@ -107,6 +107,8 @@ void afs_fileserver_probe_result(struct afs_call *call)_enter ("%pU,%u" , &server->uuid, index); +WRITE_ONCE (addr->last_error, ret); +spin_lock (&server->probe_lock);switch (ret) {
fs/afs/proc.c +16 -8
@@ -377,31 +377,39 @@ static int afs_proc_servers_show(struct seq_file *m, void *v) {struct afs_server *server;struct afs_addr_list *alist; +unsigned long failed;int i;if (v ==SEQ_START_TOKEN ) { -seq_puts (m,"UUID REF ACT\n" ); +seq_puts (m,"UUID REF ACT CELL\n" );return 0 ; } server = list_entry(v, struct afs_server, proc_link); alist =rcu_dereference (server->addresses); -seq_printf (m,"%pU %3d %3d\n" , +seq_printf (m,"%pU %3d %3d %s\n" , &server->uuid,refcount_read (&server->ref), -atomic_read (&server->active)); +atomic_read (&server->active), + server->cell->name);seq_printf (m," - info: fl=%lx rtt=%u brk=%x\n" , server->flags, server->rtt, server->cb_s_break);seq_printf (m," - probe: last=%d out=%d\n" , (int )(jiffies - server->probed_at) /HZ ,atomic_read (&server->probe_outstanding)); + failed = alist->probe_failed;seq_printf (m," - ALIST v=%u rsp=%lx f=%lx\n" , alist->version, alist->responded, alist->probe_failed); -for (i =0 ; i < alist->nr_addrs; i++) -seq_printf (m," [%x] %pISpc%s rtt=%d\n" , - i,rxrpc_kernel_remote_addr (alist->addrs[i].peer), - alist->preferred == i ?"*" :"" , -rxrpc_kernel_get_srtt (alist->addrs[i].peer)); +for (i =0 ; i < alist->nr_addrs; i++) { +const struct afs_address *addr = &alist->addrs[i]; + +seq_printf (m," [%x] %pISpc%s rtt=%d err=%d\n" , + i,rxrpc_kernel_remote_addr (addr->peer), + alist->preferred == i ?"*" : +test_bit (i, &failed) ?"!" :"" , +rxrpc_kernel_get_srtt (addr->peer), + addr->last_error); + }return 0 ; }
fs/afs/rotate.c +2 -0
@@ -133,6 +133,8 @@ bool afs_select_fileserver(struct afs_operation *op)if (op->nr_iterations ==0 ) goto start; +WRITE_ONCE (alist->addrs[op->addr_index].last_error, error); +/* Evaluate the result of the previous operation, if there was one. */ switch (op->call_error) {case 0 :
fs/afs/vl_rotate.c +2 -0
@@ -114,6 +114,8 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)if (vc->nr_iterations ==0 ) goto start; +WRITE_ONCE (alist->addrs[vc->addr_index].last_error, error); +/* Evaluate the result of the previous operation, if there was one. */ switch (error) {default :
David Howells
maintainerPATCH 25/41 afs: Remove the unimplemented afs_cmp_addr_list()
In reply to David HowellsRemove afs_cmp_addr_list() as it was never implemented.
--- fs/afs/addr_list.c | 13 ------------- 1 file changed, 13 deletions(-)
fs/afs/addr_list.c +0 -13
@@ -244,19 +244,6 @@ struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *net,return ERR_PTR (ret); } -/* -* Compare old and new address lists to see if there's been any change. -* - How to do this in better than O(Nlog(N)) time? -* - We don't really want to sort the address list, but would rather take the -* list as we got it so as not to undo record rotation by the DNS server. -*/ -#if 0 -static int afs_cmp_addr_list (const struct afs_addr_list *a1, -const struct afs_addr_list *a2) -{ -} -#endif -/* * Perform a DNS query for VL servers and build a up an address list. */
David Howells
maintainerPATCH 26/41 afs: Provide a way to configure address priorities
In reply to David HowellsAFS servers may have multiple addresses, but the client can't easily judge between them as to which one is best. For instance, an address that has a larger RTT might actually have a better bandwidth because it goes through a switch rather than being directly connected - but we can't work this out dynamically unless we push through sufficient data that we can measure it.
To allow the administrator to configure this, add a list of preference weightings for server addresses by IPv4/IPv6 address or subnet and allow this to be viewed through a procfile and altered by writing text commands to that same file. Preference rules can be added/updated by:
echo "add <proto> <addr>[/<subnet>] <prior>" >/proc/fs/afs/addr_prefs echo "add udp 1.2.3.4 1000" >/proc/fs/afs/addr_prefs echo "add udp 192.168.0.0/16 3000" >/proc/fs/afs/addr_prefs echo "add udp 1001:2002:0:6::/64 4000" >/proc/fs/afs/addr_prefs
and removed by:
echo "del <proto> <addr>[/<subnet>]" >/proc/fs/afs/addr_prefs echo "del udp 1.2.3.4" >/proc/fs/afs/addr_prefs
where the priority is a number between 0 and 65535.
The list is split between IPv4 and IPv6 addresses and each sublist is kept in numerical order, with rules that would otherwise match but have different subnet masking being ordered with the most specific submatch first.
A subsequent patch will apply these rules.
--- fs/afs/Makefile | 1 + fs/afs/addr_prefs.c | 449 ++++++++++++++++++++++++++++++++++++++++++++ fs/afs/internal.h | 29 +++ fs/afs/main.c | 1 + fs/afs/proc.c | 55 +++++- 5 files changed, 534 insertions(+), 1 deletion(-) create mode 100644 fs/afs/addr_prefs.c
fs/afs/Makefile +1 -0
@@ -5,6 +5,7 @@ kafs-y := \ addr_list.o \ + addr_prefs.o \ callback.o \ cell.o \ cmservice.o \
fs/afs/addr_prefs.c new file +449 -0
449 lines not on this page · raw message
fs/afs/internal.h +29 -0
@@ -72,6 +72,28 @@ enum afs_call_state { AFS_CALL_COMPLETE, /* Completed or failed */ }; +/* +* Address preferences. +*/ +struct afs_addr_preference { +union { +struct in_addr ipv4_addr;/* AF_INET address to compare against */ +struct in6_addr ipv6_addr;/* AF_INET6 address to compare against */ + }; +sa_family_t family;/* Which address to use */ +u16 prio;/* Priority */ +u8 subnet_mask;/* How many bits to compare */ +}; + +struct afs_addr_preference_list { +struct rcu_head rcu; +u16 version;/* Incremented when prefs list changes */ +u8 ipv6_off;/* Offset of IPv6 addresses */ +u8 nr;/* Number of addresses in total */ +u8 max_prefs;/* Number of prefs allocated */ + struct afs_addr_preference prefs[] __counted_by(max_prefs); +}; +struct afs_address {struct rxrpc_peer *peer;short last_error;/* Last error from this address */
@@ -315,6 +337,8 @@ struct afs_net {struct proc_dir_entry *proc_afs;/* /proc/net/afs directory */ struct afs_sysnames *sysnames;rwlock_t sysnames_lock; +struct afs_addr_preference_list __rcu *address_prefs; +u16 address_pref_version;/* Statistics counters */ atomic_t n_lookup;/* Number of lookups done */
@@ -981,6 +1005,11 @@ extern int afs_merge_fs_addr4(struct afs_net *net, struct afs_addr_list *addr,extern int afs_merge_fs_addr6 (struct afs_net *net,struct afs_addr_list *addr,__be32 *xdr,u16 port); +/* +* addr_prefs.c +*/ +int afs_proc_addr_prefs_write (struct file *file,char *buf,size_t size); +/* * callback.c */
fs/afs/main.c +1 -0
@@ -158,6 +158,7 @@ static void __net_exit afs_net_exit(struct net *net_ns)afs_close_socket (net);afs_proc_cleanup (net);afs_put_sysnames (net->sysnames); +kfree_rcu (net->address_prefs, rcu); }static struct pernet_operations afs_net_ops = {
fs/afs/proc.c +54 -1
67 lines not on this page · raw message
David Howells
maintainerPATCH 27/41 afs: Mark address lists with configured priorities
In reply to David HowellsAdd a field to each address in an address list (afs_addr_list struct) that records the current priority for that address according to the address preference table. We don't want to do this every time we use an address list, so the version number of the address preference table is recorded in the address list too and we only re-mark the list when we see the version change.
These numbers are then displayed through /proc/net/afs/servers.
--- fs/afs/addr_prefs.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ fs/afs/internal.h | 4 +++ fs/afs/proc.c | 9 ++--- 3 files changed, 91 insertions(+), 4 deletions(-)
fs/afs/addr_prefs.c +82 -0
@@ -447,3 +447,85 @@ int afs_proc_addr_prefs_write(struct file *file, char *buf, size_t size) ret = -EINVAL ; goto done; } + +/* +* Mark the priorities on an address list if the address preferences table has +* changed. The caller must hold the RCU read lock. +*/ +void afs_get_address_preferences_rcu (struct afs_net *net,struct afs_addr_list *alist) +{ +const struct afs_addr_preference_list *preflist = +rcu_dereference (net->address_prefs); +const struct sockaddr_in6 *sin6; +const struct sockaddr_in *sin; +const struct sockaddr *sa; +struct afs_addr_preference test; +enum cmp_ret cmp; +int i, j; + +if (!preflist || !preflist->nr || !alist->nr_addrs || +smp_load_acquire (&alist->addr_pref_version) == preflist->version) +return ; + + test.family =AF_INET ; + test.subnet_mask =32 ; + test.prio =0 ; +for (i =0 ; i < alist->nr_ipv4; i++) { + sa =rxrpc_kernel_remote_addr (alist->addrs[i].peer); + sin = (const struct sockaddr_in *)sa; + test.ipv4_addr = sin->sin_addr; +for (j =0 ; j < preflist->ipv6_off; j++) { + cmp =afs_cmp_address_pref (&test, &preflist->prefs[j]); +switch (cmp) { +case CONTINUE_SEARCH : +continue ; +case INSERT_HERE : +break ; +case EXACT_MATCH : +case SUBNET_MATCH : +WRITE_ONCE (alist->addrs[i].prio, preflist->prefs[j].prio); +break ; + } + } + } + + test.family =AF_INET6 ; + test.subnet_mask =128 ; + test.prio =0 ; +for (; i < alist->nr_addrs; i++) { + sa =rxrpc_kernel_remote_addr (alist->addrs[i].peer); + sin6 = (const struct sockaddr_in6 *)sa; + test.ipv6_addr = sin6->sin6_addr; +for (j = preflist->ipv6_off; j < preflist->nr; j++) { + cmp =afs_cmp_address_pref (&test, &preflist->prefs[j]); +switch (cmp) { +case CONTINUE_SEARCH : +continue ; +case INSERT_HERE : +break ; +case EXACT_MATCH : +case SUBNET_MATCH : +WRITE_ONCE (alist->addrs[i].prio, preflist->prefs[j].prio); +break ; + } + } + } + +smp_store_release (&alist->addr_pref_version, preflist->version); +} + +/* +* Mark the priorities on an address list if the address preferences table has +* changed. Avoid taking the RCU read lock if we can. +*/ +void afs_get_address_preferences (struct afs_net *net,struct afs_addr_list *alist) +{ +if (!net->address_prefs || +/* Load version before prefs */ +smp_load_acquire (&net->address_pref_version) == alist->addr_pref_version) +return ; + +rcu_read_lock (); +afs_get_address_preferences_rcu (net, alist); +rcu_read_unlock (); +}
fs/afs/internal.h +4 -0
@@ -97,6 +97,7 @@ struct afs_addr_preference_list {struct afs_address {struct rxrpc_peer *peer;short last_error;/* Last error from this address */ +u16 prio;/* Address priority */ };/*
@@ -107,6 +108,7 @@ struct afs_addr_list {refcount_t usage;u32 version;/* Version */ unsigned int debug_id; +unsigned int addr_pref_version;/* Version of address preference list */ unsigned char max_addrs;unsigned char nr_addrs;unsigned char preferred;/* Preferred address */
@@ -1009,6 +1011,8 @@ extern int afs_merge_fs_addr6(struct afs_net *net, struct afs_addr_list *addr,* addr_prefs.c */ int afs_proc_addr_prefs_write (struct file *file,char *buf,size_t size); +void afs_get_address_preferences_rcu (struct afs_net *net,struct afs_addr_list *alist); +void afs_get_address_preferences (struct afs_net *net,struct afs_addr_list *alist);/* * callback.c
fs/afs/proc.c +5 -4
@@ -447,17 +447,18 @@ static int afs_proc_servers_show(struct seq_file *m, void *v) (int )(jiffies - server->probed_at) /HZ , atomic_read(&server->probe_outstanding)); failed = alist->probe_failed; -seq_printf (m," - ALIST v=%u rsp=%lx f=%lx\n" , - alist->version, alist->responded, alist->probe_failed); +seq_printf (m," - ALIST v=%u rsp=%lx f=%lx ap=%u\n" , + alist->version, alist->responded, alist->probe_failed, + alist->addr_pref_version);for (i =0 ; i < alist->nr_addrs; i++) {const struct afs_address *addr = &alist->addrs[i]; -seq_printf (m," [%x] %pISpc%s rtt=%d err=%d\n" , +seq_printf (m," [%x] %pISpc%s rtt=%d err=%d p=%u\n" , i,rxrpc_kernel_remote_addr (addr->peer), alist->preferred == i ?"*" :test_bit (i, &failed) ?"!" :"" ,rxrpc_kernel_get_srtt (addr->peer), - addr->last_error); + addr->last_error, addr->prio); }return 0 ; }
David Howells
maintainerPATCH 28/41 afs: Dispatch fileserver probes in priority order
In reply to David HowellsWhen probing all the addresses for a fileserver, dispatch them in order of descending priority to try and get back highest priority one first.
Also add a tracepoint to show the transmission and completion of the probes.
--- fs/afs/fs_probe.c | 25 +++++++++++++++++++++++-- include/trace/events/afs.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-)
fs/afs/fs_probe.c +23 -2
@@ -102,7 +102,7 @@ void afs_fileserver_probe_result(struct afs_call *call)struct afs_address *addr = &alist->addrs[call->probe_index];struct afs_server *server = call->server;unsigned int index = call->probe_index; -unsigned int rtt_us =0 , cap0; +unsigned int rtt_us =-1 , cap0;int ret = call->error;_enter ("%pU,%u" , &server->uuid, index);
@@ -182,6 +182,7 @@ void afs_fileserver_probe_result(struct afs_call *call) out:spin_unlock (&server->probe_lock); +trace_afs_fs_probe (server, false, alist, index, call->error, call->abort_code, rtt_us);_debug ("probe %pU [%u] %pISpc rtt=%d ret=%d" , &server->uuid, index,rxrpc_kernel_remote_addr (alist->addrs[index].peer), rtt_us, ret);
@@ -207,6 +208,8 @@ void afs_fs_probe_fileserver(struct afs_net *net, struct afs_server *server,afs_get_addrlist (alist, afs_alist_trace_get_probe);read_unlock (&server->fs_lock); +afs_get_address_preferences (net, alist); + server->probed_at = jiffies;atomic_set (&server->probe_outstanding, all ? alist->nr_addrs :1 );memset (&server->probe,0 ,sizeof (server->probe));
@@ -217,10 +220,28 @@ void afs_fs_probe_fileserver(struct afs_net *net, struct afs_server *server, all = true;if (all) { -for (index =0 ; index < alist->nr_addrs; index++) +unsigned long unprobed = (1UL << alist->nr_addrs) -1 ; +unsigned int i; +int best_prio; + +while (unprobed) { + best_prio =-1 ; + index =0 ; +for (i =0 ; i < alist->nr_addrs; i++) { +if (test_bit (i, &unprobed) && + alist->addrs[i].prio > best_prio) { + index = i; + best_prio = alist->addrs[i].prio; + } + } +__clear_bit (index, &unprobed); + +trace_afs_fs_probe (server, true, alist, index,0 ,0 ,0 );if (!afs_fs_get_capabilities (net, server, alist, index, key))afs_fs_probe_not_done (net, server, alist, index); + } }else { +trace_afs_fs_probe (server, true, alist, index,0 ,0 ,0 );if (!afs_fs_get_capabilities (net, server, alist, index, key))afs_fs_probe_not_done (net, server, alist, index); }
include/trace/events/afs.h +33 -0
@@ -1387,6 +1387,39 @@ TRACE_EVENT(afs_alist, __entry->ref) ); +TRACE_EVENT (afs_fs_probe, + TP_PROTO(struct afs_server *server, bool tx, struct afs_addr_list *alist, + unsigned int addr_index, int error, s32 abort_code, unsigned int rtt_us), + +TP_ARGS (server, tx, alist, addr_index, error, abort_code, rtt_us), + +TP_STRUCT__entry ( + __field(unsigned int, server) + __field(bool, tx) + __field(u16, addr_index) + __field(short, error) + __field(s32, abort_code) + __field(unsigned int, rtt_us) + __field_struct(struct sockaddr_rxrpc, srx) + ), + +TP_fast_assign ( + __entry->server = server->debug_id; + __entry->tx = tx; + __entry->addr_index = addr_index; + __entry->error = error; + __entry->abort_code = abort_code; + __entry->rtt_us = rtt_us; +memcpy (&__entry->srx,rxrpc_kernel_remote_srx (alist->addrs[addr_index].peer), + sizeof(__entry->srx)); + ), + +TP_printk ("s=%08x %s ax=%u e=%d ac=%d rtt=%d %pISpc" , + __entry->server, __entry->tx ?"tx" :"rx" , __entry->addr_index, + __entry->error, __entry->abort_code, __entry->rtt_us, + &__entry->srx.transport) + ); +#endif /* _TRACE_AFS_H */ /* This part must be outside protection */
David Howells
maintainerPATCH 29/41 afs: Dispatch vlserver probes in priority order
In reply to David HowellsWhen probing all the addresses for a volume location server, dispatch them in order of descending priority to try and get back highest priority one first.
Also add a tracepoint to show the transmission and completion of the probes.
--- fs/afs/internal.h | 1 + fs/afs/vl_list.c | 2 ++ fs/afs/vl_probe.c | 20 ++++++++++++++++++-- include/trace/events/afs.h | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-)
fs/afs/internal.h +1 -0
@@ -447,6 +447,7 @@ struct afs_vlserver {rwlock_t lock;/* Lock on addresses */ refcount_t ref;unsigned int rtt;/* Server's current RTT in uS */ +unsigned int debug_id;/* Probe state */ wait_queue_head_t probe_wq;
fs/afs/vl_list.c +2 -0
@@ -13,6 +13,7 @@ struct afs_vlserver *afs_alloc_vlserver(const char *name, size_t name_len, unsigned short port) {struct afs_vlserver *vlserver; +static atomic_t debug_ids; vlserver =kzalloc (struct_size (vlserver, name, name_len +1 ),GFP_KERNEL );
@@ -21,6 +22,7 @@ struct afs_vlserver *afs_alloc_vlserver(const char *name, size_t name_len,rwlock_init (&vlserver->lock);init_waitqueue_head (&vlserver->probe_wq);spin_lock_init (&vlserver->probe_lock); + vlserver->debug_id =atomic_inc_return (&debug_ids); vlserver->rtt =UINT_MAX ; vlserver->name_len = name_len; vlserver->service_id =VL_SERVICE ;
fs/afs/vl_probe.c +18 -2
@@ -131,6 +131,7 @@ void afs_vlserver_probe_result(struct afs_call *call) out:spin_unlock (&server->probe_lock); +trace_afs_vl_probe (server, false, alist, index, call->error, call->abort_code, rtt_us);_debug ("probe [%u][%u] %pISpc rtt=%d ret=%d" , server_index, index,rxrpc_kernel_remote_addr (addr->peer), rtt_us, ret);
@@ -150,8 +151,10 @@ static bool afs_do_probe_vlserver(struct afs_net *net, {struct afs_addr_list *alist;struct afs_call *call; -unsigned int index; +unsigned long unprobed; +unsigned int index, i;bool in_progress = false; +int best_prio;_enter ("%s" , server->name);
@@ -165,7 +168,20 @@ static bool afs_do_probe_vlserver(struct afs_net *net,memset (&server->probe,0 ,sizeof (server->probe)); server->probe.rtt =UINT_MAX ; -for (index =0 ; index < alist->nr_addrs; index++) { + unprobed = (1UL << alist->nr_addrs) -1 ; +while (unprobed) { + best_prio =-1 ; + index =0 ; +for (i =0 ; i < alist->nr_addrs; i++) { +if (test_bit (i, &unprobed) && + alist->addrs[i].prio > best_prio) { + index = i; + best_prio = alist->addrs[i].prio; + } + } +__clear_bit (index, &unprobed); + +trace_afs_vl_probe (server, true, alist, index,0 ,0 ,0 ); call =afs_vl_get_capabilities (net, alist, index, key, server, server_index);if (!IS_ERR (call)) {
include/trace/events/afs.h +34 -0
@@ -1420,6 +1420,40 @@ TRACE_EVENT(afs_fs_probe, &__entry->srx.transport) ); +TRACE_EVENT (afs_vl_probe, + TP_PROTO(struct afs_vlserver *server, bool tx, struct afs_addr_list *alist, + unsigned int addr_index, int error, s32 abort_code, unsigned int rtt_us), + +TP_ARGS (server, tx, alist, addr_index, error, abort_code, rtt_us), + +TP_STRUCT__entry ( + __field(unsigned int, server) + __field(bool, tx) + __field(unsigned short, flags) + __field(u16, addr_index) + __field(short, error) + __field(s32, abort_code) + __field(unsigned int, rtt_us) + __field_struct(struct sockaddr_rxrpc, srx) + ), + +TP_fast_assign ( + __entry->server = server->debug_id; + __entry->tx = tx; + __entry->addr_index = addr_index; + __entry->error = error; + __entry->abort_code = abort_code; + __entry->rtt_us = rtt_us; +memcpy (&__entry->srx,rxrpc_kernel_remote_srx (alist->addrs[addr_index].peer), + sizeof(__entry->srx)); + ), + +TP_printk ("vl=%08x %s ax=%u e=%d ac=%d rtt=%d %pISpc" , + __entry->server, __entry->tx ?"tx" :"rx" , __entry->addr_index, + __entry->error, __entry->abort_code, __entry->rtt_us, + &__entry->srx.transport) + ); +#endif /* _TRACE_AFS_H */ /* This part must be outside protection */
David Howells
maintainerPATCH 30/41 afs: Keep a record of the current fileserver endpoint state
In reply to David HowellsKeep a record of the current fileserver endpoint state, including the probe state, and replace it when a new probe is started rather than just squelching the old state and overwriting it. Clearance of the old state can cause a race if there's another thread also currently trying to communicate with that server.
It appears that this race might be the culprit for some occasions where kafs complains about invalid data in the RPC reply because the rotation algorithm fell all the way through without actually issuing an RPC call and the error return got filled in from the probe state (which has a zero error recorded). Whatever happens to be in the caller's reply buffer is then taken as the response.
--- fs/afs/fs_operation.c | 19 +-- fs/afs/fs_probe.c | 235 ++++++++++++++++++++++--------------- fs/afs/fsclient.c | 8 +- fs/afs/internal.h | 66 +++++++---- fs/afs/proc.c | 21 ++-- fs/afs/rotate.c | 80 +++++++------ fs/afs/server.c | 69 +++++++---- fs/afs/vl_alias.c | 4 +- fs/afs/vl_probe.c | 2 +- fs/afs/vlclient.c | 4 +- include/trace/events/afs.h | 69 ++++++++--- 11 files changed, 366 insertions(+), 211 deletions(-)
fs/afs/fs_operation.c +11 -8
@@ -228,6 +228,7 @@ void afs_wait_for_operation(struct afs_operation *op)*/ int afs_put_operation (struct afs_operation *op) { +struct afs_endpoint_state *estate = op->estate;struct afs_addr_list *alist;int i, ret =afs_op_error (op);
@@ -251,14 +252,16 @@ int afs_put_operation(struct afs_operation *op)kfree (op->more_files); } - alist = op->alist; -if (alist) { -if (op->call_responded && - op->addr_index != alist->preferred && -test_bit (alist->preferred, &op->addr_tried)) -WRITE_ONCE (alist->preferred, op->addr_index); -afs_put_addrlist (alist, afs_alist_trace_put_operation); - op->alist =NULL ; +if (estate) { + alist = estate->addresses; +if (alist) { +if (op->call_responded && + op->addr_index != alist->preferred && +test_bit (alist->preferred, &op->addr_tried)) +WRITE_ONCE (alist->preferred, op->addr_index); + } +afs_put_endpoint_state (estate, afs_estate_trace_put_operation); + op->estate =NULL ; }afs_put_serverlist (op->net, op->server_list);
fs/afs/fs_probe.c +143 -92
419 lines not on this page · raw message
fs/afs/fsclient.c +4 -4
@@ -1697,7 +1697,7 @@ static int afs_deliver_fs_get_capabilities(struct afs_call *call)static void afs_fs_get_capabilities_destructor (struct afs_call *call) { -afs_put_addrlist (call->probe_alist, afs_alist_trace_put_getcaps); +afs_put_endpoint_state (call->probe, afs_estate_trace_put_getcaps);afs_flat_call_destructor (call); }
@@ -1719,7 +1719,7 @@ static const struct afs_call_type afs_RXFSGetCapabilities = {* ->done() - otherwise we return false to indicate we didn't even try. */ bool afs_fs_get_capabilities (struct afs_net *net,struct afs_server *server, -struct afs_addr_list *alist,unsigned int addr_index, +struct afs_endpoint_state *estate,unsigned int addr_index,struct key *key) {struct afs_call *call;
@@ -1733,8 +1733,8 @@ bool afs_fs_get_capabilities(struct afs_net *net, struct afs_server *server, call->key = key; call->server =afs_use_server (server, afs_server_trace_get_caps); - call->peer =rxrpc_kernel_get_peer (alist->addrs[addr_index].peer); - call->probe_alist =afs_get_addrlist (alist, afs_alist_trace_get_getcaps); + call->peer =rxrpc_kernel_get_peer (estate->addresses->addrs[addr_index].peer); + call->probe =afs_get_endpoint_state (estate, afs_estate_trace_get_getcaps); call->probe_index = addr_index; call->service_id = server->service_id; call->upgrade = true;
fs/afs/internal.h +45 -21
142 lines not on this page · raw message
fs/afs/proc.c +12 -9
@@ -424,8 +424,9 @@ static const struct seq_operations afs_proc_cell_vlservers_ops = {*/ static int afs_proc_servers_show (struct seq_file *m,void *v) { -struct afs_server *server; +struct afs_endpoint_state *estate;struct afs_addr_list *alist; +struct afs_server *server;unsigned long failed;int i;
@@ -435,7 +436,8 @@ static int afs_proc_servers_show(struct seq_file *m, void *v) } server = list_entry(v, struct afs_server, proc_link); - alist =rcu_dereference (server->addresses); + estate =rcu_dereference (server->endpoint_state); + alist = estate->addresses; seq_printf(m, "%pU %3d %3d %s\n", &server->uuid, refcount_read(&server->ref),
@@ -443,13 +445,14 @@ static int afs_proc_servers_show(struct seq_file *m, void *v) server->cell->name);seq_printf (m," - info: fl=%lx rtt=%u brk=%x\n" , server->flags, server->rtt, server->cb_s_break); -seq_printf (m," - probe: last=%d out=%d\n" , - (int )(jiffies - server->probed_at) /HZ , -atomic_read (&server->probe_outstanding)); - failed = alist->probe_failed; -seq_printf (m," - ALIST v=%u rsp=%lx f=%lx ap=%u\n" , - alist->version, alist->responded, alist->probe_failed, - alist->addr_pref_version); +seq_printf (m," - probe: last=%d\n" , + (int )(jiffies - server->probed_at) /HZ ); + failed = estate->failed_set; +seq_printf (m," - ESTATE pq=%x np=%u rsp=%lx f=%lx\n" , + estate->probe_seq,atomic_read (&estate->nr_probing), + estate->responsive_set, estate->failed_set); +seq_printf (m," - ALIST v=%u ap=%u\n" , + alist->version, alist->addr_pref_version);for (i =0 ; i < alist->nr_addrs; i++) {const struct afs_address *addr = &alist->addrs[i];
fs/afs/rotate.c +46 -34
201 lines not on this page · raw message
fs/afs/server.c +46 -23
172 lines not on this page · raw message
fs/afs/vl_alias.c +2 -2
@@ -41,8 +41,8 @@ static int afs_compare_fs_alists(const struct afs_server *server_a,const struct afs_addr_list *la, *lb;int a =0 , b =0 , addr_matches =0 ; - la =rcu_dereference (server_a->addresses); - lb =rcu_dereference (server_b->addresses); + la =rcu_dereference (server_a->endpoint_state)->addresses; + lb =rcu_dereference (server_b->endpoint_state)->addresses;while (a < la->nr_addrs && b < lb->nr_addrs) {unsigned long pa = (unsigned long )la->addrs[a].peer;
fs/afs/vl_probe.c +1 -1
@@ -46,7 +46,7 @@ static void afs_done_one_vl_probe(struct afs_vlserver *server, bool wake_up)*/ void afs_vlserver_probe_result (struct afs_call *call) { -struct afs_addr_list *alist = call->probe_alist; +struct afs_addr_list *alist = call->vl_probe;struct afs_vlserver *server = call->vlserver;struct afs_address *addr = &alist->addrs[call->probe_index];unsigned int server_index = call->server_index;
fs/afs/vlclient.c +2 -2
@@ -371,7 +371,7 @@ static int afs_deliver_vl_get_capabilities(struct afs_call *call)static void afs_destroy_vl_get_capabilities (struct afs_call *call) { -afs_put_addrlist (call->probe_alist, afs_alist_trace_put_vlgetcaps); +afs_put_addrlist (call->vl_probe, afs_alist_trace_put_vlgetcaps);afs_put_vlserver (call->net, call->vlserver);afs_flat_call_destructor (call); }
@@ -414,7 +414,7 @@ struct afs_call *afs_vl_get_capabilities(struct afs_net *net, call->vlserver =afs_get_vlserver (server); call->server_index = server_index; call->peer =rxrpc_kernel_get_peer (alist->addrs[addr_index].peer); - call->probe_alist =afs_get_addrlist (alist, afs_alist_trace_get_vlgetcaps); + call->vl_probe =afs_get_addrlist (alist, afs_alist_trace_get_vlgetcaps); call->probe_index = addr_index; call->service_id = server->service_id; call->upgrade = true;
include/trace/events/afs.h +54 -15
124 lines not on this page · raw message
David Howells
maintainerPATCH 31/41 afs: Combine the endpoint state bools into a bitmask
In reply to David HowellsCombine the endpoint state bool-type members into a bitmask so that some of them can be waited upon more easily.
--- fs/afs/fs_probe.c | 30 +++++++++++++++--------------- fs/afs/internal.h | 12 ++++++------ 2 files changed, 21 insertions(+), 21 deletions(-)
fs/afs/fs_probe.c +15 -15
@@ -77,7 +77,7 @@ static void afs_schedule_fs_probe(struct afs_net *net,static void afs_finished_fs_probe (struct afs_net *net,struct afs_server *server,struct afs_endpoint_state *estate) { -bool responded = estate->responded; +bool responded =test_bit (AFS_ESTATE_RESPONDED , &estate->flags);write_seqlock (&net->fs_lock);if (responded) {
@@ -121,7 +121,7 @@ static void afs_fs_probe_not_done(struct afs_net *net,trace_afs_io_error (0 , -ENOMEM , afs_io_error_fs_probe_fail);spin_lock (&server->probe_lock); - estate->local_failure = true; +set_bit (AFS_ESTATE_LOCAL_FAILURE , &estate->flags);if (estate->error ==0 ) estate->error = -ENOMEM ;
@@ -156,7 +156,7 @@ void afs_fileserver_probe_result(struct afs_call *call) estate->error =0 ; goto responded;case -ECONNABORTED : -if (!estate->responded) { +if (!test_bit (AFS_ESTATE_RESPONDED , &estate->flags)) { estate->abort_code = call->abort_code; estate->error = ret; }
@@ -164,7 +164,7 @@ void afs_fileserver_probe_result(struct afs_call *call)case -ENOMEM :case -ENONET :clear_bit (index, &estate->responsive_set); - estate->local_failure = true; +set_bit (AFS_ESTATE_LOCAL_FAILURE , &estate->flags);trace_afs_io_error (call->debug_id, ret, afs_io_error_fs_probe_fail); goto out;case -ECONNRESET :/* Responded, but call expired. */
@@ -179,7 +179,7 @@ void afs_fileserver_probe_result(struct afs_call *call)default :clear_bit (index, &estate->responsive_set);set_bit (index, &estate->failed_set); -if (!estate->responded && +if (!test_bit (AFS_ESTATE_RESPONDED , &estate->flags) && (estate->error ==0 || estate->error == -ETIMEDOUT || estate->error == -ETIME ))
@@ -192,13 +192,13 @@ void afs_fileserver_probe_result(struct afs_call *call)clear_bit (index, &estate->failed_set);if (call->service_id ==YFS_FS_SERVICE ) { - estate->is_yfs = true; +set_bit (AFS_ESTATE_IS_YFS , &estate->flags);set_bit (AFS_SERVER_FL_IS_YFS , &server->flags); server->service_id = call->service_id; }else { - estate->not_yfs = true; -if (!estate->is_yfs) { - estate->is_yfs = false; +set_bit (AFS_ESTATE_NOT_YFS , &estate->flags); +if (!test_bit (AFS_ESTATE_IS_YFS , &estate->flags)) { +clear_bit (AFS_SERVER_FL_IS_YFS , &server->flags); server->service_id = call->service_id; } cap0 =ntohl (call->tmp);
@@ -216,7 +216,7 @@ void afs_fileserver_probe_result(struct afs_call *call) }smp_wmb ();/* Set rtt before responded. */ - estate->responded = true; +set_bit (AFS_ESTATE_RESPONDED , &estate->flags);set_bit (index, &estate->responsive_set);set_bit (AFS_SERVER_FL_RESPONDING , &server->flags); out:
@@ -264,7 +264,7 @@ void afs_fs_probe_fileserver(struct afs_net *net, struct afs_server *server,atomic_set (&estate->nr_probing, alist->nr_addrs);rcu_assign_pointer (server->endpoint_state, estate); - old->superseded = true; +set_bit (AFS_ESTATE_SUPERSEDED , &old->flags);write_unlock (&server->fs_lock); trace_afs_estate(estate->server_id, estate->probe_seq, refcount_read(&estate->ref),
@@ -317,7 +317,7 @@ int afs_wait_for_fs_probes(struct afs_server_list *slist, unsigned long untried) estate =rcu_dereference (server->endpoint_state);if (!atomic_read (&estate->nr_probing))__clear_bit (i, &untried); -if (estate->responded) +if (test_bit (AFS_ESTATE_RESPONDED , &estate->flags)) have_responders = true; } }
@@ -344,7 +344,7 @@ int afs_wait_for_fs_probes(struct afs_server_list *slist, unsigned long untried)for (i =0 ; i < slist->nr_servers; i++) {if (test_bit (i, &untried)) { server = slist->servers[i].server; -if (estate->responded) +if (test_bit (AFS_ESTATE_RESPONDED , &estate->flags)) goto stop;if (atomic_read (&estate->nr_probing)) still_probing = true;
@@ -521,7 +521,7 @@ int afs_wait_for_one_fs_probe(struct afs_server *server, struct afs_endpoint_staprepare_to_wait_event (&server->probe_wq, &wait, is_intr ?TASK_INTERRUPTIBLE :TASK_UNINTERRUPTIBLE );if (timo ==0 || - estate->responded || +test_bit (AFS_ESTATE_RESPONDED , &estate->flags) ||atomic_read (&estate->nr_probing) ==0 || (is_intr &&signal_pending (current)))break ;
@@ -531,7 +531,7 @@ int afs_wait_for_one_fs_probe(struct afs_server *server, struct afs_endpoint_stafinish_wait (&server->probe_wq, &wait); dont_wait: -if (estate->responded) +if (test_bit (AFS_ESTATE_RESPONDED , &estate->flags))return 0 ;if (is_intr &&signal_pending (current))return -ERESTARTSYS ;
fs/afs/internal.h +6 -6
@@ -534,16 +534,16 @@ struct afs_endpoint_state {refcount_t ref;unsigned int server_id;/* Debug ID of server */ unsigned int probe_seq;/* Probe sequence (from server::probe_counter) */ -atomic_t nr_probing;/* Number of outstanding probes */ unsigned int rtt;/* Best RTT in uS (or UINT_MAX) */ s32 abort_code;short error; - bool responded:1; - bool is_yfs:1; - bool not_yfs:1; - bool local_failure:1; - bool superseded:1; /* Set if has been superseded */ +unsigned long flags; +#define AFS_ESTATE_RESPONDED 0/* Set if the server responded */ +#define AFS_ESTATE_SUPERSEDED 1/* Set if this record has been superseded */ +#define AFS_ESTATE_IS_YFS 2/* Set if probe upgraded to YFS */ +#define AFS_ESTATE_NOT_YFS 3/* Set if probe didn't upgrade to YFS */ +#define AFS_ESTATE_LOCAL_FAILURE 4/* Set if there was a local failure (eg. ENOMEM) */ };/*
David Howells
maintainerPATCH 32/41 afs: Fix file locking on R/O volumes to operate in local mode
In reply to David HowellsAFS doesn't really do locking on R/O volumes as fileservers don't maintain state with each other and thus a lock on a R/O volume file on one fileserver will not be be visible to someone looking at the same file on another fileserver.
Further, the server may return an error if you try it.
Fix this by doing what other AFS clients do and handle filelocking on R/O volume files entirely within the client and don't touch the server.
--- fs/afs/super.c | 2 ++ 1 file changed, 2 insertions(+)
fs/afs/super.c +2 -0
@@ -407,6 +407,8 @@ static int afs_validate_fc(struct fs_context *fc)return PTR_ERR (volume); ctx->volume = volume; +if (volume->type !=AFSVL_RWVOL ) + ctx->flock_mode = afs_flock_mode_local; }return 0 ;
David Howells
maintainerPATCH 33/41 afs: Mark a superblock for an R/O or Backup volume as SB_RDONLY
In reply to David HowellsMark a superblock that is for for an R/O or Backup volume as SB_RDONLY when mounting it.
--- fs/afs/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/afs/super.c +3 -1
@@ -407,8 +407,10 @@ static int afs_validate_fc(struct fs_context *fc)return PTR_ERR (volume); ctx->volume = volume; -if (volume->type !=AFSVL_RWVOL ) +if (volume->type !=AFSVL_RWVOL ) { ctx->flock_mode = afs_flock_mode_local; + fc->sb_flags |=SB_RDONLY ; + } }return 0 ;
David Howells
maintainerPATCH 34/41 afs: Make it possible to find the volumes that are using a server
In reply to David HowellsMake it possible to find the afs_volume structs that are using an afs_server struct to aid in breaking volume callbacks.
The way this is done is that each afs_volume already has an array of afs_server_entry records that point to the servers where that volume might be found. An afs_volume backpointer and a list node is added to each entry and each entry is then added to an RCU-traversable list on the afs_server to which it points.
--- fs/afs/cell.c | 1 + fs/afs/internal.h | 23 +++++---- fs/afs/server.c | 1 + fs/afs/server_list.c | 112 +++++++++++++++++++++++++++++++++++++++---- fs/afs/vl_alias.c | 2 +- fs/afs/volume.c | 36 ++++++++------ 6 files changed, 143 insertions(+), 32 deletions(-)
fs/afs/cell.c +1 -0
@@ -161,6 +161,7 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net,refcount_set (&cell->ref,1 );atomic_set (&cell->active,0 );INIT_WORK (&cell->manager, afs_manage_cell_work); +spin_lock_init (&cell->vs_lock); cell->volumes =RB_ROOT ;INIT_HLIST_HEAD (&cell->proc_volumes);seqlock_init (&cell->volume_lock);
fs/afs/internal.h +15 -8
@@ -414,6 +414,7 @@ struct afs_cell {unsigned int debug_id;/* The volumes belonging to this cell */ +spinlock_t vs_lock;/* Lock for server->volumes */ struct rb_root volumes;/* Tree of volumes on this server */ struct hlist_head proc_volumes;/* procfs volume list */ seqlock_t volume_lock;/* For volumes */
@@ -564,6 +565,7 @@ struct afs_server {struct hlist_node addr4_link;/* Link in net->fs_addresses4 */ struct hlist_node addr6_link;/* Link in net->fs_addresses6 */ struct hlist_node proc_link;/* Link in net->fs_proc */ +struct list_head volumes;/* RCU list of afs_server_entry objects */ struct work_struct initcb_work;/* Work for CB.InitCallBackState* */ struct afs_server *gc_next;/* Next server in manager's list */ time64_t unuse_time;/* Time at which last unused */
@@ -605,12 +607,14 @@ struct afs_server {*/ struct afs_server_entry {struct afs_server *server; +struct afs_volume *volume; +struct list_head slink;/* Link in server->volumes */ };struct afs_server_list {struct rcu_head rcu; -afs_volid_t vids[AFS_MAXTYPES ];/* Volume IDs */ refcount_t usage; +bool attached;/* T if attached to servers */ unsigned char nr_servers;unsigned char preferred;/* Preferred server */ unsigned short vnovol_mask;/* Servers to be skipped due to VNOVOL */
@@ -623,10 +627,9 @@ struct afs_server_list {* Live AFS volume management. */ struct afs_volume { -union { -struct rcu_head rcu; -afs_volid_t vid;/* volume ID */ - }; +struct rcu_head rcu; +afs_volid_t vid;/* The volume ID of this volume */ +afs_volid_t vids[AFS_MAXTYPES ];/* All associated volume IDs */ refcount_t ref;time64_t update_at;/* Time at which to next update */ struct afs_cell *cell;/* Cell to which belongs (pins ref) */
@@ -1527,10 +1530,14 @@ static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list }extern void afs_put_serverlist (struct afs_net *,struct afs_server_list *); -extern struct afs_server_list *afs_alloc_server_list (struct afs_cell *,struct key *, -struct afs_vldb_entry *, -u8 ); +struct afs_server_list *afs_alloc_server_list (struct afs_volume *volume, +struct key *key, +struct afs_vldb_entry *vldb);extern bool afs_annotate_server_list (struct afs_server_list *,struct afs_server_list *); +void afs_attach_volume_to_servers (struct afs_volume *volume,struct afs_server_list *slist); +void afs_reattach_volume_to_servers (struct afs_volume *volume,struct afs_server_list *slist, +struct afs_server_list *old); +void afs_detach_volume_from_servers (struct afs_volume *volume,struct afs_server_list *slist);/* * super.c
fs/afs/server.c +1 -0
@@ -216,6 +216,7 @@ static struct afs_server *afs_alloc_server(struct afs_cell *cell, server->addr_version = alist->version; server->uuid = *uuid;rwlock_init (&server->fs_lock); +INIT_LIST_HEAD (&server->volumes);INIT_WORK (&server->initcb_work, afs_server_init_callback_work);init_waitqueue_head (&server->probe_wq);INIT_LIST_HEAD (&server->probe_link);
fs/afs/server_list.c +103 -9
154 lines not on this page · raw message
fs/afs/vl_alias.c +1 -1
@@ -77,7 +77,7 @@ static int afs_compare_volume_slists(const struct afs_volume *vol_a, lb =rcu_dereference (vol_b->servers);for (i =0 ; i <AFS_MAXTYPES ; i++) -if (la->vids[i] != lb->vids[i]) +if (vol_a->vids[i] != vol_b->vids[i])return 0 ;while (a < la->nr_servers && b < lb->nr_servers) {
fs/afs/volume.c +22 -14
@@ -66,11 +66,11 @@ static void afs_remove_volume_from_cell(struct afs_volume *volume)*/ static struct afs_volume *afs_alloc_volume (struct afs_fs_context *params,struct afs_vldb_entry *vldb, -unsigned long type_mask) +struct afs_server_list **_slist) {struct afs_server_list *slist;struct afs_volume *volume; -int ret = -ENOMEM ; +int ret = -ENOMEM , i; volume =kzalloc (sizeof (struct afs_volume ),GFP_KERNEL );if (!volume)
@@ -89,13 +89,16 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params,rwlock_init (&volume->cb_v_break_lock);memcpy (volume->name, vldb->name, vldb->name_len +1 ); - slist =afs_alloc_server_list (params->cell, params->key, vldb, type_mask); +for (i =0 ; i <AFS_MAXTYPES ; i++) + volume->vids[i] = vldb->vid[i]; + + slist =afs_alloc_server_list (volume, params->key, vldb);if (IS_ERR (slist)) { ret =PTR_ERR (slist); goto error_1; } -refcount_set (&slist->usage,1 ); + *_slist = slist;rcu_assign_pointer (volume->servers, slist);trace_afs_volume (volume->vid,1 , afs_volume_trace_alloc);return volume;
@@ -111,17 +114,19 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params,* Look up or allocate a volume record. */ static struct afs_volume *afs_lookup_volume (struct afs_fs_context *params, -struct afs_vldb_entry *vldb, -unsigned long type_mask) +struct afs_vldb_entry *vldb) { +struct afs_server_list *slist;struct afs_volume *candidate, *volume; - candidate =afs_alloc_volume (params, vldb, type_mask); + candidate =afs_alloc_volume (params, vldb, &slist);if (IS_ERR (candidate))return candidate; volume =afs_insert_volume_into_cell (params->cell, candidate); -if (volume != candidate) +if (volume == candidate) +afs_attach_volume_to_servers (volume, slist); +else afs_put_volume (params->net, candidate, afs_volume_trace_put_cell_dup);return volume; }
@@ -202,8 +207,7 @@ struct afs_volume *afs_create_volume(struct afs_fs_context *params) goto error; } - type_mask =1UL << params->type; - volume =afs_lookup_volume (params, vldb, type_mask); + volume =afs_lookup_volume (params, vldb); error:kfree (vldb);
@@ -215,14 +219,17 @@ struct afs_volume *afs_create_volume(struct afs_fs_context *params)*/ static void afs_destroy_volume (struct afs_net *net,struct afs_volume *volume) { +struct afs_server_list *slist =rcu_access_pointer (volume->servers); +_enter ("%p" , volume);#ifdef CONFIG_AFS_FSCACHE ASSERTCMP(volume->cache, ==, NULL);#endif +afs_detach_volume_from_servers (volume, slist);afs_remove_volume_from_cell (volume); -afs_put_serverlist (net,rcu_access_pointer (volume->servers)); +afs_put_serverlist (net, slist);afs_put_cell (volume->cell, afs_cell_trace_put_vol);trace_afs_volume (volume->vid,refcount_read (&volume->ref), afs_volume_trace_free);
@@ -342,8 +349,7 @@ static int afs_update_volume_status(struct afs_volume *volume, struct key *key) }/* See if the volume's server list got updated. */ - new =afs_alloc_server_list (volume->cell, key, - vldb, (1 << volume->type)); + new =afs_alloc_server_list (volume, key, vldb);if (IS_ERR (new)) { ret =PTR_ERR (new); goto error_vldb;
@@ -364,9 +370,11 @@ static int afs_update_volume_status(struct afs_volume *volume, struct key *key) volume->update_at =ktime_get_real_seconds () + afs_volume_record_life;write_unlock (&volume->servers_lock); - ret =0 ; +if (discard == old) +afs_reattach_volume_to_servers (volume, new, old);afs_put_serverlist (volume->cell->net, discard); + ret =0 ; error_vldb:kfree (vldb); error:
David Howells
maintainerPATCH 35/41 afs: Defer volume record destruction to a workqueue
In reply to David HowellsDefer volume record destruction to a workqueue so that afs_put_volume() isn't going to run the destruction process in the callback workqueue whilst the server is holding up other clients whilst waiting for us to reply to a CB.CallBack notification RPC.
--- fs/afs/cell.c | 2 +- fs/afs/fs_operation.c | 2 +- fs/afs/internal.h | 3 ++- fs/afs/super.c | 7 +++---- fs/afs/vl_alias.c | 6 +++--- fs/afs/volume.c | 15 +++++++++------ 6 files changed, 19 insertions(+), 16 deletions(-)
fs/afs/cell.c +1 -1
@@ -816,7 +816,7 @@ static void afs_manage_cell(struct afs_cell *cell) final_destruction:/* The root volume is pinning the cell */ -afs_put_volume (cell->net, cell->root_volume, afs_volume_trace_put_cell_root); +afs_put_volume (cell->root_volume, afs_volume_trace_put_cell_root); cell->root_volume =NULL ;afs_put_cell (cell, afs_cell_trace_put_destroy); }
fs/afs/fs_operation.c +1 -1
@@ -265,7 +265,7 @@ int afs_put_operation(struct afs_operation *op) }afs_put_serverlist (op->net, op->server_list); -afs_put_volume (op->net, op->volume, afs_volume_trace_put_put_op); +afs_put_volume (op->volume, afs_volume_trace_put_put_op);key_put (op->key);kfree (op);return ret;
fs/afs/internal.h +2 -1
@@ -636,6 +636,7 @@ struct afs_volume {struct rb_node cell_node;/* Link in cell->volumes */ struct hlist_node proc_link;/* Link in cell->proc_volumes */ struct super_block __rcu *sb;/* Superblock on which inodes reside */ +struct work_struct destructor;/* Deferred destructor */ unsigned long flags;#define AFS_VOLUME_NEEDS_UPDATE 0/* - T if an update needs performing */ #define AFS_VOLUME_UPDATING 1/* - T if an update is in progress */
@@ -1611,7 +1612,7 @@ extern struct afs_volume *afs_create_volume(struct afs_fs_context *);extern int afs_activate_volume (struct afs_volume *);extern void afs_deactivate_volume (struct afs_volume *);extern struct afs_volume *afs_get_volume (struct afs_volume *,enum afs_volume_trace ); -extern void afs_put_volume (struct afs_net *,struct afs_volume *,enum afs_volume_trace ); +void afs_put_volume (struct afs_volume *volume,enum afs_volume_trace reason);extern int afs_check_volume_status (struct afs_volume *,struct afs_operation *);/*
fs/afs/super.c +3 -4
@@ -381,8 +381,7 @@ static int afs_validate_fc(struct fs_context *fc) ctx->key = key;if (ctx->volume) { -afs_put_volume (ctx->net, ctx->volume, - afs_volume_trace_put_validate_fc); +afs_put_volume (ctx->volume, afs_volume_trace_put_validate_fc); ctx->volume =NULL ; }
@@ -529,7 +528,7 @@ static void afs_destroy_sbi(struct afs_super_info *as) {if (as) {struct afs_net *net =afs_net (as->net_ns); -afs_put_volume (net, as->volume, afs_volume_trace_put_destroy_sbi); +afs_put_volume (as->volume, afs_volume_trace_put_destroy_sbi);afs_unuse_cell (net, as->cell, afs_cell_trace_unuse_sbi);put_net (as->net_ns);kfree (as);
@@ -615,7 +614,7 @@ static void afs_free_fc(struct fs_context *fc)struct afs_fs_context *ctx = fc->fs_private;afs_destroy_sbi (fc->s_fs_info); -afs_put_volume (ctx->net, ctx->volume, afs_volume_trace_put_free_fc); +afs_put_volume (ctx->volume, afs_volume_trace_put_free_fc);afs_unuse_cell (ctx->net, ctx->cell, afs_cell_trace_unuse_fc);key_put (ctx->key);kfree (ctx);
fs/afs/vl_alias.c +3 -3
@@ -156,7 +156,7 @@ static int afs_query_for_alias_one(struct afs_cell *cell, struct key *key,/* And see if it's in the new cell. */ volume =afs_sample_volume (cell, key, pvol->name, pvol->name_len);if (IS_ERR (volume)) { -afs_put_volume (cell->net, pvol, afs_volume_trace_put_query_alias); +afs_put_volume (pvol, afs_volume_trace_put_query_alias);if (PTR_ERR (volume) != -ENOMEDIUM )return PTR_ERR (volume);/* That volume is not in the new cell, so not an alias */
@@ -174,8 +174,8 @@ static int afs_query_for_alias_one(struct afs_cell *cell, struct key *key,rcu_read_unlock (); } -afs_put_volume (cell->net, volume, afs_volume_trace_put_query_alias); -afs_put_volume (cell->net, pvol, afs_volume_trace_put_query_alias); +afs_put_volume (volume, afs_volume_trace_put_query_alias); +afs_put_volume (pvol, afs_volume_trace_put_query_alias);return ret; }
fs/afs/volume.c +9 -6
@@ -11,6 +11,8 @@static unsigned __read_mostly afs_volume_record_life =60 *60 ; +static void afs_destroy_volume (struct work_struct *work); +/* * Insert a volume into a cell. If there's an existing volume record, that is * returned instead with a ref held.
@@ -85,6 +87,7 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params,refcount_set (&volume->ref,1 );INIT_HLIST_NODE (&volume->proc_link); +INIT_WORK (&volume->destructor, afs_destroy_volume);rwlock_init (&volume->servers_lock);rwlock_init (&volume->cb_v_break_lock);memcpy (volume->name, vldb->name, vldb->name_len +1 );
@@ -127,7 +130,7 @@ static struct afs_volume *afs_lookup_volume(struct afs_fs_context *params,if (volume == candidate)afs_attach_volume_to_servers (volume, slist);else -afs_put_volume (params->net, candidate, afs_volume_trace_put_cell_dup); +afs_put_volume (candidate, afs_volume_trace_put_cell_dup);return volume; }
@@ -217,8 +220,9 @@ struct afs_volume *afs_create_volume(struct afs_fs_context *params)/* * Destroy a volume record */ -static void afs_destroy_volume (struct afs_net *net,struct afs_volume *volume) +static void afs_destroy_volume (struct work_struct *work) { + struct afs_volume *volume = container_of(work, struct afs_volume, destructor);struct afs_server_list *slist =rcu_access_pointer (volume->servers);_enter ("%p" , volume);
@@ -229,7 +233,7 @@ static void afs_destroy_volume(struct afs_net *net, struct afs_volume *volume)afs_detach_volume_from_servers (volume, slist);afs_remove_volume_from_cell (volume); -afs_put_serverlist (net, slist); +afs_put_serverlist (volume->cell->net, slist);afs_put_cell (volume->cell, afs_cell_trace_put_vol);trace_afs_volume (volume->vid,refcount_read (&volume->ref), afs_volume_trace_free);
@@ -257,8 +261,7 @@ struct afs_volume *afs_get_volume(struct afs_volume *volume,/* * Drop a reference on a volume record. */ -void afs_put_volume (struct afs_net *net,struct afs_volume *volume, -enum afs_volume_trace reason) +void afs_put_volume (struct afs_volume *volume,enum afs_volume_trace reason) {if (volume) {afs_volid_t vid = volume->vid;
@@ -268,7 +271,7 @@ void afs_put_volume(struct afs_net *net, struct afs_volume *volume, zero =__refcount_dec_and_test (&volume->ref, &r);trace_afs_volume (vid, r -1 , reason);if (zero) -afs_destroy_volume (net, volume); +schedule_work (&volume->destructor); } }
David Howells
maintainerPATCH 36/41 afs: Move the vnode/volume validity checking code into its own file
In reply to David HowellsMove the code that does validity checking of vnodes and volumes with respect to third-party changes into its own file.
--- fs/afs/Makefile | 1 + fs/afs/inode.c | 174 ----------------------------------------- fs/afs/internal.h | 10 ++- fs/afs/validation.c | 185 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 193 insertions(+), 177 deletions(-) create mode 100644 fs/afs/validation.c
fs/afs/Makefile +1 -0
@@ -28,6 +28,7 @@ kafs-y := \ server.o \ server_list.o \ super.o \ + validation.o \ vlclient.o \ vl_alias.o \ vl_list.o \
fs/afs/inode.c +0 -174
180 lines not on this page · raw message
fs/afs/internal.h +7 -3
@@ -1234,9 +1234,6 @@ extern int afs_ilookup5_test_by_fid(struct inode *, void *);extern struct inode *afs_iget_pseudo_dir (struct super_block *,bool );extern struct inode *afs_iget (struct afs_operation *,struct afs_vnode_param *);extern struct inode *afs_root_iget (struct super_block *,struct key *); -extern bool afs_check_validity (struct afs_vnode *); -extern int afs_validate (struct afs_vnode *,struct key *); -bool afs_pagecache_valid (struct afs_vnode *);extern int afs_getattr (struct mnt_idmap *idmap,const struct path *,struct kstat *,u32 ,unsigned int );extern int afs_setattr (struct mnt_idmap *idmap,struct dentry *,struct iattr *);
@@ -1546,6 +1543,13 @@ void afs_detach_volume_from_servers(struct afs_volume *volume, struct afs_serverextern int __init afs_fs_init (void );extern void afs_fs_exit (void ); +/* +* validation.c +*/ +bool afs_check_validity (struct afs_vnode *vnode); +bool afs_pagecache_valid (struct afs_vnode *vnode); +int afs_validate (struct afs_vnode *vnode,struct key *key); +/* * vlclient.c */
fs/afs/validation.c new file +185 -0
185 lines not on this page · raw message
David Howells
maintainerPATCH 37/41 afs: Apply server breaks to mmap'd files in the call processor
In reply to David HowellsApply server breaks to mmap'd files that are being used from that server from the call processor work function rather than punting it off to a workqueue. The work item, afs_server_init_callback(), then bumps each individual inode off to its own work item introducing a potentially lengthy delay. This reduces that delay at the cost of extending the amount of time we delay replying to the CB.InitCallBack3 notification RPC from the server.
--- fs/afs/callback.c | 33 +++++++++++++++++++-------------- fs/afs/cell.c | 2 +- fs/afs/internal.h | 6 +++--- fs/afs/server.c | 2 -- fs/afs/server_list.c | 22 +++++++++++----------- fs/afs/volume.c | 15 +++++++++++++++ include/trace/events/afs.h | 2 ++ 7 files changed, 51 insertions(+), 31 deletions(-)
fs/afs/callback.c +19 -14
@@ -33,9 +33,8 @@ void afs_invalidate_mmap_work(struct work_struct *work)unmap_mapping_pages (vnode->netfs.inode.i_mapping,0 ,0 , false); } -void afs_server_init_callback_work (struct work_struct *work) +static void afs_server_init_callback (struct afs_server *server) { - struct afs_server *server = container_of(work, struct afs_server, initcb_work);struct afs_vnode *vnode;struct afs_cell *cell = server->cell;
@@ -57,15 +56,19 @@ void afs_server_init_callback_work(struct work_struct *work)*/ void afs_init_callback_state (struct afs_server *server) { -rcu_read_lock (); +struct afs_cell *cell = server->cell; + +down_read (&cell->vs_lock); +do { server->cb_s_break++;atomic_inc (&server->cell->fs_s_break);if (!list_empty (&server->cell->fs_open_mmaps)) -queue_work (system_unbound_wq, &server->initcb_work); +afs_server_init_callback (server); }while ((server =rcu_dereference (server->uuid_next))); -rcu_read_unlock (); + +up_read (&cell->vs_lock); }/*
@@ -112,7 +115,7 @@ static struct afs_volume *afs_lookup_volume_rcu(struct afs_cell *cell,struct rb_node *p;int seq =0 ; - do { +for (;;) {/* Unfortunately, rbtree walking doesn't give reliable results * under just the RCU read lock, so we have to check for * changes.
@@ -132,7 +135,12 @@ static struct afs_volume *afs_lookup_volume_rcu(struct afs_cell *cell, volume =NULL ; } - }while (need_seqretry (&cell->volume_lock, seq)); +if (volume &&afs_try_get_volume (volume, afs_volume_trace_get_callback)) +break ; +if (!need_seqretry (&cell->volume_lock, seq)) +break ; + seq |=1 ;/* Want a lock next time */ + }done_seqretry (&cell->volume_lock, seq);return volume;
@@ -187,12 +195,11 @@ static void afs_break_some_callbacks(struct afs_server *server,afs_volid_t vid = cbb->fid.vid;size_t i; +rcu_read_lock (); volume =afs_lookup_volume_rcu (server->cell, vid); -/* TODO: Find all matching volumes if we couldn't match the server and * break them anyway. */ -for (i = *_count; i >0 ; cbb++, i--) {if (cbb->fid.vid == vid) { _debug("- Fid { vl=%08llx n=%llu u=%u }",
@@ -206,6 +213,9 @@ static void afs_break_some_callbacks(struct afs_server *server, *residue++ = *cbb; } } + +rcu_read_unlock (); +afs_put_volume (volume, afs_volume_trace_put_callback); }/*
@@ -218,11 +228,6 @@ void afs_break_callbacks(struct afs_server *server, size_t count,ASSERT (server !=NULL ); -rcu_read_lock (); -while (count >0 )afs_break_some_callbacks (server, callbacks, &count); - -rcu_read_unlock (); -return ; }
fs/afs/cell.c +1 -1
@@ -161,7 +161,7 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net,refcount_set (&cell->ref,1 );atomic_set (&cell->active,0 );INIT_WORK (&cell->manager, afs_manage_cell_work); -spin_lock_init (&cell->vs_lock); +init_rwsem (&cell->vs_lock); cell->volumes =RB_ROOT ;INIT_HLIST_HEAD (&cell->proc_volumes);seqlock_init (&cell->volume_lock);
fs/afs/internal.h +3 -3
@@ -414,7 +414,7 @@ struct afs_cell {unsigned int debug_id;/* The volumes belonging to this cell */ -spinlock_t vs_lock;/* Lock for server->volumes */ +struct rw_semaphore vs_lock;/* Lock for server->volumes */ struct rb_root volumes;/* Tree of volumes on this server */ struct hlist_head proc_volumes;/* procfs volume list */ seqlock_t volume_lock;/* For volumes */
@@ -566,7 +566,6 @@ struct afs_server {struct hlist_node addr6_link;/* Link in net->fs_addresses6 */ struct hlist_node proc_link;/* Link in net->fs_proc */ struct list_head volumes;/* RCU list of afs_server_entry objects */ -struct work_struct initcb_work;/* Work for CB.InitCallBackState* */ struct afs_server *gc_next;/* Next server in manager's list */ time64_t unuse_time;/* Time at which last unused */ unsigned long flags;
@@ -1040,7 +1039,6 @@ void afs_get_address_preferences(struct afs_net *net, struct afs_addr_list *alis* callback.c */ extern void afs_invalidate_mmap_work (struct work_struct *); -extern void afs_server_init_callback_work (struct work_struct *work);extern void afs_init_callback_state (struct afs_server *);extern void __afs_break_callback (struct afs_vnode *,enum afs_cb_break_reason );extern void afs_break_callback (struct afs_vnode *,enum afs_cb_break_reason );
@@ -1619,6 +1617,8 @@ extern struct afs_volume *afs_get_volume(struct afs_volume *, enum afs_volume_trvoid afs_put_volume (struct afs_volume *volume,enum afs_volume_trace reason);extern int afs_check_volume_status (struct afs_volume *,struct afs_operation *); +bool afs_try_get_volume (struct afs_volume *volume,enum afs_volume_trace reason); +/* * write.c */
fs/afs/server.c +0 -2
@@ -217,7 +217,6 @@ static struct afs_server *afs_alloc_server(struct afs_cell *cell, server->uuid = *uuid;rwlock_init (&server->fs_lock);INIT_LIST_HEAD (&server->volumes); -INIT_WORK (&server->initcb_work, afs_server_init_callback_work);init_waitqueue_head (&server->probe_wq);INIT_LIST_HEAD (&server->probe_link);spin_lock_init (&server->probe_lock);
@@ -469,7 +468,6 @@ static void afs_destroy_server(struct afs_net *net, struct afs_server *server)if (test_bit (AFS_SERVER_FL_MAY_HAVE_CB , &server->flags))afs_give_up_callbacks (net, server); -flush_work (&server->initcb_work);afs_put_server (net, server, afs_server_trace_destroy); }
fs/afs/server_list.c +11 -11
@@ -136,7 +136,7 @@ void afs_attach_volume_to_servers(struct afs_volume *volume, struct afs_server_lstruct list_head *p;unsigned int i; -spin_lock (&volume->cell->vs_lock); +down_write (&volume->cell->vs_lock);for (i =0 ; i < slist->nr_servers; i++) { se = &slist->servers[i];
@@ -147,11 +147,11 @@ void afs_attach_volume_to_servers(struct afs_volume *volume, struct afs_server_lif (volume->vid <= pe->volume->vid)break ; } -list_add_tail_rcu (&se->slink, p); +list_add_tail (&se->slink, p); } slist->attached = true; -spin_unlock (&volume->cell->vs_lock); +up_write (&volume->cell->vs_lock); }/*
@@ -164,7 +164,7 @@ void afs_reattach_volume_to_servers(struct afs_volume *volume, struct afs_server {unsigned int n =0 , o =0 ; -spin_lock (&volume->cell->vs_lock); +down_write (&volume->cell->vs_lock);while (n < new->nr_servers || o < old->nr_servers) {struct afs_server_entry *pn = n < new->nr_servers ? &new->servers[n] :NULL ;
@@ -174,7 +174,7 @@ void afs_reattach_volume_to_servers(struct afs_volume *volume, struct afs_serverint diff;if (pn && po && pn->server == po->server) { -list_replace_rcu (&po->slink, &pn->slink); +list_replace (&po->slink, &pn->slink); n++; o++;continue ;
@@ -192,15 +192,15 @@ void afs_reattach_volume_to_servers(struct afs_volume *volume, struct afs_serverif (volume->vid <= s->volume->vid)break ; } -list_add_tail_rcu (&pn->slink, p); +list_add_tail (&pn->slink, p); n++; }else { -list_del_rcu (&po->slink); +list_del (&po->slink); o++; } } -spin_unlock (&volume->cell->vs_lock); +up_write (&volume->cell->vs_lock); }/*
@@ -213,11 +213,11 @@ void afs_detach_volume_from_servers(struct afs_volume *volume, struct afs_serverif (!slist->attached)return ; -spin_lock (&volume->cell->vs_lock); +down_write (&volume->cell->vs_lock);for (i =0 ; i < slist->nr_servers; i++) -list_del_rcu (&slist->servers[i].slink); +list_del (&slist->servers[i].slink); slist->attached = false; -spin_unlock (&volume->cell->vs_lock); +up_write (&volume->cell->vs_lock); }
fs/afs/volume.c +15 -0
@@ -242,6 +242,21 @@ static void afs_destroy_volume(struct work_struct *work)_leave (" [destroyed]" ); } + +/* +* Try to get a reference on a volume record. +*/ +bool afs_try_get_volume (struct afs_volume *volume,enum afs_volume_trace reason) +{ +int r; + +if (__refcount_inc_not_zero (&volume->ref, &r)) { +trace_afs_volume (volume->vid, r +1 , reason); +return true; + } +return false; +} +/* * Get a reference on a volume record. */
include/trace/events/afs.h +2 -0
@@ -151,9 +151,11 @@ enum yfs_cm_operation { EM(afs_volume_trace_alloc, "ALLOC ") \ EM(afs_volume_trace_free, "FREE ") \ EM(afs_volume_trace_get_alloc_sbi, "GET sbi-alloc ") \ + EM(afs_volume_trace_get_callback, "GET callback ") \ EM(afs_volume_trace_get_cell_insert, "GET cell-insrt") \ EM(afs_volume_trace_get_new_op, "GET op-new ") \ EM(afs_volume_trace_get_query_alias, "GET cell-alias") \ + EM(afs_volume_trace_put_callback, "PUT callback ") \ EM(afs_volume_trace_put_cell_dup, "PUT cell-dup ") \ EM(afs_volume_trace_put_cell_root, "PUT cell-root ") \EM (afs_volume_trace_put_destroy_sbi,"PUT sbi-destry" ) \
David Howells
maintainerPATCH 38/41 afs: Parse the VolSync record in the reply of a number of RPC ops
In reply to David HowellsA number of fileserver RPC operations return a VolSync record as part of their reply that gives some information about the state of the volume being accessed, including:
(1) A volume Creation timestamp. For an RW volume, this is the time at which the volume was created; if it changes, the RW volume was presumably restored from a backup and all cached data should be scrubbed as Data Version numbers could regress on the files in the volume.
For an RO volume, this is the time it was last snapshotted from the RW volume. It is expected to advance each time this happens; if it regresses, cached data should be scrubbed.
(2) A volume Update timestamp (Auristor only). For an RW volume, this is updated any time any change is made to a volume or its contents. If it regresses, all cached data must be scrubbed.
For an RO volume, this is a copy of the RW volume's Update timestamp at the point of snapshotting. It can be used as a version number when checking to see if a callback on a RO volume was due to a snapshot. If it regresses, all cached data must be scrubbed.
but this is currently not made use of by the in-kernel afs filesystem.
Make the afs filesystem use this by:
(1) Add a mask to the afs_volsync struct to record what fields are set there and add an update time.
(2) Add an afs_volsync struct to the afs_volume struct and use this to track the two timestamps in the afs_volume struct.
(3) Add a 'pre-op volsync' struct to the afs_operation struct to record the state of the volume tracking before the op.
(4) Add a new counter, cb_scrub, to the afs_volume struct to count events that require all data to be scrubbed. A copy is placed in the afs_vnode struct (inode) and if they no longer match, a scrub takes place.
(5) When the result of an operation is being parsed, parse the VolSync data too, if it is provided. Note that the two timestamps are handled separately, since they don't work in quite the same way.
- If the afs_volume tracking is unset, just set it and do nothing else.
- If the result timestamps are the same as the ones in afs_volume, do nothing.
- If the timestamps regress, propose incrementing cb_scrub.
- If the RW creation timestamp changes, propose incrementing cb_scrub.
- If any timestamp changes, propose incrementing cb_v_break, indicating updates may be required.
- If an update cb_scrub or cb_v_break is proposed, try to cmpxchg the copy of the timestamp in afs_volume from the pre-op version to the result version and only update if successful. This should help mitigate the case where a bunch of parallel ops all see the change and all try crank the counters.
--- fs/afs/afs.h | 4 ++ fs/afs/callback.c | 7 +-- fs/afs/fs_operation.c | 15 +++--- fs/afs/fsclient.c | 9 +++- fs/afs/inode.c | 4 +- fs/afs/internal.h | 12 +++-- fs/afs/rotate.c | 2 +- fs/afs/validation.c | 107 ++++++++++++++++++++++++++++++++++++- fs/afs/yfsclient.c | 6 ++- include/trace/events/afs.h | 27 ++++++++++ 10 files changed, 174 insertions(+), 19 deletions(-)
fs/afs/afs.h +4 -0
@@ -165,7 +165,11 @@ struct afs_status_cb {* AFS volume synchronisation information */ struct afs_volsync { +unsigned int mask;/* Bitmask of supplied fields */ +#define AFS_VOLSYNC_CREATION 0x01 +#define AFS_VOLSYNC_UPDATE 0x02time64_t creation;/* volume creation time */ +time64_t update;/* Volume update time */ };/*
fs/afs/callback.c +4 -3
@@ -81,7 +81,7 @@ void __afs_break_callback(struct afs_vnode *vnode, enum afs_cb_break_reason reasclear_bit (AFS_VNODE_NEW_CONTENT , &vnode->flags);if (test_and_clear_bit (AFS_VNODE_CB_PROMISED , &vnode->flags)) { vnode->cb_break++; - vnode->cb_v_break = vnode->volume->cb_v_break; + vnode->cb_v_break =atomic_read (&vnode->volume->cb_v_break);afs_clear_permits (vnode);if (vnode->lock_state ==AFS_VNODE_LOCK_WAITING_FOR_CB )
@@ -158,12 +158,13 @@ static void afs_break_one_callback(struct afs_volume *volume,struct super_block *sb;struct afs_vnode *vnode;struct inode *inode; +unsigned int cb_v_break;if (fid->vnode ==0 && fid->unique ==0 ) {/* The callback break applies to an entire volume. */ write_lock (&volume->cb_v_break_lock); - volume->cb_v_break++; -trace_afs_cb_break (fid, volume->cb_v_break, + cb_v_break =atomic_inc_return (&volume->cb_v_break); +trace_afs_cb_break (fid, cb_v_break, afs_cb_break_for_volume_callback, false);write_unlock (&volume->cb_v_break_lock);return ;
fs/afs/fs_operation.c +9 -6
@@ -35,11 +35,14 @@ struct afs_operation *afs_alloc_operation(struct key *key, struct afs_volume *vokey_get (key); } - op->key = key; - op->volume =afs_get_volume (volume, afs_volume_trace_get_new_op); - op->net = volume->cell->net; - op->cb_v_break = volume->cb_v_break; - op->debug_id =atomic_inc_return (&afs_operation_debug_counter); + op->key = key; + op->volume =afs_get_volume (volume, afs_volume_trace_get_new_op); + op->net = volume->cell->net; + op->cb_v_break =atomic_read (&volume->cb_v_break); + op->pre_volsync.mask =READ_ONCE (volume->volsync.mask); + op->pre_volsync.creation =READ_ONCE (volume->volsync.creation); + op->pre_volsync.update =READ_ONCE (volume->volsync.update); + op->debug_id =atomic_inc_return (&afs_operation_debug_counter); op->nr_iterations =-1 ;afs_op_set_error (op, -EDESTADDRREQ );
@@ -147,7 +150,7 @@ bool afs_begin_vnode_operation(struct afs_operation *op)afs_prepare_vnode (op, &op->file[0 ],0 );afs_prepare_vnode (op, &op->file[1 ],1 ); - op->cb_v_break = op->volume->cb_v_break; + op->cb_v_break =atomic_read (&op->volume->cb_v_break);_leave (" = true" );return true; }
fs/afs/fsclient.c +7 -2
@@ -165,8 +165,10 @@ static void xdr_decode_AFSVolSync(const __be32 **_bp, bp++;/* spare6 */ *_bp = bp; -if (volsync) +if (volsync) { volsync->creation = creation; + volsync->mask |=AFS_VOLSYNC_CREATION ; + } }/*
@@ -1870,7 +1872,10 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)return ret; bp = call->buffer; -xdr_decode_AFSVolSync (&bp, &op->volsync); +/* Unfortunately, prior to OpenAFS-1.6, volsync here is filled +* with rubbish. +*/ +xdr_decode_AFSVolSync (&bp,NULL ); call->unmarshall++; fallthrough;
fs/afs/inode.c +3 -1
@@ -329,6 +329,8 @@ static void afs_fetch_status_success(struct afs_operation *op)struct afs_vnode *vnode = vp->vnode;int ret; +afs_update_volume_state (op, vp); +if (vnode->netfs.inode.i_state &I_NEW ) { ret =afs_inode_init_from_status (op, vp, vnode);afs_op_set_error (op, ret);
@@ -542,7 +544,7 @@ struct inode *afs_root_iget(struct super_block *sb, struct key *key)BUG_ON (!(inode->i_state &I_NEW )); vnode =AFS_FS_I (inode); - vnode->cb_v_break = as->volume->cb_v_break, + vnode->cb_v_break =atomic_read (&as->volume->cb_v_break),afs_set_netfs_context (vnode); op =afs_alloc_operation (key, as->volume);
fs/afs/internal.h +9 -3
@@ -631,6 +631,7 @@ struct afs_volume {afs_volid_t vids[AFS_MAXTYPES ];/* All associated volume IDs */ refcount_t ref;time64_t update_at;/* Time at which to next update */ +struct afs_volsync volsync;/* Volume info from server */ struct afs_cell *cell;/* Cell to which belongs (pins ref) */ struct rb_node cell_node;/* Link in cell->volumes */ struct hlist_node proc_link;/* Link in cell->proc_volumes */
@@ -651,7 +652,10 @@ struct afs_volume {rwlock_t servers_lock;/* Lock for ->servers */ unsigned int servers_seq;/* Incremented each time ->servers changes */ -unsigned cb_v_break;/* Break-everything counter. */ +/* Callback management */ +atomic_t cb_ro_snapshot;/* RO volume update-from-snapshot counter */ +atomic_t cb_v_break;/* Volume-break event counter. */ +atomic_t cb_scrub;/* Scrub-all-data event counter. */ rwlock_t cb_v_break_lock;afs_voltype_t type;/* type of volume */
@@ -845,7 +849,8 @@ struct afs_operation {struct afs_volume *volume;/* Volume being accessed */ struct afs_vnode_param file[2 ];struct afs_vnode_param *more_files; -struct afs_volsync volsync; +struct afs_volsync pre_volsync;/* Volsync before op */ +struct afs_volsync volsync;/* Volsync returned by op */ struct dentry *dentry;/* Dentry to be altered */ struct dentry *dentry_2;/* Second dentry to be altered */ struct timespec64 mtime;/* Modification time to record */
@@ -1052,7 +1057,7 @@ static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode)static inline bool afs_cb_is_broken (unsigned int cb_break,const struct afs_vnode *vnode) { -return cb_break != (vnode->cb_break + vnode->volume->cb_v_break); +return cb_break != (vnode->cb_break +atomic_read (&vnode->volume->cb_v_break)); }/*
@@ -1544,6 +1549,7 @@ extern void afs_fs_exit(void);/* * validation.c */ +void afs_update_volume_state (struct afs_operation *op,struct afs_vnode_param *vp);bool afs_check_validity (struct afs_vnode *vnode);bool afs_pagecache_valid (struct afs_vnode *vnode);int afs_validate (struct afs_vnode *vnode,struct key *key);
fs/afs/rotate.c +1 -1
@@ -482,7 +482,7 @@ bool afs_select_fileserver(struct afs_operation *op) vnode->cb_server = server; vnode->cb_s_break = server->cb_s_break; vnode->cb_fs_s_break =atomic_read (&server->cell->fs_s_break); - vnode->cb_v_break = vnode->volume->cb_v_break; + vnode->cb_v_break =atomic_read (&vnode->volume->cb_v_break);clear_bit (AFS_VNODE_CB_PROMISED , &vnode->flags); }
fs/afs/validation.c +105 -2
125 lines not on this page · raw message
fs/afs/yfsclient.c +5 -1
@@ -245,12 +245,16 @@ static void xdr_decode_YFSVolSync(const __be32 **_bp, struct afs_volsync *volsync) {struct yfs_xdr_YFSVolSync *x = (void *)*_bp; -u64 creation; +u64 creation, update;if (volsync) { creation =xdr_to_u64 (x->vol_creation_date);do_div (creation,10 *1000 *1000 ); volsync->creation = creation; + update =xdr_to_u64 (x->vol_update_date); +do_div (update,10 *1000 *1000 ); + volsync->update = update; + volsync->mask |=AFS_VOLSYNC_CREATION |AFS_VOLSYNC_UPDATE ; } *_bp +=xdr_size (x);
include/trace/events/afs.h +27 -0
@@ -440,12 +440,15 @@ enum yfs_cm_operation { EM(afs_cb_break_no_break, "no-break") \ EM(afs_cb_break_no_promise, "no-promise") \ EM(afs_cb_break_for_callback, "break-cb") \ + EM(afs_cb_break_for_creation_regress, "creation-regress") \ EM(afs_cb_break_for_deleted, "break-del") \ EM(afs_cb_break_for_lapsed, "break-lapsed") \ EM(afs_cb_break_for_s_reinit, "s-reinit") \ EM(afs_cb_break_for_unlink, "break-unlink") \ + EM(afs_cb_break_for_update_regress, "update-regress") \ EM(afs_cb_break_for_v_break, "break-v") \ EM(afs_cb_break_for_volume_callback, "break-v-cb") \ + EM(afs_cb_break_for_vos_release, "break-vos-release") \E_ (afs_cb_break_for_zap,"break-zap" )/*
@@ -1249,6 +1252,30 @@ TRACE_EVENT(afs_get_tree, __entry->cell, __entry->volume, __entry->vid) ); +TRACE_EVENT (afs_cb_v_break, + TP_PROTO(afs_volid_t vid, unsigned int cb_v_break, + enum afs_cb_break_reason reason), + +TP_ARGS (vid, cb_v_break, reason), + +TP_STRUCT__entry ( + __field(afs_volid_t, vid) + __field(unsigned int, cb_v_break) + __field(enum afs_cb_break_reason, reason) + ), + +TP_fast_assign ( + __entry->vid = vid; + __entry->cb_v_break = cb_v_break; + __entry->reason = reason; + ), + +TP_printk ("%llx vb=%x %s" , + __entry->vid, + __entry->cb_v_break, +__print_symbolic (__entry->reason, afs_cb_break_reasons)) + ); + TRACE_EVENT(afs_cb_break, TP_PROTO(struct afs_fid *fid, unsigned int cb_break, enum afs_cb_break_reason reason, bool skipped),
David Howells
maintainerPATCH 39/41 afs: Overhaul invalidation handling to better support RO volumes
In reply to David HowellsOverhaul the third party-induced invalidation handling, making use of the previously added volume-level event counters (cb_scrub and cb_ro_snapshot) that are now being parsed out of the VolSync record returned by the fileserver in many of its replies.
This allows better handling of RO (and Backup) volumes. Since these are snapshot of a RW volume that are updated atomically simultantanously across all servers that host them, they only require a single callback promise for the entire volume. The currently upstream code assumes that RO volumes operate in the same manner as RW volumes, and that each file has its own individual callback - which means that it does a status fetch for *every* file in a RO volume, whether or not the volume got "released" (volume callback breaks can occur for other reasons too, such as the volumeserver taking ownership of a volume from a fileserver).
To this end, make the following changes:
(1) Change the meaning of the volume's cb_v_break counter so that it is now a hint that we need to issue a status fetch to work out the state of a volume. cb_v_break is incremented by volume break callbacks and by server initialisation callbacks.
(2) Add a second counter, cb_v_check, to the afs_volume struct such that if this differs from cb_v_break, we need to do a check. When the check is complete, cb_v_check is advanced to what cb_v_break was at the start of the status fetch.
(3) Move the list of mmap'd vnodes to the volume and trigger removal of PTEs that map to files on a volume break rather than on a server break.
(4) When a server reinitialisation callback comes in, use the server-to-volume reverse mapping added in a preceding patch to iterate over all the volumes using that server and clear the volume callback promises for that server and the general volume promise as a whole to trigger reanalysis.
(5) Replace the AFS_VNODE_CB_PROMISED flag with an AFS_NO_CB_PROMISE (TIME64_MIN) value in the cb_expires_at field, reducing the number of checks we need to make.
(6) Change afs_check_validity() to quickly see if various event counters have been incremented or if the vnode or volume callback promise is due to expire/has expired without making any changes to the state. That is now left to afs_validate() as this may get more complicated in future as we may have to examine server records too.
(7) Overhaul afs_validate() so that it does a single status fetch if we need to check the state of either the vnode or the volume - and do so under appropriate locking. The function does the following steps:
(A) If the vnode/volume is no longer seen as valid, then we take the vnode validation lock and, if the volume promise has expired, the volume check lock also. The latter prevents redundant checks being made to find out if a new version of the volume got released.
(B) If a previous RPC call found that the volsync changed unexpectedly or that a RO volume was updated, then we unmap all PTEs pointing to the file to stop mmap being used for access.
(C) If the vnode is still seen to be of uncertain validity, then we perform an FS.FetchStatus RPC op to jointly update the volume status and the vnode status. This assessment is done as part of parsing the reply:
If the RO volume creation timestamp advances, cb_ro_snapshot is incremented; if either the creation or update timestamps changes in an unexpected way, the cb_scrub counter is incremented
If the Data Version returned doesn't match the copy we have locally, then we ask for the pagecache to be zapped. This takes care of handling RO update.
(D) If cb_scrub differs between volume and vnode, the vnode's pagecache is zapped and the vnode's cb_scrub is updated unless the file is marked as having been deleted.
--- fs/afs/callback.c | 122 +++++++++------ fs/afs/cell.c | 2 - fs/afs/dir.c | 3 +- fs/afs/file.c | 13 +- fs/afs/fs_operation.c | 3 +- fs/afs/inode.c | 20 ++- fs/afs/internal.h | 32 ++-- fs/afs/proc.c | 4 +- fs/afs/rotate.c | 8 +- fs/afs/server_list.c | 2 + fs/afs/validation.c | 302 ++++++++++++++++++++++++------------- fs/afs/volume.c | 2 + include/trace/events/afs.h | 6 +- 13 files changed, 315 insertions(+), 204 deletions(-)
fs/afs/callback.c +76 -46
@@ -33,21 +33,20 @@ void afs_invalidate_mmap_work(struct work_struct *work)unmap_mapping_pages (vnode->netfs.inode.i_mapping,0 ,0 , false); } -static void afs_server_init_callback (struct afs_server *server) +static void afs_volume_init_callback (struct afs_volume *volume) {struct afs_vnode *vnode; -struct afs_cell *cell = server->cell; -down_read (&cell->fs_open_mmaps_lock); +down_read (&volume->open_mmaps_lock); -list_for_each_entry (vnode, &cell->fs_open_mmaps, cb_mmap_link) { -if (vnode->cb_server == server) { -clear_bit (AFS_VNODE_CB_PROMISED , &vnode->flags); +list_for_each_entry (vnode, &volume->open_mmaps, cb_mmap_link) { +if (vnode->cb_v_check !=atomic_read (&volume->cb_v_break)) { + vnode->cb_expires_at =AFS_NO_CB_PROMISE ;queue_work (system_unbound_wq, &vnode->cb_work); } } -up_read (&cell->fs_open_mmaps_lock); +up_read (&volume->open_mmaps_lock); }/*
@@ -56,19 +55,20 @@ static void afs_server_init_callback(struct afs_server *server)*/ void afs_init_callback_state (struct afs_server *server) { -struct afs_cell *cell = server->cell; +struct afs_server_entry *se; -down_read (&cell->vs_lock); +down_read (&server->cell->vs_lock); -do { - server->cb_s_break++; -atomic_inc (&server->cell->fs_s_break); -if (!list_empty (&server->cell->fs_open_mmaps)) -afs_server_init_callback (server); - - }while ((server =rcu_dereference (server->uuid_next))); +list_for_each_entry (se, &server->volumes, slink) { + se->cb_expires_at =AFS_NO_CB_PROMISE ; + se->volume->cb_expires_at =AFS_NO_CB_PROMISE ; +trace_afs_cb_v_break (se->volume->vid,atomic_read (&se->volume->cb_v_break), + afs_cb_break_for_s_reinit); +if (!list_empty (&se->volume->open_mmaps)) +afs_volume_init_callback (se->volume); + } -up_read (&cell->vs_lock); +up_read (&server->cell->vs_lock); }/*
@@ -79,9 +79,9 @@ void __afs_break_callback(struct afs_vnode *vnode, enum afs_cb_break_reason reas_enter ("" );clear_bit (AFS_VNODE_NEW_CONTENT , &vnode->flags); -if (test_and_clear_bit (AFS_VNODE_CB_PROMISED , &vnode->flags)) { +if (xchg (&vnode->cb_expires_at,AFS_NO_CB_PROMISE ) !=AFS_NO_CB_PROMISE ) { vnode->cb_break++; - vnode->cb_v_break =atomic_read (&vnode->volume->cb_v_break); + vnode->cb_v_check =atomic_read (&vnode->volume->cb_v_break);afs_clear_permits (vnode);if (vnode->lock_state ==AFS_VNODE_LOCK_WAITING_FOR_CB )
@@ -146,29 +146,51 @@ static struct afs_volume *afs_lookup_volume_rcu(struct afs_cell *cell,return volume; } +/* +* Allow the fileserver to break callbacks at the volume-level. This is +* typically done when, for example, a R/W volume is snapshotted to a R/O +* volume (the only way to change an R/O volume). It may also, however, happen +* when a volserver takes control of a volume (offlining it, moving it, etc.). +* +* Every file in that volume will need to be reevaluated. +*/ +static void afs_break_volume_callback (struct afs_server *server, +struct afs_volume *volume) +__releases (RCU ) +{ +struct afs_server_list *slist =rcu_dereference (volume->servers); +unsigned int i, cb_v_break; + +write_lock (&volume->cb_v_break_lock); + +for (i =0 ; i < slist->nr_servers; i++) +if (slist->servers[i].server == server) + slist->servers[i].cb_expires_at =AFS_NO_CB_PROMISE ; + volume->cb_expires_at =AFS_NO_CB_PROMISE ; + + cb_v_break =atomic_inc_return_release (&volume->cb_v_break); +trace_afs_cb_v_break (volume->vid, cb_v_break, afs_cb_break_for_volume_callback); + +write_unlock (&volume->cb_v_break_lock); +rcu_read_unlock (); + +if (!list_empty (&volume->open_mmaps)) +afs_volume_init_callback (volume); +} +/* * allow the fileserver to explicitly break one callback * - happens when * - the backing file is changed * - a lock is released */ -static void afs_break_one_callback (struct afs_volume *volume, +static void afs_break_one_callback (struct afs_server *server, +struct afs_volume *volume,struct afs_fid *fid) {struct super_block *sb;struct afs_vnode *vnode;struct inode *inode; -unsigned int cb_v_break; - -if (fid->vnode ==0 && fid->unique ==0 ) { -/* The callback break applies to an entire volume. */ -write_lock (&volume->cb_v_break_lock); - cb_v_break =atomic_inc_return (&volume->cb_v_break); -trace_afs_cb_break (fid, cb_v_break, - afs_cb_break_for_volume_callback, false); -write_unlock (&volume->cb_v_break_lock); -return ; - }/* See if we can find a matching inode - even an I_NEW inode needs to * be marked as it can have its callback broken before we finish
@@ -198,24 +220,32 @@ static void afs_break_some_callbacks(struct afs_server *server,rcu_read_lock (); volume =afs_lookup_volume_rcu (server->cell, vid); -/* TODO: Find all matching volumes if we couldn't match the server and -* break them anyway. -*/ -for (i = *_count; i >0 ; cbb++, i--) { -if (cbb->fid.vid == vid) { -_debug ("- Fid { vl=%08llx n=%llu u=%u }" , - cbb->fid.vid, - cbb->fid.vnode, - cbb->fid.unique); - --*_count; -if (volume) -afs_break_one_callback (volume, &cbb->fid); - }else { - *residue++ = *cbb; +if (cbb->fid.vnode ==0 && cbb->fid.unique ==0 ) { +afs_break_volume_callback (server, volume); + *_count -=1 ; +if (*_count) +memmove (cbb, cbb +1 ,sizeof (*cbb) * *_count); + }else { +/* TODO: Find all matching volumes if we couldn't match the server and +* break them anyway. +*/ + +for (i = *_count; i >0 ; cbb++, i--) { +if (cbb->fid.vid == vid) { +_debug ("- Fid { vl=%08llx n=%llu u=%u }" , + cbb->fid.vid, + cbb->fid.vnode, + cbb->fid.unique); + --*_count; +if (volume) +afs_break_one_callback (server, volume, &cbb->fid); + }else { + *residue++ = *cbb; + } } +rcu_read_unlock (); } -rcu_read_unlock ();afs_put_volume (volume, afs_volume_trace_put_callback); }
fs/afs/cell.c +0 -2
@@ -167,8 +167,6 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net,seqlock_init (&cell->volume_lock); cell->fs_servers =RB_ROOT ;seqlock_init (&cell->fs_lock); -INIT_LIST_HEAD (&cell->fs_open_mmaps); -init_rwsem (&cell->fs_open_mmaps_lock);rwlock_init (&cell->vl_servers_lock); cell->flags = (1 <<AFS_CELL_FL_CHECK_ALIAS );
fs/afs/dir.c +2 -1
@@ -1260,6 +1260,7 @@ void afs_check_for_remote_deletion(struct afs_operation *op)switch (afs_op_abort_code (op)) {case VNOVNODE :set_bit (AFS_VNODE_DELETED , &vnode->flags); +clear_nlink (&vnode->netfs.inode);afs_break_callback (vnode, afs_cb_break_for_deleted); } }
@@ -1375,7 +1376,7 @@ static void afs_dir_remove_subdir(struct dentry *dentry)clear_nlink (&vnode->netfs.inode);set_bit (AFS_VNODE_DELETED , &vnode->flags); -clear_bit (AFS_VNODE_CB_PROMISED , &vnode->flags); + vnode->cb_expires_at =AFS_NO_CB_PROMISE ;clear_bit (AFS_VNODE_DIR_VALID , &vnode->flags); } }
fs/afs/file.c +6 -7
@@ -514,13 +514,12 @@ static bool afs_release_folio(struct folio *folio, gfp_t gfp)static void afs_add_open_mmap (struct afs_vnode *vnode) {if (atomic_inc_return (&vnode->cb_nr_mmap) ==1 ) { -down_write (&vnode->volume->cell->fs_open_mmaps_lock); +down_write (&vnode->volume->open_mmaps_lock);if (list_empty (&vnode->cb_mmap_link)) -list_add_tail (&vnode->cb_mmap_link, - &vnode->volume->cell->fs_open_mmaps); +list_add_tail (&vnode->cb_mmap_link, &vnode->volume->open_mmaps); -up_write (&vnode->volume->cell->fs_open_mmaps_lock); +up_write (&vnode->volume->open_mmaps_lock); } }
@@ -529,12 +528,12 @@ static void afs_drop_open_mmap(struct afs_vnode *vnode)if (!atomic_dec_and_test (&vnode->cb_nr_mmap))return ; -down_write (&vnode->volume->cell->fs_open_mmaps_lock); +down_write (&vnode->volume->open_mmaps_lock);if (atomic_read (&vnode->cb_nr_mmap) ==0 )list_del_init (&vnode->cb_mmap_link); -up_write (&vnode->volume->cell->fs_open_mmaps_lock); +up_write (&vnode->volume->open_mmaps_lock);flush_work (&vnode->cb_work); }
@@ -570,7 +569,7 @@ static vm_fault_t afs_vm_map_pages(struct vm_fault *vmf, pgoff_t start_pgoff, pg {struct afs_vnode *vnode =AFS_FS_I (file_inode (vmf->vma->vm_file)); -if (afs_pagecache_valid (vnode)) +if (afs_check_validity (vnode))return filemap_map_pages (vmf, start_pgoff, end_pgoff);return 0 ; }
fs/afs/fs_operation.c +1 -2
@@ -43,7 +43,7 @@ struct afs_operation *afs_alloc_operation(struct key *key, struct afs_volume *vo op->pre_volsync.creation =READ_ONCE (volume->volsync.creation); op->pre_volsync.update =READ_ONCE (volume->volsync.update); op->debug_id =atomic_inc_return (&afs_operation_debug_counter); - op->nr_iterations =-1 ; + op->nr_iterations =-1 ;afs_op_set_error (op, -EDESTADDRREQ );_leave (" = [op=%08x]" , op->debug_id);
@@ -185,7 +185,6 @@ void afs_wait_for_operation(struct afs_operation *op) op->call_responded = false; op->call_error =0 ; op->call_abort_code =0 ; - op->cb_s_break = op->server->cb_s_break;if (test_bit (AFS_SERVER_FL_IS_YFS , &op->server->flags) && op->ops->issue_yfs_rpc) op->ops->issue_yfs_rpc (op);
fs/afs/inode.c +9 -11
@@ -85,8 +85,7 @@ static int afs_inode_init_from_status(struct afs_operation *op,write_seqlock (&vnode->cb_lock); - vnode->cb_v_break = op->cb_v_break; - vnode->cb_s_break = op->cb_s_break; + vnode->cb_v_check = op->cb_v_break; vnode->status = *status; t = status->mtime_client;
@@ -146,11 +145,10 @@ static int afs_inode_init_from_status(struct afs_operation *op,if (!vp->scb.have_cb) {/* it's a symlink we just created (the fileserver * didn't give us a callback) */ - vnode->cb_expires_at =ktime_get_real_seconds (); + vnode->cb_expires_at =AFS_NO_CB_PROMISE ; }else { - vnode->cb_expires_at = vp->scb.callback.expires_at; vnode->cb_server = op->server; -set_bit (AFS_VNODE_CB_PROMISED , &vnode->flags); + vnode->cb_expires_at = vp->scb.callback.expires_at; }write_sequnlock (&vnode->cb_lock);
@@ -214,7 +212,7 @@ static void afs_apply_status(struct afs_operation *op, vnode->status = *status;if (vp->dv_before + vp->dv_delta != status->data_version) { -if (test_bit (AFS_VNODE_CB_PROMISED , &vnode->flags)) +if (vnode->cb_expires_at !=AFS_NO_CB_PROMISE ) pr_warn("kAFS: vnode modified {%llx:%llu} %llx->%llx %s (op=%x)\n", vnode->fid.vid, vnode->fid.vnode, (unsigned long long)vp->dv_before + vp->dv_delta,
@@ -268,9 +266,9 @@ static void afs_apply_callback(struct afs_operation *op,struct afs_vnode *vnode = vp->vnode;if (!afs_cb_is_broken (vp->cb_break_before, vnode)) { - vnode->cb_expires_at = cb->expires_at; - vnode->cb_server = op->server; -set_bit (AFS_VNODE_CB_PROMISED , &vnode->flags); +if (op->volume->type ==AFSVL_RWVOL ) + vnode->cb_server = op->server; + vnode->cb_expires_at = cb->expires_at; } }
@@ -544,7 +542,7 @@ struct inode *afs_root_iget(struct super_block *sb, struct key *key)BUG_ON (!(inode->i_state &I_NEW )); vnode =AFS_FS_I (inode); - vnode->cb_v_break =atomic_read (&as->volume->cb_v_break), + vnode->cb_v_check =atomic_read (&as->volume->cb_v_break),afs_set_netfs_context (vnode); op =afs_alloc_operation (key, as->volume);
@@ -589,7 +587,7 @@ int afs_getattr(struct mnt_idmap *idmap, const struct path *path,if (vnode->volume && !(query_flags &AT_STATX_DONT_SYNC ) && - !test_bit (AFS_VNODE_CB_PROMISED , &vnode->flags)) { + vnode->cb_expires_at ==AFS_NO_CB_PROMISE ) { key =afs_request_key (vnode->volume->cell);if (IS_ERR (key))return PTR_ERR (key);
fs/afs/internal.h +16 -16
@@ -422,9 +422,6 @@ struct afs_cell {/* Active fileserver interaction state. */ struct rb_root fs_servers;/* afs_server (by server UUID) */ seqlock_t fs_lock;/* For fs_servers */ -struct rw_semaphore fs_open_mmaps_lock; -struct list_head fs_open_mmaps;/* List of vnodes that are mmapped */ -atomic_t fs_s_break;/* Counter of CB.InitCallBackState messages */ /* VL server list. */ rwlock_t vl_servers_lock;/* Lock on vl_servers */
@@ -590,9 +587,6 @@ struct afs_server {/* file service access */ rwlock_t fs_lock;/* access lock */ -/* callback promise management */ -unsigned cb_s_break;/* Break-everything counter. */ -/* Probe state */ struct afs_endpoint_state __rcu *endpoint_state;/* Latest endpoint/probe state */ unsigned long probed_at;/* Time last probe was dispatched (jiffies) */
@@ -608,6 +602,7 @@ struct afs_server_entry {struct afs_server *server;struct afs_volume *volume;struct list_head slink;/* Link in server->volumes */ +time64_t cb_expires_at;/* Time at which volume-level callback expires */ };struct afs_server_list {
@@ -653,10 +648,15 @@ struct afs_volume {unsigned int servers_seq;/* Incremented each time ->servers changes */ /* Callback management */ +struct mutex cb_check_lock;/* Lock to control race to check after v_break */ +time64_t cb_expires_at;/* Earliest volume callback expiry time */ atomic_t cb_ro_snapshot;/* RO volume update-from-snapshot counter */ atomic_t cb_v_break;/* Volume-break event counter. */ +atomic_t cb_v_check;/* Volume-break has-been-checked counter. */ atomic_t cb_scrub;/* Scrub-all-data event counter. */ rwlock_t cb_v_break_lock; +struct rw_semaphore open_mmaps_lock; +struct list_head open_mmaps;/* List of vnodes that are mmapped */ afs_voltype_t type;/* type of volume */ char type_force;/* force volume type (suppress R/O -> R/W) */
@@ -695,7 +695,6 @@ struct afs_vnode {spinlock_t wb_lock;/* lock for wb_keys */ spinlock_t lock;/* waitqueue/flags lock */ unsigned long flags; -#define AFS_VNODE_CB_PROMISED 0/* Set if vnode has a callback promise */ #define AFS_VNODE_UNSET 1/* set if vnode attributes not yet set */ #define AFS_VNODE_DIR_VALID 2/* Set if dir contents are valid */ #define AFS_VNODE_ZAP_DATA 3/* set if vnode's data should be invalidated */
@@ -721,13 +720,14 @@ struct afs_vnode {struct list_head cb_mmap_link;/* Link in cell->fs_open_mmaps */ void *cb_server;/* Server with callback/filelock */ atomic_t cb_nr_mmap;/* Number of mmaps */ -unsigned int cb_fs_s_break;/* Mass server break counter (cell->fs_s_break) */ -unsigned int cb_s_break;/* Mass break counter on ->server */ -unsigned int cb_v_break;/* Mass break counter on ->volume */ +unsigned int cb_ro_snapshot;/* RO volume release counter on ->volume */ +unsigned int cb_scrub;/* Scrub counter on ->volume */ unsigned int cb_break;/* Break counter on vnode */ +unsigned int cb_v_check;/* Break check counter on ->volume */ seqlock_t cb_lock;/* Lock for ->cb_server, ->status, ->cb_*break */ time64_t cb_expires_at;/* time at which callback expires */ +#define AFS_NO_CB_PROMISE TIME64_MIN };static inline struct fscache_cookie *afs_vnode_cache (struct afs_vnode *vnode)
@@ -824,7 +824,7 @@ struct afs_vnode_param {struct afs_fid fid;/* Fid to access */ struct afs_status_cb scb;/* Returned status and callback promise */ afs_dataversion_t dv_before;/* Data version before the call */ -unsigned int cb_break_before;/* cb_break + cb_s_break before the call */ +unsigned int cb_break_before;/* cb_break before the call */ u8 dv_delta;/* Expected change in data version */ bool put_vnode:1; /* T if we have a ref on the vnode */ bool need_io_lock:1; /* T if we need the I/O lock on this */
@@ -860,7 +860,6 @@ struct afs_operation {unsigned int debug_id;unsigned int cb_v_break;/* Volume break counter before op */ -unsigned int cb_s_break;/* Server break counter before op */ union { struct {
@@ -1051,13 +1050,15 @@ extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callbackstatic inline unsigned int afs_calc_vnode_cb_break (struct afs_vnode *vnode) { -return vnode->cb_break + vnode->cb_v_break; +return vnode->cb_break + vnode->cb_ro_snapshot + vnode->cb_scrub; }static inline bool afs_cb_is_broken (unsigned int cb_break,const struct afs_vnode *vnode) { -return cb_break != (vnode->cb_break +atomic_read (&vnode->volume->cb_v_break)); +return cb_break != (vnode->cb_break + +atomic_read (&vnode->volume->cb_ro_snapshot) + +atomic_read (&vnode->volume->cb_scrub)); }/*
@@ -1549,9 +1550,8 @@ extern void afs_fs_exit(void);/* * validation.c */ +bool afs_check_validity (const struct afs_vnode *vnode);void afs_update_volume_state (struct afs_operation *op,struct afs_vnode_param *vp); -bool afs_check_validity (struct afs_vnode *vnode); -bool afs_pagecache_valid (struct afs_vnode *vnode);int afs_validate (struct afs_vnode *vnode,struct key *key);/*
fs/afs/proc.c +2 -2
@@ -443,8 +443,8 @@ static int afs_proc_servers_show(struct seq_file *m, void *v)refcount_read (&server->ref),atomic_read (&server->active), server->cell->name); -seq_printf (m," - info: fl=%lx rtt=%u brk=%x\n" , - server->flags, server->rtt, server->cb_s_break); +seq_printf (m," - info: fl=%lx rtt=%u\n" , + server->flags, server->rtt);seq_printf (m," - probe: last=%d\n" , (int )(jiffies - server->probed_at) /HZ ); failed = estate->failed_set;
fs/afs/rotate.c +3 -5
@@ -59,7 +59,7 @@ static bool afs_start_fs_iteration(struct afs_operation *op,write_seqlock (&vnode->cb_lock); ASSERTCMP(cb_server, ==, vnode->cb_server); vnode->cb_server =NULL ; -if (test_and_clear_bit (AFS_VNODE_CB_PROMISED , &vnode->flags)) +if (xchg (&vnode->cb_expires_at,AFS_NO_CB_PROMISE ) !=AFS_NO_CB_PROMISE ) vnode->cb_break++;write_sequnlock (&vnode->cb_lock); }
@@ -480,10 +480,8 @@ bool afs_select_fileserver(struct afs_operation *op) op->server = server;if (vnode->cb_server != server) { vnode->cb_server = server; - vnode->cb_s_break = server->cb_s_break; - vnode->cb_fs_s_break =atomic_read (&server->cell->fs_s_break); - vnode->cb_v_break =atomic_read (&vnode->volume->cb_v_break); -clear_bit (AFS_VNODE_CB_PROMISED , &vnode->flags); + vnode->cb_v_check =atomic_read (&vnode->volume->cb_v_break); + vnode->cb_expires_at =AFS_NO_CB_PROMISE ; }read_lock (&server->fs_lock);
fs/afs/server_list.c +2 -0
@@ -79,6 +79,7 @@ struct afs_server_list *afs_alloc_server_list(struct afs_volume *volume, slist->servers[j].server = server; slist->servers[j].volume = volume; + slist->servers[j].cb_expires_at =AFS_NO_CB_PROMISE ; slist->nr_servers++; }
@@ -174,6 +175,7 @@ void afs_reattach_volume_to_servers(struct afs_volume *volume, struct afs_serverint diff;if (pn && po && pn->server == po->server) { + pn->cb_expires_at = po->cb_expires_at;list_replace (&po->slink, &pn->slink); n++; o++;
fs/afs/validation.c +195 -107
366 lines not on this page · raw message
fs/afs/volume.c +2 -0
@@ -90,6 +90,8 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params,INIT_WORK (&volume->destructor, afs_destroy_volume);rwlock_init (&volume->servers_lock);rwlock_init (&volume->cb_v_break_lock); +INIT_LIST_HEAD (&volume->open_mmaps); +init_rwsem (&volume->open_mmaps_lock);memcpy (volume->name, vldb->name, vldb->name_len +1 );for (i =0 ; i <AFS_MAXTYPES ; i++)
include/trace/events/afs.h +1 -5
@@ -438,18 +438,14 @@ enum yfs_cm_operation {#define afs_cb_break_reasons \ EM(afs_cb_break_no_break, "no-break") \ - EM(afs_cb_break_no_promise, "no-promise") \ EM(afs_cb_break_for_callback, "break-cb") \ EM(afs_cb_break_for_creation_regress, "creation-regress") \ EM(afs_cb_break_for_deleted, "break-del") \ - EM(afs_cb_break_for_lapsed, "break-lapsed") \ EM(afs_cb_break_for_s_reinit, "s-reinit") \ EM(afs_cb_break_for_unlink, "break-unlink") \ EM(afs_cb_break_for_update_regress, "update-regress") \ - EM(afs_cb_break_for_v_break, "break-v") \ EM(afs_cb_break_for_volume_callback, "break-v-cb") \ - EM(afs_cb_break_for_vos_release, "break-vos-release") \ - E_(afs_cb_break_for_zap, "break-zap") + E_(afs_cb_break_for_vos_release, "break-vos-release")/* * Generate enums for tracing information.
Re: [PATCH 39/41] afs: Overhaul invalidation handling to better support RO volumes
Quoted 4 lines · David Howells
This allows better handling of RO (and Backup) volumes. Since these are snapshot of a RW volume that are updated atomically simultantanously across all servers that host them, they only require a single callback promise for the entire volume.
The atomic visibility of a volume cloning operation is limited to individual volume locations. It is untrue that a "vos release" updates all RO volume locations simultaneously. If that were to occur then there would be the potential for all volume locations to be offline simultaneously causing an outage. Instead, the traditional "volume release" process updates the RO volume site co-located with the RW volume site and makes that version visible to cache managers. Then 50% of the remaining sites are updated in parallel followed by the remaining sites.
Each time a site is updated to the new version the volume location entry is updated to flag the site as VLSF_NEWREPSITE. However, changes to the volume location site flags might not be known to the cache manager. Prior to completion of the "volume release" process it is possible for a cache manager to failover from a newer snapshot to an older one.
Quoted 6 lines
The currently upstream code assumes that RO volumes
operate in the same manner as RW volumes, and that each file has its own individual callback - which means that it does a status fetch for *every* file in a RO volume, whether or not the volume got "released" (volume callback breaks can occur for other reasons too, such as the volumeserver taking ownership of a volume from a fileserver).
Knowledge that the volume snapshot has not changed can be used to avoid individual FetchStatus queries when accessing vnodes anonymously. In that case the vnode's FetchStatus.AnonymousAccess can be trusted to be unchanged. However, for authenticated access the individual FetchStatus or InlineBulkStat queries must still be issued because the FetchStatus.CallerAccess rights are determined not only by the access control list contents but the caller identity's group memberships which might have changed. This distinction only matters when evaluating authorization decisions.
Jeffrey Altman
David Howells
maintainer[PATCH 42/41] afs: Fix the handling of RO volumes
Quoted 3 lines · Jeffrey E Altman
The atomic visibility of a volume cloning operation is limited to individual volume locations. It is untrue that a "vos release" updates all RO volume locations simultaneously.
[This need folding down into the preceding patches]
Fix the handling of RO volumes which aren't actually updated all at once, but are rather updated in stages.
Switch from using the old servers to the new servers when at least half the servers are marked as new replication sites (VLSF_NEWREPSITE).
If an operation gets a reply from a server that indicates that an RO volume is of a more recent snapshot, we regenerate the server list and that excludes whichever bunch of servers we don't want to look at. If the server we got the reply from is now excluded, we reissue the operation, which will cause the rotation algorithm to start agian.
Whilst it thinks that RO replication is in progress, it rechecks the VLDB record every 2s. The problem is that as we don't then maintain a callback on an excluded server, we won't get a notification of completion of the replication process and will maintain the exclusion until the normal VLDB recheck happens after an hour.
To simplify things, the volume creation and update times are set to TIME64_MIN when not valid rather than using a separate flag, and a mutex is used to serialise attempts to modify them.
David
--- fs/afs/afs.h | 7 - fs/afs/dir.c | 4 - fs/afs/fs_operation.c | 5 - fs/afs/fsclient.c | 4 - fs/afs/inode.c | 5 - fs/afs/internal.h | 17 +++- fs/afs/rotate.c | 22 +++++- fs/afs/server_list.c | 52 ++++++++++++-- fs/afs/validation.c | 164 +++++++++++++++++++++++++++++++++++---------- fs/afs/vlclient.c | 19 ----- fs/afs/volume.c | 10 ++ fs/afs/yfsclient.c | 1 include/trace/events/afs.h | 3 13 files changed, 230 insertions(+), 83 deletions(-)
fs/afs/afs.h +2 -5
@@ -165,11 +165,8 @@ struct afs_status_cb {* AFS volume synchronisation information */ struct afs_volsync { -unsigned int mask;/* Bitmask of supplied fields */ -#define AFS_VOLSYNC_CREATION 0x01 -#define AFS_VOLSYNC_UPDATE 0x02 -time64_t creation;/* volume creation time */ -time64_t update;/* Volume update time */ +time64_t creation;/* Volume creation time (or TIME64_MIN) */ +time64_t update;/* Volume update time (or TIME64_MIN) */ };/*
fs/afs/dir.c +2 -2
@@ -807,8 +807,8 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry, cookie->fids[i].vid = dvnode->fid.vid; cookie->ctx.actor = afs_lookup_filldir; cookie->name = dentry->d_name; - cookie->nr_fids =2 ;/* slot 0 is saved for the fid we actually want -* and slot 1 for the directory */ + cookie->nr_fids =2 ;/* slot 1 is saved for the fid we actually want +* and slot 0 for the directory */ if (!afs_server_supports_ibulk (dvnode)) cookie->one_only = true;
fs/afs/fs_operation.c +2 -3
@@ -39,9 +39,8 @@ struct afs_operation *afs_alloc_operation(struct key *key, struct afs_volume *vo op->volume =afs_get_volume (volume, afs_volume_trace_get_new_op); op->net = volume->cell->net; op->cb_v_break =atomic_read (&volume->cb_v_break); - op->pre_volsync.mask =READ_ONCE (volume->volsync_mask); - op->pre_volsync.creation =atomic64_read (&volume->creation_time); - op->pre_volsync.update =atomic64_read (&volume->update_time); + op->pre_volsync.creation = volume->creation_time; + op->pre_volsync.update = volume->update_time; op->debug_id =atomic_inc_return (&afs_operation_debug_counter); op->nr_iterations =-1 ;afs_op_set_error (op, -EDESTADDRREQ );
fs/afs/fsclient.c +1 -3
@@ -165,10 +165,8 @@ static void xdr_decode_AFSVolSync(const __be32 **_bp, bp++;/* spare6 */ *_bp = bp; -if (volsync) { +if (volsync) volsync->creation = creation; - volsync->mask |=AFS_VOLSYNC_CREATION ; - } }/*
fs/afs/inode.c +2 -3
@@ -212,7 +212,8 @@ static void afs_apply_status(struct afs_operation *op, vnode->status = *status;if (vp->dv_before + vp->dv_delta != status->data_version) { -if (vnode->cb_expires_at !=AFS_NO_CB_PROMISE ) +if (vnode->cb_ro_snapshot ==atomic_read (&vnode->volume->cb_ro_snapshot) && + vnode->cb_expires_at !=AFS_NO_CB_PROMISE ) pr_warn("kAFS: vnode modified {%llx:%llu} %llx->%llx %s (op=%x)\n", vnode->fid.vid, vnode->fid.vnode, (unsigned long long)vp->dv_before + vp->dv_delta,
@@ -327,8 +328,6 @@ static void afs_fetch_status_success(struct afs_operation *op)struct afs_vnode *vnode = vp->vnode;int ret; -afs_update_volume_state (op, vp); -if (vnode->netfs.inode.i_state &I_NEW ) { ret =afs_inode_init_from_status (op, vp, vnode);afs_op_set_error (op, ret);
fs/afs/internal.h +13 -4
@@ -512,6 +512,7 @@ struct afs_vldb_entry {#define AFS_VOL_VTM_RW 0x01/* R/W version of the volume is available (on this server) */ #define AFS_VOL_VTM_RO 0x02/* R/O version of the volume is available (on this server) */ #define AFS_VOL_VTM_BAK 0x04/* backup version of the volume is available (on this server) */ +u8 vlsf_flags[AFS_NMAXNSERVERS ];short error;u8 nr_servers;/* Number of server records */ u8 name_len;
@@ -595,6 +596,12 @@ struct afs_server {spinlock_t probe_lock; }; +enum afs_ro_replicating { +AFS_RO_NOT_REPLICATING ,/* Not doing replication */ +AFS_RO_REPLICATING_USE_OLD ,/* Replicating; use old version */ +AFS_RO_REPLICATING_USE_NEW ,/* Replicating; switch to new version */ +}__mode (byte ); +/* * Replaceable volume server list. */
@@ -606,12 +613,14 @@ struct afs_server_entry {unsigned long flags;#define AFS_SE_VOLUME_OFFLINE 0/* Set if volume offline notice given */ #define AFS_SE_VOLUME_BUSY 1/* Set if volume busy notice given */ +#define AFS_SE_EXCLUDED 2/* Set if server is to be excluded in rotation */ };struct afs_server_list {struct rcu_head rcu;refcount_t usage;bool attached;/* T if attached to servers */ +enum afs_ro_replicating ro_replicating;/* RW->RO update (probably) in progress */ unsigned char nr_servers;unsigned short vnovol_mask;/* Servers to be skipped due to VNOVOL */ unsigned int seq;/* Set to ->servers_seq when installed */
@@ -647,9 +656,9 @@ struct afs_volume {unsigned int servers_seq;/* Incremented each time ->servers changes */ /* RO release tracking */ -unsigned int volsync_mask;/* Mask of what values we have obtained */ -atomic64_t creation_time;/* Volume creation time (time64_t) */ -atomic64_t update_time;/* Volume update time (time64_t) */ +struct mutex volsync_lock;/* Time/state evaluation lock */ +time64_t creation_time;/* Volume creation time (or TIME64_MIN) */ +time64_t update_time;/* Volume update time (or TIME64_MIN) */ /* Callback management */ struct mutex cb_check_lock;/* Lock to control race to check after v_break */
@@ -1571,7 +1580,7 @@ extern void afs_fs_exit(void);* validation.c */ bool afs_check_validity (const struct afs_vnode *vnode); -void afs_update_volume_state (struct afs_operation *op,struct afs_vnode_param *vp); +int afs_update_volume_state (struct afs_operation *op);int afs_validate (struct afs_vnode *vnode,struct key *key);/*
fs/afs/rotate.c +21 -1
@@ -187,6 +187,22 @@ bool afs_select_fileserver(struct afs_operation *op)clear_bit (AFS_SE_VOLUME_BUSY , &op->server_list->servers[op->server_index].flags); op->cumul_error.responded = true; + +/* We succeeded, but we may need to check the VLDB and redo the +* op from another server if we're looking at a set of RO +* volumes where some of the servers have not yet been brought +* up to date to avoid regressing the data. We only switch to +* the new version once >=50% of the servers are updated. +*/ + error =afs_update_volume_state (op); +if (error !=0 ) { +if (error ==1 ) { +afs_sleep_and_retry (op); + goto restart_from_beginning; + } +afs_op_set_error (op, error); + goto failed; + } fallthrough;default :/* Success or local failure. Stop. */
@@ -517,10 +533,12 @@ bool afs_select_fileserver(struct afs_operation *op) best_prio =-1 ;for (i =0 ; i < op->server_list->nr_servers; i++) {struct afs_endpoint_state *es; +struct afs_server_entry *se = &op->server_list->servers[i];struct afs_addr_list *sal; -struct afs_server *s = op->server_list->servers[i].server; +struct afs_server *s = se->server;if (!test_bit (i, &op->untried_servers) || +test_bit (AFS_SE_EXCLUDED , &se->flags) || !test_bit (AFS_SERVER_FL_RESPONDING , &s->flags))continue ; es = op->server_states->endpoint_state;
@@ -598,6 +616,8 @@ bool afs_select_fileserver(struct afs_operation *op) op->addr_index = addr_index;set_bit (addr_index, &op->addr_tried); + op->volsync.creation =TIME64_MIN ; + op->volsync.update =TIME64_MIN ; op->call_responded = false; _debug("address [%u] %u/%u %pISp", op->server_index, addr_index, alist->nr_addrs,
fs/afs/server_list.c +45 -7
88 lines not on this page · raw message
fs/afs/validation.c +128 -36
236 lines not on this page · raw message
fs/afs/vlclient.c +3 -16
@@ -18,8 +18,7 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call) {struct afs_uvldbentry__xdr *uvldb;struct afs_vldb_entry *entry; -bool new_only = false; -u32 tmp, nr_servers, vlflags; +u32 nr_servers, vlflags;int i, ret;_enter ("" );
@@ -41,27 +40,14 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call) entry->name[i] =0 ; entry->name_len =strlen (entry->name); -/* If there is a new replication site that we can use, ignore all the -* sites that aren't marked as new. -*/ -for (i =0 ; i < nr_servers; i++) { - tmp =ntohl (uvldb->serverFlags[i]); -if (!(tmp &AFS_VLSF_DONTUSE ) && - (tmp &AFS_VLSF_NEWREPSITE )) - new_only = true; - } - vlflags =ntohl (uvldb->flags);for (i =0 ; i < nr_servers; i++) {struct afs_uuid__xdr *xdr;struct afs_uuid *uuid; +u32 tmp =ntohl (uvldb->serverFlags[i]);int j;int n = entry->nr_servers; - tmp =ntohl (uvldb->serverFlags[i]); -if (tmp &AFS_VLSF_DONTUSE || - (new_only && !(tmp &AFS_VLSF_NEWREPSITE ))) -continue ;if (tmp &AFS_VLSF_RWVOL ) { entry->fs_mask[n] |=AFS_VOL_VTM_RW ;if (vlflags &AFS_VLF_BACKEXISTS )
@@ -82,6 +68,7 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call)for (j =0 ; j <6 ; j++) uuid->node[j] = (u8 )ntohl (xdr->node[j]); + entry->vlsf_flags[n] = tmp; entry->addr_version[n] =ntohl (uvldb->serverUnique[i]); entry->nr_servers++; }
fs/afs/volume.c +9 -1
@@ -84,11 +84,15 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params, volume->type = params->type; volume->type_force = params->force; volume->name_len = vldb->name_len; + volume->creation_time =TIME64_MIN ; + volume->update_time =TIME64_MIN ;refcount_set (&volume->ref,1 );INIT_HLIST_NODE (&volume->proc_link);INIT_WORK (&volume->destructor, afs_destroy_volume);rwlock_init (&volume->servers_lock); +mutex_init (&volume->volsync_lock); +mutex_init (&volume->cb_check_lock);rwlock_init (&volume->cb_v_break_lock);INIT_LIST_HEAD (&volume->open_mmaps);init_rwsem (&volume->open_mmaps_lock);
@@ -388,7 +392,11 @@ static int afs_update_volume_status(struct afs_volume *volume, struct key *key) discard = old; } - volume->update_at =ktime_get_real_seconds () + afs_volume_record_life; +/* Check more often if replication is ongoing. */ +if (new->ro_replicating) + volume->update_at =ktime_get_real_seconds () +2 ; +else + volume->update_at =ktime_get_real_seconds () + afs_volume_record_life;write_unlock (&volume->servers_lock);if (discard == old)
fs/afs/yfsclient.c +0 -1
@@ -254,7 +254,6 @@ static void xdr_decode_YFSVolSync(const __be32 **_bp, update =xdr_to_u64 (x->vol_update_date);do_div (update,10 *1000 *1000 ); volsync->update = update; - volsync->mask |=AFS_VOLSYNC_CREATION |AFS_VOLSYNC_UPDATE ; } *_bp +=xdr_size (x);
include/trace/events/afs.h +2 -1
@@ -442,7 +442,8 @@ enum yfs_cm_operation { EM(afs_cb_break_for_unlink, "break-unlink") \ EM(afs_cb_break_for_update_regress, "update-regress") \ EM(afs_cb_break_for_volume_callback, "break-v-cb") \ - E_(afs_cb_break_for_vos_release, "break-vos-release") + EM(afs_cb_break_for_vos_release, "break-vos-release") \ + E_(afs_cb_break_volume_excluded, "vol-excluded")#define afs_rotate_traces \ EM(afs_rotate_trace_aborted, "Abortd") \
David Howells
maintainerPATCH 40/41 afs: Fix fileserver rotation
In reply to David HowellsFix the fileserver rotation so that it doesn't use RTT as the basis for deciding which server and address to use as this doesn't necessarily give a good indication of the best path. Instead, use the configurable preference list in conjunction with whatever probes have succeeded at the time of looking.
To this end, make the following changes:
(1) Keep an array of "server states" to track what addresses we've tried on each server and move the waitqueue entries there that we'll need for probing.
(2) Each afs_server_state struct is made to pin the corresponding server's endpoint state rather than the afs_operation struct carrying a pin on the server we're currently looking at.
(3) Drop the server list preference; we now always rescan the server list.
(4) afs_wait_for_probes() now uses the server state list to guide it in what it waits for (and to provide the waitqueue entries) and returns an indication of whether we'd got a response, run out of responsive addresses or the endpoint state had been superseded and we need to restart the iteration.
(5) We call afs_get_address_preferences*() occasionally to refresh the preference values.
(6) When picking a server, scan the addresses of the servers for which we have as-yet untested communications, looking for the highest priority one and use that instead of trying all the addresses for a particular server in ascending-RTT order.
Also add a tracepoint to track progress through the rotation algorithm.
--- fs/afs/fs_operation.c | 8 +- fs/afs/fs_probe.c | 103 +++++++++-------------- fs/afs/internal.h | 23 ++++- fs/afs/rotate.c | 168 +++++++++++++++++++++++++++---------- fs/afs/server_list.c | 14 +--- include/trace/events/afs.h | 80 +++++++++++++++--- 6 files changed, 256 insertions(+), 140 deletions(-)
fs/afs/fs_operation.c +3 -5
@@ -230,7 +230,6 @@ void afs_wait_for_operation(struct afs_operation *op)*/ int afs_put_operation (struct afs_operation *op) { -struct afs_endpoint_state *estate = op->estate;struct afs_addr_list *alist;int i, ret =afs_op_error (op);
@@ -254,18 +253,17 @@ int afs_put_operation(struct afs_operation *op)kfree (op->more_files); } -if (estate) { - alist = estate->addresses; +if (op->estate) { + alist = op->estate->addresses;if (alist) {if (op->call_responded && op->addr_index != alist->preferred &&test_bit (alist->preferred, &op->addr_tried))WRITE_ONCE (alist->preferred, op->addr_index); } -afs_put_endpoint_state (estate, afs_estate_trace_put_operation); - op->estate =NULL ; } +afs_clear_server_states (op);afs_put_serverlist (op->net, op->server_list);afs_put_volume (op->volume, afs_volume_trace_put_put_op);key_put (op->key);
fs/afs/fs_probe.c +40 -63
147 lines not on this page · raw message
fs/afs/internal.h +19 -4
@@ -610,7 +610,6 @@ struct afs_server_list {refcount_t usage;bool attached;/* T if attached to servers */ unsigned char nr_servers; -unsigned char preferred;/* Preferred server */ unsigned short vnovol_mask;/* Servers to be skipped due to VNOVOL */ unsigned int seq;/* Set to ->servers_seq when installed */ rwlock_t lock;
@@ -806,6 +805,20 @@ struct afs_vl_cursor {bool call_responded;/* T if the current address responded */ }; +/* +* Fileserver state tracking for an operation. An array of these is kept, +* indexed by server index. +*/ +struct afs_server_state { +/* Tracking of fileserver probe state. Other operations may interfere +* by probing a fileserver when accessing other volumes. +*/ +unsigned int probe_seq; +unsigned long untried_addrs;/* Addresses we haven't tried yet */ +struct wait_queue_entry probe_waiter; +struct afs_endpoint_state *endpoint_state;/* Endpoint state being monitored */ +}; +/* * Fileserver operation methods. */
@@ -906,7 +919,8 @@ struct afs_operation {/* Fileserver iteration state */ struct afs_server_list *server_list;/* Current server list (pins ref) */ struct afs_server *server;/* Server we're using (ref pinned by server_list) */ -struct afs_endpoint_state *estate;/* Current endpoint state (pins ref) */ +struct afs_endpoint_state *estate;/* Current endpoint state (doesn't pin ref) */ +struct afs_server_state *server_states;/* States of the servers involved */ struct afs_call *call;unsigned long untried_servers;/* Bitmask of untried servers */ unsigned long addr_tried;/* Tried addresses */
@@ -1220,11 +1234,11 @@ void afs_put_endpoint_state(struct afs_endpoint_state *estate, enum afs_estate_textern void afs_fileserver_probe_result (struct afs_call *);void afs_fs_probe_fileserver (struct afs_net *net,struct afs_server *server,struct afs_addr_list *new_addrs,struct key *key); -extern int afs_wait_for_fs_probes (struct afs_server_list *,unsigned long ); +int afs_wait_for_fs_probes (struct afs_operation *op,struct afs_server_state *states,bool intr);extern void afs_probe_fileserver (struct afs_net *,struct afs_server *);extern void afs_fs_probe_dispatcher (struct work_struct *);int afs_wait_for_one_fs_probe (struct afs_server *server,struct afs_endpoint_state *estate, -bool is_intr); +unsigned long exclude,bool is_intr);extern void afs_fs_probe_cleanup (struct afs_net *);/*
@@ -1348,6 +1362,7 @@ static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {}/* * rotate.c */ +void afs_clear_server_states (struct afs_operation *op);extern bool afs_select_fileserver (struct afs_operation *);extern void afs_dump_edestaddrreq (const struct afs_operation *);
fs/afs/rotate.c +125 -43
352 lines not on this page · raw message
fs/afs/server_list.c +1 -13
@@ -102,8 +102,7 @@ struct afs_server_list *afs_alloc_server_list(struct afs_volume *volume,bool afs_annotate_server_list (struct afs_server_list *new,struct afs_server_list *old) { -struct afs_server *cur; -int i, j; +int i;if (old->nr_servers != new->nr_servers) goto changed;
@@ -111,19 +110,8 @@ bool afs_annotate_server_list(struct afs_server_list *new,for (i =0 ; i < old->nr_servers; i++)if (old->servers[i].server != new->servers[i].server) goto changed; -return false; - changed: -/* Maintain the same preferred server as before if possible. */ - cur = old->servers[old->preferred].server; -for (j =0 ; j < new->nr_servers; j++) { -if (new->servers[j].server == cur) { - new->preferred = j; -break ; - } - } -return true; }
include/trace/events/afs.h +68 -12
122 lines not on this page · raw message
David Howells
maintainerPATCH 41/41 afs: Fix offline and busy handling
In reply to David HowellsThe current code assumes offline and busy volume states apply to all instances of a volume, not just the one on the server that returned VOFFLINE or VBUSY.
Fix that by moving the flags recording this to the afs_server_entry struct that is used to represent a particular instance of a volume on a specific server.
Further, add a sleep for when we have iterated through all the servers so that we don't keep poking the server every few milliseconds.
--- fs/afs/internal.h | 7 ++++--- fs/afs/rotate.c | 40 ++++++++++++++++++++++++-------------- include/trace/events/afs.h | 1 + 3 files changed, 30 insertions(+), 18 deletions(-)
fs/afs/internal.h +4 -3
@@ -603,6 +603,9 @@ struct afs_server_entry {struct afs_volume *volume;struct list_head slink;/* Link in server->volumes */ time64_t cb_expires_at;/* Time at which volume-level callback expires */ +unsigned long flags; +#define AFS_SE_VOLUME_OFFLINE 0/* Set if volume offline notice given */ +#define AFS_SE_VOLUME_BUSY 1/* Set if volume busy notice given */ };struct afs_server_list {
@@ -636,9 +639,7 @@ struct afs_volume {#define AFS_VOLUME_UPDATING 1/* - T if an update is in progress */ #define AFS_VOLUME_WAIT 2/* - T if users must wait for update */ #define AFS_VOLUME_DELETED 3/* - T if volume appears deleted */ -#define AFS_VOLUME_OFFLINE 4/* - T if volume offline notice given */ -#define AFS_VOLUME_BUSY 5/* - T if volume busy notice given */ -#define AFS_VOLUME_MAYBE_NO_IBULK 6/* - T if some servers don't have InlineBulkStatus */ +#define AFS_VOLUME_MAYBE_NO_IBULK 4/* - T if some servers don't have InlineBulkStatus */ #ifdef CONFIG_AFS_FSCACHE struct fscache_volume *cache;/* Caching cookie */ #endif
fs/afs/rotate.c +25 -15
@@ -111,7 +111,7 @@ static bool afs_start_fs_iteration(struct afs_operation *op,/* * Post volume busy note. */ -static void afs_busy (struct afs_volume *volume,u32 abort_code) +static void afs_busy (struct afs_operation *op,u32 abort_code) {const char *m;
@@ -122,7 +122,8 @@ static void afs_busy(struct afs_volume *volume, u32 abort_code)default : m ="busy" ;break ; } -pr_notice ("kAFS: Volume %llu '%s' is %s\n" , volume->vid, volume->name, m); +pr_notice ("kAFS: Volume %llu '%s' on server %pU is %s\n" , + op->volume->vid, op->volume->name, &op->server->uuid, m); }/*
@@ -130,6 +131,7 @@ static void afs_busy(struct afs_volume *volume, u32 abort_code)*/ static bool afs_sleep_and_retry (struct afs_operation *op) { +trace_afs_rotate (op, afs_rotate_trace_busy_sleep,0 );if (!(op->flags &AFS_OPERATION_UNINTR )) {msleep_interruptible (1000 );if (signal_pending (current)) {
@@ -180,6 +182,10 @@ bool afs_select_fileserver(struct afs_operation *op)/* Evaluate the result of the previous operation, if there was one. */ switch (op->call_error) {case 0 : +clear_bit (AFS_SE_VOLUME_OFFLINE , + &op->server_list->servers[op->server_index].flags); +clear_bit (AFS_SE_VOLUME_BUSY , + &op->server_list->servers[op->server_index].flags); op->cumul_error.responded = true; fallthrough;default :
@@ -297,18 +303,16 @@ bool afs_select_fileserver(struct afs_operation *op)* expected to come back but it might take a long time (could be * days). */ -if (!test_and_set_bit (AFS_VOLUME_OFFLINE , &op->volume->flags)) { -afs_busy (op->volume, abort_code); -clear_bit (AFS_VOLUME_BUSY , &op->volume->flags); +if (!test_and_set_bit (AFS_SE_VOLUME_OFFLINE , + &op->server_list->servers[op->server_index].flags)) { +afs_busy (op, abort_code); +clear_bit (AFS_SE_VOLUME_BUSY , + &op->server_list->servers[op->server_index].flags); }if (op->flags &AFS_OPERATION_NO_VSLEEP ) {afs_op_set_error (op, -EADV ); goto failed; } -if (op->flags &AFS_OPERATION_CUR_ONLY ) { -afs_op_set_error (op, -ESTALE ); - goto failed; - } goto busy;case VRESTARTING :/* The fileserver is either shutting down or starting up. */
@@ -329,9 +333,11 @@ bool afs_select_fileserver(struct afs_operation *op)afs_op_set_error (op, -EBUSY ); goto failed; } -if (!test_and_set_bit (AFS_VOLUME_BUSY , &op->volume->flags)) { -afs_busy (op->volume, abort_code); -clear_bit (AFS_VOLUME_OFFLINE , &op->volume->flags); +if (!test_and_set_bit (AFS_SE_VOLUME_BUSY , + &op->server_list->servers[op->server_index].flags)) { +afs_busy (op, abort_code); +clear_bit (AFS_SE_VOLUME_OFFLINE , + &op->server_list->servers[op->server_index].flags); } busy:if (op->flags &AFS_OPERATION_CUR_ONLY ) {
@@ -411,8 +417,10 @@ bool afs_select_fileserver(struct afs_operation *op)default :afs_op_accumulate_error (op, error, abort_code); failed_but_online: -clear_bit (AFS_VOLUME_OFFLINE , &op->volume->flags); -clear_bit (AFS_VOLUME_BUSY , &op->volume->flags); +clear_bit (AFS_SE_VOLUME_OFFLINE , + &op->server_list->servers[op->server_index].flags); +clear_bit (AFS_SE_VOLUME_BUSY , + &op->server_list->servers[op->server_index].flags); goto failed; }
@@ -640,8 +648,10 @@ bool afs_select_fileserver(struct afs_operation *op)* of them were busy. */ trace_afs_rotate (op, afs_rotate_trace_no_more_servers,0 ); -if (op->flags &AFS_OPERATION_VBUSY ) +if (op->flags &AFS_OPERATION_VBUSY ) { +afs_sleep_and_retry (op); goto restart_from_beginning; + }rcu_read_lock ();for (i =0 ; i < op->server_list->nr_servers; i++) {
include/trace/events/afs.h +1 -0
@@ -446,6 +446,7 @@ enum yfs_cm_operation {#define afs_rotate_traces \ EM(afs_rotate_trace_aborted, "Abortd") \ + EM(afs_rotate_trace_busy_sleep, "BsySlp") \ EM(afs_rotate_trace_check_vol_status, "VolStt") \ EM(afs_rotate_trace_failed, "Failed") \ EM(afs_rotate_trace_iter, "Iter ") \