From 86068ab4d84dd0915fc91dbf59ac924ced9373c3 Mon Sep 17 00:00:00 2001 From: Ben Evans Date: Wed, 6 Jul 2016 11:59:55 -0400 Subject: [PATCH] LU-6401 headers: Move object_update functions to new header The header lustre_idl.h is meant to be a uapi header but it currently contains code that is only used by the lustre kernel internals. This patch moves the code related to object update handling out of lustre_idl.h into a separate header that is only needed for the kernel server side code. Signed-off-by: Ben Evans Change-Id: Ie025f8424dad8cfc625258ad189c7b7576b3a9b2 Reviewed-on: http://review.whamcloud.com/20120 Reviewed-by: Frank Zago Tested-by: Jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/Makefile.am | 1 + lustre/include/lustre/lustre_idl.h | 95 ------------------------------ lustre/include/lustre_update.h | 3 +- lustre/include/obj_update.h | 115 +++++++++++++++++++++++++++++++++++++ lustre/osp/osp_md_object.c | 10 ++++ lustre/ptlrpc/pack_generic.c | 1 + lustre/target/out_handler.c | 8 +++ 7 files changed, 137 insertions(+), 96 deletions(-) create mode 100644 lustre/include/obj_update.h diff --git a/lustre/include/Makefile.am b/lustre/include/Makefile.am index 4bb51d9..a67471c 100644 --- a/lustre/include/Makefile.am +++ b/lustre/include/Makefile.am @@ -98,6 +98,7 @@ EXTRA_DIST = \ obd.h \ obd_support.h \ obd_target.h \ + obj_update.h \ upcall_cache.h \ lustre_kernelcomm.h \ seq_range.h \ diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 23e0b1a..04413a7 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -3815,12 +3815,6 @@ struct object_update_param { char oup_buf[0]; }; -static inline size_t -object_update_param_size(const struct object_update_param *param) -{ - return cfs_size_round(sizeof(*param) + param->oup_len); -} - /* object update */ struct object_update { __u16 ou_type; /* enum update_type */ @@ -3860,52 +3854,6 @@ struct out_update_buffer { __u32 oub_padding; }; -static inline size_t -object_update_params_size(const struct object_update *update) -{ - const struct object_update_param *param; - size_t total_size = 0; - unsigned int i; - - param = &update->ou_params[0]; - for (i = 0; i < update->ou_params_count; i++) { - size_t size = object_update_param_size(param); - - param = (struct object_update_param *)((char *)param + size); - total_size += size; - } - - return total_size; -} - -static inline size_t -object_update_size(const struct object_update *update) -{ - return offsetof(struct object_update, ou_params[0]) + - object_update_params_size(update); -} - -static inline struct object_update * -object_update_request_get(const struct object_update_request *our, - unsigned int index, size_t *size) -{ - void *ptr; - unsigned int i; - - if (index >= our->ourq_count) - return NULL; - - ptr = (void *)&our->ourq_updates[0]; - for (i = 0; i < index; i++) - ptr += object_update_size(ptr); - - if (size != NULL) - *size = object_update_size(ptr); - - return ptr; -} - - /* the result of object update */ struct object_update_result { __u32 our_rc; @@ -3925,33 +3873,6 @@ struct object_update_reply { __u16 ourp_lens[0]; }; -static inline struct object_update_result * -object_update_result_get(const struct object_update_reply *reply, - unsigned int index, size_t *size) -{ - __u16 count = reply->ourp_count; - unsigned int i; - void *ptr; - - if (index >= count) - return NULL; - - ptr = (char *)reply + - cfs_size_round(offsetof(struct object_update_reply, - ourp_lens[count])); - for (i = 0; i < index; i++) { - if (reply->ourp_lens[i] == 0) - return NULL; - - ptr += cfs_size_round(reply->ourp_lens[i]); - } - - if (size != NULL) - *size = reply->ourp_lens[index]; - - return ptr; -} - /* read update result */ struct out_read_reply { __u32 orr_size; @@ -3960,22 +3881,6 @@ struct out_read_reply { char orr_data[0]; }; -static inline void orr_cpu_to_le(struct out_read_reply *orr_dst, - const struct out_read_reply *orr_src) -{ - orr_dst->orr_size = cpu_to_le32(orr_src->orr_size); - orr_dst->orr_padding = cpu_to_le32(orr_src->orr_padding); - orr_dst->orr_offset = cpu_to_le64(orr_dst->orr_offset); -} - -static inline void orr_le_to_cpu(struct out_read_reply *orr_dst, - const struct out_read_reply *orr_src) -{ - orr_dst->orr_size = le32_to_cpu(orr_src->orr_size); - orr_dst->orr_padding = le32_to_cpu(orr_src->orr_padding); - orr_dst->orr_offset = le64_to_cpu(orr_dst->orr_offset); -} - /** layout swap request structure * fid1 and fid2 are in mdt_body */ diff --git a/lustre/include/lustre_update.h b/lustre/include/lustre_update.h index a5cd4a2..bfb8317 100644 --- a/lustre/include/lustre_update.h +++ b/lustre/include/lustre_update.h @@ -30,8 +30,9 @@ #ifndef _LUSTRE_UPDATE_H #define _LUSTRE_UPDATE_H -#include #include +#include +#include #define OUT_UPDATE_INIT_BUFFER_SIZE 4096 #define OUT_UPDATE_REPLY_SIZE 4096 diff --git a/lustre/include/obj_update.h b/lustre/include/obj_update.h new file mode 100644 index 0000000..c381f77 --- /dev/null +++ b/lustre/include/obj_update.h @@ -0,0 +1,115 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2014, Intel Corporation. + * + * Selection of object_update and object_update_param handling functions + */ + +#ifndef _OBJ_UPDATE_H_ +#define _OBJ_UPDATE_H_ + +#include + +static inline size_t +object_update_param_size(const struct object_update_param *param) +{ + return cfs_size_round(sizeof(*param) + param->oup_len); +} + +static inline size_t +object_update_params_size(const struct object_update *update) +{ + const struct object_update_param *param; + size_t total_size = 0; + unsigned int i; + + param = &update->ou_params[0]; + for (i = 0; i < update->ou_params_count; i++) { + size_t size = object_update_param_size(param); + + param = (struct object_update_param *)((char *)param + size); + total_size += size; + } + + return total_size; +} + +static inline size_t +object_update_size(const struct object_update *update) +{ + return offsetof(struct object_update, ou_params[0]) + + object_update_params_size(update); +} + +static inline struct object_update * +object_update_request_get(const struct object_update_request *our, + unsigned int index, size_t *size) +{ + void *ptr; + unsigned int i; + + if (index >= our->ourq_count) + return NULL; + + ptr = (void *)&our->ourq_updates[0]; + for (i = 0; i < index; i++) + ptr += object_update_size(ptr); + + if (size != NULL) + *size = object_update_size(ptr); + + return ptr; +} + + + +static inline struct object_update_result * +object_update_result_get(const struct object_update_reply *reply, + unsigned int index, size_t *size) +{ + __u16 count = reply->ourp_count; + unsigned int i; + void *ptr; + + if (index >= count) + return NULL; + + ptr = (char *)reply + + cfs_size_round(offsetof(struct object_update_reply, + ourp_lens[count])); + for (i = 0; i < index; i++) { + if (reply->ourp_lens[i] == 0) + return NULL; + + ptr += cfs_size_round(reply->ourp_lens[i]); + } + + if (size != NULL) + *size = reply->ourp_lens[index]; + + return ptr; +} +#endif diff --git a/lustre/osp/osp_md_object.c b/lustre/osp/osp_md_object.c index 461df06..2a3c4dd 100644 --- a/lustre/osp/osp_md_object.c +++ b/lustre/osp/osp_md_object.c @@ -1107,6 +1107,16 @@ static ssize_t osp_md_write(const struct lu_env *env, struct dt_object *dt, RETURN(buf->lb_len); } +static inline void orr_le_to_cpu(struct out_read_reply *orr_dst, + const struct out_read_reply *orr_src) +{ + orr_dst->orr_size = le32_to_cpu(orr_src->orr_size); + orr_dst->orr_padding = le32_to_cpu(orr_src->orr_padding); + orr_dst->orr_offset = le64_to_cpu(orr_dst->orr_offset); +} + + + static ssize_t osp_md_read(const struct lu_env *env, struct dt_object *dt, struct lu_buf *rbuf, loff_t *pos) { diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index e520f10..199383c 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -54,6 +54,7 @@ #include #include #include +#include #include "ptlrpc_internal.h" diff --git a/lustre/target/out_handler.c b/lustre/target/out_handler.c index ab902aa..2a3f610 100644 --- a/lustre/target/out_handler.c +++ b/lustre/target/out_handler.c @@ -39,6 +39,14 @@ #include #include "tgt_internal.h" +static inline void orr_cpu_to_le(struct out_read_reply *orr_dst, + const struct out_read_reply *orr_src) +{ + orr_dst->orr_size = cpu_to_le32(orr_src->orr_size); + orr_dst->orr_padding = cpu_to_le32(orr_src->orr_padding); + orr_dst->orr_offset = cpu_to_le64(orr_dst->orr_offset); +} + static void out_reconstruct(const struct lu_env *env, struct dt_device *dt, struct dt_object *obj, struct object_update_reply *reply, -- 1.8.3.1