From patchwork Thu Aug 25 02:34:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 9298785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5E1A460757 for ; Thu, 25 Aug 2016 07:21:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47FA8291FD for ; Thu, 25 Aug 2016 07:21:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3ADD229200; Thu, 25 Aug 2016 07:21:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D881D291FD for ; Thu, 25 Aug 2016 07:21:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757891AbcHYHVP (ORCPT ); Thu, 25 Aug 2016 03:21:15 -0400 Received: from mail.kernel.org ([198.145.29.136]:54232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753607AbcHYHVO (ORCPT ); Thu, 25 Aug 2016 03:21:14 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 77C4F202FE; Thu, 25 Aug 2016 02:34:22 +0000 (UTC) Received: from localhost (107-1-141-74-ip-static.hfc.comcastbusiness.net [107.1.141.74]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 81CB120270; Thu, 25 Aug 2016 02:34:21 +0000 (UTC) From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH] f2fs: invalidate inode and data pages if inode is no longer used Date: Wed, 24 Aug 2016 19:34:19 -0700 Message-Id: <20160825023419.82566-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.8.3 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When a file is closed, let's deactivate inode page to mitigate further memory pressure. We can do data pages as well in the corner case of f2fs_drop_inode. Signed-off-by: Jaegeuk Kim --- fs/f2fs/file.c | 4 ++++ fs/f2fs/super.c | 1 + 2 files changed, 5 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index e460211..5f9a6dc 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1465,6 +1465,10 @@ static int f2fs_release_file(struct inode *inode, struct file *filp) filemap_fdatawrite(inode->i_mapping); clear_inode_flag(inode, FI_DROP_CACHE); } + + /* deactivate written inode page */ + invalidate_mapping_pages(NODE_MAPPING(F2FS_I_SB(inode)), + inode->i_ino, inode->i_ino); return 0; } diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 7f863a6..f84696d 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -618,6 +618,7 @@ static int f2fs_drop_inode(struct inode *inode) sb_end_intwrite(inode->i_sb); fscrypt_put_encryption_info(inode, NULL); + invalidate_mapping_pages(inode->i_mapping, 0, -1); spin_lock(&inode->i_lock); atomic_dec(&inode->i_count); }