1
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
89
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
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
530
531
532
533
534
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
625
626
627
628
629
630
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
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
|
// SPDX-License-Identifier: GPL-2.0
/*
* linux/fs/lockd/svc4proc.c
*
* Lockd server procedures. We don't implement the NLM_*_RES
* procedures because we don't use the async procedures.
*
* Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
*/
#include <linux/types.h>
#include <linux/time.h>
#include <linux/sunrpc/svc_xprt.h>
#include "lockd.h"
/*
* xdr.h defines SM_MAXSTRLEN and SM_PRIV_SIZE as macros.
* nlm4xdr_gen.h defines them as enum constants. Undefine the
* macros to allow the xdrgen enum definitions to be used.
*/
#undef SM_MAXSTRLEN
#undef SM_PRIV_SIZE
#include "share.h"
#include "nlm4xdr_gen.h"
/*
* Wrapper structures combine xdrgen types with legacy nlm_lock.
* The xdrgen field must be first so the structure can be cast
* to its XDR type for the RPC dispatch layer.
*/
struct nlm4_testargs_wrapper {
struct nlm4_testargs xdrgen;
struct nlm_lock lock;
};
static_assert(offsetof(struct nlm4_testargs_wrapper, xdrgen) == 0);
struct nlm4_lockargs_wrapper {
struct nlm4_lockargs xdrgen;
struct nlm_cookie cookie;
struct nlm_lock lock;
};
static_assert(offsetof(struct nlm4_lockargs_wrapper, xdrgen) == 0);
struct nlm4_cancargs_wrapper {
struct nlm4_cancargs xdrgen;
struct nlm_lock lock;
};
static_assert(offsetof(struct nlm4_cancargs_wrapper, xdrgen) == 0);
struct nlm4_unlockargs_wrapper {
struct nlm4_unlockargs xdrgen;
struct nlm_lock lock;
};
static_assert(offsetof(struct nlm4_unlockargs_wrapper, xdrgen) == 0);
struct nlm4_notifyargs_wrapper {
struct nlm4_notifyargs xdrgen;
struct nlm_reboot reboot;
};
static_assert(offsetof(struct nlm4_notifyargs_wrapper, xdrgen) == 0);
struct nlm4_notify_wrapper {
struct nlm4_notify xdrgen;
};
static_assert(offsetof(struct nlm4_notify_wrapper, xdrgen) == 0);
struct nlm4_testres_wrapper {
struct nlm4_testres xdrgen;
struct nlm_lock lock;
};
struct nlm4_shareargs_wrapper {
struct nlm4_shareargs xdrgen;
struct nlm_lock lock;
};
static_assert(offsetof(struct nlm4_shareargs_wrapper, xdrgen) == 0);
static_assert(offsetof(struct nlm4_testres_wrapper, xdrgen) == 0);
struct nlm4_res_wrapper {
struct nlm4_res xdrgen;
struct nlm_cookie cookie;
};
static_assert(offsetof(struct nlm4_res_wrapper, xdrgen) == 0);
struct nlm4_shareres_wrapper {
struct nlm4_shareres xdrgen;
};
static_assert(offsetof(struct nlm4_shareres_wrapper, xdrgen) == 0);
static __be32
nlm4_netobj_to_cookie(struct nlm_cookie *cookie, netobj *object)
{
if (object->len > NLM_MAXCOOKIELEN)
return nlm_lck_denied_nolocks;
cookie->len = object->len;
memcpy(cookie->data, object->data, object->len);
return nlm_granted;
}
static __be32
nlm4_lock_to_nlm_lock(struct nlm_lock *lock, struct nlm4_lock *alock)
{
if (alock->fh.len > NFS_MAXFHSIZE)
return nlm_lck_denied;
lock->fh.size = alock->fh.len;
memcpy(lock->fh.data, alock->fh.data, alock->fh.len);
lock->oh.len = alock->oh.len;
lock->oh.data = alock->oh.data;
lock->svid = alock->svid;
locks_init_lock(&lock->fl);
lockd_set_file_lock_range4(&lock->fl, alock->l_offset, alock->l_len);
return nlm_granted;
}
static struct nlm_host *
nlm4svc_lookup_host(struct svc_rqst *rqstp, string caller, bool monitored)
{
struct nlm_host *host;
if (!nlmsvc_ops)
return NULL;
host = nlmsvc_lookup_host(rqstp, caller.data, caller.len);
if (!host)
return NULL;
if (monitored && nsm_monitor(host) < 0) {
nlmsvc_release_host(host);
return NULL;
}
return host;
}
static __be32
nlm4svc_lookup_file(struct svc_rqst *rqstp, struct nlm_host *host,
struct nlm_lock *lock, struct nlm_file **filp,
struct nlm4_lock *xdr_lock, unsigned char type)
{
bool is_test = (rqstp->rq_proc == NLMPROC4_TEST ||
rqstp->rq_proc == NLMPROC4_TEST_MSG);
struct file_lock *fl = &lock->fl;
struct nlm_file *file = NULL;
int mode;
__be32 error;
if (xdr_lock->fh.len > NFS_MAXFHSIZE)
return nlm_lck_denied_nolocks;
lock->fh.size = xdr_lock->fh.len;
memcpy(lock->fh.data, xdr_lock->fh.data, xdr_lock->fh.len);
lock->oh.len = xdr_lock->oh.len;
lock->oh.data = xdr_lock->oh.data;
lock->svid = xdr_lock->svid;
lock->lock_start = xdr_lock->l_offset;
lock->lock_len = xdr_lock->l_len;
if (lock->lock_start > OFFSET_MAX ||
(lock->lock_len && ((lock->lock_len - 1) > (OFFSET_MAX - lock->lock_start))))
return nlm4_fbig;
locks_init_lock(fl);
fl->c.flc_type = type;
lockd_set_file_lock_range4(fl, lock->lock_start, lock->lock_len);
mode = is_test ? O_RDWR : lock_to_openmode(fl);
error = nlm_lookup_file(rqstp, &file, lock, mode);
switch (error) {
case nlm_granted:
break;
case nlm__int__stale_fh:
return nlm4_stale_fh;
case nlm__int__failed:
return nlm4_failed;
default:
return error;
}
*filp = file;
fl->c.flc_flags = FL_POSIX;
fl->c.flc_file = is_test ? nlmsvc_file_file(file)
: file->f_file[mode];
fl->c.flc_pid = current->tgid;
fl->fl_lmops = &nlmsvc_lock_operations;
nlmsvc_locks_init_private(fl, host, (pid_t)lock->svid);
if (!fl->c.flc_owner)
return nlm_lck_denied_nolocks;
return nlm_granted;
}
/**
* nlm4svc_proc_null - NULL: Test for presence of service
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully
*
* RPC synopsis:
* void NLMPROC4_NULL(void) = 0;
*/
static __be32
nlm4svc_proc_null(struct svc_rqst *rqstp)
{
return rpc_success;
}
/**
* nlm4svc_proc_test - TEST: Check for conflicting lock
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_drop_reply: Do not send an RPC reply.
*
* RPC synopsis:
* nlm4_testres NLMPROC4_TEST(nlm4_testargs) = 1;
*
* Permissible procedure status codes:
* %NLM4_GRANTED: The server would be able to grant the
* requested lock.
* %NLM4_DENIED: The requested lock conflicted with existing
* lock reservations for the file.
* %NLM4_DENIED_NOLOCKS: The server could not allocate the resources
* needed to process the request.
* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is
* re-establishing existing locks, and is not
* yet ready to accept normal service requests.
*
* The Linux NLM server implementation also returns:
* %NLM4_STALE_FH: The request specified an invalid file handle.
* %NLM4_FBIG: The request specified a length or offset
* that exceeds the range supported by the
* server.
* %NLM4_FAILED: The request failed for an unspecified reason.
*/
static __be32 nlm4svc_proc_test(struct svc_rqst *rqstp)
{
struct nlm4_testargs_wrapper *argp = rqstp->rq_argp;
unsigned char type = argp->xdrgen.exclusive ? F_WRLCK : F_RDLCK;
struct nlm4_testres_wrapper *resp = rqstp->rq_resp;
struct nlm_file *file = NULL;
struct nlm_host *host;
resp->xdrgen.cookie = argp->xdrgen.cookie;
resp->xdrgen.stat.stat = nlm_lck_denied_nolocks;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
if (!host)
goto out;
resp->xdrgen.stat.stat = nlm4svc_lookup_file(rqstp, host, &argp->lock,
&file, &argp->xdrgen.alock,
type);
if (resp->xdrgen.stat.stat)
goto out;
resp->xdrgen.stat.stat = nlmsvc_testlock(rqstp, file, host,
&argp->lock, &resp->lock);
nlmsvc_release_lockowner(&argp->lock);
if (resp->xdrgen.stat.stat == nlm_lck_denied) {
struct nlm_lock *conf = &resp->lock;
struct nlm4_holder *holder = &resp->xdrgen.stat.u.holder;
holder->exclusive = (conf->fl.c.flc_type != F_RDLCK);
holder->svid = conf->svid;
holder->oh.len = conf->oh.len;
holder->oh.data = conf->oh.data;
holder->l_offset = conf->fl.fl_start;
if (conf->fl.fl_end == OFFSET_MAX)
holder->l_len = 0;
else
holder->l_len = conf->fl.fl_end - conf->fl.fl_start + 1;
}
out:
if (file)
nlm_release_file(file);
nlmsvc_release_host(host);
return resp->xdrgen.stat.stat == nlm__int__drop_reply ?
rpc_drop_reply : rpc_success;
}
static __be32
nlm4svc_do_lock(struct svc_rqst *rqstp, bool monitored)
{
struct nlm4_lockargs_wrapper *argp = rqstp->rq_argp;
unsigned char type = argp->xdrgen.exclusive ? F_WRLCK : F_RDLCK;
struct nlm4_res_wrapper *resp = rqstp->rq_resp;
struct nlm_file *file = NULL;
struct nlm_host *host = NULL;
resp->xdrgen.cookie = argp->xdrgen.cookie;
resp->xdrgen.stat.stat = nlm4_netobj_to_cookie(&argp->cookie,
&argp->xdrgen.cookie);
if (resp->xdrgen.stat.stat)
goto out;
resp->xdrgen.stat.stat = nlm_lck_denied_nolocks;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name,
monitored);
if (!host)
goto out;
resp->xdrgen.stat.stat = nlm4svc_lookup_file(rqstp, host, &argp->lock,
&file, &argp->xdrgen.alock,
type);
if (resp->xdrgen.stat.stat)
goto out;
resp->xdrgen.stat.stat = nlmsvc_lock(rqstp, file, host, &argp->lock,
argp->xdrgen.block, &argp->cookie,
argp->xdrgen.reclaim);
if (resp->xdrgen.stat.stat == nlm__int__deadlock)
resp->xdrgen.stat.stat = nlm4_deadlock;
nlmsvc_release_lockowner(&argp->lock);
out:
if (file)
nlm_release_file(file);
nlmsvc_release_host(host);
return resp->xdrgen.stat.stat == nlm__int__drop_reply ?
rpc_drop_reply : rpc_success;
}
/**
* nlm4svc_proc_lock - LOCK: Establish a monitored lock
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_drop_reply: Do not send an RPC reply.
*
* RPC synopsis:
* nlm4_res NLMPROC4_LOCK(nlm4_lockargs) = 2;
*
* Permissible procedure status codes:
* %NLM4_GRANTED: The requested lock was granted.
* %NLM4_DENIED: The requested lock conflicted with existing
* lock reservations for the file.
* %NLM4_DENIED_NOLOCKS: The server could not allocate the resources
* needed to process the request.
* %NLM4_BLOCKED: The blocking request cannot be granted
* immediately. The server will send an
* NLMPROC4_GRANTED callback to the client when
* the lock can be granted.
* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is
* re-establishing existing locks, and is not
* yet ready to accept normal service requests.
*
* The Linux NLM server implementation also returns:
* %NLM4_DEADLCK: The request could not be granted and
* blocking would cause a deadlock.
* %NLM4_STALE_FH: The request specified an invalid file handle.
* %NLM4_FBIG: The request specified a length or offset
* that exceeds the range supported by the
* server.
* %NLM4_FAILED: The request failed for an unspecified reason.
*/
static __be32
nlm4svc_proc_lock(struct svc_rqst *rqstp)
{
return nlm4svc_do_lock(rqstp, true);
}
/**
* nlm4svc_proc_cancel - CANCEL: Cancel an outstanding blocked lock request
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully
* %rpc_drop_reply: Do not send an RPC reply
*
* RPC synopsis:
* nlm4_res NLMPROC4_CANCEL(nlm4_cancargs) = 3;
*
* Permissible procedure status codes:
* %NLM4_LCK_GRANTED: The requested lock was canceled.
* %NLM4_LCK_DENIED: There was no lock to cancel.
* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is
* re-establishing existing locks, and is not
* yet ready to accept normal service requests.
*
* The Linux NLM server implementation also returns:
* %NLM4_DENIED_NOLOCKS: A needed resource could not be allocated.
* %NLM4_STALE_FH: The request specified an invalid file handle.
* %NLM4_FBIG: The request specified a length or offset
* that exceeds the range supported by the
* server.
* %NLM4_FAILED: The request failed for an unspecified reason.
*/
static __be32
nlm4svc_proc_cancel(struct svc_rqst *rqstp)
{
struct nlm4_cancargs_wrapper *argp = rqstp->rq_argp;
unsigned char type = argp->xdrgen.exclusive ? F_WRLCK : F_RDLCK;
struct nlm4_res_wrapper *resp = rqstp->rq_resp;
struct net *net = SVC_NET(rqstp);
struct nlm_host *host = NULL;
struct nlm_file *file = NULL;
resp->xdrgen.cookie = argp->xdrgen.cookie;
resp->xdrgen.stat.stat = nlm_lck_denied_grace_period;
if (locks_in_grace(net))
goto out;
resp->xdrgen.stat.stat = nlm_lck_denied_nolocks;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
if (!host)
goto out;
resp->xdrgen.stat.stat = nlm4svc_lookup_file(rqstp, host, &argp->lock,
&file, &argp->xdrgen.alock,
type);
if (resp->xdrgen.stat.stat)
goto out;
resp->xdrgen.stat.stat = nlmsvc_cancel_blocked(net, file, &argp->lock);
nlmsvc_release_lockowner(&argp->lock);
out:
if (file)
nlm_release_file(file);
nlmsvc_release_host(host);
return resp->xdrgen.stat.stat == nlm__int__drop_reply ?
rpc_drop_reply : rpc_success;
}
/**
* nlm4svc_proc_unlock - UNLOCK: Remove a lock
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_drop_reply: Do not send an RPC reply.
*
* RPC synopsis:
* nlm4_res NLMPROC4_UNLOCK(nlm4_unlockargs) = 4;
*
* Permissible procedure status codes:
* %NLM4_GRANTED: The requested lock was released.
* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is
* re-establishing existing locks, and is not
* yet ready to accept normal service requests.
*
* The Linux NLM server implementation also returns:
* %NLM4_DENIED_NOLOCKS: A needed resource could not be allocated.
* %NLM4_STALE_FH: The request specified an invalid file handle.
* %NLM4_FBIG: The request specified a length or offset
* that exceeds the range supported by the
* server.
* %NLM4_FAILED: The request failed for an unspecified reason.
*/
static __be32
nlm4svc_proc_unlock(struct svc_rqst *rqstp)
{
struct nlm4_unlockargs_wrapper *argp = rqstp->rq_argp;
struct nlm4_res_wrapper *resp = rqstp->rq_resp;
struct net *net = SVC_NET(rqstp);
struct nlm_host *host = NULL;
struct nlm_file *file = NULL;
resp->xdrgen.cookie = argp->xdrgen.cookie;
resp->xdrgen.stat.stat = nlm_lck_denied_grace_period;
if (locks_in_grace(net))
goto out;
resp->xdrgen.stat.stat = nlm_lck_denied_nolocks;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
if (!host)
goto out;
resp->xdrgen.stat.stat = nlm4svc_lookup_file(rqstp, host, &argp->lock,
&file, &argp->xdrgen.alock,
F_UNLCK);
if (resp->xdrgen.stat.stat)
goto out;
resp->xdrgen.stat.stat = nlmsvc_unlock(net, file, &argp->lock);
nlmsvc_release_lockowner(&argp->lock);
out:
if (file)
nlm_release_file(file);
nlmsvc_release_host(host);
return resp->xdrgen.stat.stat == nlm__int__drop_reply ?
rpc_drop_reply : rpc_success;
}
/**
* nlm4svc_proc_granted - GRANTED: Server grants a previously blocked lock
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
*
* RPC synopsis:
* nlm4_res NLMPROC4_GRANTED(nlm4_testargs) = 5;
*
* Permissible procedure status codes:
* %NLM4_GRANTED: The requested lock was granted.
* %NLM4_DENIED: The server could not allocate the resources
* needed to process the request.
* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is
* re-establishing existing locks, and is not
* yet ready to accept normal service requests.
*/
static __be32
nlm4svc_proc_granted(struct svc_rqst *rqstp)
{
struct nlm4_testargs_wrapper *argp = rqstp->rq_argp;
struct nlm4_res_wrapper *resp = rqstp->rq_resp;
resp->xdrgen.cookie = argp->xdrgen.cookie;
resp->xdrgen.stat.stat = nlm4_lock_to_nlm_lock(&argp->lock,
&argp->xdrgen.alock);
if (resp->xdrgen.stat.stat)
goto out;
resp->xdrgen.stat.stat = nlmclnt_grant(svc_addr(rqstp), &argp->lock);
out:
return rpc_success;
}
/*
* This is the generic lockd callback for async RPC calls
*/
static void nlm4svc_callback_exit(struct rpc_task *task, void *data)
{
}
static void nlm4svc_callback_release(void *data)
{
nlmsvc_release_call(data);
}
static const struct rpc_call_ops nlm4svc_callback_ops = {
.rpc_call_done = nlm4svc_callback_exit,
.rpc_release = nlm4svc_callback_release,
};
/*
* Dispatch an async callback RPC to a client with a pre-resolved host.
* Caller provides a reference to @host; this function takes ownership
* and releases it via nlmsvc_release_host() before returning.
*/
static __be32
nlm4svc_callback(struct svc_rqst *rqstp, struct nlm_host *host, u32 proc,
__be32 (*func)(struct svc_rqst *, struct nlm_res *))
{
struct nlm_rqst *call;
__be32 stat;
call = nlm_alloc_call(host);
nlmsvc_release_host(host);
if (call == NULL)
return rpc_system_err;
stat = func(rqstp, &call->a_res);
if (stat != 0) {
nlmsvc_release_call(call);
return stat;
}
call->a_flags = RPC_TASK_ASYNC;
if (nlm_async_reply(call, proc, &nlm4svc_callback_ops) < 0)
return rpc_system_err;
return rpc_success;
}
static __be32
__nlm4svc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_res *resp)
{
struct nlm4_testargs_wrapper *argp = rqstp->rq_argp;
unsigned char type = argp->xdrgen.exclusive ? F_WRLCK : F_RDLCK;
struct nlm_lockowner *owner;
struct nlm_file *file = NULL;
struct nlm_host *host = NULL;
resp->status = nlm_lck_denied_nolocks;
if (nlm4_netobj_to_cookie(&resp->cookie, &argp->xdrgen.cookie))
goto out;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
if (!host)
goto out;
resp->status = nlm4svc_lookup_file(rqstp, host, &argp->lock,
&file, &argp->xdrgen.alock, type);
if (resp->status)
goto out;
owner = argp->lock.fl.c.flc_owner;
resp->status = nlmsvc_testlock(rqstp, file, host, &argp->lock,
&resp->lock);
nlmsvc_put_lockowner(owner);
out:
if (file)
nlm_release_file(file);
nlmsvc_release_host(host);
return resp->status == nlm__int__drop_reply ? rpc_drop_reply : rpc_success;
}
/**
* nlm4svc_proc_test_msg - TEST_MSG: Check for conflicting lock
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_system_err: RPC execution failed.
*
* RPC synopsis:
* void NLMPROC4_TEST_MSG(nlm4_testargs) = 6;
*
* The response to this request is delivered via the TEST_RES procedure.
*/
static __be32 nlm4svc_proc_test_msg(struct svc_rqst *rqstp)
{
struct nlm4_testargs_wrapper *argp = rqstp->rq_argp;
struct nlm_host *host;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
if (!host)
return rpc_system_err;
return nlm4svc_callback(rqstp, host, NLMPROC4_TEST_RES,
__nlm4svc_proc_test_msg);
}
static __be32
__nlm4svc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_res *resp)
{
struct nlm4_lockargs_wrapper *argp = rqstp->rq_argp;
unsigned char type = argp->xdrgen.exclusive ? F_WRLCK : F_RDLCK;
struct nlm_file *file = NULL;
struct nlm_host *host = NULL;
resp->status = nlm_lck_denied_nolocks;
if (nlm4_netobj_to_cookie(&resp->cookie, &argp->xdrgen.cookie))
goto out;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, true);
if (!host)
goto out;
resp->status = nlm4svc_lookup_file(rqstp, host, &argp->lock,
&file, &argp->xdrgen.alock, type);
if (resp->status)
goto out;
resp->status = nlmsvc_lock(rqstp, file, host, &argp->lock,
argp->xdrgen.block, &resp->cookie,
argp->xdrgen.reclaim);
nlmsvc_release_lockowner(&argp->lock);
out:
if (file)
nlm_release_file(file);
nlmsvc_release_host(host);
return resp->status == nlm__int__drop_reply ?
rpc_drop_reply : rpc_success;
}
/**
* nlm4svc_proc_lock_msg - LOCK_MSG: Establish a monitored lock
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_system_err: RPC execution failed.
*
* RPC synopsis:
* void NLMPROC4_LOCK_MSG(nlm4_lockargs) = 7;
*
* The response to this request is delivered via the LOCK_RES procedure.
*/
static __be32 nlm4svc_proc_lock_msg(struct svc_rqst *rqstp)
{
struct nlm4_lockargs_wrapper *argp = rqstp->rq_argp;
struct nlm_host *host;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, true);
if (!host)
return rpc_system_err;
return nlm4svc_callback(rqstp, host, NLMPROC4_LOCK_RES,
__nlm4svc_proc_lock_msg);
}
static __be32
__nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_res *resp)
{
struct nlm4_cancargs_wrapper *argp = rqstp->rq_argp;
unsigned char type = argp->xdrgen.exclusive ? F_WRLCK : F_RDLCK;
struct net *net = SVC_NET(rqstp);
struct nlm_file *file = NULL;
struct nlm_host *host = NULL;
resp->status = nlm_lck_denied_nolocks;
if (nlm4_netobj_to_cookie(&resp->cookie, &argp->xdrgen.cookie))
goto out;
resp->status = nlm_lck_denied_grace_period;
if (locks_in_grace(net))
goto out;
resp->status = nlm_lck_denied_nolocks;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
if (!host)
goto out;
resp->status = nlm4svc_lookup_file(rqstp, host, &argp->lock,
&file, &argp->xdrgen.alock, type);
if (resp->status)
goto out;
resp->status = nlmsvc_cancel_blocked(net, file, &argp->lock);
nlmsvc_release_lockowner(&argp->lock);
out:
if (file)
nlm_release_file(file);
nlmsvc_release_host(host);
return resp->status == nlm__int__drop_reply ?
rpc_drop_reply : rpc_success;
}
/**
* nlm4svc_proc_cancel_msg - CANCEL_MSG: Cancel an outstanding lock request
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_system_err: RPC execution failed.
*
* RPC synopsis:
* void NLMPROC4_CANCEL_MSG(nlm4_cancargs) = 8;
*
* The response to this request is delivered via the CANCEL_RES procedure.
*/
static __be32 nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp)
{
struct nlm4_cancargs_wrapper *argp = rqstp->rq_argp;
struct nlm_host *host;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
if (!host)
return rpc_system_err;
return nlm4svc_callback(rqstp, host, NLMPROC4_CANCEL_RES,
__nlm4svc_proc_cancel_msg);
}
static __be32
__nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_res *resp)
{
struct nlm4_unlockargs_wrapper *argp = rqstp->rq_argp;
struct net *net = SVC_NET(rqstp);
struct nlm_file *file = NULL;
struct nlm_host *host = NULL;
resp->status = nlm_lck_denied_nolocks;
if (nlm4_netobj_to_cookie(&resp->cookie, &argp->xdrgen.cookie))
goto out;
resp->status = nlm_lck_denied_grace_period;
if (locks_in_grace(net))
goto out;
resp->status = nlm_lck_denied_nolocks;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
if (!host)
goto out;
resp->status = nlm4svc_lookup_file(rqstp, host, &argp->lock,
&file, &argp->xdrgen.alock, F_UNLCK);
if (resp->status)
goto out;
resp->status = nlmsvc_unlock(net, file, &argp->lock);
nlmsvc_release_lockowner(&argp->lock);
out:
if (file)
nlm_release_file(file);
nlmsvc_release_host(host);
return resp->status == nlm__int__drop_reply ?
rpc_drop_reply : rpc_success;
}
/**
* nlm4svc_proc_unlock_msg - UNLOCK_MSG: Remove an existing lock
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_system_err: RPC execution failed.
*
* RPC synopsis:
* void NLMPROC4_UNLOCK_MSG(nlm4_unlockargs) = 9;
*
* The response to this request is delivered via the UNLOCK_RES procedure.
*/
static __be32 nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp)
{
struct nlm4_unlockargs_wrapper *argp = rqstp->rq_argp;
struct nlm_host *host;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
if (!host)
return rpc_system_err;
return nlm4svc_callback(rqstp, host, NLMPROC4_UNLOCK_RES,
__nlm4svc_proc_unlock_msg);
}
static __be32
__nlm4svc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_res *resp)
{
struct nlm4_testargs_wrapper *argp = rqstp->rq_argp;
resp->status = nlm_lck_denied;
if (nlm4_netobj_to_cookie(&resp->cookie, &argp->xdrgen.cookie))
goto out;
if (nlm4_lock_to_nlm_lock(&argp->lock, &argp->xdrgen.alock))
goto out;
resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock);
out:
return rpc_success;
}
/**
* nlm4svc_proc_granted_msg - GRANTED_MSG: Blocked lock has been granted
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_system_err: RPC execution failed.
*
* RPC synopsis:
* void NLMPROC4_GRANTED_MSG(nlm4_testargs) = 10;
*
* The response to this request is delivered via the GRANTED_RES procedure.
*/
static __be32 nlm4svc_proc_granted_msg(struct svc_rqst *rqstp)
{
struct nlm4_testargs_wrapper *argp = rqstp->rq_argp;
struct nlm_host *host;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false);
if (!host)
return rpc_system_err;
return nlm4svc_callback(rqstp, host, NLMPROC4_GRANTED_RES,
__nlm4svc_proc_granted_msg);
}
/**
* nlm4svc_proc_granted_res - GRANTED_RES: Lock Granted result
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
*
* RPC synopsis:
* void NLMPROC4_GRANTED_RES(nlm4_res) = 15;
*/
static __be32 nlm4svc_proc_granted_res(struct svc_rqst *rqstp)
{
struct nlm4_res_wrapper *argp = rqstp->rq_argp;
if (!nlmsvc_ops)
return rpc_success;
if (nlm4_netobj_to_cookie(&argp->cookie, &argp->xdrgen.cookie))
return rpc_success;
nlmsvc_grant_reply(&argp->cookie, argp->xdrgen.stat.stat);
return rpc_success;
}
/**
* nlm4svc_proc_sm_notify - SM_NOTIFY: Peer has rebooted
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_system_err: RPC execution failed.
*
* The SM_NOTIFY procedure is a private callback from Linux statd and is
* not part of the official NLM protocol.
*
* RPC synopsis:
* void NLMPROC4_SM_NOTIFY(nlm4_notifyargs) = 16;
*/
static __be32 nlm4svc_proc_sm_notify(struct svc_rqst *rqstp)
{
struct nlm4_notifyargs_wrapper *argp = rqstp->rq_argp;
struct nlm_reboot *reboot = &argp->reboot;
if (!nlm_privileged_requester(rqstp)) {
char buf[RPC_MAX_ADDRBUFLEN];
pr_warn("lockd: rejected NSM callback from %s\n",
svc_print_addr(rqstp, buf, sizeof(buf)));
return rpc_system_err;
}
reboot->len = argp->xdrgen.notify.name.len;
reboot->mon = (char *)argp->xdrgen.notify.name.data;
reboot->state = argp->xdrgen.notify.state;
memcpy(&reboot->priv.data, argp->xdrgen.private,
sizeof(reboot->priv.data));
nlm_host_rebooted(SVC_NET(rqstp), reboot);
return rpc_success;
}
/**
* nlm4svc_proc_unused - stub for unused procedures
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_proc_unavail: Program can't support procedure.
*/
static __be32 nlm4svc_proc_unused(struct svc_rqst *rqstp)
{
return rpc_proc_unavail;
}
/**
* nlm4svc_proc_share - SHARE: Open a file using DOS file-sharing modes
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_drop_reply: Do not send an RPC reply.
*
* RPC synopsis:
* nlm4_shareres NLMPROC4_SHARE(nlm4_shareargs) = 20;
*
* Permissible procedure status codes:
* %NLM4_GRANTED: The requested share lock was granted.
* %NLM4_DENIED: The requested lock conflicted with existing
* lock reservations for the file.
* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is
* re-establishing existing locks, and is not
* yet ready to accept normal service requests.
*
* The Linux NLM server implementation also returns:
* %NLM4_DENIED_NOLOCKS: A needed resource could not be allocated.
* %NLM4_STALE_FH: The request specified an invalid file handle.
* %NLM4_FBIG: The request specified a length or offset
* that exceeds the range supported by the
* server.
* %NLM4_FAILED: The request failed for an unspecified reason.
*/
static __be32 nlm4svc_proc_share(struct svc_rqst *rqstp)
{
struct nlm4_shareargs_wrapper *argp = rqstp->rq_argp;
struct nlm4_shareres_wrapper *resp = rqstp->rq_resp;
struct nlm_lock *lock = &argp->lock;
struct nlm_host *host = NULL;
struct nlm_file *file = NULL;
struct nlm4_lock xdr_lock = {
.fh = argp->xdrgen.share.fh,
.oh = argp->xdrgen.share.oh,
.svid = LOCKD_SHARE_SVID,
};
resp->xdrgen.cookie = argp->xdrgen.cookie;
resp->xdrgen.stat = nlm_lck_denied_grace_period;
if (locks_in_grace(SVC_NET(rqstp)) && !argp->xdrgen.reclaim)
goto out;
resp->xdrgen.stat = nlm_lck_denied_nolocks;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.share.caller_name, true);
if (!host)
goto out;
resp->xdrgen.stat = nlm4svc_lookup_file(rqstp, host, lock, &file,
&xdr_lock, F_RDLCK);
if (resp->xdrgen.stat)
goto out;
resp->xdrgen.stat = nlmsvc_share_file(host, file, &lock->oh,
argp->xdrgen.share.access,
argp->xdrgen.share.mode);
nlmsvc_release_lockowner(lock);
out:
if (file)
nlm_release_file(file);
nlmsvc_release_host(host);
return resp->xdrgen.stat == nlm__int__drop_reply ?
rpc_drop_reply : rpc_success;
}
/**
* nlm4svc_proc_unshare - UNSHARE: Release a share reservation
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_drop_reply: Do not send an RPC reply.
*
* RPC synopsis:
* nlm4_shareres NLMPROC4_UNSHARE(nlm4_shareargs) = 21;
*
* Permissible procedure status codes:
* %NLM4_GRANTED: The share reservation was released.
* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is
* re-establishing existing locks, and is not
* yet ready to accept normal service requests.
*
* The Linux NLM server implementation also returns:
* %NLM4_DENIED_NOLOCKS: A needed resource could not be allocated.
* %NLM4_STALE_FH: The request specified an invalid file handle.
* %NLM4_FBIG: The request specified a length or offset
* that exceeds the range supported by the
* server.
* %NLM4_FAILED: The request failed for an unspecified reason.
*/
static __be32 nlm4svc_proc_unshare(struct svc_rqst *rqstp)
{
struct nlm4_shareargs_wrapper *argp = rqstp->rq_argp;
struct nlm4_shareres_wrapper *resp = rqstp->rq_resp;
struct nlm_lock *lock = &argp->lock;
struct nlm4_lock xdr_lock = {
.fh = argp->xdrgen.share.fh,
.oh = argp->xdrgen.share.oh,
.svid = LOCKD_SHARE_SVID,
};
struct nlm_host *host = NULL;
struct nlm_file *file = NULL;
resp->xdrgen.cookie = argp->xdrgen.cookie;
resp->xdrgen.stat = nlm_lck_denied_grace_period;
if (locks_in_grace(SVC_NET(rqstp)))
goto out;
resp->xdrgen.stat = nlm_lck_denied_nolocks;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.share.caller_name, true);
if (!host)
goto out;
resp->xdrgen.stat = nlm4svc_lookup_file(rqstp, host, lock, &file,
&xdr_lock, F_RDLCK);
if (resp->xdrgen.stat)
goto out;
resp->xdrgen.stat = nlmsvc_unshare_file(host, file, &lock->oh);
nlmsvc_release_lockowner(lock);
out:
if (file)
nlm_release_file(file);
nlmsvc_release_host(host);
return resp->xdrgen.stat == nlm__int__drop_reply ?
rpc_drop_reply : rpc_success;
}
/**
* nlm4svc_proc_nm_lock - NM_LOCK: Establish a non-monitored lock
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
* %rpc_drop_reply: Do not send an RPC reply.
*
* RPC synopsis:
* nlm4_res NLMPROC4_NM_LOCK(nlm4_lockargs) = 22;
*
* Permissible procedure status codes:
* %NLM4_GRANTED: The requested lock was granted.
* %NLM4_DENIED: The requested lock conflicted with existing
* lock reservations for the file.
* %NLM4_DENIED_NOLOCKS: The server could not allocate the resources
* needed to process the request.
* %NLM4_BLOCKED: The blocking request cannot be granted
* immediately. The server will send an
* NLMPROC4_GRANTED callback to the client when
* the lock can be granted.
* %NLM4_DENIED_GRACE_PERIOD: The server has recently restarted and is
* re-establishing existing locks, and is not
* yet ready to accept normal service requests.
*
* The Linux NLM server implementation also returns:
* %NLM4_DEADLCK: The request could not be granted and
* blocking would cause a deadlock.
* %NLM4_STALE_FH: The request specified an invalid file handle.
* %NLM4_FBIG: The request specified a length or offset
* that exceeds the range supported by the
* server.
* %NLM4_FAILED: The request failed for an unspecified reason.
*/
static __be32 nlm4svc_proc_nm_lock(struct svc_rqst *rqstp)
{
return nlm4svc_do_lock(rqstp, false);
}
/**
* nlm4svc_proc_free_all - FREE_ALL: Discard client's lock and share state
* @rqstp: RPC transaction context
*
* Returns:
* %rpc_success: RPC executed successfully.
*
* RPC synopsis:
* void NLMPROC4_FREE_ALL(nlm4_notify) = 23;
*/
static __be32 nlm4svc_proc_free_all(struct svc_rqst *rqstp)
{
struct nlm4_notify_wrapper *argp = rqstp->rq_argp;
struct nlm_host *host;
host = nlm4svc_lookup_host(rqstp, argp->xdrgen.name, false);
if (!host)
goto out;
nlmsvc_free_host_resources(host);
nlmsvc_release_host(host);
out:
return rpc_success;
}
/*
* NLMv4 Server procedures.
*/
static const struct svc_procedure nlm4svc_procedures[24] = {
[NLMPROC4_NULL] = {
.pc_func = nlm4svc_proc_null,
.pc_decode = nlm4_svc_decode_void,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = XDR_void,
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "NULL",
},
[NLMPROC4_TEST] = {
.pc_func = nlm4svc_proc_test,
.pc_decode = nlm4_svc_decode_nlm4_testargs,
.pc_encode = nlm4_svc_encode_nlm4_testres,
.pc_argsize = sizeof(struct nlm4_testargs_wrapper),
.pc_argzero = 0,
.pc_ressize = sizeof(struct nlm4_testres_wrapper),
.pc_xdrressize = NLM4_nlm4_testres_sz,
.pc_name = "TEST",
},
[NLMPROC4_LOCK] = {
.pc_func = nlm4svc_proc_lock,
.pc_decode = nlm4_svc_decode_nlm4_lockargs,
.pc_encode = nlm4_svc_encode_nlm4_res,
.pc_argsize = sizeof(struct nlm4_lockargs_wrapper),
.pc_argzero = 0,
.pc_ressize = sizeof(struct nlm4_res_wrapper),
.pc_xdrressize = NLM4_nlm4_res_sz,
.pc_name = "LOCK",
},
[NLMPROC4_CANCEL] = {
.pc_func = nlm4svc_proc_cancel,
.pc_decode = nlm4_svc_decode_nlm4_cancargs,
.pc_encode = nlm4_svc_encode_nlm4_res,
.pc_argsize = sizeof(struct nlm4_cancargs_wrapper),
.pc_argzero = 0,
.pc_ressize = sizeof(struct nlm4_res_wrapper),
.pc_xdrressize = NLM4_nlm4_res_sz,
.pc_name = "CANCEL",
},
[NLMPROC4_UNLOCK] = {
.pc_func = nlm4svc_proc_unlock,
.pc_decode = nlm4_svc_decode_nlm4_unlockargs,
.pc_encode = nlm4_svc_encode_nlm4_res,
.pc_argsize = sizeof(struct nlm4_unlockargs_wrapper),
.pc_argzero = 0,
.pc_ressize = sizeof(struct nlm4_res_wrapper),
.pc_xdrressize = NLM4_nlm4_res_sz,
.pc_name = "UNLOCK",
},
[NLMPROC4_GRANTED] = {
.pc_func = nlm4svc_proc_granted,
.pc_decode = nlm4_svc_decode_nlm4_testargs,
.pc_encode = nlm4_svc_encode_nlm4_res,
.pc_argsize = sizeof(struct nlm4_testargs_wrapper),
.pc_argzero = 0,
.pc_ressize = sizeof(struct nlm4_res_wrapper),
.pc_xdrressize = NLM4_nlm4_res_sz,
.pc_name = "GRANTED",
},
[NLMPROC4_TEST_MSG] = {
.pc_func = nlm4svc_proc_test_msg,
.pc_decode = nlm4_svc_decode_nlm4_testargs,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_testargs_wrapper),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "TEST_MSG",
},
[NLMPROC4_LOCK_MSG] = {
.pc_func = nlm4svc_proc_lock_msg,
.pc_decode = nlm4_svc_decode_nlm4_lockargs,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_lockargs_wrapper),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "LOCK_MSG",
},
[NLMPROC4_CANCEL_MSG] = {
.pc_func = nlm4svc_proc_cancel_msg,
.pc_decode = nlm4_svc_decode_nlm4_cancargs,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_cancargs_wrapper),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "CANCEL_MSG",
},
[NLMPROC4_UNLOCK_MSG] = {
.pc_func = nlm4svc_proc_unlock_msg,
.pc_decode = nlm4_svc_decode_nlm4_unlockargs,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_unlockargs_wrapper),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "UNLOCK_MSG",
},
[NLMPROC4_GRANTED_MSG] = {
.pc_func = nlm4svc_proc_granted_msg,
.pc_decode = nlm4_svc_decode_nlm4_testargs,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_testargs_wrapper),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "GRANTED_MSG",
},
[NLMPROC4_TEST_RES] = {
.pc_func = nlm4svc_proc_null,
.pc_decode = nlm4_svc_decode_nlm4_testres,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_testres),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "TEST_RES",
},
[NLMPROC4_LOCK_RES] = {
.pc_func = nlm4svc_proc_null,
.pc_decode = nlm4_svc_decode_nlm4_res,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_res),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "LOCK_RES",
},
[NLMPROC4_CANCEL_RES] = {
.pc_func = nlm4svc_proc_null,
.pc_decode = nlm4_svc_decode_nlm4_res,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_res),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "CANCEL_RES",
},
[NLMPROC4_UNLOCK_RES] = {
.pc_func = nlm4svc_proc_null,
.pc_decode = nlm4_svc_decode_nlm4_res,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_res),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "UNLOCK_RES",
},
[NLMPROC4_GRANTED_RES] = {
.pc_func = nlm4svc_proc_granted_res,
.pc_decode = nlm4_svc_decode_nlm4_res,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_res_wrapper),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "GRANTED_RES",
},
[NLMPROC4_SM_NOTIFY] = {
.pc_func = nlm4svc_proc_sm_notify,
.pc_decode = nlm4_svc_decode_nlm4_notifyargs,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_notifyargs_wrapper),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "SM_NOTIFY",
},
[17] = {
.pc_func = nlm4svc_proc_unused,
.pc_decode = nlm4_svc_decode_void,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = 0,
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "UNUSED",
},
[18] = {
.pc_func = nlm4svc_proc_unused,
.pc_decode = nlm4_svc_decode_void,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = 0,
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "UNUSED",
},
[19] = {
.pc_func = nlm4svc_proc_unused,
.pc_decode = nlm4_svc_decode_void,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = 0,
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "UNUSED",
},
[NLMPROC4_SHARE] = {
.pc_func = nlm4svc_proc_share,
.pc_decode = nlm4_svc_decode_nlm4_shareargs,
.pc_encode = nlm4_svc_encode_nlm4_shareres,
.pc_argsize = sizeof(struct nlm4_shareargs_wrapper),
.pc_argzero = 0,
.pc_ressize = sizeof(struct nlm4_shareres_wrapper),
.pc_xdrressize = NLM4_nlm4_shareres_sz,
.pc_name = "SHARE",
},
[NLMPROC4_UNSHARE] = {
.pc_func = nlm4svc_proc_unshare,
.pc_decode = nlm4_svc_decode_nlm4_shareargs,
.pc_encode = nlm4_svc_encode_nlm4_shareres,
.pc_argsize = sizeof(struct nlm4_shareargs_wrapper),
.pc_argzero = 0,
.pc_ressize = sizeof(struct nlm4_shareres_wrapper),
.pc_xdrressize = NLM4_nlm4_shareres_sz,
.pc_name = "UNSHARE",
},
[NLMPROC4_NM_LOCK] = {
.pc_func = nlm4svc_proc_nm_lock,
.pc_decode = nlm4_svc_decode_nlm4_lockargs,
.pc_encode = nlm4_svc_encode_nlm4_res,
.pc_argsize = sizeof(struct nlm4_lockargs_wrapper),
.pc_argzero = 0,
.pc_ressize = sizeof(struct nlm4_res_wrapper),
.pc_xdrressize = NLM4_nlm4_res_sz,
.pc_name = "NM_LOCK",
},
[NLMPROC4_FREE_ALL] = {
.pc_func = nlm4svc_proc_free_all,
.pc_decode = nlm4_svc_decode_nlm4_notify,
.pc_encode = nlm4_svc_encode_void,
.pc_argsize = sizeof(struct nlm4_notify_wrapper),
.pc_argzero = 0,
.pc_ressize = 0,
.pc_xdrressize = XDR_void,
.pc_name = "FREE_ALL",
},
};
/*
* Storage requirements for XDR arguments and results
*/
union nlm4svc_xdrstore {
struct nlm4_testargs_wrapper testargs;
struct nlm4_lockargs_wrapper lockargs;
struct nlm4_cancargs_wrapper cancargs;
struct nlm4_unlockargs_wrapper unlockargs;
struct nlm4_notifyargs_wrapper notifyargs;
struct nlm4_shareargs_wrapper shareargs;
struct nlm4_notify_wrapper notify;
struct nlm4_testres_wrapper testres;
struct nlm4_res_wrapper res;
struct nlm4_shareres_wrapper shareres;
};
static DEFINE_PER_CPU_ALIGNED(unsigned long,
nlm4svc_call_counters[ARRAY_SIZE(nlm4svc_procedures)]);
const struct svc_version nlmsvc_version4 = {
.vs_vers = 4,
.vs_nproc = ARRAY_SIZE(nlm4svc_procedures),
.vs_proc = nlm4svc_procedures,
.vs_count = nlm4svc_call_counters,
.vs_dispatch = nlmsvc_dispatch,
.vs_xdrsize = sizeof(union nlm4svc_xdrstore),
};
|