- Pass lu_env to he llog callback.
- Move cat_cancel_cb() to llog_cat.c to be with all
other catalog functions.
Signed-off-by: Mikhail Pershin <tappro@whamcloud.com>
Change-Id: Iedbc7953b461ba52b52680d7d709d27c6581f934
Reviewed-on: http://review.whamcloud.com/3649
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
struct llog_handle;
/* llog.c - general API */
-typedef int (*llog_cb_t)(struct llog_handle *, struct llog_rec_hdr *, void *);
+typedef int (*llog_cb_t)(const struct lu_env *env, struct llog_handle *lgh,
+ struct llog_rec_hdr *rec, void *data);
typedef int (*llog_fill_rec_cb_t)(struct llog_rec_hdr *rec, void *data);
extern struct llog_handle *llog_alloc_handle(void);
int llog_init_handle(struct llog_handle *handle, int flags,
void *lpca_arg;
};
+int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle,
+ struct llog_rec_hdr *rec, void *data);
int llog_cat_put(struct llog_handle *cathandle);
int llog_cat_add_rec(struct llog_handle *cathandle, struct llog_rec_hdr *rec,
struct llog_cookie *reccookie, void *buf);
struct obd_device *cs_obd;
};
-static int changelog_show_cb(struct llog_handle *llh, struct llog_rec_hdr *hdr,
- void *data)
+static int changelog_show_cb(const struct lu_env *env, struct llog_handle *llh,
+ struct llog_rec_hdr *hdr, void *data)
{
struct changelog_show *cs = data;
struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
EXIT;
}
-static int changelog_init_cb(struct llog_handle *llh, struct llog_rec_hdr *hdr,
- void *data)
+static int changelog_init_cb(const struct lu_env *env, struct llog_handle *llh,
+ struct llog_rec_hdr *hdr, void *data)
{
struct mdd_device *mdd = (struct mdd_device *)data;
struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
RETURN(LLOG_PROC_BREAK);
}
-static int changelog_user_init_cb(struct llog_handle *llh,
- struct llog_rec_hdr *hdr, void *data)
+static int changelog_user_init_cb(const struct lu_env *env,
+ 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 =
__u32 mcud_usercount;
int mcud_found:1;
struct mdd_device *mcud_mdd;
- const struct lu_env *mcud_env;
};
#define MCUD_UNREGISTER -1LL
* 1. Find the smallest record everyone is willing to purge
* 2. Update the last purgeable record for this user
*/
-static int mdd_changelog_user_purge_cb(struct llog_handle *llh,
- struct llog_rec_hdr *hdr, void *data)
+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 =
- (struct mdd_changelog_user_data *)data;
- int rc;
+ struct llog_changelog_user_rec *rec;
+ struct mdd_changelog_user_data *mcud = data;
+ int rc;
+
ENTRY;
LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
/* XXX This is a workaround for the deadlock of changelog
* adding vs. changelog cancelling. LU-81. */
- th = mdd_trans_create(mcud->mcud_env, mdd);
+ th = mdd_trans_create(env, mdd);
if (IS_ERR(th)) {
CERROR("Cannot get thandle\n");
RETURN(-ENOMEM);
}
- rc = mdd_declare_llog_cancel(mcud->mcud_env, mdd, th);
+ rc = mdd_declare_llog_cancel(env, mdd, th);
if (rc)
GOTO(stop, rc);
- rc = mdd_trans_start(mcud->mcud_env, mdd, th);
+ rc = mdd_trans_start(env, mdd, th);
if (rc)
GOTO(stop, rc);
mcud->mcud_usercount--;
stop:
- mdd_trans_stop(mcud->mcud_env, mdd, 0, th);
+ mdd_trans_stop(env, mdd, 0, th);
RETURN(rc);
}
data.mcud_usercount = 0;
data.mcud_endrec = endrec;
data.mcud_mdd = mdd;
- data.mcud_env = env;
cfs_spin_lock(&mdd->mdd_cl.mc_lock);
endrec = mdd->mdd_cl.mc_index;
cfs_spin_unlock(&mdd->mdd_cl.mc_lock);
int idx;
};
-static int lprocfs_changelog_users_cb(struct llog_handle *llh,
- struct llog_rec_hdr *hdr, void *data)
+static int lprocfs_changelog_users_cb(const struct lu_env *env,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *hdr, void *data)
{
struct llog_changelog_user_rec *rec;
struct cucb_data *cucb = (struct cucb_data *)data;
static struct llog_operations changelog_orig_logops;
-static int llog_changelog_cancel_cb(struct llog_handle *llh,
- struct llog_rec_hdr *hdr, void *data)
+static int llog_changelog_cancel_cb(const struct lu_env *env,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *hdr, void *data)
{
struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
struct llog_cookie cookie;
return(rc <= 1);
}
-static int mgc_copy_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
- void *data)
+static int mgc_copy_handler(const struct lu_env *env, struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
{
struct llog_rec_hdr local_rec = *rec;
struct llog_handle *local_llh = (struct llog_handle *)data;
*/
/* It might be better to have a separate db file, instead of parsing the info
out of the client log. This is slow and potentially error-prone. */
-static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
- void *data)
+static int mgs_fsdb_handler(const struct lu_env *env, struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
{
- struct mgs_fsdb_handler_data *d = (struct mgs_fsdb_handler_data *) data;
+ struct mgs_fsdb_handler_data *d = data;
struct fs_db *fsdb = d->fsdb;
int cfg_len = rec->lrh_len;
char *cfg_buf = (char*) (rec + 1);
int mml_modified;
};
-static int mgs_modify_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
- void *data)
+static int mgs_modify_handler(const struct lu_env *env,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
{
- struct mgs_modify_lookup *mml = (struct mgs_modify_lookup *)data;
+ struct mgs_modify_lookup *mml = data;
struct cfg_marker *marker;
struct lustre_cfg *lcfg = (struct lustre_cfg *)(rec + 1);
int cfg_len = rec->lrh_len - sizeof(struct llog_rec_hdr) -
static void name_create_mdt_and_lov(char **logname, char **lovname,
struct fs_db *fsdb, int i);
-static int mgs_steal_llog_handler(struct llog_handle *llh,
- struct llog_rec_hdr *rec,
- void *data)
+static int mgs_steal_llog_handler(const struct lu_env *env,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
{
struct obd_device * obd;
struct mgs_target_info *mti, *tmti;
int msrd_skip;
};
-static int mgs_srpc_read_handler(struct llog_handle *llh,
- struct llog_rec_hdr *rec,
- void *data)
+static int mgs_srpc_read_handler(const struct lu_env *env,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
{
- struct mgs_srpc_read_data *msrd = (struct mgs_srpc_read_data *) data;
+ struct mgs_srpc_read_data *msrd = data;
struct cfg_marker *marker;
struct lustre_cfg *lcfg = (struct lustre_cfg *)(rec + 1);
char *svname, *param;
/* if set, process the callback on this record */
if (ext2_test_bit(index, llh->llh_bitmap)) {
- rc = lpi->lpi_cb(loghandle, rec,
- lpi->lpi_cbdata);
+ rc = lpi->lpi_cb(lpi->lpi_env, loghandle, rec,
+ lpi->lpi_cbdata);
last_called_index = index;
if (rc == LLOG_PROC_BREAK) {
GOTO(out, rc);
rec = (void *)tail - tail->lrt_len +
sizeof(*tail);
- rc = cb(loghandle, rec, data);
- if (rc == LLOG_PROC_BREAK) {
- GOTO(out, rc);
+ rc = cb(env, loghandle, rec, data);
+ if (rc == LLOG_PROC_BREAK) {
+ GOTO(out, rc);
} else if (rc == LLOG_DEL_RECORD) {
llog_cancel_rec(loghandle,
tail->lrt_index);
}
EXPORT_SYMBOL(llog_cat_cancel_records);
-int llog_cat_process_cb(struct llog_handle *cat_llh, struct llog_rec_hdr *rec,
- void *data)
+int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh,
+ struct llog_rec_hdr *rec, void *data)
{
struct llog_process_data *d = data;
struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
cd.lpcd_first_idx = d->lpd_startidx;
cd.lpcd_last_idx = 0;
- rc = llog_process(NULL, llh, d->lpd_cb, d->lpd_data, &cd);
+ rc = llog_process(env, llh, d->lpd_cb, d->lpd_data, &cd);
/* Continue processing the next log from idx 0 */
d->lpd_startidx = 0;
} else {
- rc = llog_process(NULL, llh, d->lpd_cb, d->lpd_data, NULL);
+ rc = llog_process(env, llh, d->lpd_cb, d->lpd_data, NULL);
}
RETURN(rc);
if (cb) {
rc = llog_cat_process(&env, llh, cb, NULL, 0, 0);
- if (rc != LLOG_PROC_BREAK && rc != 0)
- CERROR("llog_cat_process() failed %d\n", rc);
- cb(llh, NULL, NULL);
+ if (rc != LLOG_PROC_BREAK && rc != 0)
+ CERROR("llog_cat_process() failed %d\n", rc);
+ cb(&env, llh, NULL, NULL);
} else {
CWARN("No callback function for recovery\n");
}
EXPORT_SYMBOL(llog_cat_process_thread);
#endif
-static int llog_cat_reverse_process_cb(struct llog_handle *cat_llh,
- struct llog_rec_hdr *rec, void *data)
+static int llog_cat_reverse_process_cb(const struct lu_env *env,
+ struct llog_handle *cat_llh,
+ struct llog_rec_hdr *rec, void *data)
{
struct llog_process_data *d = data;
struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
RETURN(rc);
}
- rc = llog_reverse_process(NULL, llh, d->lpd_cb, d->lpd_data, NULL);
+ rc = llog_reverse_process(env, llh, d->lpd_cb, d->lpd_data, NULL);
RETURN(rc);
}
RETURN(0);
}
+
+/* callback func for llog_process in llog_obd_origin_setup */
+int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle,
+ struct llog_rec_hdr *rec, void *data)
+{
+ struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
+ struct llog_handle *loghandle;
+ struct llog_log_hdr *llh;
+ int rc, index;
+
+ ENTRY;
+
+ if (rec->lrh_type != LLOG_LOGID_MAGIC) {
+ CERROR("%s: invalid record in catalog\n",
+ loghandle->lgh_ctxt->loc_obd->obd_name);
+ RETURN(-EINVAL);
+ }
+ CDEBUG(D_HA, "processing log "LPX64":%x at index %u of catalog "
+ LPX64"\n", lir->lid_id.lgl_oid, lir->lid_id.lgl_ogen,
+ rec->lrh_index, cathandle->lgh_id.lgl_oid);
+
+ rc = llog_cat_id2handle(cathandle, &loghandle, &lir->lid_id);
+ if (rc) {
+ CERROR("%s: cannot find handle for llog "LPX64"\n",
+ loghandle->lgh_ctxt->loc_obd->obd_name,
+ lir->lid_id.lgl_oid);
+ if (rc == -ENOENT) {
+ index = rec->lrh_index;
+ goto cat_cleanup;
+ }
+ RETURN(rc);
+ }
+
+ llh = loghandle->lgh_hdr;
+ if ((llh->llh_flags & LLOG_F_ZAP_WHEN_EMPTY) &&
+ (llh->llh_count == 1)) {
+ rc = llog_destroy(loghandle);
+ if (rc)
+ CERROR("%s: fail to destroy empty log: rc = %d\n",
+ loghandle->lgh_ctxt->loc_obd->obd_name, rc);
+
+ index = loghandle->u.phd.phd_cookie.lgc_index;
+ llog_free_handle(loghandle);
+
+cat_cleanup:
+ LASSERT(index);
+ llog_cat_set_first_idx(cathandle, index);
+ rc = llog_cancel_rec(cathandle, index);
+ if (rc == 0)
+ CDEBUG(D_HA,
+ "cancel log "LPX64":%x at index %u of catalog "
+ LPX64"\n", lir->lid_id.lgl_oid,
+ lir->lid_id.lgl_ogen, rec->lrh_index,
+ cathandle->lgh_id.lgl_oid);
+ }
+
+ RETURN(rc);
+}
int llog_cat_id2handle(struct llog_handle *cathandle, struct llog_handle **res,
struct llog_logid *logid);
-int class_config_dump_handler(struct llog_handle * handle,
- struct llog_rec_hdr *rec, void *data);
+int class_config_dump_handler(const struct lu_env *env,
+ struct llog_handle *handle,
+ struct llog_rec_hdr *rec, void *data);
int llog_process_or_fork(const struct lu_env *env,
struct llog_handle *loghandle,
llog_cb_t cb, void *data, void *catdata, bool fork);
RETURN(0);
}
-static int llog_check_cb(struct llog_handle *handle, struct llog_rec_hdr *rec,
- void *data)
+static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle,
+ struct llog_rec_hdr *rec, void *data)
{
struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data;
static int l, remains, from, to;
lir->lid_id.lgl_ogen);
RETURN(rc);
}
- rc = llog_process(NULL, log_handle, llog_check_cb, NULL, NULL);
+ rc = llog_process(env, log_handle, llog_check_cb, NULL, NULL);
llog_close(log_handle);
} else {
switch (rec->lrh_type) {
RETURN(rc);
}
-static int llog_print_cb(struct llog_handle *handle, struct llog_rec_hdr *rec,
- void *data)
+static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle,
+ struct llog_rec_hdr *rec, void *data)
{
struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data;
static int l, remains, from, to;
if (handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) {
struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
+
if (rec->lrh_type != LLOG_LOGID_MAGIC) {
CERROR("invalid record in catalog\n");
RETURN(-EINVAL);
}
-static int llog_delete_cb(struct llog_handle *handle, struct llog_rec_hdr *rec,
- void *data)
+static int llog_delete_cb(const struct lu_env *env, struct llog_handle *handle,
+ struct llog_rec_hdr *rec, void *data)
{
struct llog_logid_rec *lir = (struct llog_logid_rec*)rec;
int rc;
}
EXPORT_SYMBOL(llog_cancel);
-/* callback func for llog_process in llog_obd_origin_setup */
-static int cat_cancel_cb(struct llog_handle *cathandle,
- struct llog_rec_hdr *rec, void *data)
-{
- struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
- struct llog_handle *loghandle;
- struct llog_log_hdr *llh;
- int rc, index;
- ENTRY;
-
- if (rec->lrh_type != LLOG_LOGID_MAGIC) {
- CERROR("invalid record in catalog\n");
- RETURN(-EINVAL);
- }
- CDEBUG(D_HA, "processing log "LPX64":%x at index %u of catalog "
- LPX64"\n", lir->lid_id.lgl_oid, lir->lid_id.lgl_ogen,
- rec->lrh_index, cathandle->lgh_id.lgl_oid);
-
- rc = llog_cat_id2handle(cathandle, &loghandle, &lir->lid_id);
- if (rc) {
- CERROR("Cannot find handle for log "LPX64"\n",
- lir->lid_id.lgl_oid);
- if (rc == -ENOENT) {
- index = rec->lrh_index;
- goto cat_cleanup;
- }
- RETURN(rc);
- }
-
- llh = loghandle->lgh_hdr;
- if ((llh->llh_flags & LLOG_F_ZAP_WHEN_EMPTY) &&
- (llh->llh_count == 1)) {
- rc = llog_destroy(loghandle);
- if (rc)
- CERROR("failure destroying log in postsetup: %d\n", rc);
-
- index = loghandle->u.phd.phd_cookie.lgc_index;
- llog_free_handle(loghandle);
-
-cat_cleanup:
- LASSERT(index);
- llog_cat_set_first_idx(cathandle, index);
- rc = llog_cancel_rec(cathandle, index);
- if (rc == 0)
- CDEBUG(D_HA, "cancel log "LPX64":%x at index %u of catalog "
- LPX64"\n", lir->lid_id.lgl_oid,
- lir->lid_id.lgl_ogen, rec->lrh_index,
- cathandle->lgh_id.lgl_oid);
- }
-
- RETURN(rc);
-}
-
/* lop_setup method for filter/osc */
// XXX how to set exports
int llog_obd_origin_setup(struct obd_device *obd, struct obd_llog_group *olg,
RETURN(rc);
}
-static int cat_print_cb(struct llog_handle *llh, struct llog_rec_hdr *rec,
- void *data)
+static int cat_print_cb(const struct lu_env *env, struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
{
struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
RETURN(0);
}
-static int plain_print_cb(struct llog_handle *llh, struct llog_rec_hdr *rec,
- void *data)
+static int plain_print_cb(const struct lu_env *env, struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
{
if (!(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)) {
CERROR("log is not plain\n");
RETURN(0);
}
-static int llog_cancel_rec_cb(struct llog_handle *llh, struct llog_rec_hdr *rec,
- void *data)
+static int llog_cancel_rec_cb(const struct lu_env *env,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
{
struct llog_cookie cookie;
static int i = 0;
#include <obd_class.h>
#include <obd.h>
#endif
-#include <lustre_log.h>
-#include <lprocfs_status.h>
-#include <libcfs/list.h>
#include <lustre_param.h>
+#include "llog_internal.h"
+
static cfs_hash_ops_t uuid_hash_ops;
static cfs_hash_ops_t nid_hash_ops;
static cfs_hash_ops_t nid_stat_hash_ops;
}
EXPORT_SYMBOL(class_process_proc_param);
-int class_config_dump_handler(struct llog_handle * handle,
- struct llog_rec_hdr *rec, void *data);
-
#ifdef __KERNEL__
extern int lustre_check_exclusion(struct super_block *sb, char *svname);
#else
* records, change uuids, etc), then class_process_config() resulting
* net records.
*/
-static int class_config_llog_handler(struct llog_handle * handle,
- struct llog_rec_hdr *rec, void *data)
+static int class_config_llog_handler(const struct lu_env *env,
+ struct llog_handle *handle,
+ struct llog_rec_hdr *rec, void *data)
{
struct config_llog_instance *clli = data;
int cfg_len = rec->lrh_len;
out:
if (rc) {
CERROR("Err %d on cfg command:\n", rc);
- class_config_dump_handler(handle, rec, data);
+ class_config_dump_handler(NULL, handle, rec, data);
}
RETURN(rc);
}
}
EXPORT_SYMBOL(class_config_parse_llog);
-int class_config_dump_handler(struct llog_handle * handle,
- struct llog_rec_hdr *rec, void *data)
+int class_config_dump_handler(const struct lu_env *env,
+ struct llog_handle *handle,
+ struct llog_rec_hdr *rec, void *data)
{
int cfg_len = rec->lrh_len;
char *cfg_buf = (char*) (rec + 1);
//int filter_get_catalog(struct obd_device *);
void filter_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
void *cb_data, int error);
-int filter_recov_log_mds_ost_cb(struct llog_handle *llh,
- struct llog_rec_hdr *rec, void *data);
+int filter_recov_log_mds_ost_cb(const struct lu_env *env,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data);
#ifdef LPROCFS
void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages,
RETURN(rc);
}
-int filter_recov_log_mds_ost_cb(struct llog_handle *llh,
- struct llog_rec_hdr *rec, void *data)
+int filter_recov_log_mds_ost_cb(const struct lu_env *env,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
{
struct llog_ctxt *ctxt = llh->lgh_ctxt;
struct llog_cookie cookie;
RETURN(rc);
}
-static int local_read_handler(struct llog_handle *llh,
- struct llog_rec_hdr *rec,
- void *data)
+static int local_read_handler(const struct lu_env *env,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
{
struct sptlrpc_conf *conf = (struct sptlrpc_conf *) data;
struct lustre_cfg *lcfg = (struct lustre_cfg *)(rec + 1);