4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
19 * Copyright (c) 2011, 2017, Intel Corporation.
22 * This file is part of Lustre, http://www.lustre.org/
24 * lustre/ptlrpc/pack_server.c
26 * (Un)packing of OST requests
30 #define DEBUG_SUBSYSTEM S_RPC
32 #include <llog_swab.h>
33 #include <obd_class.h>
35 void lustre_swab_object_update(struct object_update *ou)
37 struct object_update_param *param;
40 __swab16s(&ou->ou_type);
41 __swab16s(&ou->ou_params_count);
42 __swab32s(&ou->ou_result_size);
43 __swab32s(&ou->ou_flags);
44 __swab32s(&ou->ou_padding1);
45 __swab64s(&ou->ou_batchid);
46 lustre_swab_lu_fid(&ou->ou_fid);
47 param = &ou->ou_params[0];
48 for (i = 0; i < ou->ou_params_count; i++) {
49 __swab16s(¶m->oup_len);
50 __swab16s(¶m->oup_padding);
51 __swab32s(¶m->oup_padding2);
52 param = (struct object_update_param *)((char *)param +
53 object_update_param_size(param));
57 int lustre_swab_object_update_request(struct object_update_request *our,
61 struct object_update *ou;
63 __swab32s(&our->ourq_magic);
64 __swab16s(&our->ourq_count);
65 __swab16s(&our->ourq_padding);
67 /* Don't need to calculate request size if len is 0. */
69 size = sizeof(struct object_update_request);
70 for (i = 0; i < our->ourq_count; i++) {
71 ou = object_update_request_get(our, i, NULL);
74 size += sizeof(struct object_update) +
76 sizeof(struct object_update_param);
78 if (unlikely(size > len))
82 for (i = 0; i < our->ourq_count; i++) {
83 ou = object_update_request_get(our, i, NULL);
84 lustre_swab_object_update(ou);
90 void lustre_swab_object_update_result(struct object_update_result *our)
92 __swab32s(&our->our_rc);
93 __swab16s(&our->our_datalen);
94 __swab16s(&our->our_padding);
97 int lustre_swab_object_update_reply(struct object_update_reply *our, __u32 len)
101 __swab32s(&our->ourp_magic);
102 __swab16s(&our->ourp_count);
103 __swab16s(&our->ourp_padding);
105 size = sizeof(struct object_update_reply) + our->ourp_count *
106 (sizeof(__u16) + sizeof(struct object_update_result));
107 if (unlikely(size > len))
110 for (i = 0; i < our->ourp_count; i++) {
111 struct object_update_result *ourp;
113 __swab16s(&our->ourp_lens[i]);
114 ourp = object_update_result_get(our, i, NULL);
117 lustre_swab_object_update_result(ourp);
123 void lustre_swab_out_update_header(struct out_update_header *ouh)
125 __swab32s(&ouh->ouh_magic);
126 __swab32s(&ouh->ouh_count);
127 __swab32s(&ouh->ouh_inline_length);
128 __swab32s(&ouh->ouh_reply_size);
130 EXPORT_SYMBOL(lustre_swab_out_update_header);
132 void lustre_swab_out_update_buffer(struct out_update_buffer *oub)
134 __swab32s(&oub->oub_size);
135 __swab32s(&oub->oub_padding);
137 EXPORT_SYMBOL(lustre_swab_out_update_buffer);