diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-02-25 06:03:26 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-02-25 06:03:26 +0300 |
commit | d6b9cf417c62601f26fa47f97d6c0681704bf0e3 (patch) | |
tree | 2ed9a0dcd5e8b4c0d5b7cc3c4e4881f8fa83cdc5 /fs/sysv/namei.c | |
parent | 397aa6b63ff25cee0b8ed20a6d447527c8ab0849 (diff) | |
parent | abb7c742397324f8676c5b622effdce911cd52e3 (diff) | |
download | linux-d6b9cf417c62601f26fa47f97d6c0681704bf0e3.tar.xz |
Merge branch 'work.sysv' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull sysv updates from Al Viro:
"Fabio's 'switch to kmap_local_page()' patchset (originally after the
ext2 counterpart, with a lot of cleaning up done to it; as the matter
of fact, ext2 side is in need of similar cleanups - calling
conventions there are bloody awful).
Plus the equivalents of minix stuff..."
* 'work.sysv' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
sysv: fix handling of delete_entry and set_link failures
fs/sysv: Replace kmap() with kmap_local_page()
fs/sysv: Use dir_put_page() in sysv_rename()
fs/sysv: Change the signature of dir_get_page()
fs/sysv: Use the offset_in_page() helper
sysv: don't flush page immediately for DIRSYNC directories
Diffstat (limited to 'fs/sysv/namei.c')
-rw-r--r-- | fs/sysv/namei.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index ecd424461511..a25862773d82 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c @@ -153,19 +153,18 @@ static int sysv_unlink(struct inode * dir, struct dentry * dentry) struct inode * inode = d_inode(dentry); struct page * page; struct sysv_dir_entry * de; - int err = -ENOENT; + int err; de = sysv_find_entry(dentry, &page); if (!de) - goto out; + return -ENOENT; - err = sysv_delete_entry (de, page); - if (err) - goto out; - - inode->i_ctime = dir->i_ctime; - inode_dec_link_count(inode); -out: + err = sysv_delete_entry(de, page); + if (!err) { + inode->i_ctime = dir->i_ctime; + inode_dec_link_count(inode); + } + dir_put_page(page, de); return err; } @@ -227,7 +226,10 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, new_de = sysv_find_entry(new_dentry, &new_page); if (!new_de) goto out_dir; - sysv_set_link(new_de, new_page, old_inode); + err = sysv_set_link(new_de, new_page, old_inode); + dir_put_page(new_page, new_de); + if (err) + goto out_dir; new_inode->i_ctime = current_time(new_inode); if (dir_de) drop_nlink(new_inode); @@ -240,23 +242,23 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, inode_inc_link_count(new_dir); } - sysv_delete_entry(old_de, old_page); + err = sysv_delete_entry(old_de, old_page); + if (err) + goto out_dir; + mark_inode_dirty(old_inode); if (dir_de) { - sysv_set_link(dir_de, dir_page, new_dir); - inode_dec_link_count(old_dir); + err = sysv_set_link(dir_de, dir_page, new_dir); + if (!err) + inode_dec_link_count(old_dir); } - return 0; out_dir: - if (dir_de) { - kunmap(dir_page); - put_page(dir_page); - } + if (dir_de) + dir_put_page(dir_page, dir_de); out_old: - kunmap(old_page); - put_page(old_page); + dir_put_page(old_page, old_de); out: return err; } |