aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2018-01-15 04:16:46 -0500
committerJaegeuk Kim <jaegeuk@kernel.org>2018-01-22 17:56:47 -0500
commita2e2e76b23038b187e5656c467ec76eeb29b8275 (patch)
tree7b9fc292e53d8f08c0313fbe5e4dbb87357c28b5
parentf3d98e74fcddb23dba00a88145272fc8223baaee (diff)
f2fs: fix to drop all inmem pages correctly
In commit 57864ae5ce3a ("f2fs: limit # of inmemory pages"), we have limited memory footprint of all inmem pages with 20% of total memory, otherwise, if we exceed the threshold, we will try to drop all inmem pages to avoid excessive memory pressure resulting in performance regression. But in some unrelated error paths, we will also drop all inmem pages, which should be wrong, fix it in this patch. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/data.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 81fd4823a071..2db26388b6bf 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2078,7 +2078,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
2078 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 2078 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
2079 struct page *page = NULL; 2079 struct page *page = NULL;
2080 pgoff_t index = ((unsigned long long) pos) >> PAGE_SHIFT; 2080 pgoff_t index = ((unsigned long long) pos) >> PAGE_SHIFT;
2081 bool need_balance = false; 2081 bool need_balance = false, drop_atomic = false;
2082 block_t blkaddr = NULL_ADDR; 2082 block_t blkaddr = NULL_ADDR;
2083 int err = 0; 2083 int err = 0;
2084 2084
@@ -2087,6 +2087,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
2087 if (f2fs_is_atomic_file(inode) && 2087 if (f2fs_is_atomic_file(inode) &&
2088 !available_free_memory(sbi, INMEM_PAGES)) { 2088 !available_free_memory(sbi, INMEM_PAGES)) {
2089 err = -ENOMEM; 2089 err = -ENOMEM;
2090 drop_atomic = true;
2090 goto fail; 2091 goto fail;
2091 } 2092 }
2092 2093
@@ -2167,7 +2168,7 @@ repeat:
2167fail: 2168fail:
2168 f2fs_put_page(page, 1); 2169 f2fs_put_page(page, 1);
2169 f2fs_write_failed(mapping, pos + len); 2170 f2fs_write_failed(mapping, pos + len);
2170 if (f2fs_is_atomic_file(inode)) 2171 if (drop_atomic)
2171 drop_inmem_pages_all(sbi); 2172 drop_inmem_pages_all(sbi);
2172 return err; 2173 return err;
2173} 2174}