Skip to content
Open
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
25 changes: 13 additions & 12 deletions Linux-5.1/fs/winefs/xip.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,18 @@ static ssize_t pmfs_file_write_fast(struct super_block *sb, struct inode *inode,

offset = pos & (sb->s_blocksize - 1);

inode->i_ctime = inode->i_mtime = current_time(inode);
if(count + offset <= inode->i_size) {
u64 c_m_time;
/* make sure that the time is updated before any modified data may be committed */
c_m_time = (inode->i_ctime.tv_sec & 0xFFFFFFFF);
c_m_time = c_m_time | (c_m_time << 32);
pmfs_memunlock_inode(sb, pi);
pmfs_memcpy_atomic(&pi->i_ctime, &c_m_time, 8);
pmfs_memlock_inode(sb, pi);
pmfs_flush_buffer(pi, 1, true);
}

PMFS_START_TIMING(memcpy_w_t, memcpy_time);
pmfs_xip_mem_protect(sb, xmem + offset, count, 1);
copied = memcpy_to_nvmm((char *)xmem, offset, buf, count);
Expand All @@ -311,7 +323,6 @@ static ssize_t pmfs_file_write_fast(struct super_block *sb, struct inode *inode,
if (unlikely(copied != count && copied == 0))
ret = -EFAULT;
*ppos = pos;
inode->i_ctime = inode->i_mtime = current_time(inode);
if (pos > inode->i_size) {
/* make sure written data is persistent before updating
* time and size */
Expand All @@ -321,18 +332,8 @@ static ssize_t pmfs_file_write_fast(struct super_block *sb, struct inode *inode,
pmfs_memunlock_inode(sb, pi);
pmfs_update_time_and_size(inode, pi);
pmfs_memlock_inode(sb, pi);
} else {
u64 c_m_time;
/* update c_time and m_time atomically. We don't need to make the data
* persistent because the expectation is that the close() or an explicit
* fsync will do that. */
c_m_time = (inode->i_ctime.tv_sec & 0xFFFFFFFF);
c_m_time = c_m_time | (c_m_time << 32);
pmfs_memunlock_inode(sb, pi);
pmfs_memcpy_atomic(&pi->i_ctime, &c_m_time, 8);
pmfs_memlock_inode(sb, pi);
pmfs_flush_buffer(pi, 1, barrier);
}
pmfs_flush_buffer(pi, 1, barrier);
return ret;
}

Expand Down