From 88c8560727253eb04811cad643a3dcca5a553788 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Tue, 13 Jan 2015 10:06:42 -0600 Subject: [PATCH] LU-5971 llite: rename ccc_req to vvp_req Rename struct ccc_req to struct vvp_req and move related functions from lustre/llite/lcommon_cl.c to the new file lustre/llite/vvp_req.c. Signed-off-by: John L. Hammond Change-Id: I6589cd1e039b41e55fcd833476f6a58ff2492900 Reviewed-on: http://review.whamcloud.com/13377 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin --- lustre/include/cl_object.h | 22 ++++---- lustre/llite/Makefile.in | 2 +- lustre/llite/lcommon_cl.c | 112 ------------------------------------- lustre/llite/vvp_dev.c | 8 ++- lustre/llite/vvp_internal.h | 18 ++---- lustre/llite/vvp_req.c | 132 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 156 insertions(+), 138 deletions(-) create mode 100644 lustre/llite/vvp_req.c diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index 028b4a2..6df788a 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -134,17 +134,17 @@ struct cl_req_slice; * \see vvp_cl_ops, lov_cl_ops, lovsub_cl_ops, osc_cl_ops */ struct cl_device_operations { - /** - * Initialize cl_req. This method is called top-to-bottom on all - * devices in the stack to get them a chance to allocate layer-private - * data, and to attach them to the cl_req by calling - * cl_req_slice_add(). - * - * \see osc_req_init(), lov_req_init(), lovsub_req_init() - * \see ccc_req_init() - */ - int (*cdo_req_init)(const struct lu_env *env, struct cl_device *dev, - struct cl_req *req); + /** + * Initialize cl_req. This method is called top-to-bottom on all + * devices in the stack to get them a chance to allocate layer-private + * data, and to attach them to the cl_req by calling + * cl_req_slice_add(). + * + * \see osc_req_init(), lov_req_init(), lovsub_req_init() + * \see vvp_req_init() + */ + int (*cdo_req_init)(const struct lu_env *env, struct cl_device *dev, + struct cl_req *req); }; /** diff --git a/lustre/llite/Makefile.in b/lustre/llite/Makefile.in index 16a839c..02f104a 100644 --- a/lustre/llite/Makefile.in +++ b/lustre/llite/Makefile.in @@ -7,7 +7,7 @@ lustre-objs += rw26.o super25.o statahead.o lustre-objs += glimpse.o lustre-objs += lcommon_cl.o lustre-objs += lcommon_misc.o -lustre-objs += vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o +lustre-objs += vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o vvp_req.o lustre-objs += range_lock.o llite_lloop-objs := lloop.o diff --git a/lustre/llite/lcommon_cl.c b/lustre/llite/lcommon_cl.c index 79429d7..d4c4daf 100644 --- a/lustre/llite/lcommon_cl.c +++ b/lustre/llite/lcommon_cl.c @@ -60,14 +60,11 @@ #include "llite_internal.h" -static const struct cl_req_operations ccc_req_ops; - /* * ccc_ prefix stands for "Common Client Code". */ static struct kmem_cache *ccc_thread_kmem; -static struct kmem_cache *ccc_req_kmem; static struct lu_kmem_descr ccc_caches[] = { { @@ -76,11 +73,6 @@ static struct lu_kmem_descr ccc_caches[] = { .ckd_size = sizeof (struct ccc_thread_info), }, { - .ckd_cache = &ccc_req_kmem, - .ckd_name = "ccc_req_kmem", - .ckd_size = sizeof (struct ccc_req) - }, - { .ckd_cache = NULL } }; @@ -114,21 +106,6 @@ struct lu_context_key ccc_key = { .lct_fini = ccc_key_fini }; -int ccc_req_init(const struct lu_env *env, struct cl_device *dev, - struct cl_req *req) -{ - struct ccc_req *vrq; - int result; - - OBD_SLAB_ALLOC_PTR_GFP(vrq, ccc_req_kmem, GFP_NOFS); - if (vrq != NULL) { - cl_req_slice_add(req, &vrq->crq_cl, dev, &ccc_req_ops); - result = 0; - } else - result = -ENOMEM; - return result; -} - /** * An `emergency' environment used by ccc_inode_fini() when cl_env_get() * fails. Access to this environment is serialized by ccc_inode_fini_guard @@ -181,84 +158,6 @@ void ccc_global_fini(struct lu_device_type *device_type) lu_kmem_fini(ccc_caches); } -/***************************************************************************** - * - * Transfer operations. - * - */ - -void ccc_req_completion(const struct lu_env *env, - const struct cl_req_slice *slice, int ioret) -{ - struct ccc_req *vrq; - - if (ioret > 0) - cl_stats_tally(slice->crs_dev, slice->crs_req->crq_type, ioret); - - vrq = cl2ccc_req(slice); - OBD_SLAB_FREE_PTR(vrq, ccc_req_kmem); -} - -/** - * Implementation of struct cl_req_operations::cro_attr_set() for ccc - * layer. ccc is responsible for - * - * - o_[mac]time - * - * - o_mode - * - * - o_parent_seq - * - * - o_[ug]id - * - * - o_parent_oid - * - * - o_parent_ver - * - * - o_ioepoch, - * - * and capability. - */ -void ccc_req_attr_set(const struct lu_env *env, - const struct cl_req_slice *slice, - const struct cl_object *obj, - struct cl_req_attr *attr, u64 flags) -{ - struct inode *inode; - struct obdo *oa; - u32 valid_flags; - - oa = attr->cra_oa; - inode = vvp_object_inode(obj); - valid_flags = OBD_MD_FLTYPE; - - if ((flags & OBD_MD_FLOSSCAPA) != 0) { - LASSERT(attr->cra_capa == NULL); - attr->cra_capa = cl_capa_lookup(inode, - slice->crs_req->crq_type); - } - - if (slice->crs_req->crq_type == CRT_WRITE) { - if (flags & OBD_MD_FLEPOCH) { - oa->o_valid |= OBD_MD_FLEPOCH; - oa->o_ioepoch = ll_i2info(inode)->lli_ioepoch; - valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME | - OBD_MD_FLUID | OBD_MD_FLGID; - } - } - obdo_from_inode(oa, inode, valid_flags & flags); - obdo_set_parent_fid(oa, &ll_i2info(inode)->lli_fid); - if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_INVALID_PFID)) - oa->o_parent_oid++; - memcpy(attr->cra_jobid, ll_i2info(inode)->lli_jobid, - LUSTRE_JOBID_SIZE); -} - -static const struct cl_req_operations ccc_req_ops = { - .cro_attr_set = ccc_req_attr_set, - .cro_completion = ccc_req_completion -}; - int cl_setattr_ost(struct inode *inode, const struct iattr *attr, struct obd_capa *capa) { @@ -310,17 +209,6 @@ again: RETURN(result); } -/***************************************************************************** - * - * Type conversions. - * - */ - -struct ccc_req *cl2ccc_req(const struct cl_req_slice *slice) -{ - return container_of0(slice, struct ccc_req, crq_cl); -} - /** * Initialize or update CLIO structures for regular files when new * meta-data arrives from the server. diff --git a/lustre/llite/vvp_dev.c b/lustre/llite/vvp_dev.c index c76e222..60520b3 100644 --- a/lustre/llite/vvp_dev.c +++ b/lustre/llite/vvp_dev.c @@ -59,6 +59,7 @@ struct kmem_cache *vvp_lock_kmem; struct kmem_cache *vvp_object_kmem; +struct kmem_cache *vvp_req_kmem; static struct kmem_cache *vvp_thread_kmem; static struct kmem_cache *vvp_session_kmem; static struct lu_kmem_descr vvp_caches[] = { @@ -72,6 +73,11 @@ static struct lu_kmem_descr vvp_caches[] = { .ckd_name = "vvp_object_kmem", .ckd_size = sizeof(struct vvp_object), }, + { + .ckd_cache = &vvp_req_kmem, + .ckd_name = "vvp_req_kmem", + .ckd_size = sizeof(struct vvp_req), + }, { .ckd_cache = &vvp_thread_kmem, .ckd_name = "vvp_thread_kmem", @@ -144,7 +150,7 @@ static const struct lu_device_operations vvp_lu_ops = { }; static const struct cl_device_operations vvp_cl_ops = { - .cdo_req_init = ccc_req_init + .cdo_req_init = vvp_req_init, }; static struct lu_device *vvp_device_free(const struct lu_env *env, diff --git a/lustre/llite/vvp_internal.h b/lustre/llite/vvp_internal.h index 2de6586..f9396d6 100644 --- a/lustre/llite/vvp_internal.h +++ b/lustre/llite/vvp_internal.h @@ -177,6 +177,7 @@ extern struct lu_context_key vvp_session_key; extern struct kmem_cache *vvp_lock_kmem; extern struct kmem_cache *vvp_object_kmem; +extern struct kmem_cache *vvp_req_kmem; struct ccc_thread_info { struct cl_lock cti_lock; @@ -322,27 +323,18 @@ struct vvp_lock { struct cl_lock_slice vlk_cl; }; -struct ccc_req { - struct cl_req_slice crq_cl; +struct vvp_req { + struct cl_req_slice vrq_cl; }; void *ccc_key_init(const struct lu_context *ctx, struct lu_context_key *key); void ccc_key_fini(const struct lu_context *ctx, struct lu_context_key *key, void *data); -int ccc_req_init(const struct lu_env *env, struct cl_device *dev, - struct cl_req *req); void ccc_umount(const struct lu_env *env, struct cl_device *dev); int ccc_global_init(struct lu_device_type *device_type); void ccc_global_fini(struct lu_device_type *device_type); -void ccc_req_completion(const struct lu_env *env, - const struct cl_req_slice *slice, int ioret); -void ccc_req_attr_set(const struct lu_env *env, - const struct cl_req_slice *slice, - const struct cl_object *obj, - struct cl_req_attr *oa, obd_valid flags); - static inline struct lu_device *vvp2lu_dev(struct vvp_device *vdv) { return &vdv->vdv_cl.cd_lu_dev; @@ -386,8 +378,6 @@ static inline struct vvp_lock *cl2vvp_lock(const struct cl_lock_slice *slice) return container_of(slice, struct vvp_lock, vlk_cl); } -struct ccc_req *cl2ccc_req(const struct cl_req_slice *slice); - int cl_setattr_ost(struct inode *inode, const struct iattr *attr, struct obd_capa *capa); @@ -458,6 +448,8 @@ int vvp_lock_init(const struct lu_env *env, struct cl_object *obj, struct cl_lock *lock, const struct cl_io *io); int vvp_page_init(const struct lu_env *env, struct cl_object *obj, struct cl_page *page, pgoff_t index); +int vvp_req_init(const struct lu_env *env, struct cl_device *dev, + struct cl_req *req); struct lu_object *vvp_object_alloc(const struct lu_env *env, const struct lu_object_header *hdr, struct lu_device *dev); diff --git a/lustre/llite/vvp_req.c b/lustre/llite/vvp_req.c new file mode 100644 index 0000000..262fc4e --- /dev/null +++ b/lustre/llite/vvp_req.c @@ -0,0 +1,132 @@ +/* + * 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2014, Intel Corporation. + */ + +#define DEBUG_SUBSYSTEM S_LLITE + +#include +#include +#include +#include +#include "llite_internal.h" +#include "vvp_internal.h" + +static inline struct vvp_req *cl2vvp_req(const struct cl_req_slice *slice) +{ + return container_of0(slice, struct vvp_req, vrq_cl); +} + +/** + * Implementation of struct cl_req_operations::cro_attr_set() for VVP + * layer. VVP is responsible for + * + * - o_[mac]time + * + * - o_mode + * + * - o_parent_seq + * + * - o_[ug]id + * + * - o_parent_oid + * + * - o_parent_ver + * + * - o_ioepoch, + * + * and capability. + */ +static void vvp_req_attr_set(const struct lu_env *env, + const struct cl_req_slice *slice, + const struct cl_object *obj, + struct cl_req_attr *attr, u64 flags) +{ + struct inode *inode; + struct obdo *oa; + u32 valid_flags; + + oa = attr->cra_oa; + inode = vvp_object_inode(obj); + valid_flags = OBD_MD_FLTYPE; + + if ((flags & OBD_MD_FLOSSCAPA) != 0) { + LASSERT(attr->cra_capa == NULL); + attr->cra_capa = cl_capa_lookup(inode, + slice->crs_req->crq_type); + } + + if (slice->crs_req->crq_type == CRT_WRITE) { + if (flags & OBD_MD_FLEPOCH) { + oa->o_valid |= OBD_MD_FLEPOCH; + oa->o_ioepoch = ll_i2info(inode)->lli_ioepoch; + valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME | + OBD_MD_FLUID | OBD_MD_FLGID; + } + } + + obdo_from_inode(oa, inode, valid_flags & flags); + obdo_set_parent_fid(oa, &ll_i2info(inode)->lli_fid); + if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_INVALID_PFID)) + oa->o_parent_oid++; + + memcpy(attr->cra_jobid, ll_i2info(inode)->lli_jobid, + LUSTRE_JOBID_SIZE); +} + +static void vvp_req_completion(const struct lu_env *env, + const struct cl_req_slice *slice, int ioret) +{ + struct vvp_req *vrq; + + if (ioret > 0) + cl_stats_tally(slice->crs_dev, slice->crs_req->crq_type, ioret); + + vrq = cl2vvp_req(slice); + OBD_SLAB_FREE_PTR(vrq, vvp_req_kmem); +} + +static const struct cl_req_operations vvp_req_ops = { + .cro_attr_set = vvp_req_attr_set, + .cro_completion = vvp_req_completion, +}; + +int vvp_req_init(const struct lu_env *env, struct cl_device *dev, + struct cl_req *req) +{ + struct vvp_req *vrq; + int result; + + OBD_SLAB_ALLOC_PTR_GFP(vrq, vvp_req_kmem, GFP_NOFS); + if (vrq != NULL) { + cl_req_slice_add(req, &vrq->vrq_cl, dev, &vvp_req_ops); + result = 0; + } else { + result = -ENOMEM; + } + + return result; +} -- 1.8.3.1