Commit e21d4f41 authored by Jeff Layton's avatar Jeff Layton Committed by Christian Brauner

nilfs2: convert to ctime accessor functions

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.
Acked-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Message-Id: <20230705190309.579783-57-jlayton@kernel.org>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 38d721b1
...@@ -429,7 +429,7 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, ...@@ -429,7 +429,7 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
nilfs_set_de_type(de, inode); nilfs_set_de_type(de, inode);
nilfs_commit_chunk(page, mapping, from, to); nilfs_commit_chunk(page, mapping, from, to);
nilfs_put_page(page); nilfs_put_page(page);
dir->i_mtime = dir->i_ctime = current_time(dir); dir->i_mtime = inode_set_ctime_current(dir);
} }
/* /*
...@@ -519,7 +519,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) ...@@ -519,7 +519,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
de->inode = cpu_to_le64(inode->i_ino); de->inode = cpu_to_le64(inode->i_ino);
nilfs_set_de_type(de, inode); nilfs_set_de_type(de, inode);
nilfs_commit_chunk(page, page->mapping, from, to); nilfs_commit_chunk(page, page->mapping, from, to);
dir->i_mtime = dir->i_ctime = current_time(dir); dir->i_mtime = inode_set_ctime_current(dir);
nilfs_mark_inode_dirty(dir); nilfs_mark_inode_dirty(dir);
/* OFFSET_CACHE */ /* OFFSET_CACHE */
out_put: out_put:
...@@ -567,7 +567,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page) ...@@ -567,7 +567,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
pde->rec_len = nilfs_rec_len_to_disk(to - from); pde->rec_len = nilfs_rec_len_to_disk(to - from);
dir->inode = 0; dir->inode = 0;
nilfs_commit_chunk(page, mapping, from, to); nilfs_commit_chunk(page, mapping, from, to);
inode->i_ctime = inode->i_mtime = current_time(inode); inode->i_mtime = inode_set_ctime_current(inode);
out: out:
nilfs_put_page(page); nilfs_put_page(page);
return err; return err;
......
...@@ -366,7 +366,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode) ...@@ -366,7 +366,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode)
atomic64_inc(&root->inodes_count); atomic64_inc(&root->inodes_count);
inode_init_owner(&nop_mnt_idmap, inode, dir, mode); inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
inode->i_ino = ino; inode->i_ino = ino;
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) { if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) {
err = nilfs_bmap_read(ii->i_bmap, NULL); err = nilfs_bmap_read(ii->i_bmap, NULL);
...@@ -450,10 +450,10 @@ int nilfs_read_inode_common(struct inode *inode, ...@@ -450,10 +450,10 @@ int nilfs_read_inode_common(struct inode *inode,
set_nlink(inode, le16_to_cpu(raw_inode->i_links_count)); set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
inode->i_size = le64_to_cpu(raw_inode->i_size); inode->i_size = le64_to_cpu(raw_inode->i_size);
inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime); inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
inode->i_ctime.tv_sec = le64_to_cpu(raw_inode->i_ctime); inode_set_ctime(inode, le64_to_cpu(raw_inode->i_ctime),
le32_to_cpu(raw_inode->i_ctime_nsec));
inode->i_mtime.tv_sec = le64_to_cpu(raw_inode->i_mtime); inode->i_mtime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
inode->i_atime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec); inode->i_atime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
inode->i_ctime.tv_nsec = le32_to_cpu(raw_inode->i_ctime_nsec);
inode->i_mtime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec); inode->i_mtime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
if (nilfs_is_metadata_file_inode(inode) && !S_ISREG(inode->i_mode)) if (nilfs_is_metadata_file_inode(inode) && !S_ISREG(inode->i_mode))
return -EIO; /* this inode is for metadata and corrupted */ return -EIO; /* this inode is for metadata and corrupted */
...@@ -768,9 +768,9 @@ void nilfs_write_inode_common(struct inode *inode, ...@@ -768,9 +768,9 @@ void nilfs_write_inode_common(struct inode *inode,
raw_inode->i_gid = cpu_to_le32(i_gid_read(inode)); raw_inode->i_gid = cpu_to_le32(i_gid_read(inode));
raw_inode->i_links_count = cpu_to_le16(inode->i_nlink); raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
raw_inode->i_size = cpu_to_le64(inode->i_size); raw_inode->i_size = cpu_to_le64(inode->i_size);
raw_inode->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); raw_inode->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
raw_inode->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec); raw_inode->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
raw_inode->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec); raw_inode->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
raw_inode->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); raw_inode->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
raw_inode->i_blocks = cpu_to_le64(inode->i_blocks); raw_inode->i_blocks = cpu_to_le64(inode->i_blocks);
...@@ -875,7 +875,7 @@ void nilfs_truncate(struct inode *inode) ...@@ -875,7 +875,7 @@ void nilfs_truncate(struct inode *inode)
nilfs_truncate_bmap(ii, blkoff); nilfs_truncate_bmap(ii, blkoff);
inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_mtime = inode_set_ctime_current(inode);
if (IS_SYNC(inode)) if (IS_SYNC(inode))
nilfs_set_transaction_flag(NILFS_TI_SYNC); nilfs_set_transaction_flag(NILFS_TI_SYNC);
......
...@@ -149,7 +149,7 @@ int nilfs_fileattr_set(struct mnt_idmap *idmap, ...@@ -149,7 +149,7 @@ int nilfs_fileattr_set(struct mnt_idmap *idmap,
NILFS_I(inode)->i_flags = oldflags | (flags & FS_FL_USER_MODIFIABLE); NILFS_I(inode)->i_flags = oldflags | (flags & FS_FL_USER_MODIFIABLE);
nilfs_set_inode_flags(inode); nilfs_set_inode_flags(inode);
inode->i_ctime = current_time(inode); inode_set_ctime_current(inode);
if (IS_SYNC(inode)) if (IS_SYNC(inode))
nilfs_set_transaction_flag(NILFS_TI_SYNC); nilfs_set_transaction_flag(NILFS_TI_SYNC);
......
...@@ -185,7 +185,7 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -185,7 +185,7 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir,
if (err) if (err)
return err; return err;
inode->i_ctime = current_time(inode); inode_set_ctime_current(inode);
inode_inc_link_count(inode); inode_inc_link_count(inode);
ihold(inode); ihold(inode);
...@@ -283,7 +283,7 @@ static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry) ...@@ -283,7 +283,7 @@ static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry)
if (err) if (err)
goto out; goto out;
inode->i_ctime = dir->i_ctime; inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
drop_nlink(inode); drop_nlink(inode);
err = 0; err = 0;
out: out:
...@@ -387,7 +387,7 @@ static int nilfs_rename(struct mnt_idmap *idmap, ...@@ -387,7 +387,7 @@ static int nilfs_rename(struct mnt_idmap *idmap,
goto out_dir; goto out_dir;
nilfs_set_link(new_dir, new_de, new_page, old_inode); nilfs_set_link(new_dir, new_de, new_page, old_inode);
nilfs_mark_inode_dirty(new_dir); nilfs_mark_inode_dirty(new_dir);
new_inode->i_ctime = current_time(new_inode); inode_set_ctime_current(new_inode);
if (dir_de) if (dir_de)
drop_nlink(new_inode); drop_nlink(new_inode);
drop_nlink(new_inode); drop_nlink(new_inode);
...@@ -406,7 +406,7 @@ static int nilfs_rename(struct mnt_idmap *idmap, ...@@ -406,7 +406,7 @@ static int nilfs_rename(struct mnt_idmap *idmap,
* Like most other Unix systems, set the ctime for inodes on a * Like most other Unix systems, set the ctime for inodes on a
* rename. * rename.
*/ */
old_inode->i_ctime = current_time(old_inode); inode_set_ctime_current(old_inode);
nilfs_delete_entry(old_de, old_page); nilfs_delete_entry(old_de, old_page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment