From f168371f40e1ebcbf380e655888530476e431421 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Fri, 17 Nov 2017 15:20:02 -0600 Subject: [PATCH] LU-10257 clio: remove unused cl_lock layers Remove the struct vvp_lock and struct lovsub_lock, omitting these layers from cl_lock. Adjust cl_lock_enqueue() to allow for empty locks (corresponding to unstriped files). Signed-off-by: John L. Hammond Change-Id: Ib1478d0cfb9604540ffc38eb9b01da4f4f96212a Reviewed-on: https://review.whamcloud.com/30192 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Jinshan Xiong Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/include/cl_object.h | 14 +++----- lustre/llite/Makefile.in | 2 +- lustre/llite/vvp_dev.c | 6 ---- lustre/llite/vvp_internal.h | 12 ------- lustre/llite/vvp_lock.c | 86 -------------------------------------------- lustre/llite/vvp_object.c | 1 - lustre/lov/Makefile.in | 1 - lustre/lov/lov_cl_internal.h | 27 -------------- lustre/lov/lov_dev.c | 6 ---- lustre/lov/lovsub_lock.c | 82 ------------------------------------------ lustre/lov/lovsub_object.c | 4 +-- lustre/obdclass/cl_lock.c | 9 +++-- 12 files changed, 13 insertions(+), 237 deletions(-) delete mode 100644 lustre/llite/vvp_lock.c delete mode 100644 lustre/lov/lovsub_lock.c diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index 14d111b..eaf0fac 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -1073,15 +1073,13 @@ static inline bool __page_in_use(const struct cl_page *page, int refc) * (struct cl_lock) and a list of layers (struct cl_lock_slice), linked to * cl_lock::cll_layers list through cl_lock_slice::cls_linkage. * - * Typical cl_lock consists of the two layers: + * Typical cl_lock consists of one layer: * - * - vvp_lock (vvp specific data), and * - lov_lock (lov specific data). * * lov_lock contains an array of sub-locks. Each of these sub-locks is a * normal cl_lock: it has a header (struct cl_lock) and a list of layers: * - * - lovsub_lock, and * - osc_lock * * Each sub-lock is associated with a cl_object (representing stripe @@ -1201,7 +1199,7 @@ struct cl_lock { /** * Per-layer part of cl_lock * - * \see vvp_lock, lov_lock, lovsub_lock, osc_lock + * \see lov_lock, osc_lock */ struct cl_lock_slice { struct cl_lock *cls_lock; @@ -1215,7 +1213,7 @@ struct cl_lock_slice { /** * - * \see vvp_lock_ops, lov_lock_ops, lovsub_lock_ops, osc_lock_ops + * \see lov_lock_ops, osc_lock_ops */ struct cl_lock_operations { /** @{ */ @@ -1227,8 +1225,7 @@ struct cl_lock_operations { * @anchor for resources * \retval -ve failure * - * \see vvp_lock_enqueue(), lov_lock_enqueue(), lovsub_lock_enqueue(), - * \see osc_lock_enqueue() + * \see lov_lock_enqueue(), osc_lock_enqueue() */ int (*clo_enqueue)(const struct lu_env *env, const struct cl_lock_slice *slice, @@ -1243,8 +1240,7 @@ struct cl_lock_operations { /** * Destructor. Frees resources and the slice. * - * \see vvp_lock_fini(), lov_lock_fini(), lovsub_lock_fini(), - * \see osc_lock_fini() + * \see lov_lock_fini(), osc_lock_fini() */ void (*clo_fini)(const struct lu_env *env, struct cl_lock_slice *slice); /** diff --git a/lustre/llite/Makefile.in b/lustre/llite/Makefile.in index 08ca2c2..a2414bd 100644 --- a/lustre/llite/Makefile.in +++ b/lustre/llite/Makefile.in @@ -8,7 +8,7 @@ lustre-objs += rw26.o super25.o statahead.o xattr_security.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_io.o vvp_object.o lustre-objs += range_lock.o EXTRA_DIST := $(lustre-objs:.o=.c) llite_internal.h rw26.c super25.c diff --git a/lustre/llite/vvp_dev.c b/lustre/llite/vvp_dev.c index 9f193b7..0ceee42 100644 --- a/lustre/llite/vvp_dev.c +++ b/lustre/llite/vvp_dev.c @@ -53,7 +53,6 @@ */ static struct kmem_cache *ll_thread_kmem; -struct kmem_cache *vvp_lock_kmem; struct kmem_cache *vvp_object_kmem; static struct kmem_cache *vvp_session_kmem; static struct kmem_cache *vvp_thread_kmem; @@ -65,11 +64,6 @@ static struct lu_kmem_descr vvp_caches[] = { .ckd_size = sizeof(struct ll_thread_info), }, { - .ckd_cache = &vvp_lock_kmem, - .ckd_name = "vvp_lock_kmem", - .ckd_size = sizeof(struct vvp_lock), - }, - { .ckd_cache = &vvp_object_kmem, .ckd_name = "vvp_object_kmem", .ckd_size = sizeof(struct vvp_object), diff --git a/lustre/llite/vvp_internal.h b/lustre/llite/vvp_internal.h index 058086d..077ec84 100644 --- a/lustre/llite/vvp_internal.h +++ b/lustre/llite/vvp_internal.h @@ -123,7 +123,6 @@ extern struct lu_device_type vvp_device_type; extern struct lu_context_key vvp_session_key; extern struct lu_context_key vvp_thread_key; -extern struct kmem_cache *vvp_lock_kmem; extern struct kmem_cache *vvp_object_kmem; struct vvp_thread_info { @@ -251,10 +250,6 @@ struct vvp_device { struct cl_device *vdv_next; }; -struct vvp_lock { - struct cl_lock_slice vlk_cl; -}; - static inline struct lu_device *vvp2lu_dev(struct vvp_device *vdv) { return &vdv->vdv_cl.cd_lu_dev; @@ -293,11 +288,6 @@ static inline struct page *cl2vm_page(const struct cl_page_slice *slice) return cl2vvp_page(slice)->vpg_page; } -static inline struct vvp_lock *cl2vvp_lock(const struct cl_lock_slice *slice) -{ - return container_of(slice, struct vvp_lock, vlk_cl); -} - #ifdef CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK # define CLOBINVRNT(env, clob, expr) \ do { \ @@ -317,8 +307,6 @@ int lov_read_and_clear_async_rc(struct cl_object *clob); int vvp_io_init(const struct lu_env *env, struct cl_object *obj, struct cl_io *io); int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io); -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); struct lu_object *vvp_object_alloc(const struct lu_env *env, diff --git a/lustre/llite/vvp_lock.c b/lustre/llite/vvp_lock.c deleted file mode 100644 index 651b8e1..0000000 --- a/lustre/llite/vvp_lock.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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) 2014, 2015, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * Implementation of cl_lock for VVP layer. - * - * Author: Nikita Danilov - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include "vvp_internal.h" - -/***************************************************************************** - * - * Vvp lock functions. - * - */ - -static void vvp_lock_fini(const struct lu_env *env, struct cl_lock_slice *slice) -{ - struct vvp_lock *vlk = cl2vvp_lock(slice); - - OBD_SLAB_FREE_PTR(vlk, vvp_lock_kmem); -} - -static int vvp_lock_enqueue(const struct lu_env *env, - const struct cl_lock_slice *slice, - struct cl_io *unused, struct cl_sync_io *anchor) -{ - CLOBINVRNT(env, slice->cls_obj, vvp_object_invariant(slice->cls_obj)); - - return 0; -} - -static const struct cl_lock_operations vvp_lock_ops = { - .clo_fini = vvp_lock_fini, - .clo_enqueue = vvp_lock_enqueue, -}; - -int vvp_lock_init(const struct lu_env *env, struct cl_object *obj, - struct cl_lock *lock, const struct cl_io *unused) -{ - struct vvp_lock *vlk; - int result; - - CLOBINVRNT(env, obj, vvp_object_invariant(obj)); - - OBD_SLAB_ALLOC_PTR_GFP(vlk, vvp_lock_kmem, GFP_NOFS); - if (vlk != NULL) { - cl_lock_slice_add(lock, &vlk->vlk_cl, obj, &vvp_lock_ops); - result = 0; - } else { - result = -ENOMEM; - } - - return result; -} diff --git a/lustre/llite/vvp_object.c b/lustre/llite/vvp_object.c index 6ca4212..b7fb1d3 100644 --- a/lustre/llite/vvp_object.c +++ b/lustre/llite/vvp_object.c @@ -224,7 +224,6 @@ static void vvp_req_attr_set(const struct lu_env *env, struct cl_object *obj, static const struct cl_object_operations vvp_ops = { .coo_page_init = vvp_page_init, - .coo_lock_init = vvp_lock_init, .coo_io_init = vvp_io_init, .coo_attr_get = vvp_attr_get, .coo_attr_update = vvp_attr_update, diff --git a/lustre/lov/Makefile.in b/lustre/lov/Makefile.in index 755aad4..0763571 100644 --- a/lustre/lov/Makefile.in +++ b/lustre/lov/Makefile.in @@ -12,7 +12,6 @@ lov-objs := lov_dev.o \ lov_pool.o \ lov_request.o \ lovsub_dev.o \ - lovsub_lock.o \ lovsub_object.o \ lovsub_page.o \ lproc_lov.o diff --git a/lustre/lov/lov_cl_internal.h b/lustre/lov/lov_cl_internal.h index 56c8bc2..d13cce1 100644 --- a/lustre/lov/lov_cl_internal.h +++ b/lustre/lov/lov_cl_internal.h @@ -81,7 +81,6 @@ struct lovsub_device; struct lovsub_object; -struct lovsub_lock; enum lov_device_flags { LOV_DEV_INITIALIZED = 1 << 0 @@ -457,13 +456,6 @@ struct lovsub_object { }; /** - * Lock state at lovsub layer. - */ -struct lovsub_lock { - struct cl_lock_slice lss_cl; -}; - -/** * Describe the environment settings for sublocks. */ struct lov_sublock_env { @@ -605,7 +597,6 @@ extern struct kmem_cache *lov_object_kmem; extern struct kmem_cache *lov_thread_kmem; extern struct kmem_cache *lov_session_kmem; -extern struct kmem_cache *lovsub_lock_kmem; extern struct kmem_cache *lovsub_object_kmem; int lov_object_init (const struct lu_env *env, struct lu_object *obj, @@ -616,8 +607,6 @@ int lov_lock_init (const struct lu_env *env, struct cl_object *obj, struct cl_lock *lock, const struct cl_io *io); int lov_io_init (const struct lu_env *env, struct cl_object *obj, struct cl_io *io); -int lovsub_lock_init (const struct lu_env *env, struct cl_object *obj, - struct cl_lock *lock, const struct cl_io *io); int lov_lock_init_composite(const struct lu_env *env, struct cl_object *obj, struct cl_lock *lock, const struct cl_io *io); @@ -780,22 +769,6 @@ static inline struct lovsub_object *lu2lovsub(const struct lu_object *obj) return container_of0(obj, struct lovsub_object, lso_cl.co_lu); } -static inline struct lovsub_lock * -cl2lovsub_lock(const struct cl_lock_slice *slice) -{ - LINVRNT(lovsub_is_object(&slice->cls_obj->co_lu)); - return container_of(slice, struct lovsub_lock, lss_cl); -} - -static inline struct lovsub_lock *cl2sub_lock(const struct cl_lock *lock) -{ - const struct cl_lock_slice *slice; - - slice = cl_lock_at(lock, &lovsub_device_type); - LASSERT(slice != NULL); - return cl2lovsub_lock(slice); -} - static inline struct lov_lock *cl2lov_lock(const struct cl_lock_slice *slice) { LINVRNT(lov_is_object(&slice->cls_obj->co_lu)); diff --git a/lustre/lov/lov_dev.c b/lustre/lov/lov_dev.c index bf9dba2..b9c7b0c 100644 --- a/lustre/lov/lov_dev.c +++ b/lustre/lov/lov_dev.c @@ -46,7 +46,6 @@ struct kmem_cache *lov_object_kmem; struct kmem_cache *lov_thread_kmem; struct kmem_cache *lov_session_kmem; -struct kmem_cache *lovsub_lock_kmem; struct kmem_cache *lovsub_object_kmem; struct lu_kmem_descr lov_caches[] = { @@ -71,11 +70,6 @@ struct lu_kmem_descr lov_caches[] = { .ckd_size = sizeof (struct lov_session) }, { - .ckd_cache = &lovsub_lock_kmem, - .ckd_name = "lovsub_lock_kmem", - .ckd_size = sizeof (struct lovsub_lock) - }, - { .ckd_cache = &lovsub_object_kmem, .ckd_name = "lovsub_object_kmem", .ckd_size = sizeof (struct lovsub_object) diff --git a/lustre/lov/lovsub_lock.c b/lustre/lov/lovsub_lock.c deleted file mode 100644 index de8b5c7..0000000 --- a/lustre/lov/lovsub_lock.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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, 2016, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * Implementation of cl_lock for LOVSUB layer. - * - * Author: Nikita Danilov - */ - -#define DEBUG_SUBSYSTEM S_LOV - -#include "lov_cl_internal.h" - -/** \addtogroup lov - * @{ - */ - -/***************************************************************************** - * - * Lovsub lock operations. - * - */ - -static void lovsub_lock_fini(const struct lu_env *env, - struct cl_lock_slice *slice) -{ - struct lovsub_lock *lsl; - - ENTRY; - lsl = cl2lovsub_lock(slice); - OBD_SLAB_FREE_PTR(lsl, lovsub_lock_kmem); - EXIT; -} - -static const struct cl_lock_operations lovsub_lock_ops = { - .clo_fini = lovsub_lock_fini, -}; - -int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, - struct cl_lock *lock, const struct cl_io *io) -{ - struct lovsub_lock *lsk; - int result; - - ENTRY; - OBD_SLAB_ALLOC_PTR_GFP(lsk, lovsub_lock_kmem, GFP_NOFS); - if (lsk != NULL) { - cl_lock_slice_add(lock, &lsk->lss_cl, obj, &lovsub_lock_ops); - result = 0; - } else - result = -ENOMEM; - RETURN(result); -} - -/** @} lov */ diff --git a/lustre/lov/lovsub_object.c b/lustre/lov/lovsub_object.c index 1471de7..47d90e4 100644 --- a/lustre/lov/lovsub_object.c +++ b/lustre/lov/lovsub_object.c @@ -62,7 +62,7 @@ int lovsub_object_init(const struct lu_env *env, struct lu_object *obj, below = under->ld_ops->ldo_object_alloc(env, obj->lo_header, under); if (below != NULL) { lu_object_add(obj, below); - cl_object_page_init(lu2cl(obj), sizeof(struct lovsub_page)); + cl_object_page_init(lu2cl(obj), 0); result = 0; } else result = -ENOMEM; @@ -151,8 +151,6 @@ static void lovsub_req_attr_set(const struct lu_env *env, struct cl_object *obj, } static const struct cl_object_operations lovsub_ops = { - .coo_page_init = lovsub_page_init, - .coo_lock_init = lovsub_lock_init, .coo_attr_update = lovsub_attr_update, .coo_glimpse = lovsub_object_glimpse, .coo_req_attr_set = lovsub_req_attr_set diff --git a/lustre/obdclass/cl_lock.c b/lustre/obdclass/cl_lock.c index 83a3e8f..30c7186 100644 --- a/lustre/obdclass/cl_lock.c +++ b/lustre/obdclass/cl_lock.c @@ -111,7 +111,10 @@ int cl_lock_init(const struct lu_env *env, struct cl_lock *lock, INIT_LIST_HEAD(&lock->cll_layers); list_for_each_entry(scan, &obj->co_lu.lo_header->loh_layers, co_lu.lo_linkage) { - result = scan->co_ops->coo_lock_init(env, scan, lock, io); + if (scan->co_ops->coo_lock_init != NULL) + result = scan->co_ops->coo_lock_init(env, scan, lock, + io); + if (result != 0) { cl_lock_fini(env, lock); break; @@ -167,8 +170,8 @@ EXPORT_SYMBOL(cl_lock_cancel); int cl_lock_enqueue(const struct lu_env *env, struct cl_io *io, struct cl_lock *lock, struct cl_sync_io *anchor) { - const struct cl_lock_slice *slice; - int rc = -ENOSYS; + const struct cl_lock_slice *slice; + int rc = 0; ENTRY; -- 1.8.3.1