From 329ec3e6328a9a38776ea63c52a19c85129535c3 Mon Sep 17 00:00:00 2001 From: tappro Date: Fri, 16 Sep 2005 23:30:58 +0000 Subject: [PATCH] b=7230 update mtime as well as size on MDS and in llite --- lustre/llite/file.c | 13 ++++++++----- lustre/mds/handler.c | 7 ++++--- lustre/mds/mds_open.c | 11 +++++++++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index b5362c7b..85102a5 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -41,7 +41,8 @@ __u64 lov_merge_size(struct lov_stripe_md *lsm, int kms); __u64 lov_merge_blocks(struct lov_stripe_md *lsm); __u64 lov_merge_mtime(struct lov_stripe_md *lsm, __u64 current_time); -int ll_validate_size(struct inode *inode, __u64 *size, __u64 *blocks) +int ll_validate_size(struct inode *inode, __u64 *size, __u64 *blocks, + __u64 *mtime) { ldlm_policy_data_t extent = { .l_extent = { 0, OBD_OBJECT_EOF } }; struct obd_export *exp = ll_i2sbi(inode)->ll_dt_exp; @@ -68,6 +69,8 @@ int ll_validate_size(struct inode *inode, __u64 *size, __u64 *blocks) down(&lli->lli_size_sem); *size = lov_merge_size(lli->lli_smd, 0); *blocks = lov_merge_blocks(lli->lli_smd); + *mtime = lov_merge_mtime(lli->lli_smd, LTIME_S(inode->i_mtime)); + up(&lli->lli_size_sem); finish: @@ -121,8 +124,9 @@ int ll_md_och_close(struct obd_export *md_exp, struct inode *inode, op_data->io_epoch = epoch; op_data->flags |= MDS_BFLAG_DIRTY_EPOCH; op_data->valid |= OBD_MD_FLFLAGS | OBD_MD_FLEPOCH; - if (ll_validate_size(inode, &op_data->size, &op_data->blocks)) - op_data->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; + if (ll_validate_size(inode, &op_data->size, &op_data->blocks, + &op_data->mtime)) + op_data->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLMTIME; } rc = md_close(md_exp, op_data, och, &req); @@ -1038,10 +1042,9 @@ int ll_glimpse_size(struct inode *inode) down(&lli->lli_size_sem); inode->i_size = lov_merge_size(lli->lli_smd, 0); inode->i_blocks = lov_merge_blocks(lli->lli_smd); - up(&lli->lli_size_sem); - LTIME_S(inode->i_mtime) = lov_merge_mtime(lli->lli_smd, LTIME_S(inode->i_mtime)); + up(&lli->lli_size_sem); CDEBUG(D_DLMTRACE, "glimpse: size: "LPU64", blocks: "LPU64"\n", (__u64)inode->i_size, (__u64)inode->i_blocks); diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 3f1a247..9353e7d 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1233,6 +1233,7 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry, !(body->valid & OBD_MD_FLDIREA)) body->valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLATIME | OBD_MD_FLMTIME); + } else if (S_ISLNK(inode->i_mode) && (reqbody->valid & OBD_MD_LINKNAME) != 0) { rc = mds_pack_link(dentry, req, body, reply_off); @@ -1464,7 +1465,7 @@ int mds_getattr_size(struct obd_device *obd, struct dentry *dentry, /* XXX: quite a ugly hack, need to check old code * drop FLSIZE/FLBLOCKS prior any checking to */ - body->valid &= ~(OBD_MD_FLSIZE | OBD_MD_FLBLOCKS); + body->valid &= ~(OBD_MD_FLSIZE | OBD_MD_FLBLOCKS|OBD_MD_FLMTIME); if (obd->obd_recovering) { CDEBUG(D_INODE, "size for "DLID4" is unknown yet (recovering)\n", @@ -1481,7 +1482,7 @@ int mds_getattr_size(struct obd_device *obd, struct dentry *dentry, } CDEBUG(D_INODE, "MDS returns "LPD64"/"LPD64" for"DLID4"\n", body->size, body->blocks, OLID4(&body->id1)); - body->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; + body->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLMTIME; RETURN(0); } @@ -2789,7 +2790,7 @@ static int mdt_set_info(struct ptlrpc_request *req) lustre_swab_audit_attr); msg = *p; - CDEBUG(D_INFO, "Get new audit setting 0x%x\n", (__u32)msg.attr); + //CDEBUG(D_INFO, "Get new audit setting 0x%x\n", (__u32)msg.attr); rc = obd_set_info(exp, keylen, key, sizeof(msg), &msg); req->rq_repmsg->status = rc; diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index c4fc1d0..963a74d 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -1541,8 +1541,11 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset, request_body->io_epoch); i_size_write(inode, request_body->size); inode->i_blocks = request_body->blocks; + LTIME_S(inode->i_mtime) = (request_body->mtime); + + LTIME_S(iattr.ia_mtime) = request_body->mtime; iattr.ia_size = inode->i_size; - iattr.ia_valid |= ATTR_SIZE; + iattr.ia_valid |= ATTR_SIZE|ATTR_MTIME; mds_inode_unset_attrs_old(inode); } @@ -1766,6 +1769,7 @@ static int mds_extent_lock_callback(struct ldlm_lock *lock, } __u64 lov_merge_size(struct lov_stripe_md *lsm, int kms); __u64 lov_merge_blocks(struct lov_stripe_md *lsm); +__u64 lov_merge_mtime(struct lov_stripe_md *lsm, __u64 current_time); int mds_validate_size(struct obd_device *obd, struct inode *inode, struct mds_body *body, struct iattr *iattr) @@ -1854,8 +1858,11 @@ int mds_validate_size(struct obd_device *obd, struct inode *inode, i_size_write(inode, lov_merge_size(lsm, 0)); inode->i_blocks = lov_merge_blocks(lsm); + LTIME_S(inode->i_mtime) = lov_merge_mtime(lsm, LTIME_S(inode->i_mtime)); iattr->ia_size = inode->i_size; - iattr->ia_valid |= ATTR_SIZE; + LTIME_S(iattr->ia_mtime) = LTIME_S(inode->i_mtime); + iattr->ia_valid |= ATTR_SIZE | ATTR_MTIME; + DOWN_WRITE_I_ALLOC_SEM(inode); mds_inode_unset_attrs_old(inode); UP_WRITE_I_ALLOC_SEM(inode); -- 1.8.3.1