Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use truncate time instead of current time during truncate list recovery #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Linux-5.1/fs/winefs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions Linux-5.1/fs/winefs/inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Linux-5.1/fs/winefs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions Linux-5.1/fs/winefs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down