Skip to content

Commit

Permalink
disable fast write path (append) for strict mode, reverse update orde…
Browse files Browse the repository at this point in the history
…r for relaxed mode (fix utsaslab#16)
  • Loading branch information
paulwedeck committed Oct 11, 2023
1 parent b4017d0 commit 63f8656
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions Linux-5.1/fs/winefs/inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,17 +343,15 @@ static inline void check_eof_blocks(struct super_block *sb,
static inline void pmfs_update_time_and_size(struct inode *inode,
struct pmfs_inode *pi)
{
__le32 words[2];
__le64 words;
__le64 new_pi_size = cpu_to_le64(i_size_read(inode));

/* pi->i_size, pi->i_ctime, and pi->i_mtime need to be atomically updated.
* So use cmpxchg16b here. */
words[0] = cpu_to_le32(inode->i_ctime.tv_sec);
words[1] = cpu_to_le32(inode->i_mtime.tv_sec);
/* TODO: the following function assumes cmpxchg16b instruction writes
* 16 bytes atomically. Confirm if it is really true. */
cmpxchg_double_local(&pi->i_size, (u64 *)&pi->i_ctime, pi->i_size,
*(u64 *)&pi->i_ctime, new_pi_size, *(u64 *)words);
words = cpu_to_le32(inode->i_mtime.tv_sec);
words <<= 32;
words |= cpu_to_le32(inode->i_ctime.tv_sec);
volatile __le64* target = (__le64*) &pi->i_ctime;
*target = words;
((volatile struct pmfs_inode*)pi)->i_size = new_pi_size;
}

int pmfs_init_inode_inuse_list(struct super_block *sb);
Expand Down
2 changes: 1 addition & 1 deletion Linux-5.1/fs/winefs/xip.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ ssize_t pmfs_xip_file_write(struct file *filp, const char __user *buf,
start_blk = pos >> sb->s_blocksize_bits;
end_blk = start_blk + num_blocks - 1;

if (!(strong_guarantees && pos < i_size_read(inode))) {
if (!strong_guarantees) {
num_blocks_found = pmfs_find_data_blocks(inode, start_blk, &block, 1);

/* Referring to the inode's block size, not 4K */
Expand Down

0 comments on commit 63f8656

Please sign in to comment.