diff options
author | Christoph Hellwig <hch@lst.de> | 2023-01-18 20:30:21 +0300 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2023-01-20 03:26:24 +0300 |
commit | 35bb6a092cfcab895ea7e9c31a2cc6b80b25c134 (patch) | |
tree | 1ae34dd0fa0e83f8763d916d5856e4f7e2ac9ff5 /fs/minix/namei.c | |
parent | 4a29a1262a47acd8e81a3824492a5aa8f8c5fc95 (diff) | |
download | linux-35bb6a092cfcab895ea7e9c31a2cc6b80b25c134.tar.xz |
minix: move releasing pages into unlink and rename
Instead of consuming the page reference and kmap in the low-level
minix_delete_entry and minix_set_link helpers, do it in the callers
where that code can be shared with the error cleanup path.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/minix/namei.c')
-rw-r--r-- | fs/minix/namei.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/minix/namei.c b/fs/minix/namei.c index a4f5e6caf8fe..7dc481418871 100644 --- a/fs/minix/namei.c +++ b/fs/minix/namei.c @@ -140,23 +140,23 @@ out_fail: static int minix_unlink(struct inode * dir, struct dentry *dentry) { - int err = -ENOENT; struct inode * inode = d_inode(dentry); struct page * page; struct minix_dir_entry * de; + int err; de = minix_find_entry(dentry, &page); if (!de) - goto end_unlink; - + return -ENOENT; err = minix_delete_entry(de, page); - if (err) - goto end_unlink; + kunmap(page); + put_page(page); + if (err) + return err; inode->i_ctime = dir->i_ctime; inode_dec_link_count(inode); -end_unlink: - return err; + return 0; } static int minix_rmdir(struct inode * dir, struct dentry *dentry) @@ -213,7 +213,10 @@ static int minix_rename(struct user_namespace *mnt_userns, new_de = minix_find_entry(new_dentry, &new_page); if (!new_de) goto out_dir; + err = 0; minix_set_link(new_de, new_page, old_inode); + kunmap(new_page); + put_page(new_page); new_inode->i_ctime = current_time(new_inode); if (dir_de) drop_nlink(new_inode); @@ -233,8 +236,6 @@ static int minix_rename(struct user_namespace *mnt_userns, minix_set_link(dir_de, dir_page, new_dir); inode_dec_link_count(old_dir); } - return 0; - out_dir: if (dir_de) { kunmap(dir_page); |