* ext2_set_link()->ext2_put_page() question
@ 2021-03-23 0:49 Ira Weiny
2021-03-25 14:54 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Ira Weiny @ 2021-03-23 0:49 UTC (permalink / raw)
To: Jan Kara, linux-ext4; +Cc: linux-kernel
Jan,
Why does ext2_set_link() need to call ext2_put_page()?
I don't see any reason that we could not match up the ext2_put_page() calls
with the ext2_find_entry().
Similarly am I missing something by moving the ext2_put_page() out of
ext2_delete_entry()?
See below patch.
I'm in the process of changing the kmap() calls in ext2_[get|put]_page() into
kmap_local_page() and I noticed this imbalance. It does not really save me
anything because I need to pass the kaddr into these calls but IMO it makes the
code a bit easier to follow.
If you agree I will get a patch together to submit with the kmap_local_page()
patch.
Thanks,
Ira
17:29:44 > git di
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 14aa45316ad2..bd572cead638 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -449,7 +449,6 @@ void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
de->inode = cpu_to_le32(inode->i_ino);
ext2_set_de_type(de, inode);
err = ext2_commit_chunk(page, pos, len);
- ext2_put_page(page);
if (update_times)
dir->i_mtime = dir->i_ctime = current_time(dir);
EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL;
@@ -594,7 +593,6 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
EXT2_I(inode)->i_flags &= ~EXT2_BTREE_FL;
mark_inode_dirty(inode);
out:
- ext2_put_page(page);
return err;
}
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 3367384d344d..a841b00c6828 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -371,6 +371,7 @@ static int ext2_rename (struct user_namespace * mnt_userns,
goto out_dir;
}
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);
if (dir_de)
drop_nlink(new_inode);
@@ -391,12 +392,13 @@ static int ext2_rename (struct user_namespace * mnt_userns,
mark_inode_dirty(old_inode);
ext2_delete_entry (old_de, old_page);
+ ext2_put_page(old_page);
if (dir_de) {
if (old_dir != new_dir)
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);
}
return 0;
17:35:41 > git di
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 14aa45316ad2..bd572cead638 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -449,7 +449,6 @@ void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
de->inode = cpu_to_le32(inode->i_ino);
ext2_set_de_type(de, inode);
err = ext2_commit_chunk(page, pos, len);
- ext2_put_page(page);
if (update_times)
dir->i_mtime = dir->i_ctime = current_time(dir);
EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL;
@@ -594,7 +593,6 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
EXT2_I(inode)->i_flags &= ~EXT2_BTREE_FL;
mark_inode_dirty(inode);
out:
- ext2_put_page(page);
return err;
}
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 3367384d344d..7af9ab3f975e 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -294,6 +294,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry)
}
err = ext2_delete_entry (de, page);
+ ext2_put_page(page);
if (err)
goto out;
@@ -371,6 +372,7 @@ static int ext2_rename (struct user_namespace * mnt_userns,
goto out_dir;
}
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);
if (dir_de)
drop_nlink(new_inode);
@@ -391,12 +393,13 @@ static int ext2_rename (struct user_namespace * mnt_userns,
mark_inode_dirty(old_inode);
ext2_delete_entry (old_de, old_page);
+ ext2_put_page(old_page);
if (dir_de) {
if (old_dir != new_dir)
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);
}
return 0;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: ext2_set_link()->ext2_put_page() question
2021-03-23 0:49 ext2_set_link()->ext2_put_page() question Ira Weiny
@ 2021-03-25 14:54 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2021-03-25 14:54 UTC (permalink / raw)
To: Ira Weiny; +Cc: Jan Kara, linux-ext4, linux-kernel
On Mon 22-03-21 17:49:48, Ira Weiny wrote:
> Jan,
>
> Why does ext2_set_link() need to call ext2_put_page()?
>
> I don't see any reason that we could not match up the ext2_put_page() calls
> with the ext2_find_entry().
>
> Similarly am I missing something by moving the ext2_put_page() out of
> ext2_delete_entry()?
>
> See below patch.
I agree that your patch improves readability. But please fixup comments
about releasing a page as well. Thanks!
> I'm in the process of changing the kmap() calls in ext2_[get|put]_page() into
> kmap_local_page() and I noticed this imbalance. It does not really save me
> anything because I need to pass the kaddr into these calls but IMO it makes the
> code a bit easier to follow.
>
> If you agree I will get a patch together to submit with the kmap_local_page()
> patch.
OK :).
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-25 14:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 0:49 ext2_set_link()->ext2_put_page() question Ira Weiny
2021-03-25 14:54 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).