Skip to content

Commit 35bb6a0

Browse files
Christoph HellwigAl Viro
authored andcommitted
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 <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 4a29a12 commit 35bb6a0

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

fs/minix/dir.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ int minix_delete_entry(struct minix_dir_entry *de, struct page *page)
306306
} else {
307307
unlock_page(page);
308308
}
309-
dir_put_page(page);
310309
inode->i_ctime = inode->i_mtime = current_time(inode);
311310
mark_inode_dirty(inode);
312311
return err;
@@ -430,7 +429,6 @@ void minix_set_link(struct minix_dir_entry *de, struct page *page,
430429
} else {
431430
unlock_page(page);
432431
}
433-
dir_put_page(page);
434432
dir->i_mtime = dir->i_ctime = current_time(dir);
435433
mark_inode_dirty(dir);
436434
}

fs/minix/namei.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,23 @@ static int minix_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
140140

141141
static int minix_unlink(struct inode * dir, struct dentry *dentry)
142142
{
143-
int err = -ENOENT;
144143
struct inode * inode = d_inode(dentry);
145144
struct page * page;
146145
struct minix_dir_entry * de;
146+
int err;
147147

148148
de = minix_find_entry(dentry, &page);
149149
if (!de)
150-
goto end_unlink;
151-
150+
return -ENOENT;
152151
err = minix_delete_entry(de, page);
153-
if (err)
154-
goto end_unlink;
152+
kunmap(page);
153+
put_page(page);
155154

155+
if (err)
156+
return err;
156157
inode->i_ctime = dir->i_ctime;
157158
inode_dec_link_count(inode);
158-
end_unlink:
159-
return err;
159+
return 0;
160160
}
161161

162162
static int minix_rmdir(struct inode * dir, struct dentry *dentry)
@@ -213,7 +213,10 @@ static int minix_rename(struct user_namespace *mnt_userns,
213213
new_de = minix_find_entry(new_dentry, &new_page);
214214
if (!new_de)
215215
goto out_dir;
216+
err = 0;
216217
minix_set_link(new_de, new_page, old_inode);
218+
kunmap(new_page);
219+
put_page(new_page);
217220
new_inode->i_ctime = current_time(new_inode);
218221
if (dir_de)
219222
drop_nlink(new_inode);
@@ -233,8 +236,6 @@ static int minix_rename(struct user_namespace *mnt_userns,
233236
minix_set_link(dir_de, dir_page, new_dir);
234237
inode_dec_link_count(old_dir);
235238
}
236-
return 0;
237-
238239
out_dir:
239240
if (dir_de) {
240241
kunmap(dir_page);

0 commit comments

Comments
 (0)