vlclient.c 16.1 KB
Newer Older
D
David Howells 已提交
1
/* AFS Volume Location Service client
L
Linus Torvalds 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
 *
 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
 * Written by David Howells (dhowells@redhat.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */

#include <linux/init.h>
#include <linux/sched.h>
#include <rxrpc/rxrpc.h>
#include <rxrpc/transport.h>
#include <rxrpc/connection.h>
#include <rxrpc/call.h>
#include "server.h"
#include "volume.h"
#include "vlclient.h"
#include "kafsasyncd.h"
#include "kafstimod.h"
#include "errors.h"
#include "internal.h"

#define VLGETENTRYBYID		503	/* AFS Get Cache Entry By ID operation ID */
#define VLGETENTRYBYNAME	504	/* AFS Get Cache Entry By Name operation ID */
#define VLPROBE			514	/* AFS Probe Volume Location Service operation ID */

static void afs_rxvl_get_entry_by_id_attn(struct rxrpc_call *call);
static void afs_rxvl_get_entry_by_id_error(struct rxrpc_call *call);

/*
 * map afs VL abort codes to/from Linux error codes
 * - called with call->lock held
 */
static void afs_rxvl_aemap(struct rxrpc_call *call)
{
	int err;

	_enter("{%u,%u,%d}",
	       call->app_err_state, call->app_abort_code, call->app_errno);

	switch (call->app_err_state) {
	case RXRPC_ESTATE_LOCAL_ABORT:
		call->app_abort_code = -call->app_errno;
		return;

	case RXRPC_ESTATE_PEER_ABORT:
		switch (call->app_abort_code) {
		case AFSVL_IDEXIST:		err = -EEXIST;		break;
		case AFSVL_IO:			err = -EREMOTEIO;	break;
		case AFSVL_NAMEEXIST:		err = -EEXIST;		break;
		case AFSVL_CREATEFAIL:		err = -EREMOTEIO;	break;
		case AFSVL_NOENT:		err = -ENOMEDIUM;	break;
		case AFSVL_EMPTY:		err = -ENOMEDIUM;	break;
		case AFSVL_ENTDELETED:		err = -ENOMEDIUM;	break;
		case AFSVL_BADNAME:		err = -EINVAL;		break;
		case AFSVL_BADINDEX:		err = -EINVAL;		break;
		case AFSVL_BADVOLTYPE:		err = -EINVAL;		break;
		case AFSVL_BADSERVER:		err = -EINVAL;		break;
		case AFSVL_BADPARTITION:	err = -EINVAL;		break;
		case AFSVL_REPSFULL:		err = -EFBIG;		break;
		case AFSVL_NOREPSERVER:		err = -ENOENT;		break;
		case AFSVL_DUPREPSERVER:	err = -EEXIST;		break;
		case AFSVL_RWNOTFOUND:		err = -ENOENT;		break;
		case AFSVL_BADREFCOUNT:		err = -EINVAL;		break;
		case AFSVL_SIZEEXCEEDED:	err = -EINVAL;		break;
		case AFSVL_BADENTRY:		err = -EINVAL;		break;
		case AFSVL_BADVOLIDBUMP:	err = -EINVAL;		break;
		case AFSVL_IDALREADYHASHED:	err = -EINVAL;		break;
		case AFSVL_ENTRYLOCKED:		err = -EBUSY;		break;
		case AFSVL_BADVOLOPER:		err = -EBADRQC;		break;
		case AFSVL_BADRELLOCKTYPE:	err = -EINVAL;		break;
		case AFSVL_RERELEASE:		err = -EREMOTEIO;	break;
		case AFSVL_BADSERVERFLAG:	err = -EINVAL;		break;
		case AFSVL_PERM:		err = -EACCES;		break;
		case AFSVL_NOMEM:		err = -EREMOTEIO;	break;
		default:
			err = afs_abort_to_error(call->app_abort_code);
			break;
		}
		call->app_errno = err;
		return;

	default:
		return;
	}
D
David Howells 已提交
89
}
L
Linus Torvalds 已提交
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

#if 0
/*
 * probe a volume location server to see if it is still alive -- unused
 */
static int afs_rxvl_probe(struct afs_server *server, int alloc_flags)
{
	struct rxrpc_connection *conn;
	struct rxrpc_call *call;
	struct kvec piov[1];
	size_t sent;
	int ret;
	__be32 param[1];

	DECLARE_WAITQUEUE(myself, current);

	/* get hold of the vlserver connection */
	ret = afs_server_get_vlconn(server, &conn);
	if (ret < 0)
		goto out;

	/* create a call through that connection */
	ret = rxrpc_create_call(conn, NULL, NULL, afs_rxvl_aemap, &call);
	if (ret < 0) {
		printk("kAFS: Unable to create call: %d\n", ret);
		goto out_put_conn;
	}
	call->app_opcode = VLPROBE;

	/* we want to get event notifications from the call */
	add_wait_queue(&call->waitq, &myself);

	/* marshall the parameters */
	param[0] = htonl(VLPROBE);
	piov[0].iov_len = sizeof(param);
	piov[0].iov_base = param;

	/* send the parameters to the server */
	ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET,
				    alloc_flags, 0, &sent);
	if (ret < 0)
		goto abort;

	/* wait for the reply to completely arrive */
	for (;;) {
		set_current_state(TASK_INTERRUPTIBLE);
		if (call->app_call_state != RXRPC_CSTATE_CLNT_RCV_REPLY ||
		    signal_pending(current))
			break;
		schedule();
	}
	set_current_state(TASK_RUNNING);

	ret = -EINTR;
	if (signal_pending(current))
		goto abort;

	switch (call->app_call_state) {
	case RXRPC_CSTATE_ERROR:
		ret = call->app_errno;
		goto out_unwait;

	case RXRPC_CSTATE_CLNT_GOT_REPLY:
		ret = 0;
		goto out_unwait;

	default:
		BUG();
	}

D
David Howells 已提交
160
abort:
L
Linus Torvalds 已提交
161 162 163 164
	set_current_state(TASK_UNINTERRUPTIBLE);
	rxrpc_call_abort(call, ret);
	schedule();

D
David Howells 已提交
165
out_unwait:
L
Linus Torvalds 已提交
166 167 168
	set_current_state(TASK_RUNNING);
	remove_wait_queue(&call->waitq, &myself);
	rxrpc_put_call(call);
D
David Howells 已提交
169
out_put_conn:
L
Linus Torvalds 已提交
170
	rxrpc_put_connection(conn);
D
David Howells 已提交
171
out:
L
Linus Torvalds 已提交
172
	return ret;
D
David Howells 已提交
173
}
L
Linus Torvalds 已提交
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
#endif

/*
 * look up a volume location database entry by name
 */
int afs_rxvl_get_entry_by_name(struct afs_server *server,
			       const char *volname,
			       unsigned volnamesz,
			       struct afs_cache_vlocation *entry)
{
	DECLARE_WAITQUEUE(myself, current);

	struct rxrpc_connection *conn;
	struct rxrpc_call *call;
	struct kvec piov[3];
	unsigned tmp;
	size_t sent;
	int ret, loop;
	__be32 *bp, param[2], zero;

	_enter(",%*.*s,%u,", volnamesz, volnamesz, volname, volnamesz);

	memset(entry, 0, sizeof(*entry));

	/* get hold of the vlserver connection */
	ret = afs_server_get_vlconn(server, &conn);
	if (ret < 0)
		goto out;

	/* create a call through that connection */
	ret = rxrpc_create_call(conn, NULL, NULL, afs_rxvl_aemap, &call);
	if (ret < 0) {
		printk("kAFS: Unable to create call: %d\n", ret);
		goto out_put_conn;
	}
	call->app_opcode = VLGETENTRYBYNAME;

	/* we want to get event notifications from the call */
	add_wait_queue(&call->waitq, &myself);

	/* marshall the parameters */
	piov[1].iov_len = volnamesz;
	piov[1].iov_base = (char *) volname;

	zero = 0;
	piov[2].iov_len = (4 - (piov[1].iov_len & 3)) & 3;
	piov[2].iov_base = &zero;

	param[0] = htonl(VLGETENTRYBYNAME);
	param[1] = htonl(piov[1].iov_len);

	piov[0].iov_len = sizeof(param);
	piov[0].iov_base = param;

	/* send the parameters to the server */
	ret = rxrpc_call_write_data(call, 3, piov, RXRPC_LAST_PACKET, GFP_NOFS,
				    0, &sent);
	if (ret < 0)
		goto abort;

	/* wait for the reply to completely arrive */
	bp = rxrpc_call_alloc_scratch(call, 384);

	ret = rxrpc_call_read_data(call, bp, 384,
				   RXRPC_CALL_READ_BLOCK |
				   RXRPC_CALL_READ_ALL);
	if (ret < 0) {
		if (ret == -ECONNABORTED) {
			ret = call->app_errno;
			goto out_unwait;
		}
		goto abort;
	}

	/* unmarshall the reply */
	for (loop = 0; loop < 64; loop++)
		entry->name[loop] = ntohl(*bp++);
	bp++; /* final NUL */

	bp++; /* type */
	entry->nservers = ntohl(*bp++);

	for (loop = 0; loop < 8; loop++)
		entry->servers[loop].s_addr = *bp++;

	bp += 8; /* partition IDs */

	for (loop = 0; loop < 8; loop++) {
		tmp = ntohl(*bp++);
		if (tmp & AFS_VLSF_RWVOL)
			entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
		if (tmp & AFS_VLSF_ROVOL)
			entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
		if (tmp & AFS_VLSF_BACKVOL)
			entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
	}

	entry->vid[0] = ntohl(*bp++);
	entry->vid[1] = ntohl(*bp++);
	entry->vid[2] = ntohl(*bp++);

	bp++; /* clone ID */

	tmp = ntohl(*bp++); /* flags */
	if (tmp & AFS_VLF_RWEXISTS)
		entry->vidmask |= AFS_VOL_VTM_RW;
	if (tmp & AFS_VLF_ROEXISTS)
		entry->vidmask |= AFS_VOL_VTM_RO;
	if (tmp & AFS_VLF_BACKEXISTS)
		entry->vidmask |= AFS_VOL_VTM_BAK;

	ret = -ENOMEDIUM;
	if (!entry->vidmask)
		goto abort;

	/* success */
	entry->rtime = get_seconds();
	ret = 0;

D
David Howells 已提交
293
out_unwait:
L
Linus Torvalds 已提交
294 295 296
	set_current_state(TASK_RUNNING);
	remove_wait_queue(&call->waitq, &myself);
	rxrpc_put_call(call);
D
David Howells 已提交
297
out_put_conn:
L
Linus Torvalds 已提交
298
	rxrpc_put_connection(conn);
D
David Howells 已提交
299
out:
L
Linus Torvalds 已提交
300 301 302
	_leave(" = %d", ret);
	return ret;

D
David Howells 已提交
303
abort:
L
Linus Torvalds 已提交
304 305 306 307
	set_current_state(TASK_UNINTERRUPTIBLE);
	rxrpc_call_abort(call, ret);
	schedule();
	goto out_unwait;
D
David Howells 已提交
308
}
L
Linus Torvalds 已提交
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431

/*
 * look up a volume location database entry by ID
 */
int afs_rxvl_get_entry_by_id(struct afs_server *server,
			     afs_volid_t volid,
			     afs_voltype_t voltype,
			     struct afs_cache_vlocation *entry)
{
	DECLARE_WAITQUEUE(myself, current);

	struct rxrpc_connection *conn;
	struct rxrpc_call *call;
	struct kvec piov[1];
	unsigned tmp;
	size_t sent;
	int ret, loop;
	__be32 *bp, param[3];

	_enter(",%x,%d,", volid, voltype);

	memset(entry, 0, sizeof(*entry));

	/* get hold of the vlserver connection */
	ret = afs_server_get_vlconn(server, &conn);
	if (ret < 0)
		goto out;

	/* create a call through that connection */
	ret = rxrpc_create_call(conn, NULL, NULL, afs_rxvl_aemap, &call);
	if (ret < 0) {
		printk("kAFS: Unable to create call: %d\n", ret);
		goto out_put_conn;
	}
	call->app_opcode = VLGETENTRYBYID;

	/* we want to get event notifications from the call */
	add_wait_queue(&call->waitq, &myself);

	/* marshall the parameters */
	param[0] = htonl(VLGETENTRYBYID);
	param[1] = htonl(volid);
	param[2] = htonl(voltype);

	piov[0].iov_len = sizeof(param);
	piov[0].iov_base = param;

	/* send the parameters to the server */
	ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS,
				    0, &sent);
	if (ret < 0)
		goto abort;

	/* wait for the reply to completely arrive */
	bp = rxrpc_call_alloc_scratch(call, 384);

	ret = rxrpc_call_read_data(call, bp, 384,
				   RXRPC_CALL_READ_BLOCK |
				   RXRPC_CALL_READ_ALL);
	if (ret < 0) {
		if (ret == -ECONNABORTED) {
			ret = call->app_errno;
			goto out_unwait;
		}
		goto abort;
	}

	/* unmarshall the reply */
	for (loop = 0; loop < 64; loop++)
		entry->name[loop] = ntohl(*bp++);
	bp++; /* final NUL */

	bp++; /* type */
	entry->nservers = ntohl(*bp++);

	for (loop = 0; loop < 8; loop++)
		entry->servers[loop].s_addr = *bp++;

	bp += 8; /* partition IDs */

	for (loop = 0; loop < 8; loop++) {
		tmp = ntohl(*bp++);
		if (tmp & AFS_VLSF_RWVOL)
			entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
		if (tmp & AFS_VLSF_ROVOL)
			entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
		if (tmp & AFS_VLSF_BACKVOL)
			entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
	}

	entry->vid[0] = ntohl(*bp++);
	entry->vid[1] = ntohl(*bp++);
	entry->vid[2] = ntohl(*bp++);

	bp++; /* clone ID */

	tmp = ntohl(*bp++); /* flags */
	if (tmp & AFS_VLF_RWEXISTS)
		entry->vidmask |= AFS_VOL_VTM_RW;
	if (tmp & AFS_VLF_ROEXISTS)
		entry->vidmask |= AFS_VOL_VTM_RO;
	if (tmp & AFS_VLF_BACKEXISTS)
		entry->vidmask |= AFS_VOL_VTM_BAK;

	ret = -ENOMEDIUM;
	if (!entry->vidmask)
		goto abort;

#if 0 /* TODO: remove */
	entry->nservers = 3;
	entry->servers[0].s_addr = htonl(0xac101249);
	entry->servers[1].s_addr = htonl(0xac101243);
	entry->servers[2].s_addr = htonl(0xac10125b /*0xac10125b*/);

	entry->srvtmask[0] = AFS_VOL_VTM_RO;
	entry->srvtmask[1] = AFS_VOL_VTM_RO;
	entry->srvtmask[2] = AFS_VOL_VTM_RO | AFS_VOL_VTM_RW;
#endif

	/* success */
	entry->rtime = get_seconds();
	ret = 0;

D
David Howells 已提交
432
out_unwait:
L
Linus Torvalds 已提交
433 434 435
	set_current_state(TASK_RUNNING);
	remove_wait_queue(&call->waitq, &myself);
	rxrpc_put_call(call);
D
David Howells 已提交
436
out_put_conn:
L
Linus Torvalds 已提交
437
	rxrpc_put_connection(conn);
D
David Howells 已提交
438
out:
L
Linus Torvalds 已提交
439 440 441
	_leave(" = %d", ret);
	return ret;

D
David Howells 已提交
442
abort:
L
Linus Torvalds 已提交
443 444 445 446
	set_current_state(TASK_UNINTERRUPTIBLE);
	rxrpc_call_abort(call, ret);
	schedule();
	goto out_unwait;
D
David Howells 已提交
447
}
L
Linus Torvalds 已提交
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529

/*
 * look up a volume location database entry by ID asynchronously
 */
int afs_rxvl_get_entry_by_id_async(struct afs_async_op *op,
				   afs_volid_t volid,
				   afs_voltype_t voltype)
{
	struct rxrpc_connection *conn;
	struct rxrpc_call *call;
	struct kvec piov[1];
	size_t sent;
	int ret;
	__be32 param[3];

	_enter(",%x,%d,", volid, voltype);

	/* get hold of the vlserver connection */
	ret = afs_server_get_vlconn(op->server, &conn);
	if (ret < 0) {
		_leave(" = %d", ret);
		return ret;
	}

	/* create a call through that connection */
	ret = rxrpc_create_call(conn,
				afs_rxvl_get_entry_by_id_attn,
				afs_rxvl_get_entry_by_id_error,
				afs_rxvl_aemap,
				&op->call);
	rxrpc_put_connection(conn);

	if (ret < 0) {
		printk("kAFS: Unable to create call: %d\n", ret);
		_leave(" = %d", ret);
		return ret;
	}

	op->call->app_opcode = VLGETENTRYBYID;
	op->call->app_user = op;

	call = op->call;
	rxrpc_get_call(call);

	/* send event notifications from the call to kafsasyncd */
	afs_kafsasyncd_begin_op(op);

	/* marshall the parameters */
	param[0] = htonl(VLGETENTRYBYID);
	param[1] = htonl(volid);
	param[2] = htonl(voltype);

	piov[0].iov_len = sizeof(param);
	piov[0].iov_base = param;

	/* allocate result read buffer in scratch space */
	call->app_scr_ptr = rxrpc_call_alloc_scratch(op->call, 384);

	/* send the parameters to the server */
	ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS,
				    0, &sent);
	if (ret < 0) {
		rxrpc_call_abort(call, ret); /* handle from kafsasyncd */
		ret = 0;
		goto out;
	}

	/* wait for the reply to completely arrive */
	ret = rxrpc_call_read_data(call, call->app_scr_ptr, 384, 0);
	switch (ret) {
	case 0:
	case -EAGAIN:
	case -ECONNABORTED:
		ret = 0;
		break;	/* all handled by kafsasyncd */

	default:
		rxrpc_call_abort(call, ret); /* make kafsasyncd handle it */
		ret = 0;
		break;
	}

D
David Howells 已提交
530
out:
L
Linus Torvalds 已提交
531 532 533
	rxrpc_put_call(call);
	_leave(" = %d", ret);
	return ret;
D
David Howells 已提交
534
}
L
Linus Torvalds 已提交
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624

/*
 * attend to the asynchronous get VLDB entry by ID
 */
int afs_rxvl_get_entry_by_id_async2(struct afs_async_op *op,
				    struct afs_cache_vlocation *entry)
{
	__be32 *bp;
	__u32 tmp;
	int loop, ret;

	_enter("{op=%p cst=%u}", op, op->call->app_call_state);

	memset(entry, 0, sizeof(*entry));

	if (op->call->app_call_state == RXRPC_CSTATE_COMPLETE) {
		/* operation finished */
		afs_kafsasyncd_terminate_op(op);

		bp = op->call->app_scr_ptr;

		/* unmarshall the reply */
		for (loop = 0; loop < 64; loop++)
			entry->name[loop] = ntohl(*bp++);
		bp++; /* final NUL */

		bp++; /* type */
		entry->nservers = ntohl(*bp++);

		for (loop = 0; loop < 8; loop++)
			entry->servers[loop].s_addr = *bp++;

		bp += 8; /* partition IDs */

		for (loop = 0; loop < 8; loop++) {
			tmp = ntohl(*bp++);
			if (tmp & AFS_VLSF_RWVOL)
				entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
			if (tmp & AFS_VLSF_ROVOL)
				entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
			if (tmp & AFS_VLSF_BACKVOL)
				entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
		}

		entry->vid[0] = ntohl(*bp++);
		entry->vid[1] = ntohl(*bp++);
		entry->vid[2] = ntohl(*bp++);

		bp++; /* clone ID */

		tmp = ntohl(*bp++); /* flags */
		if (tmp & AFS_VLF_RWEXISTS)
			entry->vidmask |= AFS_VOL_VTM_RW;
		if (tmp & AFS_VLF_ROEXISTS)
			entry->vidmask |= AFS_VOL_VTM_RO;
		if (tmp & AFS_VLF_BACKEXISTS)
			entry->vidmask |= AFS_VOL_VTM_BAK;

		ret = -ENOMEDIUM;
		if (!entry->vidmask) {
			rxrpc_call_abort(op->call, ret);
			goto done;
		}

#if 0 /* TODO: remove */
		entry->nservers = 3;
		entry->servers[0].s_addr = htonl(0xac101249);
		entry->servers[1].s_addr = htonl(0xac101243);
		entry->servers[2].s_addr = htonl(0xac10125b /*0xac10125b*/);

		entry->srvtmask[0] = AFS_VOL_VTM_RO;
		entry->srvtmask[1] = AFS_VOL_VTM_RO;
		entry->srvtmask[2] = AFS_VOL_VTM_RO | AFS_VOL_VTM_RW;
#endif

		/* success */
		entry->rtime = get_seconds();
		ret = 0;
		goto done;
	}

	if (op->call->app_call_state == RXRPC_CSTATE_ERROR) {
		/* operation error */
		ret = op->call->app_errno;
		goto done;
	}

	_leave(" = -EAGAIN");
	return -EAGAIN;

D
David Howells 已提交
625
done:
L
Linus Torvalds 已提交
626 627 628 629
	rxrpc_put_call(op->call);
	op->call = NULL;
	_leave(" = %d", ret);
	return ret;
D
David Howells 已提交
630
}
L
Linus Torvalds 已提交
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667

/*
 * handle attention events on an async get-entry-by-ID op
 * - called from krxiod
 */
static void afs_rxvl_get_entry_by_id_attn(struct rxrpc_call *call)
{
	struct afs_async_op *op = call->app_user;

	_enter("{op=%p cst=%u}", op, call->app_call_state);

	switch (call->app_call_state) {
	case RXRPC_CSTATE_COMPLETE:
		afs_kafsasyncd_attend_op(op);
		break;
	case RXRPC_CSTATE_CLNT_RCV_REPLY:
		if (call->app_async_read)
			break;
	case RXRPC_CSTATE_CLNT_GOT_REPLY:
		if (call->app_read_count == 0)
			break;
		printk("kAFS: Reply bigger than expected"
		       " {cst=%u asyn=%d mark=%Zu rdy=%Zu pr=%u%s}",
		       call->app_call_state,
		       call->app_async_read,
		       call->app_mark,
		       call->app_ready_qty,
		       call->pkt_rcv_count,
		       call->app_last_rcv ? " last" : "");

		rxrpc_call_abort(call, -EBADMSG);
		break;
	default:
		BUG();
	}

	_leave("");
D
David Howells 已提交
668
}
L
Linus Torvalds 已提交
669 670 671 672 673 674 675 676 677 678 679 680 681 682

/*
 * handle error events on an async get-entry-by-ID op
 * - called from krxiod
 */
static void afs_rxvl_get_entry_by_id_error(struct rxrpc_call *call)
{
	struct afs_async_op *op = call->app_user;

	_enter("{op=%p cst=%u}", op, call->app_call_state);

	afs_kafsasyncd_attend_op(op);

	_leave("");
D
David Howells 已提交
683
}