X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fcmm%2Fcmm_object.c;h=c9301cf9327f8f2eda655c534682910171dbab96;hb=6e3ec5812ebd1b5ecf7cae584f429b013ffe7431;hp=88cf0fd95254560ecf893a43b0b7b8b84a5656f5;hpb=d2d56f38da01001c92a09afc6b52b5acbd9bc13c;p=fs%2Flustre-release.git diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 88cf0fd..c9301cf 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -1,29 +1,43 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * lustre/cmm/cmm_object.c - * Lustre Cluster Metadata Manager (cmm) + * GPL HEADER START * - * Copyright (c) 2006 Cluster File Systems, Inc. - * Author: Mike Pershin + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This file is part of the Lustre file system, http://www.lustre.org - * Lustre is a trademark of Cluster File Systems, Inc. + * 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. * - * You may have signed or agreed to another license before downloading - * this software. If so, you are bound by the terms and conditions - * of that agreement, and the following does not apply to you. See the - * LICENSE file included with this distribution for more information. + * 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). * - * If you did not agree to a different license, then this copy of Lustre - * is open source software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * In either case, Lustre 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 - * license text for more details. + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + * GPL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. + * + * lustre/cmm/cmm_object.c + * + * Lustre Cluster Metadata Manager (cmm) + * + * Author: Mike Pershin */ #ifndef EXPORT_SYMTAB @@ -52,24 +66,24 @@ int cmm_fld_lookup(struct cmm_device *cm, const struct lu_fid *fid, } if (*mds > cm->cmm_tgt_count) { - CERROR("Got invalid mdsno: "LPU64" (max: %u)\n", + CERROR("Got invalid mdsno: %x (max: %x)\n", *mds, cm->cmm_tgt_count); rc = -EINVAL; } else { - CDEBUG(D_INFO, "CMM: got MDS "LPU64" for sequence: " - LPU64"\n", *mds, fid_seq(fid)); + CDEBUG(D_INFO, "CMM: got MDS %x for sequence: " + LPX64"\n", *mds, fid_seq(fid)); } RETURN (rc); } -static struct md_object_operations cml_mo_ops; -static struct md_dir_operations cml_dir_ops; -static struct lu_object_operations cml_obj_ops; +static const struct md_object_operations cml_mo_ops; +static const struct md_dir_operations cml_dir_ops; +static const struct lu_object_operations cml_obj_ops; -static struct md_object_operations cmr_mo_ops; -static struct md_dir_operations cmr_dir_ops; -static struct lu_object_operations cmr_obj_ops; +static const struct md_object_operations cmr_mo_ops; +static const struct md_dir_operations cmr_dir_ops; +static const struct lu_object_operations cmr_obj_ops; struct lu_object *cmm_object_alloc(const struct lu_env *env, const struct lu_object_header *loh, @@ -102,8 +116,8 @@ struct lu_object *cmm_object_alloc(const struct lu_env *env, struct cml_object *clo; OBD_ALLOC_PTR(clo); - if (clo != NULL) { - lo = &clo->cmm_obj.cmo_obj.mo_lu; + if (clo != NULL) { + lo = &clo->cmm_obj.cmo_obj.mo_lu; lu_object_init(lo, NULL, ld); clo->cmm_obj.cmo_obj.mo_ops = &cml_mo_ops; clo->cmm_obj.cmo_obj.mo_dir_ops = &cml_dir_ops; @@ -113,8 +127,8 @@ struct lu_object *cmm_object_alloc(const struct lu_env *env, struct cmr_object *cro; OBD_ALLOC_PTR(cro); - if (cro != NULL) { - lo = &cro->cmm_obj.cmo_obj.mo_lu; + if (cro != NULL) { + lo = &cro->cmm_obj.cmo_obj.mo_lu; lu_object_init(lo, NULL, ld); cro->cmm_obj.cmo_obj.mo_ops = &cmr_mo_ops; cro->cmm_obj.cmo_obj.mo_dir_ops = &cmr_dir_ops; @@ -145,7 +159,8 @@ static void cml_object_free(const struct lu_env *env, OBD_FREE_PTR(clo); } -static int cml_object_init(const struct lu_env *env, struct lu_object *lo) +static int cml_object_init(const struct lu_env *env, struct lu_object *lo, + const struct lu_object_conf *unused) { struct cmm_device *cd = lu2cmm_dev(lo->lo_dev); struct lu_device *c_dev; @@ -180,13 +195,13 @@ static int cml_object_init(const struct lu_env *env, struct lu_object *lo) static int cml_object_print(const struct lu_env *env, void *cookie, lu_printer_t p, const struct lu_object *lo) { - return (*p)(env, cookie, LUSTRE_CMM_NAME"-local@%p", lo); + return (*p)(env, cookie, "[local]"); } -static struct lu_object_operations cml_obj_ops = { - .loo_object_init = cml_object_init, - .loo_object_free = cml_object_free, - .loo_object_print = cml_object_print +static const struct lu_object_operations cml_obj_ops = { + .loo_object_init = cml_object_init, + .loo_object_free = cml_object_free, + .loo_object_print = cml_object_print }; /* CMM local md_object operations */ @@ -258,8 +273,8 @@ static int cml_xattr_list(const struct lu_env *env, struct md_object *mo, } static int cml_xattr_set(const struct lu_env *env, struct md_object *mo, - const struct lu_buf *buf, - const char *name, int fl) + const struct lu_buf *buf, const char *name, + int fl) { int rc; ENTRY; @@ -330,7 +345,36 @@ static int cml_capa_get(const struct lu_env *env, struct md_object *mo, RETURN(rc); } -static struct md_object_operations cml_mo_ops = { +static int cml_path(const struct lu_env *env, struct md_object *mo, + char *path, int pathlen, __u64 *recno, int *linkno) +{ + int rc; + ENTRY; + rc = mo_path(env, md_object_next(mo), path, pathlen, recno, linkno); + RETURN(rc); +} + +static int cml_object_sync(const struct lu_env *env, struct md_object *mo) +{ + int rc; + ENTRY; + rc = mo_object_sync(env, md_object_next(mo)); + RETURN(rc); +} + +static dt_obj_version_t cml_version_get(const struct lu_env *env, + struct md_object *mo) +{ + return mo_version_get(env, md_object_next(mo)); +} + +static void cml_version_set(const struct lu_env *env, struct md_object *mo, + dt_obj_version_t version) +{ + return mo_version_set(env, md_object_next(mo), version); +} + +static const struct md_object_operations cml_mo_ops = { .moo_permission = cml_permission, .moo_attr_get = cml_attr_get, .moo_attr_set = cml_attr_set, @@ -345,7 +389,11 @@ static struct md_object_operations cml_mo_ops = { .moo_close = cml_close, .moo_readpage = cml_readpage, .moo_readlink = cml_readlink, - .moo_capa_get = cml_capa_get + .moo_capa_get = cml_capa_get, + .moo_object_sync = cml_object_sync, + .moo_version_get = cml_version_get, + .moo_version_set = cml_version_set, + .moo_path = cml_path, }; /* md_dir operations */ @@ -413,7 +461,7 @@ static int cml_create(const struct lu_env *env, struct md_object *mo_p, * Try to split @mo_p. If split is ok, -ERESTART is returned and * current thread will not peoceed with create. Instead it sends * -ERESTART to client to let it know that correct MDT should be - * choosen. + * chosen. */ rc = cmm_split_dir(env, mo_p); if (rc) @@ -440,7 +488,9 @@ static int cml_create(const struct lu_env *env, struct md_object *mo_p, spec, ma); EXIT; +#ifdef HAVE_SPLIT_SUPPORT out: +#endif return rc; } @@ -478,30 +528,11 @@ static int cml_unlink(const struct lu_env *env, struct md_object *mo_p, RETURN(rc); } -/* rename is split to local/remote by location of new parent dir */ -struct md_object *md_object_find(const struct lu_env *env, - struct md_device *md, - const struct lu_fid *f) -{ - struct lu_object *o; - struct md_object *m; - ENTRY; - - o = lu_object_find(env, md2lu_dev(md)->ld_site, f); - if (IS_ERR(o)) - m = (struct md_object *)o; - else { - o = lu_object_locate(o->lo_header, md2lu_dev(md)->ld_type); - m = o ? lu2md(o) : NULL; - } - RETURN(m); -} - static int cmm_mode_get(const struct lu_env *env, struct md_device *md, const struct lu_fid *lf, struct md_attr *ma, int *remote) { - struct md_object *mo_s = md_object_find(env, md, lf); + struct md_object *mo_s = md_object_find_slice(env, md, lf); struct cmm_thread_info *cmi; struct md_attr *tmp_ma; int rc; @@ -533,7 +564,7 @@ static int cmm_mode_get(const struct lu_env *env, struct md_device *md, static int cmm_rename_ctime(const struct lu_env *env, struct md_device *md, const struct lu_fid *lf, struct md_attr *ma) { - struct md_object *mo_s = md_object_find(env, md, lf); + struct md_object *mo_s = md_object_find_slice(env, md, lf); int rc; ENTRY; @@ -594,7 +625,7 @@ static int cml_rename(const struct lu_env *env, struct md_object *mo_po, /* XXX: mo_t is remote object and there is RPC to unlink it. * before that, do local sanity check for rename first. */ if (!remote) { - struct md_object *mo_s = md_object_find(env, + struct md_object *mo_s = md_object_find_slice(env, md_obj2dev(mo_po), lf); if (IS_ERR(mo_s)) RETURN(PTR_ERR(mo_s)); @@ -735,7 +766,7 @@ static int cmm_is_subdir(const struct lu_env *env, struct md_object *mo, RETURN(rc); } -static struct md_dir_operations cml_dir_ops = { +static const struct md_dir_operations cml_dir_ops = { .mdo_is_subdir = cmm_is_subdir, .mdo_lookup = cml_lookup, .mdo_lock_mode = cml_lock_mode, @@ -770,14 +801,14 @@ static struct lu_device *cmr_child_dev(struct cmm_device *d, __u32 num) struct lu_device *next = NULL; struct mdc_device *mdc; - spin_lock(&d->cmm_tgt_guard); - list_for_each_entry(mdc, &d->cmm_targets, mc_linkage) { + cfs_spin_lock(&d->cmm_tgt_guard); + cfs_list_for_each_entry(mdc, &d->cmm_targets, mc_linkage) { if (mdc->mc_num == num) { next = mdc2lu_dev(mdc); break; } } - spin_unlock(&d->cmm_tgt_guard); + cfs_spin_unlock(&d->cmm_tgt_guard); return next; } @@ -790,7 +821,8 @@ static void cmr_object_free(const struct lu_env *env, OBD_FREE_PTR(cro); } -static int cmr_object_init(const struct lu_env *env, struct lu_object *lo) +static int cmr_object_init(const struct lu_env *env, struct lu_object *lo, + const struct lu_object_conf *unused) { struct cmm_device *cd = lu2cmm_dev(lo->lo_dev); struct lu_device *c_dev; @@ -819,13 +851,14 @@ static int cmr_object_init(const struct lu_env *env, struct lu_object *lo) static int cmr_object_print(const struct lu_env *env, void *cookie, lu_printer_t p, const struct lu_object *lo) { - return (*p)(env, cookie, LUSTRE_CMM_NAME"-remote@%p", lo); + const struct cmr_object *cro = lu2cmr_obj((struct lu_object *)lo); + return (*p)(env, cookie, "[remote](mds_num=%d)", cro->cmo_num); } -static struct lu_object_operations cmr_obj_ops = { - .loo_object_init = cmr_object_init, - .loo_object_free = cmr_object_free, - .loo_object_print = cmr_object_print +static const struct lu_object_operations cmr_obj_ops = { + .loo_object_init = cmr_object_init, + .loo_object_free = cmr_object_free, + .loo_object_print = cmr_object_print }; /* CMM remote md_object operations. All are invalid */ @@ -875,7 +908,8 @@ static int cmr_xattr_list(const struct lu_env *env, struct md_object *mo, } static int cmr_xattr_set(const struct lu_env *env, struct md_object *mo, - const struct lu_buf *buf, const char *name, int fl) + const struct lu_buf *buf, const char *name, + int fl) { return -EFAULT; } @@ -922,7 +956,32 @@ static int cmr_capa_get(const struct lu_env *env, struct md_object *mo, return -EFAULT; } -static struct md_object_operations cmr_mo_ops = { +static int cmr_path(const struct lu_env *env, struct md_object *obj, + char *path, int pathlen, __u64 *recno, int *linkno) +{ + return -EREMOTE; +} + +static int cmr_object_sync(const struct lu_env *env, struct md_object *mo) +{ + return -EFAULT; +} + +static dt_obj_version_t cmr_version_get(const struct lu_env *env, + struct md_object *mo) +{ + /* Don't check remote object version */ + return 0; +} + +static void cmr_version_set(const struct lu_env *env, struct md_object *mo, + dt_obj_version_t version) +{ + /* No need to update remote object version here, it is done as a part + * of reintegration of partial operation on the remote server */ +} + +static const struct md_object_operations cmr_mo_ops = { .moo_permission = cmr_permission, .moo_attr_get = cmr_attr_get, .moo_attr_set = cmr_attr_set, @@ -937,7 +996,11 @@ static struct md_object_operations cmr_mo_ops = { .moo_close = cmr_close, .moo_readpage = cmr_readpage, .moo_readlink = cmr_readlink, - .moo_capa_get = cmr_capa_get + .moo_capa_get = cmr_capa_get, + .moo_object_sync = cmr_object_sync, + .moo_version_get = cmr_version_get, + .moo_version_set = cmr_version_set, + .moo_path = cmr_path, }; /* remote part of md_dir operations */ @@ -1251,7 +1314,7 @@ static int cmr_rename_tgt(const struct lu_env *env, RETURN(rc); } -static struct md_dir_operations cmr_dir_ops = { +static const struct md_dir_operations cmr_dir_ops = { .mdo_is_subdir = cmm_is_subdir, .mdo_lookup = cmr_lookup, .mdo_lock_mode = cmr_lock_mode, @@ -1259,5 +1322,5 @@ static struct md_dir_operations cmr_dir_ops = { .mdo_link = cmr_link, .mdo_unlink = cmr_unlink, .mdo_rename = cmr_rename, - .mdo_rename_tgt = cmr_rename_tgt, + .mdo_rename_tgt = cmr_rename_tgt };