From 77071f22591389b472bafb8e524d2a28fefe16a8 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 29 Aug 2005 12:28:58 +0000 Subject: [PATCH] - replay i/o epochs along with other attributes to improve isize consistency without involving OST --- lustre/include/linux/lustre_idl.h | 1 + lustre/include/linux/lustre_mds.h | 1 + lustre/mdc/mdc_lib.c | 1 + lustre/mdc/mdc_request.c | 1 + lustre/mds/mds_lib.c | 1 + lustre/mds/mds_open.c | 20 ++++++++++++-------- lustre/ptlrpc/pack_generic.c | 1 + 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index 67a1784..3b0e1ea 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -818,6 +818,7 @@ struct mds_rec_create { __u64 cr_rdev; __u64 cr_enkey; __u64 cr_mac; + __u64 cr_ioepoch; }; extern void lustre_swab_mds_rec_create (struct mds_rec_create *cr); diff --git a/lustre/include/linux/lustre_mds.h b/lustre/include/linux/lustre_mds.h index 07b957c..ee98a4e 100644 --- a/lustre/include/linux/lustre_mds.h +++ b/lustre/include/linux/lustre_mds.h @@ -71,6 +71,7 @@ struct mds_update_record { __u32 ur_mode; __u64 ur_time; __u32 ur_flags; + __u64 ur_ioepoch; }; #define ur_fsuid ur_uc.luc_fsuid diff --git a/lustre/mdc/mdc_lib.c b/lustre/mdc/mdc_lib.c index 36dc34c..8130e88 100644 --- a/lustre/mdc/mdc_lib.c +++ b/lustre/mdc/mdc_lib.c @@ -70,6 +70,7 @@ void mdc_open_pack(struct lustre_msg *msg, int offset, rec->cr_time = op_data->mod_time; rec->cr_mode = mode; rec->cr_rdev = rdev; + rec->cr_ioepoch = 0; if (op_data->name) { tmp = lustre_msg_buf(msg, offset + 1, diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 24a9920..4078860 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -672,6 +672,7 @@ int mdc_set_open_replay_data(struct obd_export *exp, mod->mod_open_req = ptlrpc_request_addref(open_req); memcpy(&rec->cr_replayid, &body->id1, sizeof rec->cr_replayid); + memcpy(&rec->cr_ioepoch, &body->io_epoch, sizeof rec->cr_ioepoch); open_req->rq_replay_cb = mdc_replay_open; open_req->rq_commit_cb = mdc_commit_open; open_req->rq_cb_data = mod; diff --git a/lustre/mds/mds_lib.c b/lustre/mds/mds_lib.c index b97f854..bc0fb6f 100644 --- a/lustre/mds/mds_lib.c +++ b/lustre/mds/mds_lib.c @@ -606,6 +606,7 @@ static int mds_open_unpack(struct ptlrpc_request *req, int offset, r->ur_rdev = rec->cr_rdev; r->ur_time = rec->cr_time; r->ur_flags = rec->cr_flags; + r->ur_ioepoch = rec->cr_ioepoch; LASSERT_REQSWAB(req, offset + 1); r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0); diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index 482ef7c..f96835e 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -168,13 +168,16 @@ static int mds_get_write_access(struct mds_obd *mds, struct inode *inode, rc = -ENOMEM; goto out; } - if (epoch > mds->mds_io_epoch) + if (epoch > mds->mds_io_epoch) { mds->mds_io_epoch = epoch; - else + CDEBUG(D_INODE, "repair MDS epoch "LPU64" for ino %lu/%u\n", + mds->mds_io_epoch, inode->i_ino, inode->i_generation); + } else { mds->mds_io_epoch++; + CDEBUG(D_INODE, "starting MDS epoch "LPU64" for ino %lu/%u\n", + mds->mds_io_epoch, inode->i_ino, inode->i_generation); + } MDS_FILTERDATA(inode)->io_epoch = mds->mds_io_epoch; - CDEBUG(D_INODE, "starting MDS epoch "LPU64" for ino %lu/%u\n", - mds->mds_io_epoch, inode->i_ino, inode->i_generation); out: if (rc == 0) atomic_inc(&inode->i_writecount); @@ -234,7 +237,8 @@ int mds_query_write_access(struct inode *inode) /* This replaces the VFS dentry_open, it manages mfd and writecount */ static struct mds_file_data *mds_dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags, - struct ptlrpc_request *req) + struct ptlrpc_request *req, + struct mds_update_record *rec) { struct mds_export_data *med = &req->rq_export->exp_mds_data; struct mds_obd *mds = mds_req2mds(req); @@ -253,7 +257,7 @@ static struct mds_file_data *mds_dentry_open(struct dentry *dentry, if (flags & FMODE_WRITE) { /* FIXME: in recovery, need to pass old epoch here */ - rc = mds_get_write_access(mds, dentry->d_inode, 0); + rc = mds_get_write_access(mds, dentry->d_inode, rec->ur_ioepoch); if (rc) GOTO(cleanup_mfd, rc); body->io_epoch = MDS_FILTERDATA(dentry->d_inode)->io_epoch; @@ -667,7 +671,7 @@ static void reconstruct_open(struct mds_update_record *rec, int offset, mntget(mds->mds_vfsmnt); CERROR("Re-opened file \n"); mfd = mds_dentry_open(dchild, mds->mds_vfsmnt, - rec->ur_flags & ~MDS_OPEN_TRUNC, req); + rec->ur_flags & ~MDS_OPEN_TRUNC, req, rec); if (!mfd) { CERROR("mds: out of memory\n"); GOTO(out_dput, req->rq_status = -ENOMEM); @@ -807,7 +811,7 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild, up(&dchild->d_inode->i_sem); intent_set_disposition(rep, DISP_OPEN_OPEN); - mfd = mds_dentry_open(dchild, mds->mds_vfsmnt, flags, req); + mfd = mds_dentry_open(dchild, mds->mds_vfsmnt, flags, req, rec); if (IS_ERR(mfd)) RETURN(PTR_ERR(mfd)); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 5fc436a..f07d95b 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -789,6 +789,7 @@ void lustre_swab_mds_rec_create(struct mds_rec_create *cr) lustre_swab_lustre_id(&cr->cr_replayid); __swab64s(&cr->cr_time); __swab64s(&cr->cr_rdev); + __swab64s(&cr->cr_ioepoch); } void lustre_swab_mds_rec_link(struct mds_rec_link *lk) -- 1.8.3.1