From 08463f3f3e954f8af72303ed3fde58615cd53bb3 Mon Sep 17 00:00:00 2001 From: vitaly Date: Tue, 3 Oct 2006 20:31:52 +0000 Subject: [PATCH] Branch b_new_cmd recover IO epoch number from replayed open request. --- lustre/include/lustre/lustre_idl.h | 3 +-- lustre/mdc/mdc_request.c | 1 + lustre/mdt/mdt_internal.h | 4 ++-- lustre/mdt/mdt_lib.c | 1 + lustre/mdt/mdt_open.c | 17 +++++++---------- lustre/mdt/mdt_reint.c | 3 +-- lustre/ptlrpc/pack_generic.c | 3 +-- 7 files changed, 14 insertions(+), 18 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index c6fd621..e605aa5 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -1221,12 +1221,11 @@ struct mdt_rec_create { struct lu_fid cr_fid2; __u64 cr_time; __u64 cr_rdev; + __u64 cr_ioepoch; __u32 cr_suppgid; __u32 cr_padding_1; /* also fix lustre_swab_mds_rec_create */ __u32 cr_padding_2; /* also fix lustre_swab_mds_rec_create */ __u32 cr_padding_3; /* also fix lustre_swab_mds_rec_create */ - __u32 cr_padding_4; /* also fix lustre_swab_mds_rec_create */ - __u32 cr_padding_5; /* also fix lustre_swab_mds_rec_create */ }; extern void lustre_swab_mdt_rec_create (struct mdt_rec_create *cr); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index d5e8f2d..a118851 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -720,6 +720,7 @@ int mdc_set_open_replay_data(struct obd_export *exp, } rec->cr_fid2 = body->fid1; + rec->cr_ioepoch = body->ioepoch; open_req->rq_replay_cb = mdc_replay_open; if (!fid_is_sane(&body->fid1)) { DEBUG_REQ(D_ERROR, open_req, "saving replay request with " diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 0c35829..16bcc91 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -319,6 +319,7 @@ struct mdt_thread_info { /* IO epoch related stuff. */ struct mdt_epoch *mti_epoch; + __u64 mti_replayepoch; /* server and client data buffers */ struct mdt_server_data mti_msd; @@ -446,8 +447,7 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc); struct mdt_file_data *mdt_handle2mfd(const struct lustre_handle *handle); -int mdt_epoch_open(struct mdt_thread_info *info, struct mdt_object *o, - __u64 epoch); +int mdt_epoch_open(struct mdt_thread_info *info, struct mdt_object *o); void mdt_sizeonmds_enable(struct mdt_thread_info *info, struct mdt_object *mo); int mdt_sizeonmds_enabled(struct mdt_object *mo); int mdt_write_get(struct mdt_device *mdt, struct mdt_object *o); diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index 41d2d9e..01c30a1 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -912,6 +912,7 @@ static int mdt_open_unpack(struct mdt_thread_info *info) attr->la_valid = LA_MODE | LA_RDEV | LA_UID | LA_GID | LA_CTIME | LA_MTIME | LA_ATIME; info->mti_spec.sp_cr_flags = rec->cr_flags; + info->mti_replayepoch = rec->cr_ioepoch; if (req_capsule_get_size(pill, &RMF_CAPA1, RCL_CLIENT)) rr->rr_capa1 = req_capsule_client_get(pill, &RMF_CAPA1); diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 0e3e404..89dd16e 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -114,11 +114,8 @@ void mdt_sizeonmds_enable(struct mdt_thread_info *info, } /* Open the epoch. Epoch open is allowed if @writecount is not negative. - * The epoch and writecount handling is performed under the mdt_ioepoch_lock. - * - * @epoch is nonzero during recovery XXX not ready. */ -int mdt_epoch_open(struct mdt_thread_info *info, struct mdt_object *o, - __u64 epoch) + * The epoch and writecount handling is performed under the mdt_ioepoch_lock. */ +int mdt_epoch_open(struct mdt_thread_info *info, struct mdt_object *o) { struct mdt_device *mdt = info->mti_mdt; int cancel = 0; @@ -134,11 +131,12 @@ int mdt_epoch_open(struct mdt_thread_info *info, struct mdt_object *o, CDEBUG(D_INODE, "continue epoch "LPU64" for "DFID"\n", o->mot_ioepoch, PFID(mdt_object_fid(o))); } else { - if (epoch > mdt->mdt_ioepoch) - mdt->mdt_ioepoch = epoch; + if (info->mti_replayepoch > mdt->mdt_ioepoch) + mdt->mdt_ioepoch = info->mti_replayepoch; else mdt->mdt_ioepoch++; - o->mot_ioepoch = epoch ? epoch : mdt->mdt_ioepoch; + o->mot_ioepoch = info->mti_replayepoch ? + info->mti_replayepoch : mdt->mdt_ioepoch; CDEBUG(D_INODE, "starting epoch "LPU64" for "DFID"\n", mdt->mdt_ioepoch, PFID(mdt_object_fid(o))); cancel = 1; @@ -451,8 +449,7 @@ static int mdt_mfd_open(struct mdt_thread_info *info, if (flags & FMODE_WRITE) { rc = mdt_write_get(info->mti_mdt, o); if (rc == 0) { - /* FIXME: in recovery, need to pass old epoch here */ - mdt_epoch_open(info, o, 0); + mdt_epoch_open(info, o); repbody->ioepoch = o->mot_ioepoch; } } else if (flags & MDS_FMODE_EXEC) { diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 25cadbe2..3774e54 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -226,8 +226,7 @@ static int mdt_reint_setattr(struct mdt_thread_info *info, if (mfd == NULL) GOTO(out, rc = -ENOMEM); - /* FIXME: in recovery, need to pass old epoch here */ - mdt_epoch_open(info, mo, 0); + mdt_epoch_open(info, mo); repbody->ioepoch = mo->mot_ioepoch; mdt_object_get(info->mti_env, mo); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 2e23555..1606771 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -1817,12 +1817,11 @@ void lustre_swab_mdt_rec_create (struct mdt_rec_create *cr) lustre_swab_lu_fid (&cr->cr_fid2); __swab64s (&cr->cr_time); __swab64s (&cr->cr_rdev); + __swab64s (&cr->cr_ioepoch); __swab32s (&cr->cr_suppgid); CLASSERT(offsetof(typeof(*cr), cr_padding_1) != 0); CLASSERT(offsetof(typeof(*cr), cr_padding_2) != 0); CLASSERT(offsetof(typeof(*cr), cr_padding_3) != 0); - CLASSERT(offsetof(typeof(*cr), cr_padding_4) != 0); - CLASSERT(offsetof(typeof(*cr), cr_padding_5) != 0); } void lustre_swab_mds_rec_link (struct mds_rec_link *lk) -- 1.8.3.1