diff options
author | Ira Weiny <ira.weiny@intel.com> | 2020-11-12 09:42:44 -0800 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2020-11-13 11:19:30 +0100 |
commit | a6fbd0ab3d7a1a02e61733a80c22fb01c65819b9 (patch) | |
tree | bf52e9b7de2af835d4066e88569b13a006799dee /fs/ext2/dir.c | |
parent | 2356eb80ca42deba0bf2523c62530d4c79dad08f (diff) | |
download | lwn-a6fbd0ab3d7a1a02e61733a80c22fb01c65819b9.tar.gz lwn-a6fbd0ab3d7a1a02e61733a80c22fb01c65819b9.zip |
fs/ext2: Use ext2_put_page
There are 3 places in namei.c where the equivalent of ext2_put_page() is
open coded on a page which was returned from the ext2_get_page() call
[through the use of ext2_find_entry() and ext2_dotdot()].
Move ext2_put_page() to ext2.h and use it in namei.c
Also add a comment regarding the proper way to release the page returned
from ext2_find_entry() and ext2_dotdot().
Link: https://lore.kernel.org/r/20201112174244.701325-1-ira.weiny@intel.com
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext2/dir.c')
-rw-r--r-- | fs/ext2/dir.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index 70355ab6740e..14aa45316ad2 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c @@ -66,12 +66,6 @@ static inline unsigned ext2_chunk_size(struct inode *inode) return inode->i_sb->s_blocksize; } -static inline void ext2_put_page(struct page *page) -{ - kunmap(page); - put_page(page); -} - /* * Return the offset into page `page_nr' of the last valid * byte in that page, plus one. @@ -336,6 +330,8 @@ ext2_readdir(struct file *file, struct dir_context *ctx) * returns the page in which the entry was found (as a parameter - res_page), * and the entry itself. Page is returned mapped and unlocked. * Entry is guaranteed to be valid. + * + * On Success ext2_put_page() should be called on *res_page. */ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir, const struct qstr *child, struct page **res_page) @@ -401,6 +397,12 @@ found: return de; } +/** + * Return the '..' directory entry and the page in which the entry was found + * (as a parameter - p). + * + * On Success ext2_put_page() should be called on *p. + */ struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p) { struct page *page = ext2_get_page(dir, 0, 0); |