Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

afs: Implement client support for the YFSVL.GetCellName RPC op

Implement client support for the YFSVL.GetCellName RPC operation by which
YFS permits the canonical cell name to be queried from a VL server.

Signed-off-by: David Howells <dhowells@redhat.com>

+120 -2
+1 -1
fs/afs/afs.h
··· 10 10 11 11 #include <linux/in.h> 12 12 13 - #define AFS_MAXCELLNAME 64 /* Maximum length of a cell name */ 13 + #define AFS_MAXCELLNAME 256 /* Maximum length of a cell name */ 14 14 #define AFS_MAXVOLNAME 64 /* Maximum length of a volume name */ 15 15 #define AFS_MAXNSERVERS 8 /* Maximum servers in a basic volume record */ 16 16 #define AFS_NMAXNSERVERS 13 /* Maximum servers in a N/U-class volume record */
+1
fs/afs/afs_vl.h
··· 22 22 VLGETENTRYBYNAMEU = 527, /* AFS Get VLDB entry by name (UUID-variant) */ 23 23 VLGETADDRSU = 533, /* AFS Get addrs for fileserver */ 24 24 YVLGETENDPOINTS = 64002, /* YFS Get endpoints for file/volume server */ 25 + YVLGETCELLNAME = 64014, /* YFS Get actual cell name */ 25 26 VLGETCAPABILITIES = 65537, /* AFS Get server capabilities */ 26 27 }; 27 28
+2
fs/afs/internal.h
··· 116 116 long ret0; /* Value to reply with instead of 0 */ 117 117 struct afs_addr_list *ret_alist; 118 118 struct afs_vldb_entry *ret_vldb; 119 + char *ret_str; 119 120 }; 120 121 struct afs_operation *op; 121 122 unsigned int server_index; ··· 1374 1373 extern struct afs_call *afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, 1375 1374 struct key *, struct afs_vlserver *, unsigned int); 1376 1375 extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *); 1376 + extern char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *); 1377 1377 1378 1378 /* 1379 1379 * vl_probe.c
+1 -1
fs/afs/protocol_yfs.h
··· 8 8 #define YFS_FS_SERVICE 2500 9 9 #define YFS_CM_SERVICE 2501 10 10 11 - #define YFSCBMAX 1024 11 + #define YFSCBMAX 1024 12 12 13 13 enum YFS_CM_Operations { 14 14 YFSCBProbe = 206, /* probe client */
+111
fs/afs/vlclient.c
··· 645 645 afs_make_call(&vc->ac, call, GFP_KERNEL); 646 646 return (struct afs_addr_list *)afs_wait_for_call_to_complete(call, &vc->ac); 647 647 } 648 + 649 + /* 650 + * Deliver reply data to a YFSVL.GetCellName operation. 651 + */ 652 + static int afs_deliver_yfsvl_get_cell_name(struct afs_call *call) 653 + { 654 + char *cell_name; 655 + u32 namesz, paddedsz; 656 + int ret; 657 + 658 + _enter("{%u,%zu/%u}", 659 + call->unmarshall, iov_iter_count(call->iter), call->count); 660 + 661 + switch (call->unmarshall) { 662 + case 0: 663 + afs_extract_to_tmp(call); 664 + call->unmarshall++; 665 + 666 + /* Fall through - and extract the cell name length */ 667 + case 1: 668 + ret = afs_extract_data(call, true); 669 + if (ret < 0) 670 + return ret; 671 + 672 + namesz = ntohl(call->tmp); 673 + if (namesz > AFS_MAXCELLNAME) 674 + return afs_protocol_error(call, afs_eproto_cellname_len); 675 + paddedsz = (namesz + 3) & ~3; 676 + call->count = namesz; 677 + call->count2 = paddedsz - namesz; 678 + 679 + cell_name = kmalloc(namesz + 1, GFP_KERNEL); 680 + if (!cell_name) 681 + return -ENOMEM; 682 + cell_name[namesz] = 0; 683 + call->ret_str = cell_name; 684 + 685 + afs_extract_begin(call, cell_name, namesz); 686 + call->unmarshall++; 687 + 688 + /* Fall through - and extract cell name */ 689 + case 2: 690 + ret = afs_extract_data(call, true); 691 + if (ret < 0) 692 + return ret; 693 + 694 + afs_extract_discard(call, call->count2); 695 + call->unmarshall++; 696 + 697 + /* Fall through - and extract padding */ 698 + case 3: 699 + ret = afs_extract_data(call, false); 700 + if (ret < 0) 701 + return ret; 702 + 703 + call->unmarshall++; 704 + break; 705 + } 706 + 707 + _leave(" = 0 [done]"); 708 + return 0; 709 + } 710 + 711 + static void afs_destroy_yfsvl_get_cell_name(struct afs_call *call) 712 + { 713 + kfree(call->ret_str); 714 + afs_flat_call_destructor(call); 715 + } 716 + 717 + /* 718 + * VL.GetCapabilities operation type 719 + */ 720 + static const struct afs_call_type afs_YFSVLGetCellName = { 721 + .name = "YFSVL.GetCellName", 722 + .op = afs_YFSVL_GetCellName, 723 + .deliver = afs_deliver_yfsvl_get_cell_name, 724 + .destructor = afs_destroy_yfsvl_get_cell_name, 725 + }; 726 + 727 + /* 728 + * Probe a volume server for the capabilities that it supports. This can 729 + * return up to 196 words. 730 + * 731 + * We use this to probe for service upgrade to determine what the server at the 732 + * other end supports. 733 + */ 734 + char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *vc) 735 + { 736 + struct afs_call *call; 737 + struct afs_net *net = vc->cell->net; 738 + __be32 *bp; 739 + 740 + _enter(""); 741 + 742 + call = afs_alloc_flat_call(net, &afs_YFSVLGetCellName, 1 * 4, 0); 743 + if (!call) 744 + return ERR_PTR(-ENOMEM); 745 + 746 + call->key = vc->key; 747 + call->ret_str = NULL; 748 + call->max_lifespan = AFS_VL_MAX_LIFESPAN; 749 + 750 + /* marshall the parameters */ 751 + bp = call->request; 752 + *bp++ = htonl(YVLGETCELLNAME); 753 + 754 + /* Can't take a ref on server */ 755 + trace_afs_make_vl_call(call); 756 + afs_make_call(&vc->ac, call, GFP_KERNEL); 757 + return (char *)afs_wait_for_call_to_complete(call, &vc->ac); 758 + }
+4
include/trace/events/afs.h
··· 111 111 afs_VL_GetEntryByNameU = 527, /* AFS Get Vol Entry By Name operation ID */ 112 112 afs_VL_GetAddrsU = 533, /* AFS Get FS server addresses */ 113 113 afs_YFSVL_GetEndpoints = 64002, /* YFS Get FS & Vol server addresses */ 114 + afs_YFSVL_GetCellName = 64014, /* YFS Get actual cell name */ 114 115 afs_VL_GetCapabilities = 65537, /* AFS Get VL server capabilities */ 115 116 }; 116 117 ··· 144 143 afs_eproto_bad_status, 145 144 afs_eproto_cb_count, 146 145 afs_eproto_cb_fid_count, 146 + afs_eproto_cellname_len, 147 147 afs_eproto_file_type, 148 148 afs_eproto_ibulkst_cb_count, 149 149 afs_eproto_ibulkst_count, ··· 318 316 EM(afs_VL_GetEntryByNameU, "VL.GetEntryByNameU") \ 319 317 EM(afs_VL_GetAddrsU, "VL.GetAddrsU") \ 320 318 EM(afs_YFSVL_GetEndpoints, "YFSVL.GetEndpoints") \ 319 + EM(afs_YFSVL_GetCellName, "YFSVL.GetCellName") \ 321 320 E_(afs_VL_GetCapabilities, "VL.GetCapabilities") 322 321 323 322 #define afs_edit_dir_ops \ ··· 348 345 EM(afs_eproto_bad_status, "BadStatus") \ 349 346 EM(afs_eproto_cb_count, "CbCount") \ 350 347 EM(afs_eproto_cb_fid_count, "CbFidCount") \ 348 + EM(afs_eproto_cellname_len, "CellNameLen") \ 351 349 EM(afs_eproto_file_type, "FileTYpe") \ 352 350 EM(afs_eproto_ibulkst_cb_count, "IBS.CbCount") \ 353 351 EM(afs_eproto_ibulkst_count, "IBS.FidCount") \