diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2017-10-19 04:05:57 +0200 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2017-10-26 10:44:21 +0200 |
commit | 57864ae5ce3ab5c6e3137dd03edefdb2e5531ba1 (patch) | |
tree | 759d8b6d20e4c1eae6ea718708288ba484b0e778 /fs/f2fs/data.c | |
parent | f2fs: update ctx->pos correctly when hitting hole in directory (diff) | |
download | linux-57864ae5ce3ab5c6e3137dd03edefdb2e5531ba1.tar.xz linux-57864ae5ce3ab5c6e3137dd03edefdb2e5531ba1.zip |
f2fs: limit # of inmemory pages
If some abnormal users try lots of atomic write operations, f2fs is able to
produce pinned pages in the main memory which affects system performance.
This patch limits that as 20% over total memory size, and if f2fs reaches
to the limit, it will drop all the inmemory pages.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r-- | fs/f2fs/data.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 95fdbe3e6cca..7fd09837820a 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1944,6 +1944,12 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, trace_f2fs_write_begin(inode, pos, len, flags); + if (f2fs_is_atomic_file(inode) && + !available_free_memory(sbi, INMEM_PAGES)) { + err = -ENOMEM; + goto fail; + } + /* * We should check this at this moment to avoid deadlock on inode page * and #0 page. The locking rule for inline_data conversion should be: @@ -2021,6 +2027,8 @@ repeat: fail: f2fs_put_page(page, 1); f2fs_write_failed(mapping, pos + len); + if (f2fs_is_atomic_file(inode)) + drop_inmem_pages_all(sbi); return err; } |