Skip to content

Commit e2ebb12

Browse files
weiny2jankara
authored andcommitted
ext2: Match up ext2_put_page() with ext2_dotdot() and ext2_find_entry()
ext2_dotdot() and ext2_find_entry() both require ext2_put_page() to be called after successful return. For some of the calls this corresponding put was hidden in ext2_set_link and ext2_delete_entry(). Match up ext2_put_page() with ext2_dotdot() and ext2_find_entry() in the functions which call them. This makes the code easier to follow regarding the get/put of the page. Clean up comments to match new behavior. To: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ira Weiny <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent e312c97 commit e2ebb12

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

fs/ext2/dir.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ static int ext2_prepare_chunk(struct page *page, loff_t pos, unsigned len)
434434
return __block_write_begin(page, pos, len, ext2_get_block);
435435
}
436436

437-
/* Releases the page */
438437
void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
439438
struct page *page, struct inode *inode, int update_times)
440439
{
@@ -449,7 +448,6 @@ void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
449448
de->inode = cpu_to_le32(inode->i_ino);
450449
ext2_set_de_type(de, inode);
451450
err = ext2_commit_chunk(page, pos, len);
452-
ext2_put_page(page);
453451
if (update_times)
454452
dir->i_mtime = dir->i_ctime = current_time(dir);
455453
EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL;
@@ -556,7 +554,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
556554

557555
/*
558556
* ext2_delete_entry deletes a directory entry by merging it with the
559-
* previous entry. Page is up-to-date. Releases the page.
557+
* previous entry. Page is up-to-date.
560558
*/
561559
int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
562560
{
@@ -594,7 +592,6 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
594592
EXT2_I(inode)->i_flags &= ~EXT2_BTREE_FL;
595593
mark_inode_dirty(inode);
596594
out:
597-
ext2_put_page(page);
598595
return err;
599596
}
600597

fs/ext2/namei.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry)
294294
}
295295

296296
err = ext2_delete_entry (de, page);
297+
ext2_put_page(page);
297298
if (err)
298299
goto out;
299300

@@ -371,6 +372,7 @@ static int ext2_rename (struct user_namespace * mnt_userns,
371372
goto out_dir;
372373
}
373374
ext2_set_link(new_dir, new_de, new_page, old_inode, 1);
375+
ext2_put_page(new_page);
374376
new_inode->i_ctime = current_time(new_inode);
375377
if (dir_de)
376378
drop_nlink(new_inode);
@@ -391,12 +393,13 @@ static int ext2_rename (struct user_namespace * mnt_userns,
391393
mark_inode_dirty(old_inode);
392394

393395
ext2_delete_entry (old_de, old_page);
396+
ext2_put_page(old_page);
394397

395398
if (dir_de) {
396399
if (old_dir != new_dir)
397400
ext2_set_link(old_inode, dir_de, dir_page, new_dir, 0);
398-
else
399-
ext2_put_page(dir_page);
401+
402+
ext2_put_page(dir_page);
400403
inode_dec_link_count(old_dir);
401404
}
402405
return 0;

0 commit comments

Comments
 (0)