Skip to content

Commit c3e9f88

Browse files
committed
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>
1 parent 194d28c commit c3e9f88

6 files changed

Lines changed: 120 additions & 2 deletions

File tree

‎fs/afs/afs.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <linux/in.h>
1212

13-
#define AFS_MAXCELLNAME 64 /* Maximum length of a cell name */
13+
#define AFS_MAXCELLNAME 256 /* Maximum length of a cell name */
1414
#define AFS_MAXVOLNAME 64 /* Maximum length of a volume name */
1515
#define AFS_MAXNSERVERS 8 /* Maximum servers in a basic volume record */
1616
#define AFS_NMAXNSERVERS 13 /* Maximum servers in a N/U-class volume record */

‎fs/afs/afs_vl.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ enum AFSVL_Operations {
2222
VLGETENTRYBYNAMEU = 527, /* AFS Get VLDB entry by name (UUID-variant) */
2323
VLGETADDRSU = 533, /* AFS Get addrs for fileserver */
2424
YVLGETENDPOINTS = 64002, /* YFS Get endpoints for file/volume server */
25+
YVLGETCELLNAME = 64014, /* YFS Get actual cell name */
2526
VLGETCAPABILITIES = 65537, /* AFS Get server capabilities */
2627
};
2728

‎fs/afs/internal.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ struct afs_call {
116116
long ret0; /* Value to reply with instead of 0 */
117117
struct afs_addr_list *ret_alist;
118118
struct afs_vldb_entry *ret_vldb;
119+
char *ret_str;
119120
};
120121
struct afs_operation *op;
121122
unsigned int server_index;
@@ -1373,6 +1374,7 @@ extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uu
13731374
extern struct afs_call *afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *,
13741375
struct key *, struct afs_vlserver *, unsigned int);
13751376
extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *);
1377+
extern char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *);
13761378

13771379
/*
13781380
* vl_probe.c

‎fs/afs/protocol_yfs.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define YFS_FS_SERVICE 2500
99
#define YFS_CM_SERVICE 2501
1010

11-
#define YFSCBMAX 1024
11+
#define YFSCBMAX 1024
1212

1313
enum YFS_CM_Operations {
1414
YFSCBProbe = 206, /* probe client */

‎fs/afs/vlclient.c‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,3 +645,114 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc,
645645
afs_make_call(&vc->ac, call, GFP_KERNEL);
646646
return (struct afs_addr_list *)afs_wait_for_call_to_complete(call, &vc->ac);
647647
}
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+
}

‎include/trace/events/afs.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ enum afs_vl_operation {
111111
afs_VL_GetEntryByNameU = 527, /* AFS Get Vol Entry By Name operation ID */
112112
afs_VL_GetAddrsU = 533, /* AFS Get FS server addresses */
113113
afs_YFSVL_GetEndpoints = 64002, /* YFS Get FS & Vol server addresses */
114+
afs_YFSVL_GetCellName = 64014, /* YFS Get actual cell name */
114115
afs_VL_GetCapabilities = 65537, /* AFS Get VL server capabilities */
115116
};
116117

@@ -143,6 +144,7 @@ enum afs_eproto_cause {
143144
afs_eproto_bad_status,
144145
afs_eproto_cb_count,
145146
afs_eproto_cb_fid_count,
147+
afs_eproto_cellname_len,
146148
afs_eproto_file_type,
147149
afs_eproto_ibulkst_cb_count,
148150
afs_eproto_ibulkst_count,
@@ -316,6 +318,7 @@ enum afs_cb_break_reason {
316318
EM(afs_VL_GetEntryByNameU, "VL.GetEntryByNameU") \
317319
EM(afs_VL_GetAddrsU, "VL.GetAddrsU") \
318320
EM(afs_YFSVL_GetEndpoints, "YFSVL.GetEndpoints") \
321+
EM(afs_YFSVL_GetCellName, "YFSVL.GetCellName") \
319322
E_(afs_VL_GetCapabilities, "VL.GetCapabilities")
320323

321324
#define afs_edit_dir_ops \
@@ -345,6 +348,7 @@ enum afs_cb_break_reason {
345348
EM(afs_eproto_bad_status, "BadStatus") \
346349
EM(afs_eproto_cb_count, "CbCount") \
347350
EM(afs_eproto_cb_fid_count, "CbFidCount") \
351+
EM(afs_eproto_cellname_len, "CellNameLen") \
348352
EM(afs_eproto_file_type, "FileTYpe") \
349353
EM(afs_eproto_ibulkst_cb_count, "IBS.CbCount") \
350354
EM(afs_eproto_ibulkst_count, "IBS.FidCount") \

0 commit comments

Comments
 (0)