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 Cache Manager Service
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2002 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/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/ip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "afs_cm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "protocol_yfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) static int afs_deliver_cb_init_call_back_state(struct afs_call *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) static int afs_deliver_cb_init_call_back_state3(struct afs_call *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static int afs_deliver_cb_probe(struct afs_call *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) static int afs_deliver_cb_callback(struct afs_call *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) static int afs_deliver_cb_probe_uuid(struct afs_call *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) static void afs_cm_destructor(struct afs_call *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static void SRXAFSCB_CallBack(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static void SRXAFSCB_InitCallBackState(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) static void SRXAFSCB_Probe(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static void SRXAFSCB_ProbeUuid(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static void SRXAFSCB_TellMeAboutYourself(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) static int afs_deliver_yfs_cb_callback(struct afs_call *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * CB.CallBack operation type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) static const struct afs_call_type afs_SRXCBCallBack = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	.name		= "CB.CallBack",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	.deliver	= afs_deliver_cb_callback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	.destructor	= afs_cm_destructor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	.work		= SRXAFSCB_CallBack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * CB.InitCallBackState operation type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) static const struct afs_call_type afs_SRXCBInitCallBackState = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	.name		= "CB.InitCallBackState",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	.deliver	= afs_deliver_cb_init_call_back_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	.destructor	= afs_cm_destructor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	.work		= SRXAFSCB_InitCallBackState,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * CB.InitCallBackState3 operation type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) static const struct afs_call_type afs_SRXCBInitCallBackState3 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	.name		= "CB.InitCallBackState3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	.deliver	= afs_deliver_cb_init_call_back_state3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	.destructor	= afs_cm_destructor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	.work		= SRXAFSCB_InitCallBackState,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * CB.Probe operation type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) static const struct afs_call_type afs_SRXCBProbe = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	.name		= "CB.Probe",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	.deliver	= afs_deliver_cb_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	.destructor	= afs_cm_destructor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	.work		= SRXAFSCB_Probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * CB.ProbeUuid operation type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static const struct afs_call_type afs_SRXCBProbeUuid = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	.name		= "CB.ProbeUuid",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	.deliver	= afs_deliver_cb_probe_uuid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	.destructor	= afs_cm_destructor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	.work		= SRXAFSCB_ProbeUuid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * CB.TellMeAboutYourself operation type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static const struct afs_call_type afs_SRXCBTellMeAboutYourself = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	.name		= "CB.TellMeAboutYourself",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	.deliver	= afs_deliver_cb_tell_me_about_yourself,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	.destructor	= afs_cm_destructor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	.work		= SRXAFSCB_TellMeAboutYourself,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * YFS CB.CallBack operation type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) static const struct afs_call_type afs_SRXYFSCB_CallBack = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	.name		= "YFSCB.CallBack",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	.deliver	= afs_deliver_yfs_cb_callback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	.destructor	= afs_cm_destructor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	.work		= SRXAFSCB_CallBack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  * route an incoming cache manager call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * - return T if supported, F if not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) bool afs_cm_incoming_call(struct afs_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	_enter("{%u, CB.OP %u}", call->service_id, call->operation_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	switch (call->operation_ID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	case CBCallBack:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		call->type = &afs_SRXCBCallBack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	case CBInitCallBackState:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		call->type = &afs_SRXCBInitCallBackState;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	case CBInitCallBackState3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		call->type = &afs_SRXCBInitCallBackState3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	case CBProbe:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		call->type = &afs_SRXCBProbe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	case CBProbeUuid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		call->type = &afs_SRXCBProbeUuid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	case CBTellMeAboutYourself:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		call->type = &afs_SRXCBTellMeAboutYourself;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	case YFSCBCallBack:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		if (call->service_id != YFS_CM_SERVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		call->type = &afs_SRXYFSCB_CallBack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * Find the server record by peer address and record a probe to the cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * manager from a server.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static int afs_find_cm_server_by_peer(struct afs_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	struct sockaddr_rxrpc srx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	struct afs_server *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	rxrpc_kernel_get_peer(call->net->socket, call->rxcall, &srx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	server = afs_find_server(call->net, &srx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (!server) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		trace_afs_cm_no_server(call, &srx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	call->server = server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * Find the server record by server UUID and record a probe to the cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * manager from a server.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static int afs_find_cm_server_by_uuid(struct afs_call *call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 				      struct afs_uuid *uuid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	struct afs_server *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	server = afs_find_server_by_uuid(call->net, call->request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (!server) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		trace_afs_cm_no_server_u(call, call->request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	call->server = server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  * Clean up a cache manager call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static void afs_cm_destructor(struct afs_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	kfree(call->buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	call->buffer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * Abort a service call from within an action function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static void afs_abort_service_call(struct afs_call *call, u32 abort_code, int error,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 				   const char *why)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	rxrpc_kernel_abort_call(call->net->socket, call->rxcall,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 				abort_code, error, why);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	afs_set_call_complete(call, error, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  * The server supplied a list of callbacks that it wanted to break.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static void SRXAFSCB_CallBack(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	struct afs_call *call = container_of(work, struct afs_call, work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	/* We need to break the callbacks before sending the reply as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	 * server holds up change visibility till it receives our reply so as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	 * to maintain cache coherency.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	if (call->server) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		trace_afs_server(call->server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 				 atomic_read(&call->server->ref),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 				 atomic_read(&call->server->active),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 				 afs_server_trace_callback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		afs_break_callbacks(call->server, call->count, call->request);
^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_send_empty_reply(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	afs_put_call(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	_leave("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  * deliver request data to a CB.CallBack call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static int afs_deliver_cb_callback(struct afs_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	struct afs_callback_break *cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	__be32 *bp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	int ret, loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	_enter("{%u}", call->unmarshall);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	switch (call->unmarshall) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		afs_extract_to_tmp(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		/* extract the FID array and its count in two steps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		_debug("extract FID count");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		ret = afs_extract_data(call, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		call->count = ntohl(call->tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		_debug("FID count: %u", call->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		if (call->count > AFSCBMAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 			return afs_protocol_error(call, afs_eproto_cb_fid_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		call->buffer = kmalloc(array3_size(call->count, 3, 4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 				       GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		if (!call->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		afs_extract_to_buf(call, call->count * 3 * 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		_debug("extract FID array");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		ret = afs_extract_data(call, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		_debug("unmarshall FID array");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		call->request = kcalloc(call->count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 					sizeof(struct afs_callback_break),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 					GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		if (!call->request)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		cb = call->request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		bp = call->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		for (loop = call->count; loop > 0; loop--, cb++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 			cb->fid.vid	= ntohl(*bp++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 			cb->fid.vnode	= ntohl(*bp++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 			cb->fid.unique	= ntohl(*bp++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		afs_extract_to_tmp(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		/* extract the callback array and its count in two steps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		_debug("extract CB count");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		ret = afs_extract_data(call, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		call->count2 = ntohl(call->tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		_debug("CB count: %u", call->count2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		if (call->count2 != call->count && call->count2 != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 			return afs_protocol_error(call, afs_eproto_cb_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		call->iter = &call->def_iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		iov_iter_discard(&call->def_iter, READ, call->count2 * 3 * 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	case 4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		_debug("extract discard %zu/%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		       iov_iter_count(call->iter), call->count2 * 3 * 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		ret = afs_extract_data(call, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	case 5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 		return afs_io_error(call, afs_io_error_cm_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	/* we'll need the file server record as that tells us which set of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	 * vnodes to operate upon */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	return afs_find_cm_server_by_peer(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)  * allow the fileserver to request callback state (re-)initialisation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static void SRXAFSCB_InitCallBackState(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	struct afs_call *call = container_of(work, struct afs_call, work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	_enter("{%p}", call->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	if (call->server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		afs_init_callback_state(call->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	afs_send_empty_reply(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	afs_put_call(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	_leave("");
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)  * deliver request data to a CB.InitCallBackState call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static int afs_deliver_cb_init_call_back_state(struct afs_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	afs_extract_discard(call, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	ret = afs_extract_data(call, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	/* we'll need the file server record as that tells us which set of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	 * vnodes to operate upon */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	return afs_find_cm_server_by_peer(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)  * deliver request data to a CB.InitCallBackState3 call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	struct afs_uuid *r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	unsigned loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	__be32 *b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	_enter("{%u}", call->unmarshall);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	switch (call->unmarshall) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		if (!call->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		afs_extract_to_buf(call, 11 * sizeof(__be32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		_debug("extract UUID");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		ret = afs_extract_data(call, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		switch (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		case 0:		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		case -EAGAIN:	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		default:	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		_debug("unmarshall UUID");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		if (!call->request)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		b = call->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		r = call->request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		r->time_low			= b[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		r->time_mid			= htons(ntohl(b[1]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		r->time_hi_and_version		= htons(ntohl(b[2]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		r->clock_seq_hi_and_reserved 	= ntohl(b[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		r->clock_seq_low		= ntohl(b[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		for (loop = 0; loop < 6; loop++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 			r->node[loop] = ntohl(b[loop + 5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		return afs_io_error(call, afs_io_error_cm_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	/* we'll need the file server record as that tells us which set of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	 * vnodes to operate upon */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	return afs_find_cm_server_by_uuid(call, call->request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)  * allow the fileserver to see if the cache manager is still alive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) static void SRXAFSCB_Probe(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	struct afs_call *call = container_of(work, struct afs_call, work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	afs_send_empty_reply(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	afs_put_call(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	_leave("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)  * deliver request data to a CB.Probe call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) static int afs_deliver_cb_probe(struct afs_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	afs_extract_discard(call, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	ret = afs_extract_data(call, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 		return afs_io_error(call, afs_io_error_cm_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	return afs_find_cm_server_by_peer(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)  * Allow the fileserver to quickly find out if the cache manager has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)  * rebooted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) static void SRXAFSCB_ProbeUuid(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	struct afs_call *call = container_of(work, struct afs_call, work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	struct afs_uuid *r = call->request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	if (memcmp(r, &call->net->uuid, sizeof(call->net->uuid)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		afs_send_empty_reply(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 		afs_abort_service_call(call, 1, 1, "K-1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	afs_put_call(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	_leave("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)  * deliver request data to a CB.ProbeUuid call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) static int afs_deliver_cb_probe_uuid(struct afs_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	struct afs_uuid *r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	unsigned loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	__be32 *b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	_enter("{%u}", call->unmarshall);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	switch (call->unmarshall) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 		call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 		if (!call->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		afs_extract_to_buf(call, 11 * sizeof(__be32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 		_debug("extract UUID");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		ret = afs_extract_data(call, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 		switch (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 		case 0:		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 		case -EAGAIN:	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		default:	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 		_debug("unmarshall UUID");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 		if (!call->request)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		b = call->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		r = call->request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		r->time_low			= b[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		r->time_mid			= htons(ntohl(b[1]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 		r->time_hi_and_version		= htons(ntohl(b[2]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 		r->clock_seq_hi_and_reserved 	= ntohl(b[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 		r->clock_seq_low		= ntohl(b[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 		for (loop = 0; loop < 6; loop++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 			r->node[loop] = ntohl(b[loop + 5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 		return afs_io_error(call, afs_io_error_cm_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	return afs_find_cm_server_by_peer(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)  * allow the fileserver to ask about the cache manager's capabilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	struct afs_call *call = container_of(work, struct afs_call, work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	int loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 		struct /* InterfaceAddr */ {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 			__be32 nifs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 			__be32 uuid[11];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 			__be32 ifaddr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 			__be32 netmask[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 			__be32 mtu[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 		} ia;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 		struct /* Capabilities */ {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 			__be32 capcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 			__be32 caps[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 		} cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	} reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	memset(&reply, 0, sizeof(reply));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	reply.ia.uuid[0] = call->net->uuid.time_low;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	reply.ia.uuid[1] = htonl(ntohs(call->net->uuid.time_mid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	reply.ia.uuid[2] = htonl(ntohs(call->net->uuid.time_hi_and_version));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	reply.ia.uuid[3] = htonl((s8) call->net->uuid.clock_seq_hi_and_reserved);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	reply.ia.uuid[4] = htonl((s8) call->net->uuid.clock_seq_low);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	for (loop = 0; loop < 6; loop++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 		reply.ia.uuid[loop + 5] = htonl((s8) call->net->uuid.node[loop]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	reply.cap.capcount = htonl(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	reply.cap.caps[0] = htonl(AFS_CAP_ERROR_TRANSLATION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	afs_send_simple_reply(call, &reply, sizeof(reply));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	afs_put_call(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	_leave("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)  * deliver request data to a CB.TellMeAboutYourself call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	afs_extract_discard(call, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	ret = afs_extract_data(call, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 	if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 		return afs_io_error(call, afs_io_error_cm_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	return afs_find_cm_server_by_peer(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)  * deliver request data to a YFS CB.CallBack call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) static int afs_deliver_yfs_cb_callback(struct afs_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	struct afs_callback_break *cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	struct yfs_xdr_YFSFid *bp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	size_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	int ret, loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 	_enter("{%u}", call->unmarshall);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 	switch (call->unmarshall) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 		afs_extract_to_tmp(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 		/* extract the FID array and its count in two steps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 		_debug("extract FID count");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 		ret = afs_extract_data(call, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 		call->count = ntohl(call->tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 		_debug("FID count: %u", call->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 		if (call->count > YFSCBMAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 			return afs_protocol_error(call, afs_eproto_cb_fid_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 		size = array_size(call->count, sizeof(struct yfs_xdr_YFSFid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 		call->buffer = kmalloc(size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 		if (!call->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 		afs_extract_to_buf(call, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 	case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 		_debug("extract FID array");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 		ret = afs_extract_data(call, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 		_debug("unmarshall FID array");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 		call->request = kcalloc(call->count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 					sizeof(struct afs_callback_break),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 					GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 		if (!call->request)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 		cb = call->request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 		bp = call->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 		for (loop = call->count; loop > 0; loop--, cb++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 			cb->fid.vid	= xdr_to_u64(bp->volume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 			cb->fid.vnode	= xdr_to_u64(bp->vnode.lo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 			cb->fid.vnode_hi = ntohl(bp->vnode.hi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 			cb->fid.unique	= ntohl(bp->vnode.unique);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 			bp++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 		afs_extract_to_tmp(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 		call->unmarshall++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 		return afs_io_error(call, afs_io_error_cm_reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 	/* We'll need the file server record as that tells us which set of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	 * vnodes to operate upon.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 	return afs_find_cm_server_by_peer(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) }