* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2017, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#include <linux/module.h>
#include <linux/kthread.h>
#include <obd_class.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre/lustre_ioctl.h>
#include <lustre_mds.h>
#include <obd_support.h>
#include <lu_object.h>
-#include <lustre_param.h>
+#include <uapi/linux/lustre/lustre_param.h>
#include <lustre_fid.h>
#include <lustre_nodemap.h>
+#include <lustre_barrier.h>
#include "mdd_internal.h"
/* LU-8040 Set defaults here, before values configs */
mdd->mdd_cl.mc_flags = 0; /* off by default */
mdd->mdd_cl.mc_mask = CHANGELOG_DEFMASK;
+ mdd->mdd_cl.mc_deniednext = 60; /* 60 secs by default */
dev = lustre_cfg_string(lcfg, 0);
if (dev == NULL)
RETURN(rc);
mdd->mdd_atime_diff = MAX_ATIME_DIFF;
- /* sync permission changes */
- mdd->mdd_sync_permission = 1;
+ /* sync permission changes */
+ mdd->mdd_sync_permission = 1;
+ /* enable changelog garbage collection */
+ mdd->mdd_changelog_gc = 0;
+ /* with a significant amount of idle time */
+ mdd->mdd_changelog_max_idle_time = CHLOG_MAX_IDLE_TIME;
+ /* or a significant amount of late indexes */
+ mdd->mdd_changelog_max_idle_indexes = CHLOG_MAX_IDLE_INDEXES;
+ /* with a reasonable interval between each check */
+ mdd->mdd_changelog_min_gc_interval = CHLOG_MIN_GC_INTERVAL;
+ /* with a very few number of free entries */
+ mdd->mdd_changelog_min_free_cat_entries = CHLOG_MIN_FREE_CAT_ENTRIES;
dt_conf_get(env, mdd->mdd_child, &mdd->mdd_dt_conf);
CDEBUG(D_INFO,
"seeing record at index %d/%d/%llu t=%x %.*s in log"
- DOSTID"\n", hdr->lrh_index, rec->cr_hdr.lrh_index,
+ DFID"\n", hdr->lrh_index, rec->cr_hdr.lrh_index,
rec->cr.cr_index, rec->cr.cr_type, rec->cr.cr_namelen,
- changelog_rec_name(&rec->cr), POSTID(&llh->lgh_id.lgl_oi));
+ changelog_rec_name(&rec->cr), PFID(&llh->lgh_id.lgl_oi.oi_fid));
mdd->mdd_cl.mc_index = rec->cr.cr_index;
return LLOG_PROC_BREAK;
struct llog_handle *llh,
struct llog_rec_hdr *hdr, void *data)
{
- struct mdd_device *mdd = (struct mdd_device *)data;
- struct llog_changelog_user_rec *rec =
- (struct llog_changelog_user_rec *)hdr;
+ struct mdd_device *mdd = (struct mdd_device *)data;
+ struct llog_changelog_user_rec *rec =
+ (struct llog_changelog_user_rec *)hdr;
- LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
- LASSERT(rec->cur_hdr.lrh_type == CHANGELOG_USER_REC);
+ LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
+ LASSERT(rec->cur_hdr.lrh_type == CHANGELOG_USER_REC);
CDEBUG(D_INFO, "seeing user at index %d/%d id=%d endrec=%llu"
- " in log "DOSTID"\n", hdr->lrh_index, rec->cur_hdr.lrh_index,
- rec->cur_id, rec->cur_endrec, POSTID(&llh->lgh_id.lgl_oi));
+ " in log "DFID"\n", hdr->lrh_index, rec->cur_hdr.lrh_index,
+ rec->cur_id, rec->cur_endrec, PFID(&llh->lgh_id.lgl_oi.oi_fid));
spin_lock(&mdd->mdd_cl.mc_user_lock);
mdd->mdd_cl.mc_lastuser = rec->cur_id;
/* 0 or 1 means we're done */
rc = 0;
else
- CERROR("%s: cancel idx %u of catalog "DOSTID" rc=%d\n",
+ CERROR("%s: cancel idx %u of catalog "DFID": rc = %d\n",
ctxt->loc_obd->obd_name, cathandle->lgh_last_idx,
- POSTID(&cathandle->lgh_id.lgl_oi), rc);
+ PFID(&cathandle->lgh_id.lgl_oi.oi_fid), rc);
RETURN(rc);
}
mdd->mdd_cl.mc_index = 0;
spin_lock_init(&mdd->mdd_cl.mc_lock);
- mdd->mdd_cl.mc_starttime = cfs_time_current_64();
+ mdd->mdd_cl.mc_starttime = ktime_get();
spin_lock_init(&mdd->mdd_cl.mc_user_lock);
mdd->mdd_cl.mc_lastuser = 0;
/* Some records were purged, so reset repeat-access time (so we
record new mtime update records, so users can see a file has been
changed since the last purge) */
- mdd->mdd_cl.mc_starttime = cfs_time_current_64();
+ mdd->mdd_cl.mc_starttime = ktime_get();
rc = llog_cancel(env, ctxt, (struct llog_cookie *)&endrec, 0);
out:
ENTRY;
if (mdd->mdd_cl.mc_mask & (1 << CL_MARK)) {
- mdd->mdd_cl.mc_starttime = cfs_time_current_64();
+ mdd->mdd_cl.mc_starttime = ktime_get();
RETURN(0);
}
llog_ctxt_put(ctxt);
/* assume on or off event; reset repeat-access time */
- mdd->mdd_cl.mc_starttime = cfs_time_current_64();
+ mdd->mdd_cl.mc_starttime = ktime_get();
RETURN(rc);
}
static void mdd_device_shutdown(const struct lu_env *env, struct mdd_device *m,
struct lustre_cfg *cfg)
{
+ barrier_deregister(m->mdd_bottom);
lfsck_degister(env, m->mdd_bottom);
mdd_hsm_actions_llog_fini(env, m);
mdd_changelog_fini(env, m);
- orph_index_fini(env, m);
+ mdd_orphan_index_fini(env, m);
mdd_dot_lustre_cleanup(env, m);
- nm_config_file_deregister_tgt(env, mdd2obd_dev(m)->u.obt.obt_nodemap_config_file);
+ if (mdd2obd_dev(m)->u.obt.obt_nodemap_config_file) {
+ nm_config_file_deregister_tgt(env,
+ mdd2obd_dev(m)->u.obt.obt_nodemap_config_file);
+ mdd2obd_dev(m)->u.obt.obt_nodemap_config_file = NULL;
+ }
if (m->mdd_los != NULL) {
local_oid_storage_fini(env, m->mdd_los);
m->mdd_los = NULL;
break;
case LCFG_PRE_CLEANUP:
rc = next->ld_ops->ldo_process_config(env, next, cfg);
- mdd_generic_thread_stop(&m->mdd_orph_cleanup_thread);
+ mdd_generic_thread_stop(&m->mdd_orphan_cleanup_thread);
break;
case LCFG_CLEANUP:
rc = next->ld_ops->ldo_process_config(env, next, cfg);
}
static int mdd_recovery_complete(const struct lu_env *env,
- struct lu_device *d)
+ struct lu_device *d)
{
- struct mdd_device *mdd = lu2mdd_dev(d);
+ struct mdd_device *mdd = lu2mdd_dev(d);
struct lu_device *next;
- int rc;
- ENTRY;
+ int rc;
+ ENTRY;
- LASSERT(mdd != NULL);
+ LASSERT(mdd != NULL);
next = &mdd->mdd_child->dd_lu_dev;
- /* XXX: orphans handling. */
- mdd_orphan_cleanup(env, mdd);
- rc = next->ld_ops->ldo_recovery_complete(env, next);
+ if (!mdd->mdd_bottom->dd_rdonly)
+ mdd_orphan_cleanup(env, mdd);
+ rc = next->ld_ops->ldo_recovery_complete(env, next);
- RETURN(rc);
+ RETURN(rc);
}
int mdd_local_file_create(const struct lu_env *env, struct mdd_device *mdd,
__u32 mode, struct lu_fid *fid)
{
struct dt_object *parent, *dto;
- int rc;
+ int rc = 0;
ENTRY;
*fid = *lu_object_fid(&dto->do_lu);
/* since stack is not fully set up the local_storage uses own stack
* and we should drop its object from cache */
- lu_object_put_nocache(env, &dto->do_lu);
+ dt_object_put_nocache(env, dto);
EXIT;
out_put:
- lu_object_put(env, &parent->do_lu);
- return 0;
+ dt_object_put(env, parent);
+ return rc;
}
static int mdd_lfsck_out_notify(const struct lu_env *env, void *data,
struct mdd_device *mdd = lu2mdd_dev(cdev);
struct lu_device *next = &mdd->mdd_child->dd_lu_dev;
struct nm_config_file *nodemap_config;
+ struct obd_device_target *obt = &mdd2obd_dev(mdd)->u.obt;
struct lu_fid fid;
int rc;
mdd->mdd_root_fid = fid;
}
- rc = orph_index_init(env, mdd);
+ rc = mdd_orphan_index_init(env, mdd);
if (rc < 0)
GOTO(out_dot, rc);
nodemap_config = nm_config_file_register_tgt(env, mdd->mdd_bottom,
mdd->mdd_los);
- if (IS_ERR(nodemap_config))
- GOTO(out_hsm, rc = PTR_ERR(nodemap_config));
-
- mdd2obd_dev(mdd)->u.obt.obt_nodemap_config_file = nodemap_config;
+ if (IS_ERR(nodemap_config)) {
+ rc = PTR_ERR(nodemap_config);
+ if (rc != -EROFS)
+ GOTO(out_hsm, rc);
+ } else {
+ obt->obt_nodemap_config_file = nodemap_config;
+ }
rc = lfsck_register(env, mdd->mdd_bottom, mdd->mdd_child,
mdd2obd_dev(mdd), mdd_lfsck_out_notify,
GOTO(out_nodemap, rc);
}
+ rc = barrier_register(mdd->mdd_bottom, mdd->mdd_child);
+ if (rc) {
+ CERROR("%s: failed to register to barrier: rc = %d\n",
+ mdd2obd_dev(mdd)->obd_name, rc);
+ GOTO(out_lfsck, rc);
+ }
+
RETURN(0);
+out_lfsck:
+ lfsck_degister(env, mdd->mdd_bottom);
out_nodemap:
- nm_config_file_deregister_tgt(env, mdd2obd_dev(mdd)->u.obt.obt_nodemap_config_file);
- mdd2obd_dev(mdd)->u.obt.obt_nodemap_config_file = NULL;
+ nm_config_file_deregister_tgt(env, obt->obt_nodemap_config_file);
+ obt->obt_nodemap_config_file = NULL;
out_hsm:
mdd_hsm_actions_llog_fini(env, mdd);
out_changelog:
mdd_changelog_fini(env, mdd);
out_orph:
- orph_index_fini(env, mdd);
+ mdd_orphan_index_fini(env, mdd);
out_dot:
if (mdd_seq_site(mdd)->ss_node_id == 0)
mdd_dot_lustre_cleanup(env, mdd);
RETURN(rc);
}
-static int mdd_maxeasize_get(const struct lu_env *env, struct md_device *m,
- int *easize)
+static const struct dt_device_param *mdd_dtconf_get(const struct lu_env *env,
+ struct md_device *m)
{
struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
- ENTRY;
-
- *easize = mdd->mdd_dt_conf.ddp_max_ea_size;
- RETURN(0);
+ return &mdd->mdd_dt_conf;
}
static int mdd_llog_ctxt_get(const struct lu_env *env, struct md_device *m,
}
*id = rec->cur_id = ++mdd->mdd_cl.mc_lastuser;
rec->cur_endrec = mdd->mdd_cl.mc_index;
+
+ rec->cur_time = (__u32)get_seconds();
+ if (OBD_FAIL_CHECK(OBD_FAIL_TIME_IN_CHLOG_USER))
+ rec->cur_time = 0;
+
spin_unlock(&mdd->mdd_cl.mc_user_lock);
rc = llog_cat_add(env, ctxt->loc_handle, &rec->cur_hdr, NULL);
RETURN(rc);
}
-struct mdd_changelog_user_data {
- __u64 mcud_endrec; /**< purge record for this user */
- __u64 mcud_minrec; /**< lowest changelog recno still referenced */
- __u32 mcud_id;
- __u32 mcud_minid; /**< user id with lowest rec reference */
- __u32 mcud_usercount;
- unsigned int mcud_found:1;
+struct mdd_changelog_user_purge {
+ __u32 mcup_id;
+ __u32 mcup_usercount;
+ __u64 mcup_minrec;
+ bool mcup_found;
};
-#define MCUD_UNREGISTER -1LL
-/** Two things:
- * 1. Find the smallest record everyone is willing to purge
- * 2. Update the last purgeable record for this user
+/**
+ * changelog_user_purge callback
+ *
+ * Is called once per user.
+ *
+ * Check to see the user requested is available from rec.
+ * Truncate the changelog.
+ * Keep track of the total number of users (calls).
*/
static int mdd_changelog_user_purge_cb(const struct lu_env *env,
struct llog_handle *llh,
struct llog_rec_hdr *hdr, void *data)
{
struct llog_changelog_user_rec *rec;
- struct mdd_changelog_user_data *mcud = data;
+ struct mdd_changelog_user_purge *mcup = data;
+ struct llog_cookie cookie;
int rc;
- ENTRY;
+ ENTRY;
- LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
+ if ((llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN) == 0)
+ RETURN(-ENXIO);
- rec = (struct llog_changelog_user_rec *)hdr;
+ rec = container_of(hdr, struct llog_changelog_user_rec, cur_hdr);
- mcud->mcud_usercount++;
+ mcup->mcup_usercount++;
- /* If we have a new endrec for this id, use it for the following
- min check instead of its old value */
- if (rec->cur_id == mcud->mcud_id)
- rec->cur_endrec = max(rec->cur_endrec, mcud->mcud_endrec);
+ if (rec->cur_id != mcup->mcup_id) {
+ /* truncate to the lowest endrec that is not this user */
+ mcup->mcup_minrec = min(mcup->mcup_minrec,
+ rec->cur_endrec);
+ RETURN(0);
+ }
- /* Track the minimum referenced record */
- if (mcud->mcud_minid == 0 || mcud->mcud_minrec > rec->cur_endrec) {
- mcud->mcud_minid = rec->cur_id;
- mcud->mcud_minrec = rec->cur_endrec;
- }
+ /* Unregister this user */
+ cookie.lgc_lgl = llh->lgh_id;
+ cookie.lgc_index = hdr->lrh_index;
- if (rec->cur_id != mcud->mcud_id)
- RETURN(0);
+ rc = llog_cat_cancel_records(env, llh->u.phd.phd_cat_handle,
+ 1, &cookie);
+ if (rc == 0) {
+ mcup->mcup_found = true;
+ mcup->mcup_usercount--;
+ }
- /* Update this user's record */
- mcud->mcud_found = 1;
+ RETURN(rc);
+}
- /* Special case: unregister this user */
- if (mcud->mcud_endrec == MCUD_UNREGISTER) {
- struct llog_cookie cookie;
+int mdd_changelog_user_purge(const struct lu_env *env,
+ struct mdd_device *mdd, __u32 id)
+{
+ struct mdd_changelog_user_purge mcup = {
+ .mcup_id = id,
+ .mcup_found = false,
+ .mcup_usercount = 0,
+ .mcup_minrec = ULLONG_MAX,
+ };
+ struct llog_ctxt *ctxt;
+ int rc;
- cookie.lgc_lgl = llh->lgh_id;
- cookie.lgc_index = hdr->lrh_index;
+ ENTRY;
- rc = llog_cat_cancel_records(env, llh->u.phd.phd_cat_handle,
- 1, &cookie);
- if (rc == 0)
- mcud->mcud_usercount--;
+ CDEBUG(D_IOCTL, "%s: Purge request: id=%u\n",
+ mdd2obd_dev(mdd)->obd_name, id);
- RETURN(rc);
- }
+ ctxt = llog_get_context(mdd2obd_dev(mdd),
+ LLOG_CHANGELOG_USER_ORIG_CTXT);
+ if (ctxt == NULL ||
+ (ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) == 0)
+ GOTO(out, rc = -ENXIO);
+
+ rc = llog_cat_process(env, ctxt->loc_handle,
+ mdd_changelog_user_purge_cb, &mcup,
+ 0, 0);
+
+ if ((rc == 0) && mcup.mcup_found) {
+ CDEBUG(D_IOCTL, "%s: Purging changelog entries for user %d "
+ "record=%llu\n",
+ mdd2obd_dev(mdd)->obd_name, id, mcup.mcup_minrec);
+ /* Cancelling record 0 destroys the entire changelog, make sure
+ we don't do that unless we mean it. */
+ if (mcup.mcup_minrec != 0 || mcup.mcup_usercount == 0) {
+ rc = mdd_changelog_llog_cancel(env, mdd,
+ mcup.mcup_minrec);
+ }
+ } else {
+ CWARN("%s: No changelog for user %u; rc=%d\n",
+ mdd2obd_dev(mdd)->obd_name, id, rc);
+ GOTO(out, rc = -ENOENT);
+ }
+
+ if ((rc == 0) && (mcup.mcup_usercount == 0)) {
+ /* No more users; turn changelogs off */
+ CDEBUG(D_IOCTL, "turning off changelogs\n");
+ rc = mdd_changelog_off(env, mdd);
+ }
+
+ EXIT;
+out:
+ if (ctxt != NULL)
+ llog_ctxt_put(ctxt);
+
+ return rc;
+}
+
+struct mdd_changelog_user_clear {
+ __u64 mcuc_endrec;
+ __u64 mcuc_minrec;
+ __u32 mcuc_id;
+ bool mcuc_flush;
+};
+
+/**
+ * changelog_clear callback
+ *
+ * Is called once per user.
+ *
+ * Check to see the user requested is available from rec.
+ * Check the oldest (smallest) record for boundary conditions.
+ * Truncate the changelog.
+ */
+static int mdd_changelog_clear_cb(const struct lu_env *env,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *hdr,
+ void *data)
+{
+ struct llog_changelog_user_rec *rec;
+ struct mdd_changelog_user_clear *mcuc = data;
+ int rc;
+
+ ENTRY;
+
+ if ((llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN) == 0)
+ RETURN(-ENXIO);
+
+ rec = container_of(hdr, struct llog_changelog_user_rec, cur_hdr);
+
+ /* Does the changelog id match the requested id? */
+ if (rec->cur_id != mcuc->mcuc_id) {
+ mcuc->mcuc_minrec = min(mcuc->mcuc_minrec,
+ rec->cur_endrec);
+ RETURN(0);
+ }
+
+ /* cur_endrec is the oldest purgeable record, make sure we're newer */
+ if (rec->cur_endrec > mcuc->mcuc_endrec) {
+ CDEBUG(D_IOCTL, "Request %llu out of range: %llu\n",
+ mcuc->mcuc_endrec, rec->cur_endrec);
+ RETURN(-EINVAL);
+ }
+
+ /* Flag that we've met all the range and user checks.
+ * We now know the record to flush.
+ */
+ rec->cur_endrec = mcuc->mcuc_endrec;
+
+ rec->cur_time = (__u32)get_seconds();
+ if (OBD_FAIL_CHECK(OBD_FAIL_TIME_IN_CHLOG_USER))
+ rec->cur_time = 0;
- /* Update the endrec */
- CDEBUG(D_IOCTL, "Rewriting changelog user %d endrec to %llu\n",
- mcud->mcud_id, rec->cur_endrec);
+ mcuc->mcuc_flush = true;
+ CDEBUG(D_IOCTL, "Rewriting changelog user %u endrec to %llu\n",
+ mcuc->mcuc_id, rec->cur_endrec);
+
+ /* Update the endrec */
rc = llog_write(env, llh, hdr, hdr->lrh_index);
- RETURN(rc);
+ RETURN(rc);
}
-static int mdd_changelog_user_purge(const struct lu_env *env,
- struct mdd_device *mdd, int id,
- long long endrec)
+/**
+ * Clear a changelog up to entry specified by endrec for user id.
+ */
+static int mdd_changelog_clear(const struct lu_env *env,
+ struct mdd_device *mdd, __u32 id,
+ __u64 endrec)
{
- struct mdd_changelog_user_data data;
- struct llog_ctxt *ctxt;
- int rc;
- ENTRY;
+ struct mdd_changelog_user_clear mcuc = {
+ .mcuc_id = id,
+ .mcuc_minrec = endrec,
+ .mcuc_flush = false,
+ };
+ struct llog_ctxt *ctxt;
+ __u64 start_rec;
+ int rc;
- CDEBUG(D_IOCTL, "Purge request: id=%d, endrec=%lld\n", id, endrec);
+ ENTRY;
- data.mcud_id = id;
- data.mcud_minid = 0;
- data.mcud_minrec = 0;
- data.mcud_usercount = 0;
- data.mcud_endrec = endrec;
+ CDEBUG(D_IOCTL, "%s: Purge request: id=%u, endrec=%llu\n",
+ mdd2obd_dev(mdd)->obd_name, id, endrec);
+ /* start_rec is the newest (largest value) entry in the changelogs*/
spin_lock(&mdd->mdd_cl.mc_lock);
- endrec = mdd->mdd_cl.mc_index;
+ start_rec = mdd->mdd_cl.mc_index;
spin_unlock(&mdd->mdd_cl.mc_lock);
- if ((data.mcud_endrec == 0) ||
- ((data.mcud_endrec > endrec) &&
- (data.mcud_endrec != MCUD_UNREGISTER)))
- data.mcud_endrec = endrec;
- ctxt = llog_get_context(mdd2obd_dev(mdd),
- LLOG_CHANGELOG_USER_ORIG_CTXT);
- if (ctxt == NULL)
- return -ENXIO;
+ if (start_rec < endrec) {
+ CDEBUG(D_IOCTL, "%s: Could not clear changelog, requested "\
+ "address out of range\n", mdd2obd_dev(mdd)->obd_name);
+ RETURN(-EINVAL);
+ }
- LASSERT(ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT);
+ if (endrec == 0) {
+ mcuc.mcuc_endrec = start_rec;
+ mcuc.mcuc_minrec = ULLONG_MAX;
+ } else {
+ mcuc.mcuc_endrec = endrec;
+ }
+
+ ctxt = llog_get_context(mdd2obd_dev(mdd),
+ LLOG_CHANGELOG_USER_ORIG_CTXT);
+ if (ctxt == NULL ||
+ (ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) == 0)
+ GOTO(out, rc = -ENXIO);
rc = llog_cat_process(env, ctxt->loc_handle,
- mdd_changelog_user_purge_cb, (void *)&data,
+ mdd_changelog_clear_cb, (void *)&mcuc,
0, 0);
- if ((rc >= 0) && (data.mcud_minrec > 0)) {
- CDEBUG(D_IOCTL, "Purging changelog entries up to %lld"
- ", referenced by "CHANGELOG_USER_PREFIX"%d\n",
- data.mcud_minrec, data.mcud_minid);
- rc = mdd_changelog_llog_cancel(env, mdd, data.mcud_minrec);
- } else {
- CWARN("Could not determine changelog records to purge; rc=%d\n",
- rc);
- }
-
- llog_ctxt_put(ctxt);
- if (!data.mcud_found) {
- CWARN("No entry for user %d. Last changelog reference is "
- "%lld by changelog user %d\n", data.mcud_id,
- data.mcud_minrec, data.mcud_minid);
- rc = -ENOENT;
- }
+ if (rc < 0) {
+ CWARN("%s: Failure to clear the changelog for user %d: %d\n",
+ mdd2obd_dev(mdd)->obd_name, id, rc);
+ } else if (mcuc.mcuc_flush) {
+ /* Cancelling record 0 destroys the entire changelog, make sure
+ we don't do that unless we mean it. */
+ if (mcuc.mcuc_minrec != 0) {
+ CDEBUG(D_IOCTL, "%s: Purging changelog entries up "\
+ "to %llu\n", mdd2obd_dev(mdd)->obd_name,
+ mcuc.mcuc_minrec);
+
+ rc = mdd_changelog_llog_cancel(env, mdd,
+ mcuc.mcuc_minrec);
+ }
+ } else {
+ CWARN("%s: No entry for user %d\n",
+ mdd2obd_dev(mdd)->obd_name, id);
+ rc = -ENOENT;
+ }
- if (!rc && data.mcud_usercount == 0)
- /* No more users; turn changelogs off */
- rc = mdd_changelog_off(env, mdd);
+ EXIT;
+out:
+ if (ctxt != NULL)
+ llog_ctxt_put(ctxt);
- RETURN(rc);
+ return rc;
}
/** mdd_iocontrol
static int mdd_iocontrol(const struct lu_env *env, struct md_device *m,
unsigned int cmd, int len, void *karg)
{
- struct mdd_device *mdd;
- struct obd_ioctl_data *data = karg;
- int rc;
- ENTRY;
+ struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
+ struct obd_ioctl_data *data = karg;
+ int rc;
+ ENTRY;
- mdd = lu2mdd_dev(&m->md_lu_dev);
+ /* Doesn't use obd_ioctl_data */
+ switch (cmd) {
+ case OBD_IOC_CHANGELOG_CLEAR: {
+ struct changelog_setinfo *cs = karg;
- /* Doesn't use obd_ioctl_data */
- switch (cmd) {
- case OBD_IOC_CHANGELOG_CLEAR: {
- struct changelog_setinfo *cs = karg;
- rc = mdd_changelog_user_purge(env, mdd, cs->cs_id,
- cs->cs_recno);
- RETURN(rc);
- }
- case OBD_IOC_GET_MNTOPT: {
- mntopt_t *mntopts = (mntopt_t *)karg;
- *mntopts = mdd->mdd_dt_conf.ddp_mntopts;
- RETURN(0);
- }
+ if (unlikely(!barrier_entry(mdd->mdd_bottom)))
+ RETURN(-EINPROGRESS);
+
+ rc = mdd_changelog_clear(env, mdd, cs->cs_id,
+ cs->cs_recno);
+ barrier_exit(mdd->mdd_bottom);
+ RETURN(rc);
+ }
case OBD_IOC_START_LFSCK: {
rc = lfsck_start(env, mdd->mdd_bottom,
(struct lfsck_start_param *)karg);
}
}
- /* Below ioctls use obd_ioctl_data */
- if (len != sizeof(*data)) {
- CERROR("Bad ioctl size %d\n", len);
- RETURN(-EINVAL);
- }
- if (data->ioc_version != OBD_IOCTL_VERSION) {
- CERROR("Bad magic %x != %x\n", data->ioc_version,
- OBD_IOCTL_VERSION);
- RETURN(-EINVAL);
- }
+ /* Below ioctls use obd_ioctl_data */
+ if (len != sizeof(*data)) {
+ CERROR("Bad ioctl size %d\n", len);
+ RETURN(-EINVAL);
+ }
+ if (data->ioc_version != OBD_IOCTL_VERSION) {
+ CERROR("Bad magic %x != %x\n", data->ioc_version,
+ OBD_IOCTL_VERSION);
+ RETURN(-EINVAL);
+ }
- switch (cmd) {
- case OBD_IOC_CHANGELOG_REG:
- rc = mdd_changelog_user_register(env, mdd, &data->ioc_u32_1);
- break;
- case OBD_IOC_CHANGELOG_DEREG:
- rc = mdd_changelog_user_purge(env, mdd, data->ioc_u32_1,
- MCUD_UNREGISTER);
- break;
- default:
- rc = -ENOTTY;
- }
+ switch (cmd) {
+ case OBD_IOC_CHANGELOG_REG:
+ if (unlikely(!barrier_entry(mdd->mdd_bottom)))
+ RETURN(-EINPROGRESS);
+
+ rc = mdd_changelog_user_register(env, mdd, &data->ioc_u32_1);
+ barrier_exit(mdd->mdd_bottom);
+ break;
+ case OBD_IOC_CHANGELOG_DEREG:
+ if (unlikely(!barrier_entry(mdd->mdd_bottom)))
+ RETURN(-EINPROGRESS);
- RETURN (rc);
+ rc = mdd_changelog_user_purge(env, mdd, data->ioc_u32_1);
+ barrier_exit(mdd->mdd_bottom);
+ break;
+ default:
+ rc = -ENOTTY;
+ }
+
+ RETURN(rc);
}
/* type constructor/destructor: mdd_type_init, mdd_type_fini */
.mdo_root_get = mdd_root_get,
.mdo_llog_ctxt_get = mdd_llog_ctxt_get,
.mdo_iocontrol = mdd_iocontrol,
- .mdo_maxeasize_get = mdd_maxeasize_get,
+ .mdo_dtconf_get = mdd_dtconf_get,
};
static struct lu_device_type_operations mdd_device_type_ops = {
LU_KEY_INIT(mdd, struct mdd_thread_info);
static void mdd_key_fini(const struct lu_context *ctx,
- struct lu_context_key *key, void *data)
+ struct lu_context_key *key, void *data)
{
- struct mdd_thread_info *info = data;
+ struct mdd_thread_info *info = data;
lu_buf_free(&info->mti_big_buf);
lu_buf_free(&info->mti_link_buf);
+ lu_buf_free(&info->mti_xattr_buf);
- OBD_FREE_PTR(info);
+ OBD_FREE_PTR(info);
}
/* context key: mdd_thread_key */