/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * lustre/osd/osd_handler.c
- * Top-level entry points into osd module
+ * GPL HEADER START
*
- * Copyright (c) 2006 Cluster File Systems, Inc.
- * Author: Nikita Danilov <nikita@clusterfs.com>
+ * 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/osd/osd_handler.c
+ *
+ * Top-level entry points into osd module
+ *
+ * Author: Nikita Danilov <nikita@clusterfs.com>
*/
#ifndef EXPORT_SYMTAB
#include <obd_support.h>
/* struct ptlrpc_thread */
#include <lustre_net.h>
-/* LUSTRE_OSD_NAME */
-#include <obd.h>
-/* class_register_type(), class_unregister_type(), class_get_type() */
-#include <obd_class.h>
-#include <lustre_disk.h>
/* fid_is_local() */
#include <lustre_fid.h>
#endif
};
-/*
- * osd device.
- */
-struct osd_device {
- /* super-class */
- struct dt_device od_dt_dev;
- /* information about underlying file system */
- struct lustre_mount_info *od_mount;
- /* object index */
- struct osd_oi od_oi;
- /*
- * XXX temporary stuff for object index: directory where every object
- * is named by its fid.
- */
- struct dentry *od_obj_area;
-
- /* Environment for transaction commit callback.
- * Currently, OSD is based on ext3/JBD. Transaction commit in ext3/JBD
- * is serialized, that is there is no more than one transaction commit
- * at a time (JBD journal_commit_transaction() is serialized).
- * This means that it's enough to have _one_ lu_context.
- */
- struct lu_env od_env_for_commit;
-
- /*
- * Fid Capability
- */
- unsigned int od_fl_capa:1;
- unsigned long od_capa_timeout;
- __u32 od_capa_alg;
- struct lustre_capa_key *od_capa_keys;
- struct hlist_head *od_capa_hash;
-
- /*
- * statfs optimization: we cache a bit.
- */
- cfs_time_t od_osfs_age;
- struct kstatfs od_kstatfs;
- spinlock_t od_osfs_lock;
-};
-
static int osd_root_get (const struct lu_env *env,
struct dt_device *dev, struct lu_fid *f);
-static int osd_statfs (const struct lu_env *env,
- struct dt_device *dev, struct kstatfs *sfs);
static int lu_device_is_osd (const struct lu_device *d);
static void osd_mod_exit (void) __exit;
struct lu_object *l);
static int osd_object_print (const struct lu_env *env, void *cookie,
lu_printer_t p, const struct lu_object *o);
-static void osd_device_free (const struct lu_env *env,
+static struct lu_device *osd_device_free (const struct lu_env *env,
struct lu_device *m);
static void *osd_key_init (const struct lu_context *ctx,
struct lu_context_key *key);
static struct lu_device_type osd_device_type;
static struct lu_object_operations osd_lu_obj_ops;
static struct obd_ops osd_obd_device_ops;
-static struct lprocfs_vars lprocfs_osd_module_vars[];
-static struct lprocfs_vars lprocfs_osd_obd_vars[];
static struct lu_device_operations osd_lu_ops;
static struct lu_context_key osd_key;
static struct dt_object_operations osd_obj_ops;
/*
* Concurrency: shouldn't matter.
*/
-static int osd_statfs(const struct lu_env *env,
- struct dt_device *d, struct kstatfs *sfs)
+int osd_statfs(const struct lu_env *env, struct dt_device *d,
+ struct kstatfs *sfs)
{
struct osd_device *osd = osd_dt_dev(d);
struct super_block *sb = osd_sb(osd);
if (error) {
CERROR("transaction @0x%p commit error: %d\n", th, error);
} else {
+ struct lu_env *env = &osd_dt_dev(dev)->od_env_for_commit;
/*
* This od_env_for_commit is only for commit usage. see
* "struct dt_device"
*/
- dt_txn_hook_commit(&osd_dt_dev(dev)->od_env_for_commit, th);
+ lu_context_enter(&env->le_ctx);
+ dt_txn_hook_commit(env, th);
+ lu_context_exit(&env->le_ctx);
}
lu_device_put(&dev->dd_lu_dev);
inode->i_nlink = attr->la_nlink;
if (bits & LA_RDEV)
inode->i_rdev = attr->la_rdev;
- if (bits & LA_BLKSIZE)
- inode->i_blksize = attr->la_blksize;
if (bits & LA_FLAGS) {
struct ldiskfs_inode_info *li = LDISKFS_I(inode);
LASSERT(th != NULL);
spin_lock(&obj->oo_guard);
- if (inode->i_nlink < LDISKFS_LINK_MAX) {
- inode->i_nlink ++;
- spin_unlock(&obj->oo_guard);
- mark_inode_dirty(inode);
- } else {
- spin_unlock(&obj->oo_guard);
- LU_OBJECT_DEBUG(D_ERROR, env, &dt->do_lu,
- "Overflowed nlink\n");
- }
+ LASSERT(inode->i_nlink < LDISKFS_LINK_MAX);
+ inode->i_nlink++;
+ spin_unlock(&obj->oo_guard);
+ mark_inode_dirty(inode);
LASSERT(osd_invariant(obj));
}
LASSERT(th != NULL);
spin_lock(&obj->oo_guard);
- if (inode->i_nlink > 0) {
- inode->i_nlink --;
- spin_unlock(&obj->oo_guard);
- mark_inode_dirty(inode);
- } else {
- spin_unlock(&obj->oo_guard);
- LU_OBJECT_DEBUG(D_ERROR, env, &dt->do_lu,
- "Underflowed nlink\n");
- }
+ LASSERT(inode->i_nlink > 0);
+ inode->i_nlink--;
+ spin_unlock(&obj->oo_guard);
+ mark_inode_dirty(inode);
LASSERT(osd_invariant(obj));
}
const struct lu_buf *buf, const char *name, int fl,
struct thandle *handle, struct lustre_capa *capa)
{
- int fs_flags;
-
struct osd_object *obj = osd_dt_obj(dt);
struct inode *inode = obj->oo_inode;
struct osd_thread_info *info = osd_oti_get(env);
struct dentry *dentry = &info->oti_dentry;
+ struct timespec *t = &info->oti_time;
+ int fs_flags = 0, rc;
LASSERT(dt_object_exists(dt));
LASSERT(inode->i_op != NULL && inode->i_op->setxattr != NULL);
if (osd_object_auth(env, dt, capa, CAPA_OPC_META_WRITE))
return -EACCES;
- dentry->d_inode = inode;
-
- fs_flags = 0;
if (fl & LU_XATTR_REPLACE)
fs_flags |= XATTR_REPLACE;
if (fl & LU_XATTR_CREATE)
fs_flags |= XATTR_CREATE;
- return inode->i_op->setxattr(dentry, name,
- buf->lb_buf, buf->lb_len, fs_flags);
+ dentry->d_inode = inode;
+ *t = inode->i_ctime;
+ rc = inode->i_op->setxattr(dentry, name,
+ buf->lb_buf, buf->lb_len, fs_flags);
+ if (likely(rc == 0)) {
+ /* ctime should not be updated with server-side time. */
+ spin_lock(&obj->oo_guard);
+ inode->i_ctime = *t;
+ spin_unlock(&obj->oo_guard);
+ mark_inode_dirty(inode);
+ }
+ return rc;
}
/*
struct inode *inode = obj->oo_inode;
struct osd_thread_info *info = osd_oti_get(env);
struct dentry *dentry = &info->oti_dentry;
+ struct timespec *t = &info->oti_time;
+ int rc;
LASSERT(dt_object_exists(dt));
LASSERT(inode->i_op != NULL && inode->i_op->removexattr != NULL);
return -EACCES;
dentry->d_inode = inode;
- return inode->i_op->removexattr(dentry, name);
+ *t = inode->i_ctime;
+ rc = inode->i_op->removexattr(dentry, name);
+ if (likely(rc == 0)) {
+ /* ctime should not be updated with server-side time. */
+ spin_lock(&obj->oo_guard);
+ inode->i_ctime = *t;
+ spin_unlock(&obj->oo_guard);
+ mark_inode_dirty(inode);
+ }
+ return rc;
}
static struct obd_capa *osd_capa_get(const struct lu_env *env,
spin_unlock(&capa_lock);
capa->lc_keyid = key->lk_keyid;
- capa->lc_expiry = CURRENT_SECONDS + dev->od_capa_timeout;
+ capa->lc_expiry = cfs_time_current_sec() + dev->od_capa_timeout;
rc = capa_hmac(capa->lc_hmac, capa, key->lk_key);
if (rc) {
return (struct dt_rec *)iam_it_rec_get(&it->oi_it);
}
-static __u32 osd_it_store(const struct lu_env *env, const struct dt_it *di)
+static __u64 osd_it_store(const struct lu_env *env, const struct dt_it *di)
{
struct osd_it *it = (struct osd_it *)di;
}
static int osd_it_load(const struct lu_env *env,
- const struct dt_it *di, __u32 hash)
+ const struct dt_it *di, __u64 hash)
{
struct osd_it *it = (struct osd_it *)di;
static int osd_device_init(const struct lu_env *env, struct lu_device *d,
const char *name, struct lu_device *next)
{
- return lu_env_init(&osd_dev(d)->od_env_for_commit, NULL, LCT_MD_THREAD);
+ int rc;
+ /* context for commit hooks */
+ rc = lu_context_init(&osd_dev(d)->od_env_for_commit.le_ctx,
+ LCT_MD_THREAD);
+ if (rc == 0)
+ rc = osd_procfs_init(osd_dev(d), name);
+ return rc;
}
static int osd_shutdown(const struct lu_env *env, struct osd_device *o)
if (result == 0) {
struct dentry *d;
- d = simple_mkdir(osd_sb(o)->s_root, "*OBJ-TEMP*", 0777, 1);
+ d = simple_mkdir(osd_sb(o)->s_root, lmi->lmi_mnt, "*OBJ-TEMP*",
+ 0777, 1);
if (!IS_ERR(d)) {
o->od_obj_area = d;
} else
static struct lu_device *osd_device_fini(const struct lu_env *env,
struct lu_device *d)
{
+ int rc;
ENTRY;
shrink_dcache_sb(osd_sb(osd_dev(d)));
osd_sync(env, lu2dt_dev(d));
+ rc = osd_procfs_fini(osd_dev(d));
+ if (rc) {
+ CERROR("proc fini error %d \n", rc);
+ RETURN (ERR_PTR(rc));
+ }
+
if (osd_dev(d)->od_mount)
server_put_mount(osd_dev(d)->od_mount->lmi_name,
osd_dev(d)->od_mount->lmi_mnt);
osd_dev(d)->od_mount = NULL;
- lu_env_fini(&osd_dev(d)->od_env_for_commit);
+ lu_context_fini(&osd_dev(d)->od_env_for_commit.le_ctx);
RETURN(NULL);
}
spin_lock_init(&o->od_osfs_lock);
o->od_osfs_age = cfs_time_shift_64(-1000);
o->od_capa_hash = init_capa_hash();
- if (o->od_capa_hash == NULL)
+ if (o->od_capa_hash == NULL) {
+ dt_device_fini(&o->od_dt_dev);
l = ERR_PTR(-ENOMEM);
+ }
} else
l = ERR_PTR(result);
+
+ if (IS_ERR(l))
+ OBD_FREE_PTR(o);
} else
l = ERR_PTR(-ENOMEM);
return l;
}
-static void osd_device_free(const struct lu_env *env, struct lu_device *d)
+static struct lu_device *osd_device_free(const struct lu_env *env,
+ struct lu_device *d)
{
struct osd_device *o = osd_dev(d);
+ ENTRY;
cleanup_capa_hash(o->od_capa_hash);
dt_device_fini(&o->od_dt_dev);
OBD_FREE_PTR(o);
+ RETURN(NULL);
}
static int osd_process_config(const struct lu_env *env,
attr->la_flags = LDISKFS_I(inode)->i_flags;
attr->la_nlink = inode->i_nlink;
attr->la_rdev = inode->i_rdev;
- attr->la_blksize = inode->i_blksize;
+ attr->la_blksize = ll_inode_blksize(inode);
+ attr->la_blkbits = inode->i_blkbits;
}
/*
/*
* lprocfs legacy support.
*/
-static struct lprocfs_vars lprocfs_osd_obd_vars[] = {
- { 0 }
-};
-
-static struct lprocfs_vars lprocfs_osd_module_vars[] = {
- { 0 }
-};
-
static struct obd_ops osd_obd_device_ops = {
.o_owner = THIS_MODULE
};
-static void lprocfs_osd_init_vars(struct lprocfs_static_vars *lvars)
-{
- lvars->module_vars = lprocfs_osd_module_vars;
- lvars->obd_vars = lprocfs_osd_obd_vars;
-}
-
-
static int __init osd_mod_init(void)
{
struct lprocfs_static_vars lvars;
class_unregister_type(LUSTRE_OSD_NAME);
}
-MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
+MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
MODULE_DESCRIPTION("Lustre Object Storage Device ("LUSTRE_OSD_NAME")");
MODULE_LICENSE("GPL");