-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* Author: Yury Umanets <umka@clusterfs.com>
*/
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
#define DEBUG_SUBSYSTEM S_FID
#ifdef __KERNEL__
#include <obd.h>
#include <obd_class.h>
-#include <lu_target.h>
#include <dt_object.h>
#include <md_object.h>
#include <obd_support.h>
* Ask client for new range, assign that range to ->seq_space and write
* seq state to backing store should be atomic.
*/
- cfs_down(&seq->lss_sem);
+ mutex_lock(&seq->lss_mutex);
if (cli == NULL) {
CDEBUG(D_INFO, "%s: Detached sequence client %s\n",
seq->lss_name, cli->lcs_name);
seq->lss_cli = cli;
- cli->lcs_space.lsr_mdt = seq->lss_site->ms_node_id;
+ cli->lcs_space.lsr_index = seq->lss_site->ms_node_id;
EXIT;
out_up:
- cfs_up(&seq->lss_sem);
+ mutex_unlock(&seq->lss_mutex);
return rc;
}
EXPORT_SYMBOL(seq_server_set_cli);
struct lu_seq_range *out,
const struct lu_env *env)
{
- struct lu_seq_range *space = &seq->lss_space;
- int rc;
- ENTRY;
+ struct lu_seq_range *space = &seq->lss_space;
+ int rc;
+ ENTRY;
- LASSERT(range_is_sane(space));
+ LASSERT(range_is_sane(space));
- if (range_is_exhausted(space)) {
- CERROR("%s: Sequences space is exhausted\n",
- seq->lss_name);
- RETURN(-ENOSPC);
- } else {
- range_alloc(out, space, seq->lss_width);
- }
+ if (range_is_exhausted(space)) {
+ CERROR("%s: Sequences space is exhausted\n",
+ seq->lss_name);
+ RETURN(-ENOSPC);
+ } else {
+ range_alloc(out, space, seq->lss_width);
+ }
- rc = seq_store_update(env, seq, out, 1 /* sync */);
+ rc = seq_store_update(env, seq, out, 1 /* sync */);
- CDEBUG(D_INFO, "%s: super-sequence allocation rc = %d "
- DRANGE"\n", seq->lss_name, rc, PRANGE(out));
+ LCONSOLE_INFO("%s: super-sequence allocation rc = %d " DRANGE"\n",
+ seq->lss_name, rc, PRANGE(out));
- RETURN(rc);
+ RETURN(rc);
}
int seq_server_alloc_super(struct lu_server_seq *seq,
int rc;
ENTRY;
- cfs_down(&seq->lss_sem);
+ mutex_lock(&seq->lss_mutex);
rc = __seq_server_alloc_super(seq, out, env);
- cfs_up(&seq->lss_sem);
+ mutex_unlock(&seq->lss_mutex);
RETURN(rc);
}
range_alloc(&seq->lss_hiwater_set, space, seq->lss_set_width);
rc = seq_store_update(env, seq, NULL, 1);
- seq->lss_set_transno = 0;
return rc;
}
if (range_is_exhausted(loset)) {
/* reached high water mark. */
- struct lu_device *dev = seq->lss_site->ms_lu.ls_top_dev;
- struct lu_target *tg = dev->ld_obd->u.obt.obt_lut;
+ struct lu_device *dev = seq->lss_site->ms_lu->ls_top_dev;
int obd_num_clients = dev->ld_obd->obd_num_exports;
__u64 set_sz;
- int sync = 0;
/* calculate new seq width based on number of clients */
set_sz = max(seq->lss_set_width,
- obd_num_clients * seq->lss_width);
+ obd_num_clients * seq->lss_width);
set_sz = min(range_space(space), set_sz);
/* Switch to hiwater range now */
- loset = hiset;
+ *loset = *hiset;
/* allocate new hiwater range */
range_alloc(hiset, space, set_sz);
- if (seq->lss_set_transno > dev->ld_obd->obd_last_committed)
- sync = 1;
-
/* update ondisk seq with new *space */
- rc = seq_store_update(env, seq, NULL, sync);
-
- /* set new hiwater transno */
- cfs_spin_lock(&tg->lut_translock);
- seq->lss_set_transno = tg->lut_last_transno;
- cfs_spin_unlock(&tg->lut_translock);
+ rc = seq_store_update(env, seq, NULL, seq->lss_need_sync);
}
LASSERTF(!range_is_exhausted(loset) || range_is_sane(loset),
struct lu_seq_range *out,
const struct lu_env *env)
{
- struct lu_seq_range *space = &seq->lss_space;
- int rc = 0;
-
- ENTRY;
-
- LASSERT(range_is_sane(space));
-
- /* Check if available space ends and allocate new super seq */
- if (range_is_exhausted(space)) {
- if (!seq->lss_cli) {
- CERROR("%s: No sequence controller is attached.\n",
- seq->lss_name);
- RETURN(-ENODEV);
- }
-
- rc = seq_client_alloc_super(seq->lss_cli, env);
- if (rc) {
- CERROR("%s: Can't allocate super-sequence, rc %d\n",
- seq->lss_name, rc);
- RETURN(rc);
- }
-
- /* Saving new range to allocation space. */
- *space = seq->lss_cli->lcs_space;
- LASSERT(range_is_sane(space));
- }
-
- rc = range_alloc_set(env, out, seq);
- if (rc == 0) {
- CDEBUG(D_INFO, "%s: Allocated meta-sequence "
- DRANGE"\n", seq->lss_name, PRANGE(out));
- }
-
- RETURN(rc);
+ struct lu_seq_range *space = &seq->lss_space;
+ int rc = 0;
+
+ ENTRY;
+
+ LASSERT(range_is_sane(space));
+
+ /* Check if available space ends and allocate new super seq */
+ if (range_is_exhausted(space)) {
+ if (!seq->lss_cli) {
+ CERROR("%s: No sequence controller is attached.\n",
+ seq->lss_name);
+ RETURN(-ENODEV);
+ }
+
+ rc = seq_client_alloc_super(seq->lss_cli, env);
+ if (rc) {
+ CERROR("%s: Can't allocate super-sequence, rc %d\n",
+ seq->lss_name, rc);
+ RETURN(rc);
+ }
+
+ /* Saving new range to allocation space. */
+ *space = seq->lss_cli->lcs_space;
+ LASSERT(range_is_sane(space));
+ }
+
+ rc = range_alloc_set(env, out, seq);
+ if (rc != 0) {
+ CERROR("%s: Allocated meta-sequence failed: rc = %d\n",
+ seq->lss_name, rc);
+ RETURN(rc);
+ }
+
+ CDEBUG(D_INFO, "%s: Allocated meta-sequence " DRANGE"\n",
+ seq->lss_name, PRANGE(out));
+
+ RETURN(rc);
}
int seq_server_alloc_meta(struct lu_server_seq *seq,
int rc;
ENTRY;
- cfs_down(&seq->lss_sem);
+ mutex_lock(&seq->lss_mutex);
rc = __seq_server_alloc_meta(seq, out, env);
- cfs_up(&seq->lss_sem);
+ mutex_unlock(&seq->lss_mutex);
RETURN(rc);
}
/* seq client passed mdt id, we need to pass that using out
* range parameter */
- out->lsr_mdt = tmp->lsr_mdt;
+ out->lsr_index = tmp->lsr_index;
+ out->lsr_flags = tmp->lsr_flags;
rc = seq_server_handle(site, env, *opc, out);
} else
rc = err_serious(-EPROTO);
LASSERT(dev != NULL);
LASSERT(prefix != NULL);
+ LASSERT(ms != NULL);
+ LASSERT(ms->ms_lu != NULL);
seq->lss_cli = NULL;
seq->lss_type = type;
range_init(&seq->lss_hiwater_set);
seq->lss_set_width = LUSTRE_SEQ_BATCH_WIDTH;
- cfs_sema_init(&seq->lss_sem, 1);
+ mutex_init(&seq->lss_mutex);
seq->lss_width = is_srv ?
LUSTRE_SEQ_META_WIDTH : LUSTRE_SEQ_SUPER_WIDTH;
LUSTRE_SEQ_ZERO_RANGE:
LUSTRE_SEQ_SPACE_RANGE;
- seq->lss_space.lsr_mdt = ms->ms_node_id;
- CDEBUG(D_INFO, "%s: No data found "
- "on store. Initialize space\n",
- seq->lss_name);
+ seq->lss_space.lsr_index = ms->ms_node_id;
+ LCONSOLE_INFO("%s: No data found "
+ "on store. Initialize space\n",
+ seq->lss_name);
rc = seq_store_update(env, seq, NULL, 0);
if (rc) {
cfs_proc_dir_entry_t *seq_type_proc_dir = NULL;
-static struct lu_local_obj_desc llod_seq_srv = {
- .llod_name = LUSTRE_SEQ_SRV_NAME,
- .llod_oid = FID_SEQ_SRV_OID,
- .llod_is_index = 0,
-};
-
-static struct lu_local_obj_desc llod_seq_ctl = {
- .llod_name = LUSTRE_SEQ_CTL_NAME,
- .llod_oid = FID_SEQ_CTL_OID,
- .llod_is_index = 0,
-};
-
static int __init fid_mod_init(void)
{
seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ_NAME,
if (IS_ERR(seq_type_proc_dir))
return PTR_ERR(seq_type_proc_dir);
- llo_local_obj_register(&llod_seq_srv);
- llo_local_obj_register(&llod_seq_ctl);
-
LU_CONTEXT_KEY_INIT(&seq_thread_key);
lu_context_key_register(&seq_thread_key);
return 0;
static void __exit fid_mod_exit(void)
{
- llo_local_obj_unregister(&llod_seq_srv);
- llo_local_obj_unregister(&llod_seq_ctl);
-
lu_context_key_degister(&seq_thread_key);
if (seq_type_proc_dir != NULL && !IS_ERR(seq_type_proc_dir)) {
lprocfs_remove(&seq_type_proc_dir);