提交 70d45cdb 编写于 作者: A Al Viro

ufs: don't touch mtime/ctime of directory being moved

See "ext2: Do not update mtime of a moved directory" (and followup in
"ext2: fix unbalanced kmap()/kunmap()") for background; this is UFS
equivalent - the same problem exists here.
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 a50e4a02
...@@ -87,7 +87,8 @@ ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr) ...@@ -87,7 +87,8 @@ ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr)
/* Releases the page */ /* Releases the page */
void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
struct page *page, struct inode *inode) struct page *page, struct inode *inode,
bool update_times)
{ {
loff_t pos = page_offset(page) + loff_t pos = page_offset(page) +
(char *) de - (char *) page_address(page); (char *) de - (char *) page_address(page);
...@@ -103,6 +104,7 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, ...@@ -103,6 +104,7 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
err = ufs_commit_chunk(page, pos, len); err = ufs_commit_chunk(page, pos, len);
ufs_put_page(page); ufs_put_page(page);
if (update_times)
dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC; dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(dir); mark_inode_dirty(dir);
} }
......
...@@ -276,7 +276,7 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -276,7 +276,7 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry,
new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_page); new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_page);
if (!new_de) if (!new_de)
goto out_dir; goto out_dir;
ufs_set_link(new_dir, new_de, new_page, old_inode); ufs_set_link(new_dir, new_de, new_page, old_inode, 1);
new_inode->i_ctime = CURRENT_TIME_SEC; new_inode->i_ctime = CURRENT_TIME_SEC;
if (dir_de) if (dir_de)
drop_nlink(new_inode); drop_nlink(new_inode);
...@@ -299,7 +299,12 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -299,7 +299,12 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry,
mark_inode_dirty(old_inode); mark_inode_dirty(old_inode);
if (dir_de) { if (dir_de) {
ufs_set_link(old_inode, dir_de, dir_page, new_dir); if (old_dir != new_dir)
ufs_set_link(old_inode, dir_de, dir_page, new_dir, 0);
else {
kunmap(dir_page);
page_cache_release(dir_page);
}
inode_dec_link_count(old_dir); inode_dec_link_count(old_dir);
} }
return 0; return 0;
......
...@@ -106,7 +106,7 @@ extern int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page ...@@ -106,7 +106,7 @@ extern int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page
extern int ufs_empty_dir (struct inode *); extern int ufs_empty_dir (struct inode *);
extern struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **); extern struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **);
extern void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, extern void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
struct page *page, struct inode *inode); struct page *page, struct inode *inode, bool update_times);
/* file.c */ /* file.c */
extern const struct inode_operations ufs_file_inode_operations; extern const struct inode_operations ufs_file_inode_operations;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册