Commit e2ebb123 authored by Ira Weiny's avatar Ira Weiny Committed by Jan Kara

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 <jack@suse.com>
Link: https://lore.kernel.org/r/20210329065402.3297092-2-ira.weiny@intel.comSigned-off-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent e312c97e
...@@ -434,7 +434,6 @@ static int ext2_prepare_chunk(struct page *page, loff_t pos, unsigned len) ...@@ -434,7 +434,6 @@ static int ext2_prepare_chunk(struct page *page, loff_t pos, unsigned len)
return __block_write_begin(page, pos, len, ext2_get_block); return __block_write_begin(page, pos, len, ext2_get_block);
} }
/* Releases the page */
void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de, void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
struct page *page, struct inode *inode, int update_times) struct page *page, struct inode *inode, int update_times)
{ {
...@@ -449,7 +448,6 @@ void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de, ...@@ -449,7 +448,6 @@ void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
de->inode = cpu_to_le32(inode->i_ino); de->inode = cpu_to_le32(inode->i_ino);
ext2_set_de_type(de, inode); ext2_set_de_type(de, inode);
err = ext2_commit_chunk(page, pos, len); err = ext2_commit_chunk(page, pos, len);
ext2_put_page(page);
if (update_times) if (update_times)
dir->i_mtime = dir->i_ctime = current_time(dir); dir->i_mtime = dir->i_ctime = current_time(dir);
EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL; EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL;
...@@ -556,7 +554,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode) ...@@ -556,7 +554,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
/* /*
* ext2_delete_entry deletes a directory entry by merging it with the * ext2_delete_entry deletes a directory entry by merging it with the
* previous entry. Page is up-to-date. Releases the page. * previous entry. Page is up-to-date.
*/ */
int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ) int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
{ {
...@@ -594,7 +592,6 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ) ...@@ -594,7 +592,6 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
EXT2_I(inode)->i_flags &= ~EXT2_BTREE_FL; EXT2_I(inode)->i_flags &= ~EXT2_BTREE_FL;
mark_inode_dirty(inode); mark_inode_dirty(inode);
out: out:
ext2_put_page(page);
return err; return err;
} }
......
...@@ -294,6 +294,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry) ...@@ -294,6 +294,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry)
} }
err = ext2_delete_entry (de, page); err = ext2_delete_entry (de, page);
ext2_put_page(page);
if (err) if (err)
goto out; goto out;
...@@ -371,6 +372,7 @@ static int ext2_rename (struct user_namespace * mnt_userns, ...@@ -371,6 +372,7 @@ static int ext2_rename (struct user_namespace * mnt_userns,
goto out_dir; goto out_dir;
} }
ext2_set_link(new_dir, new_de, new_page, old_inode, 1); ext2_set_link(new_dir, new_de, new_page, old_inode, 1);
ext2_put_page(new_page);
new_inode->i_ctime = current_time(new_inode); new_inode->i_ctime = current_time(new_inode);
if (dir_de) if (dir_de)
drop_nlink(new_inode); drop_nlink(new_inode);
...@@ -391,12 +393,13 @@ static int ext2_rename (struct user_namespace * mnt_userns, ...@@ -391,12 +393,13 @@ static int ext2_rename (struct user_namespace * mnt_userns,
mark_inode_dirty(old_inode); mark_inode_dirty(old_inode);
ext2_delete_entry (old_de, old_page); ext2_delete_entry (old_de, old_page);
ext2_put_page(old_page);
if (dir_de) { if (dir_de) {
if (old_dir != new_dir) if (old_dir != new_dir)
ext2_set_link(old_inode, dir_de, dir_page, new_dir, 0); ext2_set_link(old_inode, dir_de, dir_page, new_dir, 0);
else
ext2_put_page(dir_page); ext2_put_page(dir_page);
inode_dec_link_count(old_dir); inode_dec_link_count(old_dir);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment