From patchwork Thu Feb 16 14:47:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rados=C5=82aw_Smogura?= X-Patchwork-Id: 141601 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 06E21B6F98 for ; Fri, 17 Feb 2012 01:48:56 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752613Ab2BPOsx (ORCPT ); Thu, 16 Feb 2012 09:48:53 -0500 Received: from flawless.hostnac.com ([67.23.244.186]:49449 "EHLO flawless.hostnac.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752564Ab2BPOsx (ORCPT ); Thu, 16 Feb 2012 09:48:53 -0500 Received: from [80.48.234.131] (port=51898 helo=radek_samsung.prointegra.corp) by flawless.hostnac.com with esmtpa (Exim 4.69) (envelope-from ) id 1Ry2df-0004wK-5f; Thu, 16 Feb 2012 09:48:51 -0500 From: =?UTF-8?q?Rados=C5=82aw=20Smogura?= To: linux-mm@kvack.org Cc: Yongqiang Yang , mail@smogura.eu, linux-ext4@vger.kernel.org Subject: [WIP 16/18] SHM: Support for splitting on truncation Date: Thu, 16 Feb 2012 15:47:55 +0100 Message-Id: <1329403677-25629-6-git-send-email-mail@smogura.eu> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1329403677-25629-1-git-send-email-mail@smogura.eu> References: <1329403677-25629-1-git-send-email-mail@smogura.eu> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - flawless.hostnac.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - smogura.eu Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Writeback will be added in next patches, but after experimental support for huge pages for EXT 4. Signed-off-by: Radosław Smogura --- mm/shmem.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 38 insertions(+), 1 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 97e76b9..db377bf 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -454,6 +454,7 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) mem_cgroup_uncharge_start(); for (i = 0; i < pagevec_count(&pvec); i++) { struct page *page = pvec.pages[i]; + struct page *head = NULL; index = indices[i]; if (index > end) @@ -464,12 +465,32 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) index, page); continue; } - if (!trylock_page(page)) continue; + if (PageCompound(page)) { + head = compound_head(page); + switch (compound_try_freeze(head, false)) { + case -1: + head = NULL; + break; + case 1: + unlock_page(page); + continue; + case 0: + if (!split_huge_page_file(head, page)) + head = NULL; + break; + } + } + /* Truncate inode page may try to freez, so unfreez. */ if (page->mapping == mapping) { VM_BUG_ON(PageWriteback(page)); + if (head != NULL) + compound_unfreeze(head); truncate_inode_page(mapping, page); + } else { + if (head != NULL) + compound_unfreeze(head); } unlock_page(page); } @@ -511,6 +532,7 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) mem_cgroup_uncharge_start(); for (i = 0; i < pagevec_count(&pvec); i++) { struct page *page = pvec.pages[i]; + struct page *head = NULL; index = indices[i]; if (index > end) @@ -523,9 +545,24 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) } lock_page(page); + if (PageCompound(page)) { + head = compound_head(page); + if (compound_freeze(head)) { + if (!split_huge_page_file(head, page)) + head = NULL; + } else { + head = NULL; + } + } + /* Truncate inode page may try to freez, so unfreez. */ if (page->mapping == mapping) { VM_BUG_ON(PageWriteback(page)); + if (head != NULL) + compound_unfreeze(head); truncate_inode_page(mapping, page); + } else { + if (head != NULL) + compound_unfreeze(head); } unlock_page(page); }