extern void lprocfs_free_stats(struct lprocfs_stats **stats);
extern void lprocfs_init_ops_stats(int num_private_stats,
struct lprocfs_stats *stats);
+extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
unsigned int num_private_stats);
+extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
+ unsigned int num_private_stats);
extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
unsigned conf, const char *name,
const char *units);
static inline void lprocfs_init_ops_stats(int num_private_stats,
struct lprocfs_stats *stats)
{ return; }
+static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
+{ return; }
static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
unsigned int num_private_stats)
{ return 0; }
+static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
+ unsigned int num_private_stats)
+{ return 0; }
static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
{ return; }
struct brw_stats fed_brw_stats;
};
+typedef struct nid_stat_uuid {
+ struct list_head ns_uuid_list;
+ struct obd_uuid ns_uuid;
+} nid_stat_uuid_t;
+
typedef struct nid_stat {
lnet_nid_t nid;
struct hlist_node nid_hash;
struct list_head nid_list;
+ struct list_head nid_uuid_list;
struct obd_device *nid_obd;
struct proc_dir_entry *nid_proc;
struct lprocfs_stats *nid_stats;
+ struct lprocfs_stats *nid_ldlm_stats;
struct brw_stats *nid_brw_stats;
int nid_exp_ref_count;
}nid_stat_t;
struct obd_import *exp_imp_reverse; /* to make RPCs backwards */
struct nid_stat *exp_nid_stats;
struct lprocfs_stats *exp_md_stats;
- struct lprocfs_stats *exp_ldlm_stats;
struct ptlrpc_connection *exp_connection;
__u32 exp_conn_cnt;
lustre_hash_t *exp_lock_hash; /* existing lock hash */
lock = req->rq_async_args.pointer_arg[1];
LASSERT(lock != NULL);
if (rc != 0) {
- /* If client canceled the lock but the cancel has not
+ /* If client canceled the lock but the cancel has not
* been recieved yet, we need to update lvbo to have the
* proper attributes cached. */
if (rc == -EINVAL && arg->type == LDLM_BL_CALLBACK)
- ldlm_res_lvbo_update(lock->l_resource, NULL,
+ ldlm_res_lvbo_update(lock->l_resource, NULL,
0, 1);
- rc = ldlm_handle_ast_error(lock, req, rc,
+ rc = ldlm_handle_ast_error(lock, req, rc,
arg->type == LDLM_BL_CALLBACK
? "blocking" : "completion");
- }
+ }
LDLM_LOCK_PUT(lock);
} else {
LDLM_LOCK_GET(lock);
ptlrpc_set_add_req(arg->set, req);
- }
+ }
RETURN(rc);
}
if (AT_OFF)
req->rq_timeout = ldlm_get_rq_timeout();
- if (lock->l_export && lock->l_export->exp_ldlm_stats)
- lprocfs_counter_incr(lock->l_export->exp_ldlm_stats,
+ if (lock->l_export && lock->l_export->exp_nid_stats &&
+ lock->l_export->exp_nid_stats->nid_ldlm_stats)
+ lprocfs_counter_incr(lock->l_export->exp_nid_stats->nid_ldlm_stats,
LDLM_BL_CALLBACK - LDLM_FIRST_OPC);
rc = ldlm_bl_and_cp_ast_fini(req, arg, lock, instant_cancel);
}
unlock_res_and_lock(lock);
- if (lock->l_export && lock->l_export->exp_ldlm_stats)
- lprocfs_counter_incr(lock->l_export->exp_ldlm_stats,
+ if (lock->l_export && lock->l_export->exp_nid_stats &&
+ lock->l_export->exp_nid_stats->nid_ldlm_stats)
+ lprocfs_counter_incr(lock->l_export->exp_nid_stats->nid_ldlm_stats,
LDLM_CP_CALLBACK - LDLM_FIRST_OPC);
rc = ldlm_bl_and_cp_ast_fini(req, arg, lock, instant_cancel);
if (AT_OFF)
req->rq_timeout = ldlm_get_rq_timeout();
- if (lock->l_export && lock->l_export->exp_ldlm_stats)
- lprocfs_counter_incr(lock->l_export->exp_ldlm_stats,
+ if (lock->l_export && lock->l_export->exp_nid_stats &&
+ lock->l_export->exp_nid_stats->nid_ldlm_stats)
+ lprocfs_counter_incr(lock->l_export->exp_nid_stats->nid_ldlm_stats,
LDLM_GL_CALLBACK - LDLM_FIRST_OPC);
rc = ptlrpc_queue_wait(req);
ldlm_svc_get_eopc(dlm_req,
req->rq_rqbd->rqbd_service->srv_stats);
- if (req->rq_export->exp_ldlm_stats)
- lprocfs_counter_incr(req->rq_export->exp_ldlm_stats,
+ if (req->rq_export && req->rq_export->exp_nid_stats &&
+ req->rq_export->exp_nid_stats->nid_ldlm_stats)
+ lprocfs_counter_incr(req->rq_export->exp_nid_stats->nid_ldlm_stats,
LDLM_ENQUEUE - LDLM_FIRST_OPC);
if (unlikely(dlm_req->lock_desc.l_resource.lr_type < LDLM_MIN_TYPE ||
if (lock->l_export->exp_lock_hash)
lustre_hash_add(lock->l_export->exp_lock_hash,
- &lock->l_remote_handle,
+ &lock->l_remote_handle,
&lock->l_exp_hash);
existing_lock:
int rc;
ENTRY;
- if (req->rq_export && req->rq_export->exp_ldlm_stats)
- lprocfs_counter_incr(req->rq_export->exp_ldlm_stats,
+ if (req->rq_export && req->rq_export->exp_nid_stats &&
+ req->rq_export->exp_nid_stats->nid_ldlm_stats)
+ lprocfs_counter_incr(req->rq_export->exp_nid_stats->nid_ldlm_stats,
LDLM_CONVERT - LDLM_FIRST_OPC);
rc = req_capsule_server_pack(&req->rq_pill);
RETURN(-EFAULT);
}
- if (req->rq_export && req->rq_export->exp_ldlm_stats)
- lprocfs_counter_incr(req->rq_export->exp_ldlm_stats,
+ if (req->rq_export && req->rq_export->exp_nid_stats &&
+ req->rq_export->exp_nid_stats->nid_ldlm_stats)
+ lprocfs_counter_incr(req->rq_export->exp_nid_stats->nid_ldlm_stats,
LDLM_CANCEL - LDLM_FIRST_OPC);
rc = req_capsule_server_pack(&req->rq_pill);
&lock->l_resource->lr_name,
sizeof(lock->l_resource->lr_name)) != 0) {
unlock_res_and_lock(lock);
- if (ldlm_lock_change_resource(ns, lock,
+ if (ldlm_lock_change_resource(ns, lock,
&dlm_req->lock_desc.l_resource.lr_name) != 0) {
LDLM_ERROR(lock, "Failed to allocate resource");
LDLM_LOCK_PUT(lock);
EXIT;
}
-/*
- * Export handle<->lock hash operations.
+/*
+ * Export handle<->lock hash operations.
*/
static unsigned
ldlm_export_lock_hash(lustre_hash_t *lh, void *key, unsigned mask)
#endif
ENTRY;
- if (!list_empty(ldlm_namespace_list(LDLM_NAMESPACE_SERVER)) ||
+ if (!list_empty(ldlm_namespace_list(LDLM_NAMESPACE_SERVER)) ||
!list_empty(ldlm_namespace_list(LDLM_NAMESPACE_CLIENT))) {
CERROR("ldlm still has namespaces; clean these up first.\n");
ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE);
LASSERT(current->journal_info == NULL);
/*
- * Checking for various OBD_FAIL_$PREF_$OPC_NET codes. _Do_ not try
- * to put same checks into handlers like mdt_close(), mdt_reint(),
+ * Checking for various OBD_FAIL_$PREF_$OPC_NET codes. _Do_ not try
+ * to put same checks into handlers like mdt_close(), mdt_reint(),
* etc., without talking to mdt authors first. Checking same thing
* there again is useless and returning 0 error wihtout packing reply
* is buggy! Handlers either pack reply or return error.
RETURN(ELDLM_LOCK_REPLACED);
}
- /*
- * Fixup the lock to be given to the client.
+ /*
+ * Fixup the lock to be given to the client.
*/
lock_res_and_lock(new_lock);
new_lock->l_readers = 0;
new_lock->l_flags &= ~LDLM_FL_LOCAL;
lustre_hash_add(new_lock->l_export->exp_lock_hash,
- &new_lock->l_remote_handle,
+ &new_lock->l_remote_handle,
&new_lock->l_exp_hash);
unlock_res_and_lock(new_lock);
lhc->mlh_reg_lh.cookie = 0ull;
if (rc == -ENOTCONN || rc == -ENODEV) {
- /*
+ /*
* If it is the disconnect error (ENODEV & ENOCONN), the error
* will be returned by rq_status, and client at ptlrpc layer
* will detect this, then disconnect, reconnect the import
*/
RETURN(rc);
} else {
- /*
+ /*
* For other cases, the error will be returned by intent.
* and client will retrieve the result from intent.
- */
- /*
+ */
+ /*
* FIXME: when open lock is finished, that should be
* checked here.
*/
- RETURN(ELDLM_LOCK_ABORTED);
+ RETURN(ELDLM_LOCK_ABORTED);
}
}
if (mdt->mdt_namespace != NULL || exp->exp_obd->obd_namespace != NULL)
ldlm_cancel_locks_for_export(exp);
+ /* release nid stat refererence */
+ lprocfs_exp_cleanup(exp);
+
/* complete all outstanding replies */
spin_lock(&exp->exp_lock);
while (!list_empty(&exp->exp_outstanding_replies)) {
struct mgs_obd *mgs;
if (!obd)
- RETURN(-EINVAL);
+ return -EINVAL;
mgs = &obd->u.mgs;
if (mgs->mgs_proc_live) {
lprocfs_remove(&mgs->mgs_proc_live);
mgs->mgs_proc_live = NULL;
}
+ lprocfs_free_per_client_stats(obd);
lprocfs_free_obd_stats(obd);
return lprocfs_obd_cleanup(obd);
}
}
-static int mgs_live_seq_show(struct seq_file *seq, void *v)
+static int mgs_live_seq_show(struct seq_file *seq, void *v)
{
struct fs_db *fsdb = seq->private;
struct mgs_tgt_srpc_conf *srpc_tgt;
int i;
-
+
down(&fsdb->fsdb_sem);
seq_printf(seq, "fsname: %s\n", fsdb->fsdb_name);
- seq_printf(seq, "flags: %#x gen: %d\n",
+ seq_printf(seq, "flags: %#x gen: %d\n",
fsdb->fsdb_flags, fsdb->fsdb_gen);
for (i = 0; i < INDEX_MAP_SIZE * 8; i++)
- if (test_bit(i, fsdb->fsdb_mdt_index_map))
+ if (test_bit(i, fsdb->fsdb_mdt_index_map))
seq_printf(seq, "%s-MDT%04x\n", fsdb->fsdb_name, i);
for (i = 0; i < INDEX_MAP_SIZE * 8; i++)
- if (test_bit(i, fsdb->fsdb_ost_index_map))
+ if (test_bit(i, fsdb->fsdb_ost_index_map))
seq_printf(seq, "%s-OST%04x\n", fsdb->fsdb_name, i);
seq_printf(seq, "\nSecure RPC Config Rules:\n");
struct mgs_obd *mgs = &obd->u.mgs;
int rc;
- if (!mgs->mgs_proc_live)
+ if (!mgs->mgs_proc_live)
return 0;
- rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0444,
+ rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0444,
&mgs_live_fops, fsdb);
return 0;
{
struct mgs_obd *mgs = &obd->u.mgs;
- if (!mgs->mgs_proc_live)
+ if (!mgs->mgs_proc_live)
return 0;
lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live);
#include <libcfs/list.h>
#include "mgs_internal.h"
+static int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp,
+ void *localdata)
+{
+ lnet_nid_t *client_nid = localdata;
+ int rc, newnid;
+
+ rc = lprocfs_exp_setup(exp, client_nid, &newnid);
+ if (rc) {
+ /* Mask error for already created
+ * /proc entries */
+ if (rc == -EALREADY)
+ rc = 0;
+ return rc;
+ }
+
+ if (!obd->md_stats &&
+ lprocfs_alloc_md_stats(obd, LPROC_MGS_LAST))
+ return rc;
+ if (newnid) {
+ /* Always add in ldlm_stats */
+ exp->exp_nid_stats->nid_ldlm_stats =
+ lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC, 0);
+ if (exp->exp_nid_stats->nid_ldlm_stats == NULL)
+ return -ENOMEM;
+ lprocfs_init_ldlm_stats(exp->exp_nid_stats->nid_ldlm_stats);
+ rc = lprocfs_register_stats(exp->exp_nid_stats->nid_proc,
+ "ldlm_stats",
+ exp->exp_nid_stats->nid_ldlm_stats);
+ }
+ return rc;
+}
+
+/**
+ * Add client export data to the MGS. This data is currently NOT stored on
+ * disk in the last_rcvd file or anywhere else. In the event of a MGS
+ * crash all connections are treated as new connections.
+ */
+int mgs_client_add(struct obd_device *obd, struct obd_export *exp,
+ void *localdata)
+{
+ return mgs_export_stats_init(obd, exp, localdata);
+}
+
+/* Remove client export data from the MGS */
+int mgs_client_free(struct obd_export *exp)
+{
+ return 0;
+}
+
/* Same as mds_fid2dentry */
/* Look up an entry by inode number. */
/* this function ONLY returns valid dget'd dentries with an initialized inode
if (ino == 0)
RETURN(ERR_PTR(-ESTALE));
-
+
snprintf(fid_name, sizeof(fid_name), "0x%lx", (unsigned long)ino);
-
+
/* under ext3 this is neither supposed to return bad inodes nor NULL
inodes. */
result = ll_lookup_one_len(fid_name, mgs->mgs_fid_de, strlen(fid_name));
dentry = simple_mkdir(current->fs->pwd, mnt, MOUNT_CONFIGS_DIR, 0777, 1);
if (IS_ERR(dentry)) {
rc = PTR_ERR(dentry);
- CERROR("cannot create %s directory: rc = %d\n",
+ CERROR("cannot create %s directory: rc = %d\n",
MOUNT_CONFIGS_DIR, rc);
GOTO(err_pop, rc);
}
data->ocd_version = LUSTRE_VERSION_CODE;
}
+ rc = mgs_client_add(obd, exp, localdata);
+
if (rc) {
class_disconnect(exp);
} else {
if (exp == NULL || obd == NULL || cluuid == NULL)
RETURN(-EINVAL);
+ mgs_counter_incr(exp, LPROC_MGS_CONNECT);
+
if (data != NULL) {
data->ocd_connect_flags &= MGS_CONNECT_SUPPORTED;
exp->exp_connect_flags = data->ocd_connect_flags;
}
mti->mti_flags |= LDD_F_UPDATE;
/* Erased logs means start from scratch. */
- mti->mti_flags &= ~LDD_F_UPGRADE14;
+ mti->mti_flags &= ~LDD_F_UPGRADE14;
}
/* COMPAT_146 */
CERROR("Can't upgrade from 1.4 (%d)\n", rc);
GOTO(out, rc);
}
-
+
/* We're good to go */
mti->mti_flags |= LDD_F_UPDATE;
}
ENTRY;
target_destroy_export(exp);
+ mgs_client_free(exp);
ldlm_destroy_export(exp);
RETURN(0);
RETURN(0);
}
-static int mgs_iocontrol_pool(struct obd_device *obd,
+static int mgs_iocontrol_pool(struct obd_device *obd,
struct obd_ioctl_data *data)
{
int rc;
/* mgs_llog.c */
int class_dentry_readdir(struct obd_device *obd, struct dentry *dir,
- struct vfsmount *inmnt,
+ struct vfsmount *inmnt,
struct list_head *dentry_list);
-
+
struct mgs_tgt_srpc_conf {
struct mgs_tgt_srpc_conf *mtsc_next;
char *mtsc_tgt;
char *poolname, char *fsname, char *ostname);
/* mgs_fs.c */
+int mgs_client_add(struct obd_device *obd, struct obd_export *exp,
+ void *localdata);
+int mgs_client_free(struct obd_export *exp);
int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt);
int mgs_fs_cleanup(struct obd_device *obddev);
int lproc_mgs_del_live(struct obd_device *obd, struct fs_db *fsdb);
void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars);
#else
-static inline int lproc_mgs_setup(struct obd_device *dev)
+static inline int lproc_mgs_setup(struct obd_device *dev)
{return 0;}
static inline int lproc_mgs_cleanup(struct obd_device *obd)
{return 0;}
if (client_stat->nid_brw_stats)
OBD_FREE(client_stat->nid_brw_stats, sizeof(struct brw_stats));
+ if (client_stat->nid_ldlm_stats)
+ lprocfs_free_stats(&client_stat->nid_ldlm_stats);
+
OBD_FREE(client_stat, sizeof(*client_stat));
return;
LASSERT(obd->obd_proc_entry != NULL);
LASSERT(obd->md_cntr_base == 0);
- num_stats = 1 + MD_COUNTER_OFFSET(get_remote_perm) +
+ num_stats = 1 + MD_COUNTER_OFFSET(revalidate_lock) +
num_private_stats;
stats = lprocfs_alloc_stats(num_stats, 0);
if (stats == NULL)
}
}
+void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
+{
+ lprocfs_counter_init(ldlm_stats,
+ LDLM_ENQUEUE - LDLM_FIRST_OPC,
+ 0, "ldlm_enqueue", "reqs");
+ lprocfs_counter_init(ldlm_stats,
+ LDLM_CONVERT - LDLM_FIRST_OPC,
+ 0, "ldlm_convert", "reqs");
+ lprocfs_counter_init(ldlm_stats,
+ LDLM_CANCEL - LDLM_FIRST_OPC,
+ 0, "ldlm_cancel", "reqs");
+ lprocfs_counter_init(ldlm_stats,
+ LDLM_BL_CALLBACK - LDLM_FIRST_OPC,
+ 0, "ldlm_bl_callback", "reqs");
+ lprocfs_counter_init(ldlm_stats,
+ LDLM_CP_CALLBACK - LDLM_FIRST_OPC,
+ 0, "ldlm_cp_callback", "reqs");
+ lprocfs_counter_init(ldlm_stats,
+ LDLM_GL_CALLBACK - LDLM_FIRST_OPC,
+ 0, "ldlm_gl_callback", "reqs");
+}
+
int lprocfs_exp_rd_nid(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
{
struct nid_stat *stat = obj;
int i;
-
+ ENTRY;
/* object has only hash + iterate_all references.
* add/delete blocked by hash bucket lock */
CDEBUG(D_INFO,"refcnt %d\n", stat->nid_exp_ref_count);
- if(stat->nid_exp_ref_count == 2) {
+ if (stat->nid_exp_ref_count == 2) {
hlist_del_init(&stat->nid_hash);
stat->nid_exp_ref_count--;
spin_lock(&stat->nid_obd->obd_nid_lock);
- list_del_init(&stat->nid_list);
+ list_move(&stat->nid_list, data);
spin_unlock(&stat->nid_obd->obd_nid_lock);
- list_add(&stat->nid_list, data);
EXIT;
return;
}
int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
{
- int rc = 0;
- struct nid_stat *tmp = NULL, *tmp1;
+ struct nid_stat *new_stat, *old_stat;
+ struct nid_stat_uuid *new_ns_uuid;
struct obd_device *obd = NULL;
cfs_proc_dir_entry_t *entry;
+ int rc = 0;
ENTRY;
*newnid = 0;
RETURN(-EINVAL);
/* not test against zero because eric say:
- * You may only test nid against another nid, or LNET_NID_ANY. Anything else is
- * nonsense.*/
+ * You may only test nid against another nid, or LNET_NID_ANY.
+ * Anything else is nonsense.*/
if (!nid || *nid == LNET_NID_ANY)
RETURN(0);
CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash);
- OBD_ALLOC(tmp, sizeof(struct nid_stat));
- if (tmp == NULL)
+ OBD_ALLOC(new_stat, sizeof(struct nid_stat));
+ if (new_stat == NULL)
+ RETURN(-ENOMEM);
+
+ OBD_ALLOC(new_ns_uuid, sizeof(struct nid_stat_uuid));
+ if (new_ns_uuid == NULL) {
+ OBD_FREE(new_stat, sizeof(struct nid_stat));
RETURN(-ENOMEM);
+ }
+ CFS_INIT_LIST_HEAD(&new_ns_uuid->ns_uuid_list);
+ strncpy(new_ns_uuid->ns_uuid.uuid, exp->exp_client_uuid.uuid,
+ sizeof(struct obd_uuid));
- tmp->nid = *nid;
- tmp->nid_obd = exp->exp_obd;
- tmp->nid_exp_ref_count = 1; /* need live in hash after destroy export */
+ CFS_INIT_LIST_HEAD(&new_stat->nid_uuid_list);
+ new_stat->nid = *nid;
+ new_stat->nid_obd = exp->exp_obd;
+ new_stat->nid_exp_ref_count = 1; /* live in hash after destroy export */
/* protect competitive add to list, not need locking on destroy */
spin_lock(&obd->obd_nid_lock);
- list_add(&tmp->nid_list, &obd->obd_nid_stats);
+ list_add(&new_stat->nid_list, &obd->obd_nid_stats);
spin_unlock(&obd->obd_nid_lock);
- tmp1 = lustre_hash_findadd_unique(obd->obd_nid_stats_hash,
- nid, &tmp->nid_hash);
+ old_stat = lustre_hash_findadd_unique(obd->obd_nid_stats_hash,
+ nid, &new_stat->nid_hash);
CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n",
- tmp1, libcfs_nid2str(*nid), tmp->nid_exp_ref_count);
+ old_stat, libcfs_nid2str(*nid), new_stat->nid_exp_ref_count);
+
+ /* Return -EALREADY here so that we know that the /proc
+ * entry already has been created */
+ if (old_stat != new_stat) {
+ struct nid_stat_uuid *tmp_uuid;
+ int found = 0;
+
+ exp->exp_nid_stats = old_stat;
+ /* We need to decrement the refcount if the uuid was
+ * already in our list */
+ spin_lock(&obd->obd_nid_lock);
+ list_for_each_entry(tmp_uuid, &old_stat->nid_uuid_list,
+ ns_uuid_list) {
+ if (tmp_uuid && obd_uuid_equals(&tmp_uuid->ns_uuid,
+ &exp->exp_client_uuid)){
+ found = 1;
+ --old_stat->nid_exp_ref_count;
+ break;
+ }
+ }
+
+ if (!found)
+ list_add(&new_ns_uuid->ns_uuid_list,
+ &old_stat->nid_uuid_list);
+ else
+ OBD_FREE(new_ns_uuid, sizeof(struct nid_stat));
- if (tmp1 != tmp) {
- exp->exp_nid_stats = tmp1;
- GOTO(destroy_new, rc = 0);
+ spin_unlock(&obd->obd_nid_lock);
+
+ GOTO(destroy_new, rc = -EALREADY);
}
/* not found - create */
- tmp->nid_proc = lprocfs_register(libcfs_nid2str(*nid),
- obd->obd_proc_exports_entry, NULL, NULL);
- if (!tmp->nid_proc) {
- CERROR("Error making export directory for"
- " nid %s\n", libcfs_nid2str(*nid));
- lustre_hash_del(obd->obd_nid_stats_hash, nid, &tmp->nid_hash);
+ new_stat->nid_proc = lprocfs_register(libcfs_nid2str(*nid),
+ obd->obd_proc_exports_entry,
+ NULL, NULL);
+ if (new_stat->nid_proc == NULL) {
+ CERROR("Error making export directory for nid %s\n",
+ libcfs_nid2str(*nid));
+ lustre_hash_del(obd->obd_nid_stats_hash, nid,
+ &new_stat->nid_hash);
GOTO(destroy_new, rc = -ENOMEM);
}
- entry = lprocfs_add_simple(tmp->nid_proc, "uuid",
- lprocfs_exp_rd_uuid, NULL, tmp, NULL);
+ /* Add in uuid to our nid_stats list */
+ spin_lock(&obd->obd_nid_lock);
+ list_add(&new_ns_uuid->ns_uuid_list, &new_stat->nid_uuid_list);
+ spin_unlock(&obd->obd_nid_lock);
+
+ entry = lprocfs_add_simple(new_stat->nid_proc, "uuid",
+ lprocfs_exp_rd_uuid, NULL, new_stat, NULL);
if (IS_ERR(entry)) {
- CWARN("Error adding the uuid file\n");
+ CWARN("Error adding the NID stats file\n");
rc = PTR_ERR(entry);
}
- entry = lprocfs_add_simple(tmp->nid_proc, "hash",
- lprocfs_exp_rd_hash, NULL, tmp, NULL);
+ entry = lprocfs_add_simple(new_stat->nid_proc, "hash",
+ lprocfs_exp_rd_hash, NULL, new_stat, NULL);
if (IS_ERR(entry)) {
CWARN("Error adding the hash file\n");
rc = PTR_ERR(entry);
}
- exp->exp_nid_stats = tmp;
+ exp->exp_nid_stats = new_stat;
*newnid = 1;
RETURN(rc);
destroy_new:
spin_lock(&obd->obd_nid_lock);
- list_del(&tmp->nid_list);
+ list_del(&new_stat->nid_list);
spin_unlock(&obd->obd_nid_lock);
- OBD_FREE(tmp, sizeof(struct nid_stat));
+ OBD_FREE(new_stat, sizeof(struct nid_stat));
RETURN(rc);
}
int lprocfs_exp_cleanup(struct obd_export *exp)
{
struct nid_stat *stat = exp->exp_nid_stats;
+ struct nid_stat_uuid *cursor, *tmp;
+ int found = 0;
- if(!stat)
+ if(!stat || !exp->exp_obd)
RETURN(0);
+ spin_lock(&exp->exp_obd->obd_nid_lock);
+ list_for_each_entry_safe(cursor, tmp,
+ &stat->nid_uuid_list,
+ ns_uuid_list) {
+ if (cursor && obd_uuid_equals(&cursor->ns_uuid,
+ &exp->exp_client_uuid)) {
+ found = 1;
+ list_del(&cursor->ns_uuid_list);
+ OBD_FREE(cursor, sizeof(struct nid_stat_uuid));
+ break;
+ }
+ }
+ spin_unlock(&exp->exp_obd->obd_nid_lock);
+ if (!found)
+ CERROR("obd_export's client uuid %s are not found in its "
+ "nid_stats list\n", exp->exp_client_uuid.uuid);
+
stat->nid_exp_ref_count--;
CDEBUG(D_INFO, "Put stat %p - %d\n", stat, stat->nid_exp_ref_count);
exp->exp_nid_stats = NULL;
+ lprocfs_free_md_stats(exp->exp_obd);
+
return 0;
}
EXPORT_SYMBOL(lprocfs_clear_stats);
EXPORT_SYMBOL(lprocfs_register_stats);
EXPORT_SYMBOL(lprocfs_init_ops_stats);
+EXPORT_SYMBOL(lprocfs_init_ldlm_stats);
EXPORT_SYMBOL(lprocfs_alloc_obd_stats);
+EXPORT_SYMBOL(lprocfs_alloc_md_stats);
EXPORT_SYMBOL(lprocfs_free_obd_stats);
EXPORT_SYMBOL(lprocfs_exp_setup);
EXPORT_SYMBOL(lprocfs_exp_cleanup);
err = -EINVAL;
} else {
if (!force_sync)
- force_sync = fsfilt_add_journal_cb(exp->exp_obd,
+ force_sync = fsfilt_add_journal_cb(exp->exp_obd,
last_rcvd,
oti->oti_handle,
filter_commit_cb,
struct filter_export_data *fed = &exp->exp_filter_data;
unsigned long *bitmap = filter->fo_last_rcvd_slots;
int new_client = (cl_idx == -1);
-
+
ENTRY;
LASSERT(bitmap != NULL);
RETURN(PTR_ERR(dentry));
}
} else {
- dentry = simple_mkdir(filter->fo_dentry_O, filter->fo_vfsmnt,
+ dentry = simple_mkdir(filter->fo_dentry_O, filter->fo_vfsmnt,
name, 0700, 1);
if (IS_ERR(dentry)) {
CERROR("cannot lookup/create O/%s: rc = %ld\n", name,
char dir[20];
snprintf(dir, sizeof(dir), "d%u", i);
- tmp_subdirs->dentry[i] = simple_mkdir(dentry,
+ tmp_subdirs->dentry[i] = simple_mkdir(dentry,
filter->fo_vfsmnt,
dir, 0700, 1);
if (IS_ERR(tmp_subdirs->dentry[i])) {
loff_t off = 0;
ENTRY;
- O_dentry = simple_mkdir(current->fs->pwd, filter->fo_vfsmnt,
+ O_dentry = simple_mkdir(current->fs->pwd, filter->fo_vfsmnt,
"O", 0700, 1);
CDEBUG(D_INODE, "got/created O: %p\n", O_dentry);
if (IS_ERR(O_dentry)) {
if (tree->lit_mode == LCK_PR)
continue;
- interval_iterate_reverse(tree->lit_root,
+ interval_iterate_reverse(tree->lit_root,
filter_intent_cb, &arg);
}
unlock_res(res);
RETURN(rc);
}
-static int
+static int
filter_olg_init(struct obd_device *obd, struct obd_llog_group *olg,
struct obd_device *tgt)
{
/**
* Init the default olg, which is embeded in the obd_device, for filter.
*/
-static int
+static int
filter_default_olg_init(struct obd_device *obd, struct obd_llog_group *olg,
struct obd_device *tgt)
{
ctxt = llog_group_get_ctxt(olg, LLOG_MDS_OST_REPL_CTXT);
if (!ctxt) {
- CERROR("Can't get ctxt for %p:%x\n", olg,
+ CERROR("Can't get ctxt for %p:%x\n", olg,
LLOG_MDS_OST_REPL_CTXT);
GOTO(cleanup_olg, rc = -ENODEV);
}
filter->fo_lcm = NULL;
return rc;
}
-
-static int
+
+static int
filter_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
struct obd_device *tgt, int count, struct llog_catid *catid,
struct obd_uuid *uuid)
RETURN(rc);
ctxt = llog_group_get_ctxt(olg, LLOG_MDS_OST_REPL_CTXT);
if (!ctxt) {
- CERROR("Can't get ctxt for %p:%x\n", olg,
+ CERROR("Can't get ctxt for %p:%x\n", olg,
LLOG_MDS_OST_REPL_CTXT);
filter_olg_fini(olg);
RETURN(-ENODEV);
struct filter_obd *filter = &obd->u.filter;
struct llog_ctxt *ctxt;
ENTRY;
-
+
ctxt = llog_group_get_ctxt(&obd->obd_olg, LLOG_MDS_OST_REPL_CTXT);
LASSERT(ctxt != NULL);
mutex_down(&ctxt->loc_sem);
olg = filter_find_olg_internal(filter, group);
spin_unlock(&filter->fo_llog_list_lock);
- RETURN(olg);
+ RETURN(olg);
}
/**
* Find the llog_group of the filter according to the group. If it can not
- * find, create the llog_group, which only happens when mds is being synced
+ * find, create the llog_group, which only happens when mds is being synced
* with OST.
*/
struct obd_llog_group *filter_find_create_olg(struct obd_device *obd, int group)
olg = filter_find_olg(obd, body->lgdc_logid.lgl_ogr);
if (!olg) {
CERROR(" %s: can not find olg of group %d\n",
- obd->obd_name, (int)body->lgdc_logid.lgl_ogr);
+ obd->obd_name, (int)body->lgdc_logid.lgl_ogr);
RETURN(-ENOENT);
}
llog_group_set_export(olg, exp);
list_add(&olg->olg_list, &remove_list);
}
spin_unlock(&filter->fo_llog_list_lock);
-
- list_for_each_entry_safe(olg, tmp, &remove_list, olg_list) {
+
+ list_for_each_entry_safe(olg, tmp, &remove_list, olg_list) {
list_del_init(&olg->olg_list);
rc = filter_olg_fini(olg);
if (rc)
llog_ctxt_put(ctxt);
if (err)
CERROR("error flushing logs to MDS: rc %d\n",
- err);
+ err);
}
} while (olg_min != NULL);
}
/* This would be very bad - accidentally truncating a file when
* changing the time or similar - bug 12203. */
- if (oinfo->oi_oa->o_valid & OBD_MD_FLSIZE &&
+ if (oinfo->oi_oa->o_valid & OBD_MD_FLSIZE &&
oinfo->oi_policy.l_extent.end != OBD_OBJECT_EOF) {
static char mdsinum[48];
CWARN("%s: deleting orphan objects from "LPU64" to "LPU64"\n",
exp->exp_obd->obd_name, oa->o_id + 1, last);
-
+
for (id = last; id > oa->o_id; id--) {
doa.o_id = id;
rc = filter_destroy(exp, &doa, NULL, NULL, NULL);
rc = -EAGAIN;
break;
}
-
+
if (recreate_obj) {
__u64 last_id;
next_id = oa->o_id;
filter_cancel_cookies_cb,
fcc);
/* If add_journal_cb failed, then filter_finish_transno
- * will commit the handle and we will do a sync
- * on commit. then we call callback directly to free
- * the fcc.
+ * will commit the handle and we will do a sync
+ * on commit. then we call callback directly to free
+ * the fcc.
*/
rc = filter_finish_transno(exp, oti, rc, sync);
if (sync) {
- filter_cancel_cookies_cb(obd, 0, fcc, rc);
+ filter_cancel_cookies_cb(obd, 0, fcc, rc);
fcc = NULL;
}
rc2 = fsfilt_commit(obd, dparent->d_inode, handle, 0);
RETURN(PTR_ERR(olg));
llog_group_set_export(olg, exp);
-
+
ctxt = llog_group_get_ctxt(olg, LLOG_MDS_OST_REPL_CTXT);
LASSERTF(ctxt != NULL, "ctxt is null\n"),