it's not used anymore.
Signed-off-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Change-Id: Ie6e94d7a19a38ed57397ff48091597ea02f2ada1
Reviewed-on: http://review.whamcloud.com/4398
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: wangdi <di.wang@intel.com>
subdir-m += obdecho
subdir-m += mgc
-@SERVER_TRUE@subdir-m += mds ost mgs mdt mdd ofd quota osp lod
+@SERVER_TRUE@subdir-m += ost mgs mdt mdd ofd quota osp lod
@CLIENT_TRUE@subdir-m += lov osc mdc lmv llite fld
@LDISKFS_ENABLED_TRUE@subdir-m += osd-ldiskfs
@ZFS_ENABLED_TRUE@subdir-m += osd-zfs
ALWAYS_SUBDIRS = include lvfs obdclass ldlm ptlrpc obdecho \
mgc fid fld doc utils tests scripts autoconf contrib conf
-SERVER_SUBDIRS = ost mds mgs mdt mdd ofd osd-zfs osd-ldiskfs \
+SERVER_SUBDIRS = ost mgs mdt mdd ofd osd-zfs osd-ldiskfs \
quota osp lod target
CLIENT_SUBDIRS = mdc lmv llite lclient lov osc
lustre/mdc/autoMakefile
lustre/lmv/Makefile
lustre/lmv/autoMakefile
-lustre/mds/Makefile
-lustre/mds/autoMakefile
lustre/mdt/Makefile
lustre/mdt/autoMakefile
lustre/mdd/Makefile
EXTRA_DIST = lprocfs_status.h lustre_acl.h lustre_debug.h lustre_lib.h \
lustre_dlm.h lustre_handles.h lustre_net.h obd_class.h obd_support.h \
- lustre_log.h lustre_compat25.h lustre_fsfilt.h lustre_mds.h \
+ lustre_log.h lustre_compat25.h lustre_fsfilt.h \
obd.h lvfs.h lvfs_linux.h lustre_lite.h lustre_quota.h \
lustre_user.h lustre_patchless_compat.h lustre_intent.h lustre_common.h
+++ /dev/null
-/*
- * 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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * 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 (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * Copyright (c) 2012 Whamcloud, Inc.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/include/linux/lustre_mds.h
- *
- * MDS data structures.
- * See also lustre_idl.h for wire formats of requests.
- */
-
-#ifndef _LINUX_LUSTRE_MDS_H
-#define _LINUX_LUSTRE_MDS_H
-
-#ifndef _LUSTRE_MDS_H
-#error Do not #include this file directly. #include <lustre_mds.h> instead
-#endif
-
-#ifdef __KERNEL__
-# include <linux/fs.h>
-# include <linux/dcache.h>
-# ifdef CONFIG_FS_POSIX_ACL
-# include <linux/posix_acl_xattr.h>
-# endif /* CONFIG_FS_POSIX_ACL */
-# include <linux/lustre_intent.h>
-#endif /* __KERNEL__ */
-
-struct mds_obd;
-struct ptlrpc_request;
-struct obd_device;
-struct ll_file_data;
-
-/* mds/handler.c */
-#ifdef __KERNEL__
-struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid,
- struct vfsmount **mnt, int lock_mode,
- struct lustre_handle *lockh,
- __u64 lockpart);
-int mds_update_server_data(struct obd_device *, int force_sync);
-
-/* mds/mds_fs.c */
-int mds_fs_setup(struct obd_device *obddev, struct vfsmount *mnt);
-int mds_fs_cleanup(struct obd_device *obddev);
-#endif
-
-#endif
#include <lustre_dlm.h>
#include <lustre_export.h>
-#if defined(__linux__)
-#include <linux/lustre_mds.h>
-#elif defined(__APPLE__)
-#include <darwin/lustre_mds.h>
-#elif defined(__WINNT__)
-#include <winnt/lustre_mds.h>
-#else
-#error Unsupported operating system.
-#endif
-
struct mds_group_info {
struct obd_uuid *uuid;
int group;
struct lustre_capa_key *capa;
};
-/* mds/mds_lov.c */
-int mds_lov_write_objids(struct obd_device *obd);
-int mds_lov_prepare_objids(struct obd_device *obd, struct lov_mds_md *lmm);
-void mds_lov_update_objids(struct obd_device *obd, struct lov_mds_md *lmm);
-int mds_log_op_unlink(struct obd_device *, struct lov_mds_md *, int,
- struct llog_cookie *, int);
-
-
#define MDD_OBD_NAME "mdd_obd"
#define MDD_OBD_UUID "mdd_obd_uuid"
#define MDD_OBD_TYPE "mds"
};
#define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid)
-struct mds_obd {
- /* NB this field MUST be first */
- struct obd_device_target mds_obt;
- struct ptlrpc_service *mds_service;
- struct ptlrpc_service *mds_setattr_service;
- struct ptlrpc_service *mds_readpage_service;
- int mds_max_mdsize;
- int mds_max_cookiesize;
- __u64 mds_io_epoch;
- unsigned long mds_atime_diff;
- struct ll_fid mds_rootfid;
- cfs_dentry_t *mds_pending_dir;
- cfs_dentry_t *mds_logs_dir;
- cfs_dentry_t *mds_objects_dir;
- struct llog_handle *mds_cfg_llh;
- struct obd_device *mds_lov_obd;
- struct obd_uuid mds_lov_uuid;
- char *mds_profile;
- struct obd_export *mds_lov_exp;
- struct lov_desc mds_lov_desc;
- __u32 mds_id;
-
- /* mark pages dirty for write. */
- cfs_bitmap_t *mds_lov_page_dirty;
- /* array for store pages with obd_id */
- void **mds_lov_page_array;
- /* file for store objid */
- struct file *mds_lov_objid_filp;
- __u32 mds_lov_objid_count;
- __u32 mds_lov_objid_max_index;
- __u32 mds_lov_objid_lastpage;
- __u32 mds_lov_objid_lastidx;
-
-
- cfs_rw_semaphore_t mds_qonoff_sem;
- unsigned long mds_fl_user_xattr:1,
- mds_fl_acl:1,
- mds_evict_ost_nids:1,
- mds_fl_cfglog:1,
- mds_fl_synced:1,
- mds_fl_target:1; /* mds have one or
- * more targets */
-
- struct upcall_cache *mds_identity_cache;
-
- /* for capability keys update */
- struct lustre_capa_key *mds_capa_keys;
- cfs_rw_semaphore_t mds_notify_lock;
-};
-
-/* lov objid */
-extern __u32 mds_max_ost_index;
-
-#define MDS_LOV_ALLOC_SIZE (CFS_PAGE_SIZE)
-
-#define OBJID_PER_PAGE() (MDS_LOV_ALLOC_SIZE / sizeof(obd_id))
-
-#define MDS_LOV_OBJID_PAGES_COUNT (mds_max_ost_index/OBJID_PER_PAGE())
-
-extern int mds_lov_init_objids(struct obd_device *obd);
-extern void mds_lov_destroy_objids(struct obd_device *obd);
-
struct obd_id_info {
__u32 idx;
obd_id *data;
union {
struct obd_device_target obt;
struct filter_obd filter;
- struct mds_obd mds;
struct client_obd cli;
struct ost_obd ost;
struct echo_client_obd echo_client;
/*
* No permission check is needed.
*/
-static int mdd_maxsize_get(const struct lu_env *env, struct md_device *m,
- int *md_size, int *cookie_size)
-{
- struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
- ENTRY;
-
- *md_size = mdd_lov_mdsize(env, mdd);
- *cookie_size = mdd_lov_cookiesize(env, mdd);
-
- RETURN(0);
-}
-
static int mdd_init_capa_ctxt(const struct lu_env *env, struct md_device *m,
int mode, unsigned long timeout, __u32 alg,
struct lustre_capa_key *keys)
{
struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
- struct mds_obd *mds = &mdd2obd_dev(mdd)->u.mds;
int rc;
ENTRY;
/* need barrier for mds_capa_keys access. */
- cfs_down_write(&mds->mds_notify_lock);
- mds->mds_capa_keys = keys;
- cfs_up_write(&mds->mds_notify_lock);
rc = mdd_child_ops(mdd)->dt_init_capa_ctxt(env, mdd->mdd_child, mode,
timeout, alg, keys);
const struct md_device_operations mdd_ops = {
.mdo_statfs = mdd_statfs,
.mdo_root_get = mdd_root_get,
- .mdo_maxsize_get = mdd_maxsize_get,
.mdo_init_capa_ctxt = mdd_init_capa_ctxt,
.mdo_update_capa_key= mdd_update_capa_key,
.mdo_llog_ctxt_get = mdd_llog_ctxt_get,
return lu_object_attr(&obj->mod_obj.mo_lu);
}
-static inline int mdd_lov_mdsize(const struct lu_env *env,
- struct mdd_device *mdd)
-{
- struct obd_device *obd = mdd2obd_dev(mdd);
- return obd->u.mds.mds_max_mdsize;
-}
-
-static inline int mdd_lov_cookiesize(const struct lu_env *env,
- struct mdd_device *mdd)
-{
- struct obd_device *obd = mdd2obd_dev(mdd);
- return obd->u.mds.mds_max_cookiesize;
-}
-
static inline int mdd_is_immutable(struct mdd_object *obj)
{
return obj->mod_flags & IMMUTE_OBJ;
+++ /dev/null
-MODULES := mds
-mds-objs := handler.o lproc_mds.o mds_fs.o mds_log.o mds_lov.o
-
-EXTRA_DIST := $(mds-objs:%.o=%.c) mds_internal.h
-
-@INCLUDE_RULES@
+++ /dev/null
-#
-# 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.sun.com/software/products/lustre/docs/GPLv2.pdf
-#
-# 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 (c) 2001, 2010, Oracle and/or its affiliates. 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.
-#
-
-if MODULES
-modulefs_DATA = mds$(KMODEXT)
-endif
-
-MOSTLYCLEANFILES := @MOSTLYCLEANFILES@
+++ /dev/null
-/*
- * 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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * 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 (c) 2001, 2010, Oracle and/or its affiliates. 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/mds/handler.c
- *
- * Author: Peter Braam <braam@clusterfs.com>
- * Author: Andreas Dilger <adilger@clusterfs.com>
- * Author: Phil Schwan <phil@clusterfs.com>
- * Author: Mike Shaver <shaver@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_MDS
-
-#include <lustre_mds.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/fs.h>
-#include <linux/jbd.h>
-#include <linux/buffer_head.h>
-#include <linux/workqueue.h>
-#include <linux/mount.h>
-
-#include <lustre_acl.h>
-#include <obd_class.h>
-#include <lustre_dlm.h>
-#include <obd_lov.h>
-#include <lustre_fsfilt.h>
-#include <lprocfs_status.h>
-#include <lustre_disk.h>
-#include <lustre_param.h>
-#include <lustre_log.h>
-
-#include "mds_internal.h"
-
-__u32 mds_max_ost_index=0xFFFF;
-CFS_MODULE_PARM(mds_max_ost_index, "i", int, 0444,
- "maximal OST index");
-
-static int mds_lov_presetup (struct mds_obd *mds, struct lustre_cfg *lcfg)
-{
- int rc = 0;
- ENTRY;
-
- if (lcfg->lcfg_bufcount >= 4 && LUSTRE_CFG_BUFLEN(lcfg, 3) > 0) {
- class_uuid_t uuid;
-
- ll_generate_random_uuid(uuid);
- class_uuid_unparse(uuid, &mds->mds_lov_uuid);
-
- OBD_ALLOC(mds->mds_profile, LUSTRE_CFG_BUFLEN(lcfg, 3));
- if (mds->mds_profile == NULL)
- RETURN(-ENOMEM);
-
- strncpy(mds->mds_profile, lustre_cfg_string(lcfg, 3),
- LUSTRE_CFG_BUFLEN(lcfg, 3));
- }
- RETURN(rc);
-}
-
-static int mds_lov_clean(struct obd_device *obd)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct obd_device *osc = mds->mds_lov_obd;
- ENTRY;
-
- if (mds->mds_profile) {
- class_del_profile(mds->mds_profile);
- OBD_FREE(mds->mds_profile, strlen(mds->mds_profile) + 1);
- mds->mds_profile = NULL;
- }
-
- /* There better be a lov */
- if (!osc)
- RETURN(0);
- if (IS_ERR(osc))
- RETURN(PTR_ERR(osc));
-
- obd_register_observer(osc, NULL);
-
- /* Give lov our same shutdown flags */
- osc->obd_force = obd->obd_force;
- osc->obd_fail = obd->obd_fail;
-
- /* Cleanup the lov */
- obd_disconnect(mds->mds_lov_exp);
- class_manual_cleanup(osc);
-
- RETURN(0);
-}
-
-static int mds_postsetup(struct obd_device *obd)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct llog_ctxt *ctxt;
- int rc = 0;
- ENTRY;
-
- rc = llog_setup(NULL, obd, &obd->obd_olg, LLOG_CONFIG_ORIG_CTXT, obd,
- &llog_lvfs_ops);
- if (rc)
- RETURN(rc);
-
- if (mds->mds_profile) {
- struct lustre_profile *lprof;
- /* The profile defines which osc and mdc to connect to, for a
- client. We reuse that here to figure out the name of the
- lov to use (and ignore lprof->lp_md).
- The profile was set in the config log with
- LCFG_MOUNTOPT profilenm oscnm mdcnm */
- lprof = class_get_profile(mds->mds_profile);
- if (lprof == NULL) {
- CERROR("No profile found: %s\n", mds->mds_profile);
- GOTO(err_cleanup, rc = -ENOENT);
- }
- rc = mds_lov_connect(obd, lprof->lp_dt);
- if (rc)
- GOTO(err_cleanup, rc);
- }
-
- RETURN(rc);
-
-err_cleanup:
- mds_lov_clean(obd);
- ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
- if (ctxt)
- llog_cleanup(NULL, ctxt);
- return rc;
-}
-
-int mds_postrecov(struct obd_device *obd)
-{
- int rc = 0;
- ENTRY;
-
- if (obd->obd_fail)
- RETURN(0);
-
- LASSERT(!obd->obd_recovering);
- /* clean PENDING dir */
-#if 0
- if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
- rc = mds_cleanup_pending(obd);
- if (rc < 0)
- GOTO(out, rc);
-#endif
- /* FIXME Does target_finish_recovery really need this to block? */
- /* Notify the LOV, which will in turn call mds_notify for each tgt */
- /* This means that we have to hack obd_notify to think we're obd_set_up
- during mds_lov_connect. */
- obd_notify(obd->u.mds.mds_lov_obd, NULL,
- obd->obd_async_recov ? OBD_NOTIFY_SYNC_NONBLOCK :
- OBD_NOTIFY_SYNC, NULL);
-
- RETURN(rc);
-}
-
-/* We need to be able to stop an mds_lov_synchronize */
-static int mds_lov_early_clean(struct obd_device *obd)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct obd_device *osc = mds->mds_lov_obd;
-
- if (!osc || (!obd->obd_force && !obd->obd_fail))
- return(0);
-
- CDEBUG(D_HA, "abort inflight\n");
- return (obd_precleanup(osc, OBD_CLEANUP_EARLY));
-}
-
-static int mds_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct llog_ctxt *ctxt;
- int rc = 0;
- ENTRY;
-
- switch (stage) {
- case OBD_CLEANUP_EARLY:
- break;
- case OBD_CLEANUP_EXPORTS:
- mds_lov_early_clean(obd);
- cfs_down_write(&mds->mds_notify_lock);
- mds_lov_disconnect(obd);
- mds_lov_clean(obd);
- ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
- if (ctxt)
- llog_cleanup(NULL, ctxt);
- rc = obd_llog_finish(obd, 0);
- mds->mds_lov_exp = NULL;
- cfs_up_write(&mds->mds_notify_lock);
- break;
- }
- RETURN(rc);
-}
-
-/* Look up an entry by inode number. */
-/* this function ONLY returns valid dget'd dentries with an initialized inode
- or errors */
-static struct dentry *mds_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr,
- void *data)
-{
- struct fsfilt_fid fid;
- struct obd_device *obd = (struct obd_device *)data;
-
- if (id == 0)
- RETURN(ERR_PTR(-ESTALE));
-
- fid.ino = id;
- fid.gen = gen;
-
- RETURN(fsfilt_fid2dentry(obd, obd->u.mds.mds_obt.obt_vfsmnt, &fid, 0));
-}
-
-
-struct lvfs_callback_ops mds_lvfs_ops = {
- l_fid2dentry: mds_lvfs_fid2dentry,
-};
-
-static int mds_init_ctxt(struct obd_device *obd, struct vfsmount *mnt)
-{
- struct mds_obd *mds = &obd->u.mds;
- int rc;
-
- mds->mds_obt.obt_vfsmnt = mnt;
- /* why not mnt->mnt_sb instead of mnt->mnt_root->d_inode->i_sb? */
- obd->u.obt.obt_sb = mnt->mnt_root->d_inode->i_sb;
- obd->u.obt.obt_magic = OBT_MAGIC;
- rc = fsfilt_setup(obd, obd->u.obt.obt_sb);
- if (rc)
- return rc;
-
- OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
- obd->obd_lvfs_ctxt.pwdmnt = mnt;
- obd->obd_lvfs_ctxt.pwd = mnt->mnt_root;
- obd->obd_lvfs_ctxt.fs = get_ds();
- obd->obd_lvfs_ctxt.cb_ops = mds_lvfs_ops;
- return 0;
-}
-
-/*mds still need lov setup here*/
-static int mds_cmd_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct lvfs_run_ctxt saved;
- const char *dev;
- struct vfsmount *mnt;
- struct lustre_sb_info *lsi;
- struct lustre_mount_info *lmi;
- struct dentry *dentry;
- int rc = 0;
- ENTRY;
-
- CDEBUG(D_INFO, "obd %s setup \n", obd->obd_name);
- if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
- RETURN(0);
-
- if (lcfg->lcfg_bufcount < 5) {
- CERROR("invalid arg for setup %s\n", MDD_OBD_NAME);
- RETURN(-EINVAL);
- }
- dev = lustre_cfg_string(lcfg, 4);
- lmi = server_get_mount(dev);
- LASSERT(lmi != NULL);
-
- lsi = s2lsi(lmi->lmi_sb);
- mnt = lmi->lmi_mnt;
- /* FIXME: MDD LOV initialize objects.
- * we need only lmi here but not get mount
- * OSD did mount already, so put mount back
- */
- cfs_atomic_dec(&lsi->lsi_mounts);
- cfs_init_rwsem(&mds->mds_notify_lock);
-
- obd->obd_fsops = fsfilt_get_ops(lsi->lsi_fstype);
- rc = mds_init_ctxt(obd, mnt);
- if (rc)
- GOTO(err_putfs, rc);
-
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- dentry = simple_mkdir(cfs_fs_pwd(current->fs), mnt, "OBJECTS", 0777, 1);
- if (IS_ERR(dentry)) {
- rc = PTR_ERR(dentry);
- CERROR("cannot create OBJECTS directory: rc = %d\n", rc);
- GOTO(err_pop, rc);
- }
- mds->mds_objects_dir = dentry;
-
- rc = mds_lov_init_objids(obd);
- if (rc != 0) {
- CERROR("cannot init lov objid rc = %d\n", rc);
- GOTO(err_objects, rc );
- }
-
- rc = mds_lov_presetup(mds, lcfg);
- if (rc < 0)
- GOTO(err_objects, rc);
-
- /* Don't wait for mds_postrecov trying to clear orphans */
- obd->obd_async_recov = 1;
- rc = mds_postsetup(obd);
- /* Bug 11557 - allow async abort_recov start
- FIXME can remove most of this obd_async_recov plumbing
- obd->obd_async_recov = 0;
- */
-
- if (rc)
- GOTO(err_objects, rc);
-
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- RETURN(0);
-
-err_objects:
- dput(mds->mds_objects_dir);
-err_pop:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-err_putfs:
- fsfilt_put_ops(obd->obd_fsops);
- return rc;
-}
-
-static int mds_cmd_cleanup(struct obd_device *obd)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct lvfs_run_ctxt saved;
- int rc = 0;
- ENTRY;
-
- mds->mds_lov_exp = NULL;
-
- if (obd->obd_fail)
- LCONSOLE_WARN("%s: shutting down for failover; client state "
- "will be preserved.\n", obd->obd_name);
-
- if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
- RETURN(0);
-
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
- mds_lov_destroy_objids(obd);
-
- if (mds->mds_objects_dir != NULL) {
- l_dput(mds->mds_objects_dir);
- mds->mds_objects_dir = NULL;
- }
-
- shrink_dcache_sb(mds->mds_obt.obt_sb);
- fsfilt_put_ops(obd->obd_fsops);
-
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- RETURN(rc);
-}
-
-#if 0
-static int mds_cmd_health_check(struct obd_device *obd)
-{
- return 0;
-}
-#endif
-static struct obd_ops mds_cmd_obd_ops = {
- .o_owner = THIS_MODULE,
- .o_setup = mds_cmd_setup,
- .o_cleanup = mds_cmd_cleanup,
- .o_precleanup = mds_precleanup,
- .o_create = mds_obd_create,
- .o_destroy = mds_obd_destroy,
- .o_llog_init = mds_llog_init,
- .o_llog_finish = mds_llog_finish,
- .o_notify = mds_notify,
- .o_postrecov = mds_postrecov,
- // .o_health_check = mds_cmd_health_check,
-};
-
-static int __init mds_cmd_init(void)
-{
- struct lprocfs_static_vars lvars;
-
- lprocfs_mds_init_vars(&lvars);
- class_register_type(&mds_cmd_obd_ops, NULL, lvars.module_vars,
- LUSTRE_MDS_NAME, NULL);
-
- return 0;
-}
-
-static void /*__exit*/ mds_cmd_exit(void)
-{
- class_unregister_type(LUSTRE_MDS_NAME);
-}
-
-MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
-MODULE_DESCRIPTION("Lustre Metadata Server (MDS)");
-MODULE_LICENSE("GPL");
-
-module_init(mds_cmd_init);
-module_exit(mds_cmd_exit);
+++ /dev/null
-/*
- * 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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * 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 (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Whamcloud, Inc.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-#define DEBUG_SUBSYSTEM S_CLASS
-
-#include <linux/version.h>
-#include <asm/statfs.h>
-#include <obd.h>
-#include <obd_class.h>
-#include <lprocfs_status.h>
-#include "mds_internal.h"
-
-#ifdef LPROCFS
-static int lprocfs_mds_rd_evictostnids(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct obd_device* obd = (struct obd_device *)data;
-
- LASSERT(obd != NULL);
-
- return snprintf(page, count, "%d\n", obd->u.mds.mds_evict_ost_nids);
-}
-
-static int lprocfs_mds_wr_evictostnids(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- struct obd_device *obd = data;
- int val, rc;
-
- rc = lprocfs_write_helper(buffer, count, &val);
- if (rc)
- return rc;
-
- obd->u.mds.mds_evict_ost_nids = !!val;
-
- return count;
-}
-
-#define BUFLEN (UUID_MAX + 4)
-
-static int lprocfs_mds_wr_evict_client(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- struct ptlrpc_request_set *set;
- struct obd_device *obd = data;
- struct mds_obd *mds = &obd->u.mds;
- char *kbuf;
- char *tmpbuf;
- int rc;
-
- OBD_ALLOC(kbuf, BUFLEN);
- if (kbuf == NULL)
- return -ENOMEM;
-
- /*
- * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
- * bytes into kbuf, to ensure that the string is NUL-terminated.
- * UUID_MAX should include a trailing NUL already.
- */
- if (cfs_copy_from_user(kbuf, buffer,
- min_t(unsigned long, BUFLEN - 1, count))) {
- count = -EFAULT;
- goto out;
- }
- tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count));
-
- if (strncmp(tmpbuf, "nid:", 4) != 0) {
- count = lprocfs_wr_evict_client(file, buffer, count, data);
- goto out;
- }
-
- set = ptlrpc_prep_set();
- if (set == NULL) {
- count = -ENOMEM;
- goto out;
- }
-
- if (obd->u.mds.mds_evict_ost_nids) {
- rc = obd_set_info_async(NULL, mds->mds_lov_exp,
- sizeof(KEY_EVICT_BY_NID),
- KEY_EVICT_BY_NID, strlen(tmpbuf + 4) + 1,
- tmpbuf + 4, set);
- if (rc)
- CERROR("Failed to evict nid %s from OSTs: rc %d\n",
- tmpbuf + 4, rc);
-
- ptlrpc_check_set(NULL, set);
- }
-
- /* See the comments in function lprocfs_wr_evict_client()
- * in ptlrpc/lproc_ptlrpc.c for details. - jay */
- class_incref(obd, __FUNCTION__, cfs_current());
- LPROCFS_EXIT();
-
- obd_export_evict_by_nid(obd, tmpbuf + 4);
-
-
- rc = ptlrpc_set_wait(set);
- if (rc)
- CERROR("Failed to evict nid %s from OSTs: rc %d\n", tmpbuf + 4,
- rc);
-
- LPROCFS_ENTRY();
- class_decref(obd, __FUNCTION__, cfs_current());
-
- ptlrpc_set_destroy(set);
-out:
- OBD_FREE(kbuf, BUFLEN);
- return count;
-}
-
-#undef BUFLEN
-
-static int lprocfs_wr_atime_diff(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- struct obd_device *obd = data;
- struct mds_obd *mds = &obd->u.mds;
- char kernbuf[20], *end;
- unsigned long diff = 0;
-
- if (count > (sizeof(kernbuf) - 1))
- return -EINVAL;
-
- if (cfs_copy_from_user(kernbuf, buffer, count))
- return -EFAULT;
-
- kernbuf[count] = '\0';
-
- diff = simple_strtoul(kernbuf, &end, 0);
- if (kernbuf == end)
- return -EINVAL;
-
- mds->mds_atime_diff = diff;
- return count;
-}
-
-static int lprocfs_rd_atime_diff(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct obd_device *obd = data;
- struct mds_obd *mds = &obd->u.mds;
-
- *eof = 1;
- return snprintf(page, count, "%lu\n", mds->mds_atime_diff);
-}
-
-struct lprocfs_vars lprocfs_mds_obd_vars[] = {
- { "uuid", lprocfs_rd_uuid, 0, 0 },
- { "blocksize", lprocfs_rd_blksize, 0, 0 },
- { "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
- { "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
- { "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 },
- { "filestotal", lprocfs_rd_filestotal, 0, 0 },
- { "filesfree", lprocfs_rd_filesfree, 0, 0 },
- { "fstype", lprocfs_rd_fstype, 0, 0 },
- { "mntdev", lprocfs_obd_rd_mntdev, 0, 0 },
- { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },
- { "hash_stats", lprocfs_obd_rd_hash, 0, 0 },
- { "evict_client", 0, lprocfs_mds_wr_evict_client, 0 },
- { "evict_ost_nids", lprocfs_mds_rd_evictostnids,
- lprocfs_mds_wr_evictostnids, 0 },
- { "num_exports", lprocfs_rd_num_exports, 0, 0 },
- { "atime_diff", lprocfs_rd_atime_diff, lprocfs_wr_atime_diff, 0 },
- { 0 }
-};
-
-struct lprocfs_vars lprocfs_mds_module_vars[] = {
- { "num_refs", lprocfs_rd_numrefs, 0, 0 },
- { 0 }
-};
-
-struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
- { "uuid", lprocfs_rd_uuid, 0, 0 },
- { 0 }
-};
-
-void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars)
-{
- lvars->module_vars = lprocfs_mds_module_vars;
- lvars->obd_vars = lprocfs_mds_obd_vars;
-}
-
-#endif
+++ /dev/null
-/*
- * 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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * 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 (c) 2002, 2010, Oracle and/or its affiliates. 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/mds/mds_fs.c
- *
- * Lustre Metadata Server (MDS) filesystem interface code
- *
- * Author: Andreas Dilger <adilger@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_MDS
-
-#include <linux/module.h>
-#include <linux/kmod.h>
-#include <linux/version.h>
-#include <linux/sched.h>
-#include <linux/mount.h>
-#include <lustre_mds.h>
-#include <obd_class.h>
-#include <obd_support.h>
-#include <lustre_lib.h>
-#include <lustre_fsfilt.h>
-#include <lustre_disk.h>
-#include <libcfs/list.h>
-
-#include "mds_internal.h"
-
-
-/* Creates an object with the same name as its fid. Because this is not at all
- * performance sensitive, it is accomplished by creating a file, checking the
- * fid, and renaming it. */
-int mds_obd_create(const struct lu_env *env, struct obd_export *exp,
- struct obdo *oa, struct lov_stripe_md **ea,
- struct obd_trans_info *oti)
-{
- struct mds_obd *mds = &exp->exp_obd->u.mds;
- struct inode *parent_inode = mds->mds_objects_dir->d_inode;
- unsigned int tmpname = cfs_rand();
- struct file *filp;
- struct dentry *new_child;
- struct lvfs_run_ctxt saved;
- char fidname[LL_FID_NAMELEN];
- void *handle;
- struct lvfs_ucred ucred = { 0 };
- int rc = 0, err, namelen;
- ENTRY;
-
- /* the owner of object file should always be root */
- cap_raise(ucred.luc_cap, CAP_SYS_RESOURCE);
-
- if (strncmp(exp->exp_obd->obd_name, MDD_OBD_NAME,
- strlen(MDD_OBD_NAME))) {
- RETURN(0);
- }
-
- push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, &ucred);
-
- sprintf(fidname, "OBJECTS/%u.%u", tmpname, current->pid);
- filp = filp_open(fidname, O_CREAT | O_EXCL, 0666);
- if (IS_ERR(filp)) {
- rc = PTR_ERR(filp);
- if (rc == -EEXIST) {
- CERROR("impossible object name collision %u\n",
- tmpname);
- LBUG();
- }
- CERROR("error creating tmp object %u: rc %d\n", tmpname, rc);
- GOTO(out_pop, rc);
- }
-
- LASSERT(mds->mds_objects_dir == filp->f_dentry->d_parent);
-
- /* FIXME: need to see how this should change to properly store FID
- * into obdo (o_id == OID, o_seq = SEQ) (maybe as IGIF?). */
-#define o_generation o_parent_oid
- oa->o_id = filp->f_dentry->d_inode->i_ino;
- oa->o_generation = filp->f_dentry->d_inode->i_generation;
- namelen = ll_fid2str(fidname, oa->o_id, oa->o_generation);
-
- mutex_lock_nested(&parent_inode->i_mutex, I_MUTEX_PARENT);
- new_child = lookup_one_len(fidname, mds->mds_objects_dir, namelen);
-
- if (IS_ERR(new_child)) {
- CERROR("getting neg dentry for obj rename: %d\n", rc);
- GOTO(out_close, rc = PTR_ERR(new_child));
- }
- if (new_child->d_inode != NULL) {
- CERROR("impossible non-negative obj dentry " LPU64":%u!\n",
- oa->o_id, oa->o_generation);
- LBUG();
- }
-
- handle = fsfilt_start(exp->exp_obd, mds->mds_objects_dir->d_inode,
- FSFILT_OP_RENAME, NULL);
- if (IS_ERR(handle))
- GOTO(out_dput, rc = PTR_ERR(handle));
-
- rc = ll_vfs_rename(mds->mds_objects_dir->d_inode, filp->f_dentry,
- filp->f_vfsmnt, mds->mds_objects_dir->d_inode,
- new_child, filp->f_vfsmnt);
-
- if (rc)
- CERROR("error renaming new object "LPU64":%u: rc %d\n",
- oa->o_id, oa->o_generation, rc);
-
- err = fsfilt_commit(exp->exp_obd, mds->mds_objects_dir->d_inode,
- handle, 0);
- if (!err) {
- oa->o_seq = mdt_to_obd_objseq(mds->mds_id);
- oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGENER | OBD_MD_FLGROUP;
- } else if (!rc)
- rc = err;
-out_dput:
- dput(new_child);
-out_close:
- mutex_unlock(&parent_inode->i_mutex);
- err = filp_close(filp, 0);
- if (err) {
- CERROR("closing tmpfile %u: rc %d\n", tmpname, rc);
- if (!rc)
- rc = err;
- }
-out_pop:
- pop_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, &ucred);
- RETURN(rc);
-}
-
-int mds_obd_destroy(const struct lu_env *env, struct obd_export *exp,
- struct obdo *oa, struct lov_stripe_md *ea,
- struct obd_trans_info *oti, struct obd_export *md_exp,
- void *capa)
-{
- struct mds_obd *mds = &exp->exp_obd->u.mds;
- struct inode *parent_inode = mds->mds_objects_dir->d_inode;
- struct obd_device *obd = exp->exp_obd;
- struct lvfs_run_ctxt saved;
- struct lvfs_ucred ucred = { 0 };
- char fidname[LL_FID_NAMELEN];
- struct inode *inode = NULL;
- struct dentry *de;
- void *handle;
- int err, namelen, rc = 0;
- ENTRY;
-
- cap_raise(ucred.luc_cap, CAP_SYS_RESOURCE);
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, &ucred);
-
- namelen = ll_fid2str(fidname, oa->o_id, oa->o_generation);
-
- mutex_lock_nested(&parent_inode->i_mutex, I_MUTEX_PARENT);
- de = lookup_one_len(fidname, mds->mds_objects_dir, namelen);
- if (IS_ERR(de)) {
- rc = IS_ERR(de);
- de = NULL;
- CERROR("error looking up object "LPU64" %s: rc %d\n",
- oa->o_id, fidname, rc);
- GOTO(out_dput, rc);
- }
- if (de->d_inode == NULL) {
- CERROR("destroying non-existent object "LPU64" %s: rc %d\n",
- oa->o_id, fidname, rc);
- GOTO(out_dput, rc = -ENOENT);
- }
-
- /* Stripe count is 1 here since this is some MDS specific stuff
- that is unlinked, not spanned across multiple OSTs */
- handle = fsfilt_start_log(obd, mds->mds_objects_dir->d_inode,
- FSFILT_OP_UNLINK, oti, 1);
-
- if (IS_ERR(handle))
- GOTO(out_dput, rc = PTR_ERR(handle));
-
- /* take a reference to protect inode from truncation within
- vfs_unlink() context. bug 10409 */
- inode = de->d_inode;
- atomic_inc(&inode->i_count);
- rc = ll_vfs_unlink(mds->mds_objects_dir->d_inode, de,
- mds->mds_obt.obt_vfsmnt);
- if (rc)
- CERROR("error destroying object "LPU64":%u: rc %d\n",
- oa->o_id, oa->o_generation, rc);
-#undef o_generation
-
- err = fsfilt_commit(obd, mds->mds_objects_dir->d_inode, handle, 0);
- if (err && !rc)
- rc = err;
-out_dput:
- if (de != NULL)
- l_dput(de);
- mutex_unlock(&parent_inode->i_mutex);
-
- if (inode)
- iput(inode);
-
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, &ucred);
- RETURN(rc);
-}
+++ /dev/null
-/*
- * 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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * 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 (c) 2003, 2010, Oracle and/or its affiliates. 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.
- */
-
-#ifndef _MDS_INTERNAL_H
-#define _MDS_INTERNAL_H
-
-#include <lustre_disk.h>
-#include <lustre_mds.h>
-
-int mds_cleanup_pending(struct obd_device *obd);
-
-
-/* mds/mds_log.c */
-int mds_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
- struct obd_device *tgt, int *index);
-int mds_llog_finish(struct obd_device *obd, int count);
-int mds_changelog_llog_init(struct obd_device *obd, struct obd_device *tgt);
-int mds_log_op_orphan(struct obd_device *, struct lov_stripe_md *, obd_count);
-
-/* mds/mds_lov.c */
-int mds_lov_connect(struct obd_device *obd, char * lov_name);
-int mds_lov_disconnect(struct obd_device *obd);
-
-int mds_lov_clear_orphans(struct mds_obd *mds, struct obd_uuid *ost_uuid);
-void mds_lov_update_objids(struct obd_device *obd, struct lov_mds_md *lmm);
-int mds_lov_set_nextid(struct obd_device *obd);
-
-int mds_post_mds_lovconf(struct obd_device *obd);
-int mds_notify(struct obd_device *obd, struct obd_device *watched,
- enum obd_notify_event ev, void *data);
-int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode,
- struct lov_mds_md *lmm, int lmm_size,
- __u64 connect_flags);
-int mds_init_lov_desc(struct obd_device *obd, struct obd_export *osc_exp);
-
-int mds_obd_create(const struct lu_env *env, struct obd_export *exp,
- struct obdo *oa, struct lov_stripe_md **ea,
- struct obd_trans_info *oti);
-int mds_obd_destroy(const struct lu_env *env, struct obd_export *exp,
- struct obdo *oa, struct lov_stripe_md *ea,
- struct obd_trans_info *oti,
- struct obd_export *md_exp, void *capa);
-
-/* mds/handler.c */
-extern struct lvfs_callback_ops mds_lvfs_ops;
-
-/* mds/lproc_mds.c */
-void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars);
-#endif /* _MDS_INTERNAL_H */
+++ /dev/null
-/*
- * 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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * 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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Whamcloud, Inc.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/mds/mds_log.c
- *
- * Author: Peter Braam <braam@clusterfs.com>
- * Author: Andreas Dilger <adilger@clusterfs.com>
- * Author: Phil Schwan <phil@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_MDS
-
-#include <linux/module.h>
-#include <linux/version.h>
-
-#include <libcfs/list.h>
-#include <obd_class.h>
-#include <lustre_fsfilt.h>
-#include <lustre_mds.h>
-#include <lustre_log.h>
-
-#include "mds_internal.h"
-
-static int mds_llog_origin_add(const struct lu_env *env,
- struct llog_ctxt *ctxt,
- struct llog_rec_hdr *rec,
- struct lov_stripe_md *lsm,
- struct llog_cookie *logcookies, int numcookies)
-{
- struct obd_device *obd = ctxt->loc_obd;
- struct obd_device *lov_obd = obd->u.mds.mds_lov_obd;
- struct llog_ctxt *lctxt;
- int rc;
- ENTRY;
-
- lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
- rc = llog_obd_add(env, lctxt, rec, lsm, logcookies, numcookies);
- llog_ctxt_put(lctxt);
-
- RETURN(rc);
-}
-
-static int mds_llog_origin_connect(struct llog_ctxt *ctxt,
- struct llog_logid *logid,
- struct llog_gen *gen,
- struct obd_uuid *uuid)
-{
- struct obd_device *obd = ctxt->loc_obd;
- struct obd_device *lov_obd = obd->u.mds.mds_lov_obd;
- struct llog_ctxt *lctxt;
- int rc;
- ENTRY;
-
- lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
- rc = llog_connect(lctxt, logid, gen, uuid);
- llog_ctxt_put(lctxt);
- RETURN(rc);
-}
-
-static struct llog_operations mds_ost_orig_logops = {
- .lop_obd_add = mds_llog_origin_add,
- .lop_connect = mds_llog_origin_connect,
-};
-
-static int mds_llog_repl_cancel(const struct lu_env *env,
- struct llog_ctxt *ctxt,
- struct lov_stripe_md *lsm,
- int count, struct llog_cookie *cookies,
- int flags)
-{
- struct obd_device *obd = ctxt->loc_obd;
- struct obd_device *lov_obd = obd->u.mds.mds_lov_obd;
- struct llog_ctxt *lctxt;
- int rc;
- ENTRY;
-
- lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
- rc = llog_cancel(env, lctxt, lsm, count, cookies, flags);
- llog_ctxt_put(lctxt);
- RETURN(rc);
-}
-
-static struct llog_operations mds_size_repl_logops = {
- lop_cancel: mds_llog_repl_cancel,
-};
-
-int mds_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
- struct obd_device *disk_obd, int *index)
-{
- struct obd_device *lov_obd = obd->u.mds.mds_lov_obd;
- struct llog_ctxt *ctxt;
- int rc;
- ENTRY;
-
- LASSERT(olg == &obd->obd_olg);
- rc = llog_setup(NULL, obd, &obd->obd_olg, LLOG_MDS_OST_ORIG_CTXT,
- disk_obd, &mds_ost_orig_logops);
- if (rc)
- RETURN(rc);
-
- rc = llog_setup(NULL, obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT,
- disk_obd, &mds_size_repl_logops);
- if (rc)
- GOTO(err_llog, rc);
-
- rc = obd_llog_init(lov_obd, &lov_obd->obd_olg, disk_obd, index);
- if (rc) {
- CERROR("lov_llog_init err %d\n", rc);
- GOTO(err_cleanup, rc);
- }
-
- RETURN(rc);
-err_cleanup:
- ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
- if (ctxt)
- llog_cleanup(NULL, ctxt);
-err_llog:
- ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
- if (ctxt)
- llog_cleanup(NULL, ctxt);
- return rc;
-}
-
-int mds_llog_finish(struct obd_device *obd, int count)
-{
- struct llog_ctxt *ctxt;
-
- ENTRY;
-
- ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
- if (ctxt)
- llog_cleanup(NULL, ctxt);
-
- ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
- if (ctxt)
- llog_cleanup(NULL, ctxt);
-
- RETURN(0);
-}
-
-static int mds_llog_add_unlink(struct obd_device *obd,
- struct lov_stripe_md *lsm, obd_count count,
- struct llog_cookie *logcookie, int cookies)
-{
- struct llog_unlink_rec *lur;
- struct llog_ctxt *ctxt;
- int rc;
-
- if (cookies < lsm->lsm_stripe_count)
- RETURN(rc = -EFBIG);
-
- /* first prepare unlink log record */
- OBD_ALLOC_PTR(lur);
- if (!lur)
- RETURN(rc = -ENOMEM);
- lur->lur_hdr.lrh_len = lur->lur_tail.lrt_len = sizeof(*lur);
- lur->lur_hdr.lrh_type = MDS_UNLINK_REC;
- lur->lur_count = count;
-
- ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
- rc = llog_obd_add(NULL, ctxt, &lur->lur_hdr, lsm, logcookie, cookies);
- llog_ctxt_put(ctxt);
-
- OBD_FREE_PTR(lur);
- RETURN(rc);
-}
-
-int mds_log_op_unlink(struct obd_device *obd,
- struct lov_mds_md *lmm, int lmm_size,
- struct llog_cookie *logcookies, int cookies_size)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct lov_stripe_md *lsm = NULL;
- int rc;
- ENTRY;
-
- if (IS_ERR(mds->mds_lov_obd))
- RETURN(PTR_ERR(mds->mds_lov_obd));
-
- rc = obd_unpackmd(mds->mds_lov_exp, &lsm, lmm, lmm_size);
- if (rc < 0)
- RETURN(rc);
- rc = mds_llog_add_unlink(obd, lsm, 0, logcookies,
- cookies_size / sizeof(struct llog_cookie));
- obd_free_memmd(mds->mds_lov_exp, &lsm);
- RETURN(rc);
-}
-EXPORT_SYMBOL(mds_log_op_unlink);
-
-int mds_log_op_orphan(struct obd_device *obd, struct lov_stripe_md *lsm,
- obd_count count)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct llog_cookie logcookie;
- int rc;
- ENTRY;
-
- if (IS_ERR(mds->mds_lov_obd))
- RETURN(PTR_ERR(mds->mds_lov_obd));
-
- rc = mds_llog_add_unlink(obd, lsm, count - 1, &logcookie, 1);
- RETURN(rc);
-}
-
+++ /dev/null
-/*
- * 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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * 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 (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/mds/mds_lov.c
- *
- * Lustre Metadata Server (mds) handling of striped file data
- *
- * Author: Peter Braam <braam@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_MDS
-
-#include <linux/module.h>
-#include <lustre_mds.h>
-#include <lustre/lustre_idl.h>
-#include <obd_class.h>
-#include <obd_lov.h>
-#include <lustre_lib.h>
-#include <lustre_fsfilt.h>
-#include <obd_cksum.h>
-#include <lustre_log.h>
-
-#include "mds_internal.h"
-
-static void mds_lov_dump_objids(const char *label, struct obd_device *obd)
-{
- struct mds_obd *mds = &obd->u.mds;
- unsigned int i=0, j;
-
- if ((libcfs_debug & D_INFO) == 0)
- return;
-
- CDEBUG(D_INFO, "dump from %s\n", label);
- if (mds->mds_lov_page_dirty == NULL) {
- CERROR("NULL bitmap!\n");
- GOTO(skip_bitmap, i);
- }
-
- for(i = 0; i < mds->mds_lov_page_dirty->size / BITS_PER_LONG + 1; i++)
- CDEBUG(D_INFO, "%u - %lx\n", i,
- mds->mds_lov_page_dirty->data[i]);
-skip_bitmap:
- if (mds->mds_lov_page_array == NULL) {
- CERROR("not init page array!\n");
- GOTO(skip_array, i);
-
- }
- for(i = 0;i < MDS_LOV_OBJID_PAGES_COUNT; i++) {
- obd_id *data = mds->mds_lov_page_array[i];
-
- if (data == NULL)
- continue;
-
- for(j=0; j < OBJID_PER_PAGE(); j++) {
- if (data[j] == 0)
- continue;
- CDEBUG(D_INFO,"objid page %u idx %u - "LPU64" \n",
- i, j, data[j]);
- }
- }
-skip_array:
- EXIT;
-}
-
-int mds_lov_init_objids(struct obd_device *obd)
-{
- struct mds_obd *mds = &obd->u.mds;
- int size = MDS_LOV_OBJID_PAGES_COUNT*sizeof(void *);
- struct file *file;
- int rc;
- ENTRY;
-
- CLASSERT(((MDS_LOV_ALLOC_SIZE % sizeof(obd_id)) == 0));
-
- mds->mds_lov_page_dirty =
- CFS_ALLOCATE_BITMAP(MDS_LOV_OBJID_PAGES_COUNT);
- if (mds->mds_lov_page_dirty == NULL)
- RETURN(-ENOMEM);
-
-
- OBD_ALLOC(mds->mds_lov_page_array, size);
- if (mds->mds_lov_page_array == NULL)
- GOTO(err_free_bitmap, rc = -ENOMEM);
-
- /* open and test the lov objd file */
- file = filp_open(LOV_OBJID, O_RDWR | O_CREAT, 0644);
- if (IS_ERR(file)) {
- rc = PTR_ERR(file);
- CERROR("cannot open/create %s file: rc = %d\n", LOV_OBJID, rc);
- GOTO(err_free, rc = PTR_ERR(file));
- }
- if (!S_ISREG(file->f_dentry->d_inode->i_mode)) {
- CERROR("%s is not a regular file!: mode = %o\n", LOV_OBJID,
- file->f_dentry->d_inode->i_mode);
- GOTO(err_open, rc = -ENOENT);
- }
- mds->mds_lov_objid_filp = file;
-
- RETURN (0);
-err_open:
- if (filp_close((struct file *)file, 0))
- CERROR("can't close %s after error\n", LOV_OBJID);
-err_free:
- OBD_FREE(mds->mds_lov_page_array, size);
-err_free_bitmap:
- CFS_FREE_BITMAP(mds->mds_lov_page_dirty);
-
- RETURN(rc);
-}
-
-void mds_lov_destroy_objids(struct obd_device *obd)
-{
- struct mds_obd *mds = &obd->u.mds;
- int i, rc;
- ENTRY;
-
- if (mds->mds_lov_page_array != NULL) {
- for(i=0;i<MDS_LOV_OBJID_PAGES_COUNT;i++) {
- obd_id *data = mds->mds_lov_page_array[i];
- if (data != NULL)
- OBD_FREE(data, MDS_LOV_ALLOC_SIZE);
- }
- OBD_FREE(mds->mds_lov_page_array,
- MDS_LOV_OBJID_PAGES_COUNT*sizeof(void *));
- }
-
- if (mds->mds_lov_objid_filp) {
- rc = filp_close((struct file *)mds->mds_lov_objid_filp, NULL);
- mds->mds_lov_objid_filp = NULL;
- if (rc)
- CERROR("%s file won't close, rc=%d\n", LOV_OBJID, rc);
- }
-
- CFS_FREE_BITMAP(mds->mds_lov_page_dirty);
- EXIT;
-}
-
-/**
- * currently exist two ways for know about ost count and max ost index.
- * first - after ost is connected to mds and sync process finished
- * second - get from lmm in recovery process, in case when mds not have configs,
- * and ost isn't registered in mgs.
- *
- * \param mds pointer to mds structure
- * \param index maxium ost index
- *
- * \retval -ENOMEM is not hame memory for new page
- * \retval 0 is update passed
- */
-static int mds_lov_update_max_ost(struct mds_obd *mds, obd_id index)
-{
- __u32 page = index / OBJID_PER_PAGE();
- __u32 off = index % OBJID_PER_PAGE();
- obd_id *data = mds->mds_lov_page_array[page];
-
- if (data == NULL) {
- OBD_ALLOC(data, MDS_LOV_ALLOC_SIZE);
- if (data == NULL)
- RETURN(-ENOMEM);
-
- mds->mds_lov_page_array[page] = data;
- }
-
- if (index > mds->mds_lov_objid_max_index) {
- mds->mds_lov_objid_lastpage = page;
- mds->mds_lov_objid_lastidx = off;
- mds->mds_lov_objid_max_index = index;
- }
-
- /* workaround - New target not in objids file; increase mdsize */
- /* ld_tgt_count is used as the max index everywhere, despite its name. */
- if (data[off] == 0) {
- __u32 max_easize;
- __u32 stripes;
-
- max_easize = mds->mds_obt.obt_osd_properties.osd_max_ea_size;
- data[off] = 1;
- mds->mds_lov_objid_count++;
- stripes = min(lov_mds_md_stripecnt(max_easize, LOV_MAGIC_V3),
- mds->mds_lov_objid_count);
-
- mds->mds_max_mdsize = lov_mds_md_size(stripes, LOV_MAGIC_V3);
- mds->mds_max_cookiesize = stripes * sizeof(struct llog_cookie);
-
- CDEBUG(D_CONFIG, "updated max_mdsize/max_cookiesize for %d"
- " stripes: %d/%d\n", stripes, mds->mds_max_mdsize,
- mds->mds_max_cookiesize);
- }
-
- EXIT;
- return 0;
-}
-
-static int mds_lov_objinit(struct mds_obd *mds, __u32 index)
-{
- __u32 page = index / OBJID_PER_PAGE();
- __u32 off = index % OBJID_PER_PAGE();
- obd_id *data = mds->mds_lov_page_array[page];
-
- return (data[off] > 0);
-}
-
-int mds_lov_prepare_objids(struct obd_device *obd, struct lov_mds_md *lmm)
-{
- struct lov_ost_data_v1 *data;
- __u16 count;
- int rc = 0;
- __u32 j;
-
- /* if we create file without objects - lmm is NULL */
- if (lmm == NULL)
- return 0;
-
- switch (le32_to_cpu(lmm->lmm_magic)) {
- case LOV_MAGIC_V1:
- count = le16_to_cpu(((struct lov_mds_md_v1*)lmm)->lmm_stripe_count);
- data = &(((struct lov_mds_md_v1*)lmm)->lmm_objects[0]);
- break;
- case LOV_MAGIC_V3:
- count = le16_to_cpu(((struct lov_mds_md_v3*)lmm)->lmm_stripe_count);
- data = &(((struct lov_mds_md_v3*)lmm)->lmm_objects[0]);
- break;
- default:
- CERROR("Unknow lmm type %X!\n", le32_to_cpu(lmm->lmm_magic));
- RETURN(-EINVAL);
- }
-
-
- cfs_mutex_lock(&obd->obd_dev_mutex);
- for (j = 0; j < count; j++) {
- __u32 i = le32_to_cpu(data[j].l_ost_idx);
- if (mds_lov_update_max_ost(&obd->u.mds, i)) {
- rc = -ENOMEM;
- break;
- }
- }
- cfs_mutex_unlock(&obd->obd_dev_mutex);
-
- RETURN(rc);
-}
-EXPORT_SYMBOL(mds_lov_prepare_objids);
-
-/*
- * write llog orphan record about lost ost object,
- * Special lsm is allocated with single stripe, caller should deallocated it
- * after use
- */
-static int mds_log_lost_precreated(struct obd_device *obd,
- struct lov_stripe_md **lsmp, __u16 *stripes,
- obd_id id, obd_count count, int idx)
-{
- struct lov_stripe_md *lsm = *lsmp;
- int rc;
- ENTRY;
-
- if (*lsmp == NULL) {
- rc = obd_alloc_memmd(obd->u.mds.mds_lov_exp, &lsm);
- if (rc < 0)
- RETURN(rc);
- /* need only one stripe, save old value */
- *stripes = lsm->lsm_stripe_count;
- lsm->lsm_stripe_count = 1;
- *lsmp = lsm;
- }
-
- lsm->lsm_oinfo[0]->loi_id = id;
- lsm->lsm_oinfo[0]->loi_seq = mdt_to_obd_objseq(obd->u.mds.mds_id);
- lsm->lsm_oinfo[0]->loi_ost_idx = idx;
-
- rc = mds_log_op_orphan(obd, lsm, count);
- RETURN(rc);
-}
-
-void mds_lov_update_objids(struct obd_device *obd, struct lov_mds_md *lmm)
-{
- struct mds_obd *mds = &obd->u.mds;
- int j;
- struct lov_ost_data_v1 *obj;
- struct lov_stripe_md *lsm = NULL;
- __u16 stripes = 0;
- int count;
- ENTRY;
-
- /* if we create file without objects - lmm is NULL */
- if (lmm == NULL)
- return;
-
- switch (le32_to_cpu(lmm->lmm_magic)) {
- case LOV_MAGIC_V1:
- count = le16_to_cpu(((struct lov_mds_md_v1*)lmm)->lmm_stripe_count);
- obj = ((struct lov_mds_md_v1*)lmm)->lmm_objects;
- break;
- case LOV_MAGIC_V3:
- count = le16_to_cpu(((struct lov_mds_md_v3*)lmm)->lmm_stripe_count);
- obj = ((struct lov_mds_md_v3*)lmm)->lmm_objects;
- break;
- default:
- CERROR("Unknow lmm type %X !\n",
- le32_to_cpu(lmm->lmm_magic));
- return;
- }
-
- for (j = 0; j < count; j++) {
- __u32 i = le32_to_cpu(obj[j].l_ost_idx);
- obd_id id = le64_to_cpu(obj[j].l_object_id);
- __u32 page = i / OBJID_PER_PAGE();
- __u32 idx = i % OBJID_PER_PAGE();
- obd_id *data;
-
- data = mds->mds_lov_page_array[page];
-
- CDEBUG(D_INODE,"update last object for ost %u"
- " - new "LPU64" old "LPU64"\n", i, id, data[idx]);
- if (id > data[idx]) {
- int lost = id - data[idx] - 1;
- /* we might have lost precreated objects due to VBR */
- if (lost > 0 && obd->obd_recovering) {
- CDEBUG(D_HA, "Gap in objids is %u\n", lost);
- if (!obd->obd_version_recov)
- CERROR("Unexpected gap in objids\n");
- /* lsm is allocated if NULL */
- mds_log_lost_precreated(obd, &lsm, &stripes,
- data[idx]+1, lost, i);
- }
- data[idx] = id;
- cfs_bitmap_set(mds->mds_lov_page_dirty, page);
- }
- }
- if (lsm) {
- /* restore stripes number */
- lsm->lsm_stripe_count = stripes;
- obd_free_memmd(mds->mds_lov_exp, &lsm);
- }
- EXIT;
- return;
-}
-EXPORT_SYMBOL(mds_lov_update_objids);
-
-static int mds_lov_update_from_read(struct mds_obd *mds, obd_id *data,
- __u32 count)
-{
- __u32 max_easize = mds->mds_obt.obt_osd_properties.osd_max_ea_size;
- __u32 i, stripes;
-
- for (i = 0; i < count; i++) {
- if (data[i] == 0)
- continue;
-
- mds->mds_lov_objid_count++;
- }
-
- stripes = min(lov_mds_md_stripecnt(max_easize, LOV_MAGIC_V3),
- mds->mds_lov_objid_count);
-
- mds->mds_max_mdsize = lov_mds_md_size(stripes, LOV_MAGIC_V3);
- mds->mds_max_cookiesize = stripes * sizeof(struct llog_cookie);
-
- CDEBUG(D_CONFIG, "updated max_mdsize/max_cookiesize for %d stripes: "
- "%d/%d\n", stripes, mds->mds_max_mdsize,
- mds->mds_max_cookiesize);
-
- EXIT;
- return 0;
-}
-
-static int mds_lov_read_objids(struct obd_device *obd)
-{
- struct mds_obd *mds = &obd->u.mds;
- loff_t off = 0;
- int i, rc = 0, count = 0, page = 0;
- unsigned long size;
- ENTRY;
-
- /* Read everything in the file, even if our current lov desc
- has fewer targets. Old targets not in the lov descriptor
- during mds setup may still have valid objids. */
- size = i_size_read(mds->mds_lov_objid_filp->f_dentry->d_inode);
- if (size == 0)
- RETURN(0);
-
- page = (size + MDS_LOV_ALLOC_SIZE - 1) / MDS_LOV_ALLOC_SIZE;
- CDEBUG(D_INFO, "file size %lu pages %d\n", size, page);
- for (i = 0; i < page; i++) {
- obd_id *data;
- loff_t off_old = off;
-
- LASSERT(mds->mds_lov_page_array[i] == NULL);
- OBD_ALLOC(mds->mds_lov_page_array[i], MDS_LOV_ALLOC_SIZE);
- if (mds->mds_lov_page_array[i] == NULL)
- GOTO(out, rc = -ENOMEM);
-
- data = mds->mds_lov_page_array[i];
-
- rc = fsfilt_read_record(obd, mds->mds_lov_objid_filp, data,
- MDS_LOV_ALLOC_SIZE, &off);
- if (rc < 0) {
- CERROR("Error reading objids %d\n", rc);
- GOTO(out, rc);
- }
- if (off == off_old) /* hole is read */
- off += MDS_LOV_ALLOC_SIZE;
-
- count = (off - off_old) / sizeof(obd_id);
- if (mds_lov_update_from_read(mds, data, count)) {
- CERROR("Can't update mds data\n");
- GOTO(out, rc = -EIO);
- }
- }
- mds->mds_lov_objid_lastpage = page - 1;
- mds->mds_lov_objid_lastidx = count - 1;
-
- CDEBUG(D_INFO, "Read %u - %u %u objid\n", mds->mds_lov_objid_count,
- mds->mds_lov_objid_lastpage, mds->mds_lov_objid_lastidx);
-out:
- mds_lov_dump_objids("read",obd);
-
- RETURN(rc);
-}
-
-int mds_lov_write_objids(struct obd_device *obd)
-{
- struct mds_obd *mds = &obd->u.mds;
- int i = 0, rc = 0;
- ENTRY;
-
- if (cfs_bitmap_check_empty(mds->mds_lov_page_dirty))
- RETURN(0);
-
- mds_lov_dump_objids("write", obd);
-
- cfs_foreach_bit(mds->mds_lov_page_dirty, i) {
- obd_id *data = mds->mds_lov_page_array[i];
- unsigned int size = MDS_LOV_ALLOC_SIZE;
- loff_t off = i * size;
-
- LASSERT(data != NULL);
-
- if (!cfs_bitmap_test_and_clear(mds->mds_lov_page_dirty, i))
- continue;
-
- /* check for particaly filled last page */
- if (i == mds->mds_lov_objid_lastpage)
- size = (mds->mds_lov_objid_lastidx+1) * sizeof(obd_id);
-
- CDEBUG(D_INFO, "write %lld - %u\n", off, size);
- rc = fsfilt_write_record(obd, mds->mds_lov_objid_filp, data,
- size, &off, 0);
- if (rc < 0) {
- cfs_bitmap_set(mds->mds_lov_page_dirty, i);
- break;
- }
- }
- if (rc >= 0)
- rc = 0;
-
- RETURN(rc);
-}
-EXPORT_SYMBOL(mds_lov_write_objids);
-
-static int mds_lov_get_objid(struct obd_device * obd,
- obd_id idx)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct obd_export *lov_exp = mds->mds_lov_exp;
- unsigned int page;
- unsigned int off;
- obd_id *data;
- __u32 size;
- int rc = 0;
- ENTRY;
-
- page = idx / OBJID_PER_PAGE();
- off = idx % OBJID_PER_PAGE();
- data = mds->mds_lov_page_array[page];
-
- if (data[off] < 2) {
- /* We never read this lastid; ask the osc */
- struct obd_id_info lastid;
-
- size = sizeof(lastid);
- lastid.idx = idx;
- lastid.data = &data[off];
- rc = obd_get_info(NULL, lov_exp, sizeof(KEY_LAST_ID),
- KEY_LAST_ID, &size, &lastid, NULL);
- if (rc)
- GOTO(out, rc);
-
- /* workaround for clean filter */
- if (data[off] == 0)
- data[off] = 1;
-
- cfs_bitmap_set(mds->mds_lov_page_dirty, page);
- }
- CDEBUG(D_INFO, "idx "LPU64" - %p - %d/%d - "LPU64"\n",
- idx, data, page, off, data[off]);
-out:
- RETURN(rc);
-}
-
-int mds_lov_clear_orphans(struct mds_obd *mds, struct obd_uuid *ost_uuid)
-{
- int rc;
- struct obdo oa = { 0 };
- struct obd_trans_info oti = {0};
- struct lov_stripe_md *empty_ea = NULL;
- ENTRY;
-
- LASSERT(mds->mds_lov_page_array != NULL);
-
- /* This create will in fact either create or destroy: If the OST is
- * missing objects below this ID, they will be created. If it finds
- * objects above this ID, they will be removed. */
- memset(&oa, 0, sizeof(oa));
- oa.o_flags = OBD_FL_DELORPHAN;
- oa.o_seq = mdt_to_obd_objseq(mds->mds_id);
- oa.o_valid = OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
- if (ost_uuid != NULL)
- oti.oti_ost_uuid = ost_uuid;
-
- rc = obd_create(NULL, mds->mds_lov_exp, &oa, &empty_ea, &oti);
-
- RETURN(rc);
-}
-
-/* for one target */
-static int mds_lov_set_one_nextid(struct obd_device *obd, __u32 idx, obd_id *id)
-{
- struct mds_obd *mds = &obd->u.mds;
- int rc;
- struct obd_id_info info;
- ENTRY;
-
- LASSERT(!obd->obd_recovering);
-
- info.idx = idx;
- info.data = id;
- rc = obd_set_info_async(NULL, mds->mds_lov_exp, sizeof(KEY_NEXT_ID),
- KEY_NEXT_ID, sizeof(info), &info, NULL);
- if (rc)
- CERROR ("%s: mds_lov_set_nextid failed (%d)\n",
- obd->obd_name, rc);
-
- RETURN(rc);
-}
-
-/* Update the lov desc for a new size lov. */
-static int mds_lov_update_desc(struct obd_device *obd, int idx,
- struct obd_uuid *uuid)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct lov_desc *ld;
- __u32 valsize = sizeof(mds->mds_lov_desc);
- int rc = 0;
- ENTRY;
-
- OBD_ALLOC(ld, sizeof(*ld));
- if (!ld)
- RETURN(-ENOMEM);
-
- rc = obd_get_info(NULL, mds->mds_lov_exp, sizeof(KEY_LOVDESC),
- KEY_LOVDESC, &valsize, ld, NULL);
- if (rc)
- GOTO(out, rc);
-
- /* Don't change the mds_lov_desc until the objids size matches the
- count (paranoia) */
- mds->mds_lov_desc = *ld;
- CDEBUG(D_CONFIG, "updated lov_desc, tgt_count: %d - idx %d / uuid %s\n",
- mds->mds_lov_desc.ld_tgt_count, idx, uuid->uuid);
-
- cfs_mutex_lock(&obd->obd_dev_mutex);
- rc = mds_lov_update_max_ost(mds, idx);
- cfs_mutex_unlock(&obd->obd_dev_mutex);
- if (rc != 0)
- GOTO(out, rc );
-
- /* If we added a target we have to reconnect the llogs */
- /* We only _need_ to do this at first add (idx), or the first time
- after recovery. However, it should now be safe to call anytime. */
- rc = obd_llog_init(obd, &obd->obd_olg, obd, &idx);
- if (rc)
- GOTO(out, rc);
-
-out:
- OBD_FREE(ld, sizeof(*ld));
- RETURN(rc);
-}
-
-/* Inform MDS about new/updated target */
-static int mds_lov_update_mds(struct obd_device *obd,
- struct obd_device *watched,
- __u32 idx)
-{
- struct mds_obd *mds = &obd->u.mds;
- int rc = 0;
- int page;
- int off;
- obd_id *data;
- ENTRY;
-
- LASSERT(mds_lov_objinit(mds, idx));
-
- CDEBUG(D_CONFIG, "idx=%d, recov=%d/%d, cnt=%d\n",
- idx, obd->obd_recovering, obd->obd_async_recov,
- mds->mds_lov_desc.ld_tgt_count);
-
- /* idx is set as data from lov_notify. */
- if (obd->obd_recovering)
- GOTO(out, rc);
-
- if (idx >= mds->mds_lov_desc.ld_tgt_count) {
- CERROR("index %d > count %d!\n", idx,
- mds->mds_lov_desc.ld_tgt_count);
- GOTO(out, rc = -EINVAL);
- }
-
- rc = mds_lov_get_objid(obd, idx);
- if (rc)
- GOTO(out, rc);
-
- page = idx / OBJID_PER_PAGE();
- off = idx % OBJID_PER_PAGE();
- data = mds->mds_lov_page_array[page];
-
- /* We have read this lastid from disk; tell the osc.
- Don't call this during recovery. */
- rc = mds_lov_set_one_nextid(obd, idx, &data[off]);
- if (rc) {
- CERROR("Failed to set next id, idx=%d rc=%d\n", idx,rc);
- /* Don't abort the rest of the sync */
- rc = 0;
- } else {
- CDEBUG(D_CONFIG, "last object "LPU64" from OST %d rc=%d\n",
- data[off], idx, rc);
- }
-out:
- RETURN(rc);
-}
-
-/* update the LOV-OSC knowledge of the last used object id's */
-int mds_lov_connect(struct obd_device *obd, char * lov_name)
-{
- struct mds_obd *mds = &obd->u.mds;
- struct obd_connect_data *data;
- int rc;
- ENTRY;
-
- if (IS_ERR(mds->mds_lov_obd))
- RETURN(PTR_ERR(mds->mds_lov_obd));
-
- if (mds->mds_lov_obd)
- RETURN(0);
-
- mds->mds_lov_obd = class_name2obd(lov_name);
- if (!mds->mds_lov_obd) {
- CERROR("MDS cannot locate LOV %s\n", lov_name);
- mds->mds_lov_obd = ERR_PTR(-ENOTCONN);
- RETURN(-ENOTCONN);
- }
-
- cfs_mutex_lock(&obd->obd_dev_mutex);
- rc = mds_lov_read_objids(obd);
- cfs_mutex_unlock(&obd->obd_dev_mutex);
- if (rc) {
- CERROR("cannot read %s: rc = %d\n", "lov_objids", rc);
- GOTO(err_exit, rc);
- }
-
- rc = obd_register_observer(mds->mds_lov_obd, obd);
- if (rc) {
- CERROR("MDS cannot register as observer of LOV %s (%d)\n",
- lov_name, rc);
- GOTO(err_exit, rc);
- }
-
- /* ask lov to generate OBD_NOTIFY_CREATE events for already registered
- * targets */
- obd_notify(mds->mds_lov_obd, NULL, OBD_NOTIFY_CREATE, NULL);
-
- mds->mds_lov_obd->u.lov.lov_sp_me = LUSTRE_SP_MDT;
-
- OBD_ALLOC(data, sizeof(*data));
- if (data == NULL)
- GOTO(err_exit, rc = -ENOMEM);
-
- data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_INDEX |
- OBD_CONNECT_REQPORTAL | OBD_CONNECT_QUOTA64 |
- OBD_CONNECT_OSS_CAPA | OBD_CONNECT_FULL20 |
- OBD_CONNECT_CHANGE_QS | OBD_CONNECT_AT |
- OBD_CONNECT_MDS | OBD_CONNECT_SKIP_ORPHAN |
- OBD_CONNECT_SOM | OBD_CONNECT_MAX_EASIZE;
-#ifdef HAVE_LRU_RESIZE_SUPPORT
- data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
-#endif
- data->ocd_version = LUSTRE_VERSION_CODE;
- data->ocd_group = mdt_to_obd_objseq(mds->mds_id);
- data->ocd_max_easize = mds->mds_obt.obt_osd_properties.osd_max_ea_size;
-
- /* send max bytes per rpc */
- data->ocd_brw_size = PTLRPC_MAX_BRW_PAGES << CFS_PAGE_SHIFT;
- /* send the list of supported checksum types */
- data->ocd_cksum_types = cksum_types_supported_client();
- /* NB: lov_connect() needs to fill in .ocd_index for each OST */
- rc = obd_connect(NULL, &mds->mds_lov_exp, mds->mds_lov_obd, &obd->obd_uuid, data, NULL);
- OBD_FREE(data, sizeof(*data));
- if (rc) {
- CERROR("MDS cannot connect to LOV %s (%d)\n", lov_name, rc);
- mds->mds_lov_obd = ERR_PTR(rc);
- RETURN(rc);
- }
-
- /* I want to see a callback happen when the OBD moves to a
- * "For General Use" state, and that's when we'll call
- * set_nextid(). The class driver can help us here, because
- * it can use the obd_recovering flag to determine when the
- * the OBD is full available. */
- /* MDD device will care about that
- if (!obd->obd_recovering)
- rc = mds_postrecov(obd);
- */
- RETURN(rc);
-
-err_exit:
- mds->mds_lov_exp = NULL;
- mds->mds_lov_obd = ERR_PTR(rc);
- RETURN(rc);
-}
-
-int mds_lov_disconnect(struct obd_device *obd)
-{
- struct mds_obd *mds = &obd->u.mds;
- int rc = 0;
- ENTRY;
-
- if (!IS_ERR(mds->mds_lov_obd) && mds->mds_lov_exp != NULL) {
- obd_register_observer(mds->mds_lov_obd, NULL);
-
- /* The actual disconnect of the mds_lov will be called from
- * class_disconnect_exports from mds_lov_clean. So we have to
- * ensure that class_cleanup doesn't fail due to the extra ref
- * we're holding now. The mechanism to do that already exists -
- * the obd_force flag. We'll drop the final ref to the
- * mds_lov_exp in mds_cleanup. */
- mds->mds_lov_obd->obd_force = 1;
- }
-
- RETURN(rc);
-}
-
-struct mds_lov_sync_info {
- struct obd_device *mlsi_obd; /* the lov device to sync */
- struct obd_device *mlsi_watched; /* target osc */
- __u32 mlsi_index; /* index of target */
-};
-
-static int mds_propagate_capa_keys(struct mds_obd *mds, struct obd_uuid *uuid)
-{
- struct mds_capa_info info = { .uuid = uuid };
- struct lustre_capa_key *key;
- int i, rc = 0;
-
- ENTRY;
-
- if (!mds->mds_capa_keys)
- RETURN(0);
-
- OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_SYNC_CAPA_SL, 5);
- for (i = 0; i < 2; i++) {
- key = &mds->mds_capa_keys[i];
- DEBUG_CAPA_KEY(D_SEC, key, "propagate");
-
- info.capa = key;
- rc = obd_set_info_async(NULL, mds->mds_lov_exp,
- sizeof(KEY_CAPA_KEY), KEY_CAPA_KEY,
- sizeof(info), &info, NULL);
- if (rc) {
- DEBUG_CAPA_KEY(D_ERROR, key,
- "propagate failed (rc = %d) for", rc);
- RETURN(rc);
- }
- }
-
- RETURN(0);
-}
-
-/* We only sync one osc at a time, so that we don't have to hold
- any kind of lock on the whole mds_lov_desc, which may change
- (grow) as a result of mds_lov_add_ost. This also avoids any
- kind of mismatch between the lov_desc and the mds_lov_desc,
- which are not in lock-step during lov_add_obd */
-static int __mds_lov_synchronize(void *data)
-{
- struct mds_lov_sync_info *mlsi = data;
- struct obd_device *obd = mlsi->mlsi_obd;
- struct obd_device *watched = mlsi->mlsi_watched;
- struct mds_obd *mds = &obd->u.mds;
- struct obd_uuid *uuid;
- __u32 idx = mlsi->mlsi_index;
- struct mds_group_info mgi;
- struct llog_ctxt *ctxt;
- int rc = 0;
- ENTRY;
-
- OBD_FREE_PTR(mlsi);
-
- LASSERT(obd);
- LASSERT(watched);
- uuid = &watched->u.cli.cl_target_uuid;
- LASSERT(uuid);
-
- cfs_down_read(&mds->mds_notify_lock);
- if (obd->obd_stopping || obd->obd_fail)
- GOTO(out, rc = -ENODEV);
-
- OBD_RACE(OBD_FAIL_MDS_LOV_SYNC_RACE);
- rc = mds_lov_update_mds(obd, watched, idx);
- if (rc != 0) {
- CERROR("%s failed at update_mds: %d\n", obd_uuid2str(uuid), rc);
- GOTO(out, rc);
- }
- mgi.group = mdt_to_obd_objseq(mds->mds_id);
- mgi.uuid = uuid;
-
- rc = obd_set_info_async(NULL, mds->mds_lov_exp, sizeof(KEY_MDS_CONN),
- KEY_MDS_CONN, sizeof(mgi), &mgi, NULL);
- if (rc != 0)
- GOTO(out, rc);
- /* propagate capability keys */
- rc = mds_propagate_capa_keys(mds, uuid);
- if (rc)
- GOTO(out, rc);
-
- ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
- if (!ctxt)
- GOTO(out, rc = -ENODEV);
-
- OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT, 60);
- rc = llog_connect(ctxt, NULL, NULL, uuid);
- llog_ctxt_put(ctxt);
- if (rc != 0) {
- CERROR("%s failed at llog_origin_connect: %d\n",
- obd_uuid2str(uuid), rc);
- GOTO(out, rc);
- }
-
- LCONSOLE_INFO("MDS %s: %s now active, resetting orphans\n",
- obd->obd_name, obd_uuid2str(uuid));
-
- rc = mds_lov_clear_orphans(mds, uuid);
- if (rc != 0) {
- CERROR("%s failed at mds_lov_clear_orphans: %d\n",
- obd_uuid2str(uuid), rc);
- GOTO(out, rc);
- }
-
- EXIT;
-out:
- if (rc) {
- /* Deactivate it for safety */
- CERROR("%s sync failed %d, deactivating\n", obd_uuid2str(uuid),
- rc);
- if (!obd->obd_stopping && mds->mds_lov_obd &&
- !mds->mds_lov_obd->obd_stopping && !watched->obd_stopping)
- obd_notify(mds->mds_lov_obd, watched,
- OBD_NOTIFY_INACTIVE, NULL);
- }
- cfs_up_read(&mds->mds_notify_lock);
-
- class_decref(obd, "mds_lov_synchronize", obd);
- return rc;
-}
-
-int mds_lov_synchronize(void *data)
-{
- struct mds_lov_sync_info *mlsi = data;
- char name[20];
-
- snprintf(name, sizeof(name), "ll_sync_%02u", mlsi->mlsi_index);
- cfs_daemonize_ctxt(name);
-
- RETURN(__mds_lov_synchronize(data));
-}
-
-int mds_lov_start_synchronize(struct obd_device *obd,
- struct obd_device *watched,
- void *data, enum obd_notify_event ev)
-{
- struct mds_lov_sync_info *mlsi;
- int rc;
- struct obd_uuid *uuid;
- ENTRY;
-
- LASSERT(watched);
- uuid = &watched->u.cli.cl_target_uuid;
-
- OBD_ALLOC(mlsi, sizeof(*mlsi));
- if (mlsi == NULL)
- RETURN(-ENOMEM);
-
- LASSERT(data);
- mlsi->mlsi_obd = obd;
- mlsi->mlsi_watched = watched;
- mlsi->mlsi_index = *(__u32 *)data;
-
- /* Although class_export_get(obd->obd_self_export) would lock
- the MDS in place, since it's only a self-export
- it doesn't lock the LOV in place. The LOV can be disconnected
- during MDS precleanup, leaving nothing for __mds_lov_synchronize.
- Simply taking an export ref on the LOV doesn't help, because it's
- still disconnected. Taking an obd reference insures that we don't
- disconnect the LOV. This of course means a cleanup won't
- finish for as long as the sync is blocking. */
- class_incref(obd, "mds_lov_synchronize", obd);
-
- if (ev != OBD_NOTIFY_SYNC) {
- /* Synchronize in the background */
- rc = cfs_create_thread(mds_lov_synchronize, mlsi,
- CFS_DAEMON_FLAGS);
- if (rc < 0) {
- CERROR("%s: error starting mds_lov_synchronize: %d\n",
- obd->obd_name, rc);
- class_decref(obd, "mds_lov_synchronize", obd);
- } else {
- CDEBUG(D_HA, "%s: mds_lov_synchronize idx=%d "
- "thread=%d\n", obd->obd_name,
- mlsi->mlsi_index, rc);
- rc = 0;
- }
- } else {
- rc = __mds_lov_synchronize((void *)mlsi);
- }
-
- RETURN(rc);
-}
-
-int mds_notify(struct obd_device *obd, struct obd_device *watched,
- enum obd_notify_event ev, void *data)
-{
- struct mds_obd *mds = &obd->u.mds;
- int rc = 0;
- ENTRY;
-
- CDEBUG(D_CONFIG, "notify %s ev=%d\n", watched->obd_name, ev);
-
- if (strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME) != 0) {
- CERROR("unexpected notification of %s %s!\n",
- watched->obd_type->typ_name, watched->obd_name);
- RETURN(-EINVAL);
- }
-
- /*XXX this notifies the MDD until lov handling use old mds code
- * must non block!
- */
- if (obd->obd_upcall.onu_owner) {
- LASSERT(obd->obd_upcall.onu_upcall != NULL);
- rc = obd->obd_upcall.onu_upcall(obd, NULL, ev,
- obd->obd_upcall.onu_owner,
- &mds->mds_obt.obt_mount_count);
- }
-
- switch (ev) {
- /* We only handle these: */
- case OBD_NOTIFY_CREATE:
- CDEBUG(D_CONFIG, "%s: add target %s\n", obd->obd_name,
- obd_uuid2str(&watched->u.cli.cl_target_uuid));
- /* We still have to fix the lov descriptor for ost's */
- LASSERT(data);
- rc = mds_lov_update_desc(obd, *(__u32 *)data,
- &watched->u.cli.cl_target_uuid);
- RETURN(rc);
- case OBD_NOTIFY_ACTIVE:
- /* lov want one or more _active_ targets for work */
- /* activate event should be pass lov idx as argument */
- case OBD_NOTIFY_SYNC:
- case OBD_NOTIFY_SYNC_NONBLOCK:
- /* sync event should be pass lov idx as argument */
- break;
- default:
- RETURN(0);
- }
-
- if (obd->obd_recovering) {
- CDEBUG(D_CONFIG, "%s: Is in recovery, "
- "not resetting orphans on %s\n",
- obd->obd_name,
- obd_uuid2str(&watched->u.cli.cl_target_uuid));
- /* We still have to fix the lov descriptor for ost's added
- after the mdt in the config log. They didn't make it into
- mds_lov_connect. */
- rc = mds_lov_update_desc(obd, *(__u32 *)data,
- &watched->u.cli.cl_target_uuid);
- } else {
- rc = mds_lov_start_synchronize(obd, watched, data, ev);
- }
- RETURN(rc);
-}
export RLUSTRE=${RLUSTRE:-$LUSTRE}
export RPWD=${RPWD:-$PWD}
export I_MOUNTED=${I_MOUNTED:-"no"}
- if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
- ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mds.ko -a \
- ! -f `dirname $0`/../mds/mds.ko ]; then
+ if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mdt.ko -a \
+ ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mdt.ko -a \
+ ! -f `dirname $0`/../mdt/mdt.ko ]; then
export CLIENTMODSONLY=yes
fi
load_module osd-zfs/osd_zfs
fi
load_module mgs/mgs
- load_module mds/mds
load_module mdd/mdd
if [[ $(node_fstypes $HOSTNAME) == *ldiskfs* ]]; then
#