From 5cf0198f370ad65fb52e128cc41eacef15809551 Mon Sep 17 00:00:00 2001 From: vs Date: Wed, 5 Nov 2008 22:27:50 +0000 Subject: [PATCH] Branch b1_8_gate b=17359 i=adilger,bzzz use time obtained from a client to update inode timestamps on mds mds_reint_link, mds_reint_unlink and mds_reint_rename updated inode timestamps with local server time --- lustre/mds/mds_reint.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index bd2f158..1a4ee4c 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -2013,10 +2013,19 @@ cleanup: struct iattr iattr; int err; + /* update ctime of unlinked file, even if last link is + removed because open-unlinked file can be statted */ + iattr.ia_valid = ATTR_CTIME; + LTIME_S(iattr.ia_ctime) = rec->ur_time; + err = fsfilt_setattr(obd, dchild, handle, &iattr, 0); + if (err) + CERROR("error on unlinked inode time update: " + "rc = %d\n", err); + + /* update mtime and ctime of parent directory*/ iattr.ia_valid = ATTR_MTIME | ATTR_CTIME; LTIME_S(iattr.ia_mtime) = rec->ur_time; LTIME_S(iattr.ia_ctime) = rec->ur_time; - err = fsfilt_setattr(obd, dparent, handle, &iattr, 0); if (err) CERROR("error on parent setattr: rc = %d\n", err); @@ -2190,6 +2199,27 @@ static int mds_reint_link(struct mds_update_record *rec, int offset, UNLOCK_INODE_MUTEX(de_tgt_dir->d_inode); if (rc && rc != -EPERM && rc != -EACCES) CERROR("vfs_link error %d\n", rc); + if (rc == 0) { + struct iattr iattr; + int err; + + /* update ctime of old file */ + iattr.ia_valid = ATTR_CTIME; + LTIME_S(iattr.ia_ctime) = rec->ur_time; + err = fsfilt_setattr(obd, de_src, handle, &iattr, 0); + if (err) + CERROR("error on old inode time update: " + "rc = %d\n", err); + + /* update mtime and ctime of target directory */ + iattr.ia_valid = ATTR_MTIME | ATTR_CTIME; + LTIME_S(iattr.ia_mtime) = rec->ur_time; + LTIME_S(iattr.ia_ctime) = rec->ur_time; + err = fsfilt_setattr(obd, de_tgt_dir, handle, &iattr, 0); + if (err) + CERROR("error on target dir inode time update: " + "rc = %d\n", err); + } cleanup: inodes[0] = de_tgt_dir ? de_tgt_dir->d_inode : NULL; inodes[1] = (dchild && !IS_ERR(dchild)) ? dchild->d_inode : NULL; @@ -2584,6 +2614,58 @@ no_unlink: de_tgtdir->d_inode, de_new, mds->mds_vfsmnt); unlock_kernel(); + if (rc == 0) { + struct iattr iattr; + int err; + + /* update ctime of renamed file */ + iattr.ia_valid = ATTR_CTIME; + LTIME_S(iattr.ia_ctime) = rec->ur_time; + if (S_ISDIR(de_old->d_inode->i_mode) && + de_srcdir->d_inode != de_tgtdir->d_inode) { + /* cross directory rename of a directory, ".." + changed, update mtime also */ + iattr.ia_valid |= ATTR_MTIME; + LTIME_S(iattr.ia_mtime) = rec->ur_time; + } + err = fsfilt_setattr(obd, de_old, handle, &iattr, 0); + if (err) + CERROR("error on old inode time update: " + "rc = %d\n", err); + + if (de_new->d_inode) { + /* target file exists, update its ctime as it + gets unlinked */ + iattr.ia_valid = ATTR_CTIME; + LTIME_S(iattr.ia_ctime) = rec->ur_time; + err = fsfilt_setattr(obd, de_new, handle, &iattr, 0); + if (err) + CERROR("error on target inode time update: " + "rc = %d\n", err); + } + + /* update mtime and ctime of old directory */ + iattr.ia_valid = ATTR_MTIME | ATTR_CTIME; + LTIME_S(iattr.ia_mtime) = rec->ur_time; + LTIME_S(iattr.ia_ctime) = rec->ur_time; + err = fsfilt_setattr(obd, de_srcdir, handle, &iattr, 0); + if (err) + CERROR("error on old dir inode update: " + "rc = %d\n", err); + + if (de_srcdir->d_inode != de_tgtdir->d_inode) { + /* cross directory rename, update + mtime and ctime of new directory */ + iattr.ia_valid = ATTR_MTIME | ATTR_CTIME; + LTIME_S(iattr.ia_mtime) = rec->ur_time; + LTIME_S(iattr.ia_ctime) = rec->ur_time; + err = fsfilt_setattr(obd, de_tgtdir, handle, &iattr, 0); + if (err) + CERROR("error on new dir inode time update: " + "rc = %d\n", err); + } + } + if (rc == 0 && new_inode != NULL && new_inode->i_nlink == 0) { if (mds_orphan_needed(obd, new_inode)) rc = mds_orphan_add_link(rec, obd, de_new); -- 1.8.3.1