X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flov%2Flovsub_object.c;h=2cdeca6920839ed631d124b9adad320fb64b8fb4;hb=272c136099bb27550202f0a69d72bc6f344284a4;hp=d1057f3c04b840b37830ddf5ad9a8578cc4b2dbf;hpb=89c4e05eb0791665af814a9bbcadf34506d09d40;p=fs%2Flustre-release.git diff --git a/lustre/lov/lovsub_object.c b/lustre/lov/lovsub_object.c index d1057f3..2cdeca6 100644 --- a/lustre/lov/lovsub_object.c +++ b/lustre/lov/lovsub_object.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,8 +24,10 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2012, 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -66,6 +66,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)); result = 0; } else result = -ENOMEM; @@ -85,9 +86,9 @@ static void lovsub_object_free(const struct lu_env *env, struct lu_object *obj) if (lov) { LASSERT(lov->lo_type == LLT_RAID0); LASSERT(lov->u.raid0.lo_sub[los->lso_index] == los); - cfs_spin_lock(&lov->u.raid0.lo_sub_lock); - lov->u.raid0.lo_sub[los->lso_index] = NULL; - cfs_spin_unlock(&lov->u.raid0.lo_sub_lock); + spin_lock(&lov->u.raid0.lo_sub_lock); + lov->u.raid0.lo_sub[los->lso_index] = NULL; + spin_unlock(&lov->u.raid0.lo_sub_lock); } lu_object_fini(obj); @@ -101,17 +102,17 @@ static int lovsub_object_print(const struct lu_env *env, void *cookie, { struct lovsub_object *los = lu2lovsub(obj); - return (*p)(env, cookie, "[%i]", los->lso_index); + return (*p)(env, cookie, "[%d]", los->lso_index); } -static int lovsub_attr_set(const struct lu_env *env, struct cl_object *obj, - const struct cl_attr *attr, unsigned valid) +static int lovsub_attr_update(const struct lu_env *env, struct cl_object *obj, + const struct cl_attr *attr, unsigned valid) { - struct lov_object *lov = cl2lovsub(obj)->lso_super; + struct lov_object *lov = cl2lovsub(obj)->lso_super; - ENTRY; - lov_r0(lov)->lo_attr_valid = 0; - RETURN(0); + ENTRY; + lov_r0(lov)->lo_attr_valid = 0; + RETURN(0); } static int lovsub_object_glimpse(const struct lu_env *env, @@ -124,13 +125,33 @@ static int lovsub_object_glimpse(const struct lu_env *env, RETURN(cl_object_glimpse(env, &los->lso_super->lo_cl, lvb)); } +/** + * Implementation of struct cl_object_operations::coo_req_attr_set() for lovsub + * layer. Lov and lovsub are responsible only for struct obdo::o_stripe_idx + * field, which is filled there. + */ +static void lovsub_req_attr_set(const struct lu_env *env, struct cl_object *obj, + struct cl_req_attr *attr) +{ + struct lovsub_object *subobj = cl2lovsub(obj); + ENTRY; + cl_req_attr_set(env, &subobj->lso_super->lo_cl, attr); + + /* + * There is no OBD_MD_* flag for obdo::o_stripe_idx, so set it + * unconditionally. It never changes anyway. + */ + attr->cra_oa->o_stripe_idx = subobj->lso_index; + EXIT; +} static const struct cl_object_operations lovsub_ops = { - .coo_page_init = lovsub_page_init, - .coo_lock_init = lovsub_lock_init, - .coo_attr_set = lovsub_attr_set, - .coo_glimpse = lovsub_object_glimpse + .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 }; static const struct lu_object_operations lovsub_lu_obj_ops = { @@ -143,27 +164,27 @@ static const struct lu_object_operations lovsub_lu_obj_ops = { }; struct lu_object *lovsub_object_alloc(const struct lu_env *env, - const struct lu_object_header *unused, - struct lu_device *dev) + const struct lu_object_header *unused, + struct lu_device *dev) { - struct lovsub_object *los; - struct lu_object *obj; - - ENTRY; - OBD_SLAB_ALLOC_PTR_GFP(los, lovsub_object_kmem, CFS_ALLOC_IO); - if (los != NULL) { - struct cl_object_header *hdr; - - obj = lovsub2lu(los); - hdr = &los->lso_header; - cl_object_header_init(hdr); - lu_object_init(obj, &hdr->coh_lu, dev); - lu_object_add_top(&hdr->coh_lu, obj); - los->lso_cl.co_ops = &lovsub_ops; - obj->lo_ops = &lovsub_lu_obj_ops; - } else - obj = NULL; - RETURN(obj); + struct lovsub_object *los; + struct lu_object *obj; + + ENTRY; + OBD_SLAB_ALLOC_PTR_GFP(los, lovsub_object_kmem, GFP_NOFS); + if (los != NULL) { + struct cl_object_header *hdr; + + obj = lovsub2lu(los); + hdr = &los->lso_header; + cl_object_header_init(hdr); + lu_object_init(obj, &hdr->coh_lu, dev); + lu_object_add_top(&hdr->coh_lu, obj); + los->lso_cl.co_ops = &lovsub_ops; + obj->lo_ops = &lovsub_lu_obj_ops; + } else + obj = NULL; + RETURN(obj); } /** @} lov */