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).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2014, Intel Corporation.
28 * Selection of object_update and object_update_param handling functions
31 #ifndef _OBJ_UPDATE_H_
32 #define _OBJ_UPDATE_H_
34 #include <uapi/linux/lustre/lustre_idl.h>
37 object_update_param_size(const struct object_update_param *param)
39 return cfs_size_round(sizeof(*param) + param->oup_len);
43 object_update_params_size(const struct object_update *update)
45 const struct object_update_param *param;
46 size_t total_size = 0;
49 param = &update->ou_params[0];
50 for (i = 0; i < update->ou_params_count; i++) {
51 size_t size = object_update_param_size(param);
53 param = (struct object_update_param *)((char *)param + size);
61 object_update_size(const struct object_update *update)
63 return offsetof(struct object_update, ou_params[0]) +
64 object_update_params_size(update);
67 static inline struct object_update *
68 object_update_request_get(const struct object_update_request *our,
69 unsigned int index, size_t *size)
74 if (index >= our->ourq_count)
77 ptr = (void *)&our->ourq_updates[0];
78 for (i = 0; i < index; i++)
79 ptr += object_update_size(ptr);
82 *size = object_update_size(ptr);
89 static inline struct object_update_result *
90 object_update_result_get(const struct object_update_reply *reply,
91 unsigned int index, size_t *size)
93 __u16 count = reply->ourp_count;
100 ptr = (char *)reply +
101 cfs_size_round(offsetof(struct object_update_reply,
103 for (i = 0; i < index; i++) {
104 if (reply->ourp_lens[i] == 0)
107 ptr += cfs_size_round(reply->ourp_lens[i]);
111 *size = reply->ourp_lens[index];