aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGu Zheng <guz.fnst@cn.fujitsu.com>2014-01-20 18:37:30 +0800
committerrogersb11 <brettrogers11@gmail.com>2016-02-13 21:45:56 -0500
commit9e1423bdc50a030ca9ea0c5c807c427c6ed02daf (patch)
treed5780a3c2822e6ad20f08d5393c9637624e8c870
parent11acf312c7ff169cc3710db49119d47d111b1696 (diff)
downloadkernel_samsung_smdk4412-9e1423bdc50a030ca9ea0c5c807c427c6ed02daf.zip
kernel_samsung_smdk4412-9e1423bdc50a030ca9ea0c5c807c427c6ed02daf.tar.gz
kernel_samsung_smdk4412-9e1423bdc50a030ca9ea0c5c807c427c6ed02daf.tar.bz2
f2fs: remove the orphan block page array
As the orphan_blocks may be max to 504, so it is not security and rigorous to store such a large array in the kernel stack as Dan Carpenter said. In fact, grab_meta_page has locked the page in the page cache, and we can use find_get_page() to fetch the page safely in the downstream, so we can remove the page array directly. Change-Id: Ie73897038bc06f6a6342d6fbdab8f8ff36b2cd96 Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r--fs/f2fs/checkpoint.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index f9d4f7d..ed82de6 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -311,11 +311,10 @@ static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk)
unsigned short orphan_blocks = (unsigned short)((sbi->n_orphans +
(F2FS_ORPHANS_PER_BLOCK - 1)) / F2FS_ORPHANS_PER_BLOCK);
struct page *page = NULL;
- struct page *pages[orphan_blocks];
struct orphan_inode_entry *orphan = NULL;
for (index = 0; index < orphan_blocks; index++)
- pages[index] = grab_meta_page(sbi, start_blk + index);
+ grab_meta_page(sbi, start_blk + index);
index = 1;
spin_lock(&sbi->orphan_inode_lock);
@@ -324,10 +323,12 @@ static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk)
/* loop for each orphan inode entry and write them in Jornal block */
list_for_each_entry(orphan, head, list) {
if (!page) {
- page = pages[index - 1];
+ page = find_get_page(META_MAPPING(sbi), start_blk++);
+ f2fs_bug_on(!page);
orphan_blk =
(struct f2fs_orphan_block *)page_address(page);
memset(orphan_blk, 0, sizeof(*orphan_blk));
+ f2fs_put_page(page, 0);
}
orphan_blk->ino[nentries++] = cpu_to_le32(orphan->ino);