Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* AFS fileserver probing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2018, 2020 Red Hat, Inc. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Written by David Howells (dhowells@redhat.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "afs_fs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "protocol_yfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) static unsigned int afs_fs_probe_fast_poll_interval = 30 * HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) static unsigned int afs_fs_probe_slow_poll_interval = 5 * 60 * HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * Start the probe polling timer.  We have to supply it with an inc on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * outstanding server count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) static void afs_schedule_fs_probe(struct afs_net *net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 				  struct afs_server *server, bool fast)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	unsigned long atj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	if (!net->live)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	atj = server->probed_at;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	atj += fast ? afs_fs_probe_fast_poll_interval : afs_fs_probe_slow_poll_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	afs_inc_servers_outstanding(net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	if (timer_reduce(&net->fs_probe_timer, atj))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		afs_dec_servers_outstanding(net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * Handle the completion of a set of probes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) static void afs_finished_fs_probe(struct afs_net *net, struct afs_server *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	bool responded = server->probe.responded;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	write_seqlock(&net->fs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	if (responded) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		list_add_tail(&server->probe_link, &net->fs_probe_slow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		server->rtt = UINT_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		clear_bit(AFS_SERVER_FL_RESPONDING, &server->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		list_add_tail(&server->probe_link, &net->fs_probe_fast);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	write_sequnlock(&net->fs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	afs_schedule_fs_probe(net, server, !responded);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * Handle the completion of a probe.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) static void afs_done_one_fs_probe(struct afs_net *net, struct afs_server *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	if (atomic_dec_and_test(&server->probe_outstanding))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		afs_finished_fs_probe(net, server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	wake_up_all(&server->probe_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * Handle inability to send a probe due to ENOMEM when trying to allocate a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * call struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static void afs_fs_probe_not_done(struct afs_net *net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 				  struct afs_server *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 				  struct afs_addr_cursor *ac)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	struct afs_addr_list *alist = ac->alist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	unsigned int index = ac->index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	trace_afs_io_error(0, -ENOMEM, afs_io_error_fs_probe_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	spin_lock(&server->probe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	server->probe.local_failure = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	if (server->probe.error == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		server->probe.error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	set_bit(index, &alist->failed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	spin_unlock(&server->probe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	return afs_done_one_fs_probe(net, server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  * Process the result of probing a fileserver.  This is called after successful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * or failed delivery of an FS.GetCapabilities operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) void afs_fileserver_probe_result(struct afs_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct afs_addr_list *alist = call->alist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	struct afs_server *server = call->server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	unsigned int index = call->addr_ix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	unsigned int rtt_us = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	int ret = call->error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	_enter("%pU,%u", &server->uuid, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	spin_lock(&server->probe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	switch (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		server->probe.error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		goto responded;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	case -ECONNABORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		if (!server->probe.responded) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			server->probe.abort_code = call->abort_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			server->probe.error = ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		goto responded;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	case -ENOMEM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	case -ENONET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		clear_bit(index, &alist->responded);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		server->probe.local_failure = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		trace_afs_io_error(call->debug_id, ret, afs_io_error_fs_probe_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	case -ECONNRESET: /* Responded, but call expired. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	case -ERFKILL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	case -EADDRNOTAVAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	case -ENETUNREACH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	case -EHOSTUNREACH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	case -EHOSTDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	case -ECONNREFUSED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	case -ETIMEDOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	case -ETIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		clear_bit(index, &alist->responded);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		set_bit(index, &alist->failed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		if (!server->probe.responded &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		    (server->probe.error == 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		     server->probe.error == -ETIMEDOUT ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		     server->probe.error == -ETIME))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			server->probe.error = ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		trace_afs_io_error(call->debug_id, ret, afs_io_error_fs_probe_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) responded:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	clear_bit(index, &alist->failed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	if (call->service_id == YFS_FS_SERVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		server->probe.is_yfs = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		set_bit(AFS_SERVER_FL_IS_YFS, &server->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		alist->addrs[index].srx_service = call->service_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		server->probe.not_yfs = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		if (!server->probe.is_yfs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 			clear_bit(AFS_SERVER_FL_IS_YFS, &server->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 			alist->addrs[index].srx_service = call->service_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	if (rxrpc_kernel_get_srtt(call->net->socket, call->rxcall, &rtt_us) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	    rtt_us < server->probe.rtt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		server->probe.rtt = rtt_us;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		server->rtt = rtt_us;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		alist->preferred = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	smp_wmb(); /* Set rtt before responded. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	server->probe.responded = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	set_bit(index, &alist->responded);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	set_bit(AFS_SERVER_FL_RESPONDING, &server->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	spin_unlock(&server->probe_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	_debug("probe %pU [%u] %pISpc rtt=%u ret=%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	       &server->uuid, index, &alist->addrs[index].transport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	       rtt_us, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	return afs_done_one_fs_probe(call->net, server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * Probe one or all of a fileserver's addresses to find out the best route and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  * to query its capabilities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) void afs_fs_probe_fileserver(struct afs_net *net, struct afs_server *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 			     struct key *key, bool all)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	struct afs_addr_cursor ac = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		.index = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	_enter("%pU", &server->uuid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	read_lock(&server->fs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	ac.alist = rcu_dereference_protected(server->addresses,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 					     lockdep_is_held(&server->fs_lock));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	afs_get_addrlist(ac.alist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	read_unlock(&server->fs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	server->probed_at = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	atomic_set(&server->probe_outstanding, all ? ac.alist->nr_addrs : 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	memset(&server->probe, 0, sizeof(server->probe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	server->probe.rtt = UINT_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	ac.index = ac.alist->preferred;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (ac.index < 0 || ac.index >= ac.alist->nr_addrs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		all = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	if (all) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		for (ac.index = 0; ac.index < ac.alist->nr_addrs; ac.index++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			if (!afs_fs_get_capabilities(net, server, &ac, key))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 				afs_fs_probe_not_done(net, server, &ac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		if (!afs_fs_get_capabilities(net, server, &ac, key))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			afs_fs_probe_not_done(net, server, &ac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	afs_put_addrlist(ac.alist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  * Wait for the first as-yet untried fileserver to respond.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) int afs_wait_for_fs_probes(struct afs_server_list *slist, unsigned long untried)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	struct wait_queue_entry *waits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	struct afs_server *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	unsigned int rtt = UINT_MAX, rtt_s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	bool have_responders = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	int pref = -1, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	_enter("%u,%lx", slist->nr_servers, untried);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	/* Only wait for servers that have a probe outstanding. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	for (i = 0; i < slist->nr_servers; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		if (test_bit(i, &untried)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			server = slist->servers[i].server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			if (!atomic_read(&server->probe_outstanding))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 				__clear_bit(i, &untried);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 			if (server->probe.responded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 				have_responders = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	if (have_responders || !untried)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	waits = kmalloc(array_size(slist->nr_servers, sizeof(*waits)), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	if (!waits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	for (i = 0; i < slist->nr_servers; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		if (test_bit(i, &untried)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			server = slist->servers[i].server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 			init_waitqueue_entry(&waits[i], current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 			add_wait_queue(&server->probe_wq, &waits[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	for (;;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		bool still_probing = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		set_current_state(TASK_INTERRUPTIBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		for (i = 0; i < slist->nr_servers; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 			if (test_bit(i, &untried)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 				server = slist->servers[i].server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 				if (server->probe.responded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 					goto stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 				if (atomic_read(&server->probe_outstanding))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 					still_probing = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		if (!still_probing || signal_pending(current))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 			goto stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		schedule();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) stop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	set_current_state(TASK_RUNNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	for (i = 0; i < slist->nr_servers; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		if (test_bit(i, &untried)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 			server = slist->servers[i].server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 			rtt_s = READ_ONCE(server->rtt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 			if (test_bit(AFS_SERVER_FL_RESPONDING, &server->flags) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 			    rtt_s < rtt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 				pref = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 				rtt = rtt_s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 			remove_wait_queue(&server->probe_wq, &waits[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	kfree(waits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	if (pref == -1 && signal_pending(current))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		return -ERESTARTSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	if (pref >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		slist->preferred = pref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)  * Probe timer.  We have an increment on fs_outstanding that we need to pass
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)  * along to the work item.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) void afs_fs_probe_timer(struct timer_list *timer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	struct afs_net *net = container_of(timer, struct afs_net, fs_probe_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	if (!net->live || !queue_work(afs_wq, &net->fs_prober))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		afs_dec_servers_outstanding(net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)  * Dispatch a probe to a server.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) static void afs_dispatch_fs_probe(struct afs_net *net, struct afs_server *server, bool all)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	__releases(&net->fs_lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	struct key *key = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	/* We remove it from the queues here - it will be added back to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	 * one of the queues on the completion of the probe.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	list_del_init(&server->probe_link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	afs_get_server(server, afs_server_trace_get_probe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	write_sequnlock(&net->fs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	afs_fs_probe_fileserver(net, server, key, all);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	afs_put_server(net, server, afs_server_trace_put_probe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)  * Probe a server immediately without waiting for its due time to come
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)  * round.  This is used when all of the addresses have been tried.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) void afs_probe_fileserver(struct afs_net *net, struct afs_server *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	write_seqlock(&net->fs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	if (!list_empty(&server->probe_link))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		return afs_dispatch_fs_probe(net, server, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	write_sequnlock(&net->fs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)  * Probe dispatcher to regularly dispatch probes to keep NAT alive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) void afs_fs_probe_dispatcher(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	struct afs_net *net = container_of(work, struct afs_net, fs_prober);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	struct afs_server *fast, *slow, *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	unsigned long nowj, timer_at, poll_at;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	bool first_pass = true, set_timer = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	if (!net->live)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	if (list_empty(&net->fs_probe_fast) && list_empty(&net->fs_probe_slow)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		_leave(" [none]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) again:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	write_seqlock(&net->fs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	fast = slow = server = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	nowj = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	timer_at = nowj + MAX_JIFFY_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	if (!list_empty(&net->fs_probe_fast)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		fast = list_first_entry(&net->fs_probe_fast, struct afs_server, probe_link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		poll_at = fast->probed_at + afs_fs_probe_fast_poll_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		if (time_before(nowj, poll_at)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 			timer_at = poll_at;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 			set_timer = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 			fast = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	if (!list_empty(&net->fs_probe_slow)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		slow = list_first_entry(&net->fs_probe_slow, struct afs_server, probe_link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		poll_at = slow->probed_at + afs_fs_probe_slow_poll_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		if (time_before(nowj, poll_at)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 			if (time_before(poll_at, timer_at))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 			    timer_at = poll_at;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 			set_timer = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 			slow = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	server = fast ?: slow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	if (server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		_debug("probe %pU", &server->uuid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	if (server && (first_pass || !need_resched())) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		afs_dispatch_fs_probe(net, server, server == fast);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		first_pass = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		goto again;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	write_sequnlock(&net->fs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	if (server) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		if (!queue_work(afs_wq, &net->fs_prober))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			afs_dec_servers_outstanding(net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		_leave(" [requeue]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	} else if (set_timer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		if (timer_reduce(&net->fs_probe_timer, timer_at))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			afs_dec_servers_outstanding(net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		_leave(" [timer]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		afs_dec_servers_outstanding(net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		_leave(" [quiesce]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)  * Wait for a probe on a particular fileserver to complete for 2s.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) int afs_wait_for_one_fs_probe(struct afs_server *server, bool is_intr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	struct wait_queue_entry wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	unsigned long timo = 2 * HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	if (atomic_read(&server->probe_outstanding) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		goto dont_wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	init_wait_entry(&wait, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	for (;;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		prepare_to_wait_event(&server->probe_wq, &wait,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 				      is_intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 		if (timo == 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 		    server->probe.responded ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		    atomic_read(&server->probe_outstanding) == 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		    (is_intr && signal_pending(current)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 		timo = schedule_timeout(timo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	finish_wait(&server->probe_wq, &wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) dont_wait:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	if (server->probe.responded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	if (is_intr && signal_pending(current))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 		return -ERESTARTSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	if (timo == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 		return -ETIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	return -EDESTADDRREQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)  * Clean up the probing when the namespace is killed off.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) void afs_fs_probe_cleanup(struct afs_net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	if (del_timer_sync(&net->fs_probe_timer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 		afs_dec_servers_outstanding(net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }