diff --git a/Linux-5.1/fs/winefs/inode.c b/Linux-5.1/fs/winefs/inode.c index ed0ff1402..cfaa09362 100644 --- a/Linux-5.1/fs/winefs/inode.c +++ b/Linux-5.1/fs/winefs/inode.c @@ -632,8 +632,6 @@ static void __pmfs_truncate_blocks(struct inode *inode, loff_t start, unsigned int meta_bits = META_BLK_SHIFT; bool mpty; - inode->i_mtime = inode->i_ctime = current_time(inode); - if (!pi->root) goto end_truncate_blocks; @@ -2079,6 +2077,9 @@ void pmfs_truncate_add(struct inode *inode, u64 truncate_size) pmfs_memunlock_range(sb, li, sizeof(*li)); li->i_next_truncate = head->i_next_truncate; li->i_truncatesize = cpu_to_le64(truncate_size); + li->i_truncatemtime = cpu_to_le32(inode->i_mtime.tv_sec); + li->i_truncatectime = cpu_to_le32(inode->i_ctime.tv_sec); + li->i_timemarker = 1; pmfs_memlock_range(sb, li, sizeof(*li)); pmfs_flush_buffer(li, sizeof(*li), false); /* make sure above is persistent before changing the head pointer */ @@ -2117,6 +2118,7 @@ void pmfs_setsize(struct inode *inode, loff_t newsize) pmfs_block_truncate_page(inode, newsize); i_size_write(inode, newsize); } + /* FIXME: we should make sure that there is nobody reading the inode * before truncating it. Also we need to munmap the truncated range * from application address space, if mmapped. */ @@ -2195,6 +2197,7 @@ int pmfs_notify_change(struct dentry *dentry, struct iattr *attr) if ((ia_valid & ATTR_SIZE) && (attr->ia_size != inode->i_size || pi->i_flags & cpu_to_le32(PMFS_EOFBLOCKS_FL))) { + inode->i_mtime = inode->i_ctime = current_time(inode); pmfs_truncate_add(inode, attr->ia_size); /* set allocation hint */ //pmfs_set_blocksize_hint(sb, pi, attr->ia_size); diff --git a/Linux-5.1/fs/winefs/inode.h b/Linux-5.1/fs/winefs/inode.h index 5c76f6089..6756bb947 100644 --- a/Linux-5.1/fs/winefs/inode.h +++ b/Linux-5.1/fs/winefs/inode.h @@ -73,6 +73,9 @@ struct pmfs_inode_info_header { struct pmfs_inode_truncate_item { __le64 i_truncatesize; /* Size of truncated inode */ __le64 i_next_truncate; /* inode num of the next truncated inode */ + __le32 i_truncatemtime; /* The new mtime after the truncate operation */ + __le32 i_truncatectime; /* The new ctime after the truncate operation */ + u8 i_timemarker; }; struct pmfs_inode_info { diff --git a/Linux-5.1/fs/winefs/namei.c b/Linux-5.1/fs/winefs/namei.c index e062d50c6..434f240bd 100644 --- a/Linux-5.1/fs/winefs/namei.c +++ b/Linux-5.1/fs/winefs/namei.c @@ -365,9 +365,9 @@ static int pmfs_unlink(struct inode *dir, struct dentry *dentry) goto end_unlink; PMFS_START_TIMING(truncate_add_t, truncate_add_time); + inode->i_ctime = dir->i_ctime; if (inode->i_nlink == 1) pmfs_truncate_add(inode, inode->i_size); - inode->i_ctime = dir->i_ctime; PMFS_END_TIMING(truncate_add_t, truncate_add_time); pmfs_memunlock_inode(sb, pi); diff --git a/Linux-5.1/fs/winefs/super.c b/Linux-5.1/fs/winefs/super.c index acf0905c9..bd7759907 100644 --- a/Linux-5.1/fs/winefs/super.c +++ b/Linux-5.1/fs/winefs/super.c @@ -705,13 +705,19 @@ static void pmfs_recover_truncate_list(struct super_block *sb) inode = pmfs_iget(sb, ino_next); if (IS_ERR(inode)) break; - pmfs_dbg("Recover ino %llx nlink %d sz %llx:%llx\n", ino_next, - inode->i_nlink, pi->i_size, li->i_truncatesize); + pmfs_dbg("Recover ino %llx nlink %d sz %llx:%llx mtime %x ctime %x\n", ino_next, + inode->i_nlink, pi->i_size, li->i_truncatesize, li->i_truncatemtime, li->i_truncatectime); if (inode->i_nlink) { /* set allocation hint */ /*pmfs_set_blocksize_hint(sb, pi, le64_to_cpu(li->i_truncatesize)); */ + if(li->i_timemarker != 0) { + inode->i_mtime.tv_sec = le32_to_cpu(li->i_truncatemtime); + inode->i_ctime.tv_sec = le32_to_cpu(li->i_truncatectime); + } else { + inode->i_mtime = inode->i_ctime = current_time(inode); + } pmfs_setsize(inode, le64_to_cpu(li->i_truncatesize)); pmfs_update_isize(inode, pi); } else {