#endif
#include <obd_support.h>
+#include <lustre_ioctl.h>
#include <lustre_lib.h>
#include <lustre_net.h>
#include <lustre/lustre_idl.h>
Any function that expects lov_tgts to remain stationary must take a ref. */
static void lov_getref(struct obd_device *obd)
{
- struct lov_obd *lov = &obd->u.lov;
+ struct lov_obd *lov = &obd->u.lov;
- /* nobody gets through here until lov_putref is done */
+ /* nobody gets through here until lov_putref is done */
mutex_lock(&lov->lov_lock);
- cfs_atomic_inc(&lov->lov_refcount);
+ atomic_inc(&lov->lov_refcount);
mutex_unlock(&lov->lov_lock);
- return;
+ return;
}
static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt);
static void lov_putref(struct obd_device *obd)
{
- struct lov_obd *lov = &obd->u.lov;
+ struct lov_obd *lov = &obd->u.lov;
mutex_lock(&lov->lov_lock);
- /* ok to dec to 0 more than once -- ltd_exp's will be null */
- if (cfs_atomic_dec_and_test(&lov->lov_refcount) && lov->lov_death_row) {
- CFS_LIST_HEAD(kill);
- int i;
- struct lov_tgt_desc *tgt, *n;
- CDEBUG(D_CONFIG, "destroying %d lov targets\n",
- lov->lov_death_row);
- for (i = 0; i < lov->desc.ld_tgt_count; i++) {
+ /* ok to dec to 0 more than once -- ltd_exp's will be null */
+ if (atomic_dec_and_test(&lov->lov_refcount) && lov->lov_death_row) {
+ struct list_head kill = LIST_HEAD_INIT(kill);
+ struct lov_tgt_desc *tgt, *n;
+ int i;
+
+ CDEBUG(D_CONFIG, "destroying %d lov targets\n",
+ lov->lov_death_row);
+ for (i = 0; i < lov->desc.ld_tgt_count; i++) {
tgt = lov->lov_tgts[i];
if (!tgt || !tgt->ltd_reap)
int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
struct obd_connect_data *data)
{
- struct lov_obd *lov = &obd->u.lov;
- struct obd_uuid *tgt_uuid;
- struct obd_device *tgt_obd;
- static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
- struct obd_import *imp;
-#ifdef __KERNEL__
- struct proc_dir_entry *lov_proc_dir;
-#endif
- int rc;
- ENTRY;
+ struct lov_obd *lov = &obd->u.lov;
+ struct obd_uuid *tgt_uuid;
+ struct obd_device *tgt_obd;
+ static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
+ struct obd_import *imp;
+ int rc;
+ ENTRY;
- if (!lov->lov_tgts[index])
- RETURN(-EINVAL);
+ if (lov->lov_tgts[index] == NULL)
+ RETURN(-EINVAL);
tgt_uuid = &lov->lov_tgts[index]->ltd_uuid;
tgt_obd = lov->lov_tgts[index]->ltd_obd;
CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index,
obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in");
-#ifdef __KERNEL__
- lov_proc_dir = obd->obd_proc_private;
- if (lov_proc_dir) {
- struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd;
+ if (obd->obd_type->typ_procsym != NULL) {
struct proc_dir_entry *osc_symlink;
-
- LASSERT(osc_obd != NULL);
- LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC);
- LASSERT(osc_obd->obd_type->typ_name != NULL);
-
- osc_symlink = lprocfs_add_symlink(osc_obd->obd_name,
- lov_proc_dir,
- "../../../%s/%s",
- osc_obd->obd_type->typ_name,
- osc_obd->obd_name);
- if (osc_symlink == NULL) {
- CERROR("could not register LOV target "
- "/proc/fs/lustre/%s/%s/target_obds/%s.",
- obd->obd_type->typ_name, obd->obd_name,
- osc_obd->obd_name);
- lprocfs_remove(&lov_proc_dir);
- obd->obd_proc_private = NULL;
+ struct obd_device *osc_obd;
+
+ osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd;
+
+ LASSERT(osc_obd != NULL);
+ LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC);
+ LASSERT(osc_obd->obd_type->typ_name != NULL);
+
+ osc_symlink = lprocfs_add_symlink(osc_obd->obd_name,
+ obd->obd_type->typ_procsym,
+ "../../../%s/%s",
+ osc_obd->obd_type->typ_name,
+ osc_obd->obd_name);
+ if (osc_symlink == NULL) {
+ CERROR("could not register LOV target "
+ "/proc/fs/lustre/%s/%s/target_obds/%s.",
+ obd->obd_type->typ_name, obd->obd_name,
+ osc_obd->obd_name);
+ lprocfs_remove(&obd->obd_type->typ_procsym);
}
}
-#endif
-
RETURN(0);
}
if (data)
lov->lov_ocd = *data;
+ obd->obd_type->typ_procsym = lprocfs_seq_register("target_obds",
+ obd->obd_proc_entry,
+ NULL, NULL);
+ if (IS_ERR(obd->obd_type->typ_procsym)) {
+ CERROR("%s: could not register /proc/fs/lustre/%s/%s/target_obds.",
+ obd->obd_name, obd->obd_type->typ_name, obd->obd_name);
+ obd->obd_type->typ_procsym = NULL;
+ }
+
obd_getref(obd);
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
tgt = lov->lov_tgts[i];
static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
{
- struct proc_dir_entry *lov_proc_dir;
struct lov_obd *lov = &obd->u.lov;
struct obd_device *osc_obd;
int rc;
tgt->ltd_exp->exp_obd->obd_inactive = 1;
}
- lov_proc_dir = obd->obd_proc_private;
- if (lov_proc_dir)
- lprocfs_remove_proc_entry(osc_obd->obd_name, lov_proc_dir);
+ if (osc_obd) {
+ /* Pass it on to our clients.
+ * XXX This should be an argument to disconnect,
+ * XXX not a back-door flag on the OBD. Ah well.
+ */
+ osc_obd->obd_force = obd->obd_force;
+ osc_obd->obd_fail = obd->obd_fail;
+ osc_obd->obd_no_recov = obd->obd_no_recov;
- if (osc_obd) {
- /* Pass it on to our clients.
- * XXX This should be an argument to disconnect,
- * XXX not a back-door flag on the OBD. Ah well.
- */
- osc_obd->obd_force = obd->obd_force;
- osc_obd->obd_fail = obd->obd_fail;
- osc_obd->obd_no_recov = obd->obd_no_recov;
- }
+ if (obd->obd_type->typ_procsym)
+ lprocfs_remove_proc_entry(osc_obd->obd_name,
+ obd->obd_type->typ_procsym);
+ }
obd_register_observer(osc_obd, NULL);
}
obd_putref(obd);
+ if (obd->obd_type->typ_procsym)
+ lprocfs_remove(&obd->obd_type->typ_procsym);
+
out:
rc = class_disconnect(exp); /* bz 9811 */
RETURN(rc);
{
struct lov_desc *desc;
struct lov_obd *lov = &obd->u.lov;
+#ifdef LPROCFS
+ struct obd_type *type;
+#endif
int rc;
ENTRY;
lov_fix_desc(desc);
- desc->ld_active_tgt_count = 0;
- lov->desc = *desc;
- lov->lov_tgt_size = 0;
+ desc->ld_active_tgt_count = 0;
+ lov->desc = *desc;
+ lov->lov_tgt_size = 0;
mutex_init(&lov->lov_lock);
- cfs_atomic_set(&lov->lov_refcount, 0);
- lov->lov_sp_me = LUSTRE_SP_CLI;
+ atomic_set(&lov->lov_refcount, 0);
+ lov->lov_sp_me = LUSTRE_SP_CLI;
init_rwsem(&lov->lov_notify_lock);
#ifdef LPROCFS
obd->obd_vars = lprocfs_lov_obd_vars;
- lprocfs_seq_obd_setup(obd);
- rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd", 0444,
- &lov_proc_target_fops, obd);
- if (rc)
- CWARN("Error adding the target_obd file\n");
+ /* If this is true then both client (lov) and server
+ * (lod) are on the same node. The lod layer if loaded
+ * first will register the lov proc directory. In that
+ * case obd->obd_type->typ_procroot will be not set.
+ * Instead we use type->typ_procsym as the parent. */
+ type = class_search_type(LUSTRE_LOD_NAME);
+ if (type != NULL && type->typ_procsym != NULL) {
+ obd->obd_proc_entry = lprocfs_seq_register(obd->obd_name,
+ type->typ_procsym,
+ obd->obd_vars, obd);
+ if (IS_ERR(obd->obd_proc_entry)) {
+ rc = PTR_ERR(obd->obd_proc_entry);
+ CERROR("error %d setting up lprocfs for %s\n", rc,
+ obd->obd_name);
+ obd->obd_proc_entry = NULL;
+ }
+ } else {
+ rc = lprocfs_seq_obd_setup(obd);
+ }
- lov->lov_pool_proc_entry = lprocfs_seq_register("pools",
+ if (rc == 0) {
+ rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
+ 0444, &lov_proc_target_fops, obd);
+ if (rc)
+ CWARN("Error adding the target_obd file\n");
+
+ lov->lov_pool_proc_entry = lprocfs_seq_register("pools",
obd->obd_proc_entry,
NULL, NULL);
+ if (IS_ERR(lov->lov_pool_proc_entry)) {
+ rc = PTR_ERR(lov->lov_pool_proc_entry);
+ CERROR("error %d setting up lprocfs for pools\n", rc);
+ lov->lov_pool_proc_entry = NULL;
+ }
+ }
#endif
RETURN(0);
int i;
obd_getref(obd);
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
- if (!lov->lov_tgts[i])
- continue;
-
- /* Inactive targets may never have connected */
- if (lov->lov_tgts[i]->ltd_active ||
- cfs_atomic_read(&lov->lov_refcount))
- /* We should never get here - these
- should have been removed in the
- disconnect. */
- CERROR("lov tgt %d not cleaned!"
- " deathrow=%d, lovrc=%d\n",
- i, lov->lov_death_row,
- cfs_atomic_read(&lov->lov_refcount));
- lov_del_target(obd, i, 0, 0);
- }
+ if (!lov->lov_tgts[i])
+ continue;
+
+ /* Inactive targets may never have connected */
+ if (lov->lov_tgts[i]->ltd_active ||
+ atomic_read(&lov->lov_refcount))
+ /* We should never get here - these
+ * should have been removed in the
+ * disconnect. */
+ CERROR("%s: lov tgt %d not cleaned! "
+ "deathrow=%d, lovrc=%d\n",
+ obd->obd_name, i, lov->lov_death_row,
+ atomic_read(&lov->lov_refcount));
+ lov_del_target(obd, i, 0, 0);
+ }
obd_putref(obd);
OBD_FREE(lov->lov_tgts, sizeof(*lov->lov_tgts) *
lov->lov_tgt_size);
obd_str2uuid(&obd_uuid, lustre_cfg_buf(lcfg, 1));
- if (sscanf(lustre_cfg_buf(lcfg, 2), "%d", indexp) != 1)
+ if (sscanf(lustre_cfg_buf(lcfg, 2), "%u", indexp) != 1)
GOTO(out, rc = -EINVAL);
if (sscanf(lustre_cfg_buf(lcfg, 3), "%d", genp) != 1)
GOTO(out, rc = -EINVAL);
}
static int lov_getattr_interpret(struct ptlrpc_request_set *rqset,
- void *data, int rc)
+ void *data, int rc)
{
- struct lov_request_set *lovset = (struct lov_request_set *)data;
- int err;
- ENTRY;
+ struct lov_request_set *lovset = (struct lov_request_set *)data;
+ int err;
+ ENTRY;
- /* don't do attribute merge if this aysnc op failed */
- if (rc)
- cfs_atomic_set(&lovset->set_completes, 0);
- err = lov_fini_getattr_set(lovset);
- RETURN(rc ? rc : err);
+ /* don't do attribute merge if this aysnc op failed */
+ if (rc)
+ atomic_set(&lovset->set_completes, 0);
+ err = lov_fini_getattr_set(lovset);
+ RETURN(rc ? rc : err);
}
static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
RETURN(rc);
}
out:
- if (rc)
- cfs_atomic_set(&lovset->set_completes, 0);
- err = lov_fini_getattr_set(lovset);
- RETURN(rc ? rc : err);
+ if (rc)
+ atomic_set(&lovset->set_completes, 0);
+ err = lov_fini_getattr_set(lovset);
+ RETURN(rc ? rc : err);
}
static int lov_setattr_interpret(struct ptlrpc_request_set *rqset,
- void *data, int rc)
+ void *data, int rc)
{
- struct lov_request_set *lovset = (struct lov_request_set *)data;
- int err;
- ENTRY;
+ struct lov_request_set *lovset = (struct lov_request_set *)data;
+ int err;
+ ENTRY;
- if (rc)
- cfs_atomic_set(&lovset->set_completes, 0);
- err = lov_fini_setattr_set(lovset);
- RETURN(rc ? rc : err);
+ if (rc)
+ atomic_set(&lovset->set_completes, 0);
+ err = lov_fini_setattr_set(lovset);
+ RETURN(rc ? rc : err);
}
/* If @oti is given, the request goes from MDS and responses from OSTs are not
}
}
- /* If we are not waiting for responses on async requests, return. */
- if (rc || !rqset || cfs_list_empty(&rqset->set_requests)) {
- int err;
- if (rc)
- cfs_atomic_set(&set->set_completes, 0);
- err = lov_fini_setattr_set(set);
- RETURN(rc ? rc : err);
- }
+ /* If we are not waiting for responses on async requests, return. */
+ if (rc || !rqset || cfs_list_empty(&rqset->set_requests)) {
+ int err;
+ if (rc)
+ atomic_set(&set->set_completes, 0);
+ err = lov_fini_setattr_set(set);
+ RETURN(rc ? rc : err);
+ }
- LASSERT(rqset->set_interpret == NULL);
- rqset->set_interpret = lov_setattr_interpret;
- rqset->set_arg = (void *)set;
+ LASSERT(rqset->set_interpret == NULL);
+ rqset->set_interpret = lov_setattr_interpret;
+ rqset->set_arg = (void *)set;
- RETURN(0);
+ RETURN(0);
}
static int lov_change_cbdata(struct obd_export *exp,
int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc)
{
- struct lov_request_set *lovset = (struct lov_request_set *)data;
- int err;
- ENTRY;
+ struct lov_request_set *lovset = (struct lov_request_set *)data;
+ int err;
+ ENTRY;
- if (rc)
- cfs_atomic_set(&lovset->set_completes, 0);
+ if (rc)
+ atomic_set(&lovset->set_completes, 0);
- err = lov_fini_statfs_set(lovset);
- RETURN(rc ? rc : err);
+ err = lov_fini_statfs_set(lovset);
+ RETURN(rc ? rc : err);
}
static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo,
break;
}
- if (rc || cfs_list_empty(&rqset->set_requests)) {
- int err;
- if (rc)
- cfs_atomic_set(&set->set_completes, 0);
- err = lov_fini_statfs_set(set);
- RETURN(rc ? rc : err);
- }
+ if (rc || cfs_list_empty(&rqset->set_requests)) {
+ int err;
+ if (rc)
+ atomic_set(&set->set_completes, 0);
+ err = lov_fini_statfs_set(set);
+ RETURN(rc ? rc : err);
+ }
- LASSERT(rqset->set_interpret == NULL);
- rqset->set_interpret = lov_statfs_interpret;
- rqset->set_arg = (void *)set;
- RETURN(0);
+ LASSERT(rqset->set_interpret == NULL);
+ rqset->set_interpret = lov_statfs_interpret;
+ rqset->set_arg = (void *)set;
+ RETURN(0);
}
static int lov_statfs(const struct lu_env *env, struct obd_export *exp,
if (fm_end_offset == -EINVAL)
GOTO(out, rc = -EINVAL);
- if (fiemap->fm_extent_count == 0) {
- get_num_extents = 1;
- count_local = 0;
- }
-
+ if (fiemap_count_to_size(fiemap->fm_extent_count) > *vallen)
+ fiemap->fm_extent_count = fiemap_size_to_count(*vallen);
+ if (fiemap->fm_extent_count == 0) {
+ get_num_extents = 1;
+ count_local = 0;
+ }
/* Check each stripe */
for (cur_stripe = start_stripe, i = 0; i < stripe_count;
i++, cur_stripe = (cur_stripe + 1) % lsm->lsm_stripe_count) {
if (!tgt->ltd_active || tgt->ltd_reap) {
if (oqctl->qc_cmd == Q_GETOQUOTA &&
lov->lov_tgts[i]->ltd_activate) {
- rc = -EREMOTEIO;
+ rc = -ENETDOWN;
CERROR("ost %d is inactive\n", i);
} else {
CDEBUG(D_HA, "ost %d is inactive\n", i);
int __init lov_init(void)
{
+ bool enable_proc = true;
+ struct obd_type *type;
int rc;
- ENTRY;
+ ENTRY;
/* print an address of _any_ initialized kernel symbol from this
* module, to allow debugging with gdb that doesn't support data
return -ENOMEM;
}
- rc = class_register_type(&lov_obd_ops, NULL, NULL,
+ type = class_search_type(LUSTRE_LOD_NAME);
+ if (type != NULL && type->typ_procsym != NULL)
+ enable_proc = false;
+
+ rc = class_register_type(&lov_obd_ops, NULL, enable_proc, NULL,
#ifndef HAVE_ONLY_PROCFS_SEQ
- NULL,
+ NULL,
#endif
- LUSTRE_LOV_NAME, &lov_device_type);
+ LUSTRE_LOV_NAME, &lov_device_type);
if (rc) {
kmem_cache_destroy(lov_oinfo_slab);