From 7cae9dd4981b8ce602b144fd665bf362bf28ffc7 Mon Sep 17 00:00:00 2001 From: adilger Date: Fri, 3 Jun 2005 22:32:21 +0000 Subject: [PATCH] Branch b1_4 Put filter_destroy(), filter_setattr() into filter_internal.h so we can call them directly in filter_log.c instead of using obd_*() indirection. Minor code reorg of filter_llog_finish() for the same reason. --- lustre/obdfilter/filter.c | 135 ++++++++++++++++++------------------- lustre/obdfilter/filter_internal.h | 4 ++ lustre/obdfilter/filter_log.c | 12 ++-- 3 files changed, 76 insertions(+), 75 deletions(-) diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 207aa33..dcfc65a 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -62,9 +62,6 @@ static struct lvfs_callback_ops filter_lvfs_ops; -static int filter_destroy(struct obd_export *exp, struct obdo *oa, - struct lov_stripe_md *ea, struct obd_trans_info *); - static void filter_commit_cb(struct obd_device *obd, __u64 transno, void *cb_data, int error) { @@ -1300,6 +1297,13 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf, GOTO(err_post, rc); } + rc = qctxt_init(&filter->fo_quota_ctxt, filter->fo_sb, NULL); + if (rc) { + CERROR("initialize quota context failed! (rc:%d)\n", rc); + qctxt_cleanup(&filter->fo_quota_ctxt, 0); + GOTO(err_post, rc); + } + if (obd->obd_recovering) { LCONSOLE_WARN("OST %s now serving %s, but will be in recovery " "until %d %s reconnect, or if no clients " @@ -1322,13 +1326,6 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf, obd->obd_replayable ? "enabled" : "disabled"); } - rc = qctxt_init(&filter->fo_quota_ctxt, filter->fo_sb, NULL); - if (rc) { - CERROR("initialize quota context failed! (rc:%d)\n", rc); - qctxt_cleanup(&filter->fo_quota_ctxt, 0); - GOTO(err_post, rc); - } - RETURN(0); err_post: @@ -1373,17 +1370,69 @@ static int filter_setup(struct obd_device *obd, obd_count len, void *buf) return rc; } +static struct llog_operations filter_mds_ost_repl_logops /* initialized below*/; +static struct llog_operations filter_size_orig_logops = { + lop_setup: llog_obd_origin_setup, + lop_cleanup: llog_obd_origin_cleanup, + lop_add: llog_obd_origin_add +}; + +static int filter_llog_init(struct obd_device *obd, struct obd_device *tgt, + int count, struct llog_catid *catid) +{ + struct llog_ctxt *ctxt; + int rc; + ENTRY; + + filter_mds_ost_repl_logops = llog_client_ops; + filter_mds_ost_repl_logops.lop_cancel = llog_obd_repl_cancel; + filter_mds_ost_repl_logops.lop_connect = llog_repl_connect; + filter_mds_ost_repl_logops.lop_sync = llog_obd_repl_sync; + + rc = llog_setup(obd, LLOG_MDS_OST_REPL_CTXT, tgt, 0, NULL, + &filter_mds_ost_repl_logops); + if (rc) + RETURN(rc); + + /* FIXME - assign unlink_cb for filter's recovery */ + ctxt = llog_get_context(obd, LLOG_MDS_OST_REPL_CTXT); + ctxt->llog_proc_cb = filter_recov_log_mds_ost_cb; + + rc = llog_setup(obd, LLOG_SIZE_ORIG_CTXT, tgt, 0, NULL, + &filter_size_orig_logops); + RETURN(rc); +} + +static int filter_llog_finish(struct obd_device *obd, int count) +{ + struct llog_ctxt *ctxt; + int rc = 0, rc2 = 0; + ENTRY; + + ctxt = llog_get_context(obd, LLOG_MDS_OST_REPL_CTXT); + if (ctxt) + rc = llog_cleanup(ctxt); + + ctxt = llog_get_context(obd, LLOG_SIZE_ORIG_CTXT); + if (ctxt) + rc2 = llog_cleanup(ctxt); + if (!rc) + rc = rc2; + + RETURN(rc); +} + static int filter_precleanup(struct obd_device *obd, int stage) { int rc = 0; ENTRY; switch(stage) { - case 1: + case 1: target_cleanup_recovery(obd); break; - case 2: - rc = obd_llog_finish(obd, 0); + case 2: + rc = filter_llog_finish(obd, 0); } RETURN(rc); } @@ -1727,8 +1776,8 @@ static int filter_getattr(struct obd_export *exp, struct obdo *oa, } /* this is called from filter_truncate() until we have filter_punch() */ -static int filter_setattr(struct obd_export *exp, struct obdo *oa, - struct lov_stripe_md *md, struct obd_trans_info *oti) +int filter_setattr(struct obd_export *exp, struct obdo *oa, + struct lov_stripe_md *md, struct obd_trans_info *oti) { struct obd_device *obd; struct obd_run_ctxt saved; @@ -2231,8 +2280,8 @@ static int filter_create(struct obd_export *exp, struct obdo *oa, RETURN(rc); } -static int filter_destroy(struct obd_export *exp, struct obdo *oa, - struct lov_stripe_md *ea, struct obd_trans_info *oti) +int filter_destroy(struct obd_export *exp, struct obdo *oa, + struct lov_stripe_md *md, struct obd_trans_info *oti) { struct obd_device *obd; struct filter_obd *filter; @@ -2625,58 +2674,6 @@ static int filter_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl) RETURN(rc); } -static struct llog_operations filter_mds_ost_repl_logops; -static struct llog_operations filter_size_orig_logops = { - lop_setup: llog_obd_origin_setup, - lop_cleanup: llog_obd_origin_cleanup, - lop_add: llog_obd_origin_add -}; - -static int filter_llog_init(struct obd_device *obd, struct obd_device *tgt, - int count, struct llog_catid *catid) -{ - struct llog_ctxt *ctxt; - int rc; - ENTRY; - - filter_mds_ost_repl_logops = llog_client_ops; - filter_mds_ost_repl_logops.lop_cancel = llog_obd_repl_cancel; - filter_mds_ost_repl_logops.lop_connect = llog_repl_connect; - filter_mds_ost_repl_logops.lop_sync = llog_obd_repl_sync; - - rc = llog_setup(obd, LLOG_MDS_OST_REPL_CTXT, tgt, 0, NULL, - &filter_mds_ost_repl_logops); - if (rc) - RETURN(rc); - - /* FIXME - assign unlink_cb for filter's recovery */ - ctxt = llog_get_context(obd, LLOG_MDS_OST_REPL_CTXT); - ctxt->llog_proc_cb = filter_recov_log_mds_ost_cb; - - rc = llog_setup(obd, LLOG_SIZE_ORIG_CTXT, tgt, 0, NULL, - &filter_size_orig_logops); - RETURN(rc); -} - -static int filter_llog_finish(struct obd_device *obd, int count) -{ - struct llog_ctxt *ctxt; - int rc = 0, rc2 = 0; - ENTRY; - - ctxt = llog_get_context(obd, LLOG_MDS_OST_REPL_CTXT); - if (ctxt) - rc = llog_cleanup(ctxt); - - ctxt = llog_get_context(obd, LLOG_SIZE_ORIG_CTXT); - if (ctxt) - rc2 = llog_cleanup(ctxt); - if (!rc) - rc = rc2; - - RETURN(rc); -} - static struct dentry *filter_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr, void *data) { diff --git a/lustre/obdfilter/filter_internal.h b/lustre/obdfilter/filter_internal.h index a0fcee7..47ad2ce 100644 --- a/lustre/obdfilter/filter_internal.h +++ b/lustre/obdfilter/filter_internal.h @@ -111,6 +111,10 @@ int filter_update_server_data(struct obd_device *, struct file *, int filter_update_last_objid(struct obd_device *, obd_gr, int force_sync); int filter_common_setup(struct obd_device *, obd_count len, void *buf, char *option); +int filter_destroy(struct obd_export *exp, struct obdo *oa, + struct lov_stripe_md *md, struct obd_trans_info *); +int filter_setattr(struct obd_export *exp, struct obdo *oa, + struct lov_stripe_md *md, struct obd_trans_info *oti); /* filter_lvb.c */ extern struct ldlm_valblock_ops filter_lvbo; diff --git a/lustre/obdfilter/filter_log.c b/lustre/obdfilter/filter_log.c index 34ad008..2ddfe72 100644 --- a/lustre/obdfilter/filter_log.c +++ b/lustre/obdfilter/filter_log.c @@ -137,7 +137,7 @@ static int filter_recov_log_unlink_cb(struct llog_ctxt *ctxt, memcpy(obdo_logcookie(oa), cookie, sizeof(*cookie)); oid = oa->o_id; - rc = obd_destroy(exp, oa, NULL, NULL); + rc = filter_destroy(exp, oa, NULL, NULL); obdo_free(oa); if (rc == -ENOENT) { CDEBUG(D_HA, "object already removed, send cookie\n"); @@ -165,10 +165,10 @@ static int filter_recov_log_setattr_cb(struct llog_ctxt *ctxt, obd_id oid; int rc = 0; ENTRY; - + lsr = (struct llog_setattr_rec *)rec; oa = obdo_alloc(); - + oa->o_valid |= (OBD_MD_FLID | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLCOOKIE); oa->o_id = lsr->lsr_oid; @@ -178,7 +178,7 @@ static int filter_recov_log_setattr_cb(struct llog_ctxt *ctxt, memcpy(obdo_logcookie(oa), cookie, sizeof(*cookie)); oid = oa->o_id; - rc = obd_setattr(exp, oa, NULL, NULL); + rc = filter_setattr(exp, oa, NULL, NULL); obdo_free(oa); if (rc == -ENOENT) { @@ -186,10 +186,10 @@ static int filter_recov_log_setattr_cb(struct llog_ctxt *ctxt, llog_cancel(ctxt, NULL, 1, cookie, 0); RETURN(0); } - + if (rc == 0) CDEBUG(D_HA, "object: "LPU64" in record is chown/chgrp\n", oid); - + RETURN(rc); } -- 1.8.3.1