From patchwork Sat Dec 15 15:01:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 1013938 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nod.at Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="P/l5JsH1"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43H9d73S7Mz9sB5 for ; Sun, 16 Dec 2018 02:02:35 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=E947dU8PzwU7bG214cavifrg2ZFMFxom5glLF1l9Sz4=; b=P/l5JsH1p9XVTI P8VQLw6lM9rLsNdJhLYM/6HYCR87yRg5loWPcDXd0bEd2mmstQedASfSYlOPw2KAYb7OrrT1C03u6 DPzH6oXAb03HigA7nneli2riNuCS3DwIprQmjv90pwMB3vwML0gujPLDCWm3GEaTx5O4JC1VqAsX/ e2UdtgQ5CW0P/5cjbCIo5bvOdWy2bEI3sfwtfc/iInnssm2NJf6Wr435CJyZOBDKimTW0/2Krg4+t nFW1v2gS94VqiGvaoijFFadzO/WZ4l2pT5I1XOKPwAhE12M97mJuKZcZz/aMyAshbSBIPpKhxUAi0 xHtD5CK+YAyyELPgVu5Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gYBSZ-00055H-Bi; Sat, 15 Dec 2018 15:02:31 +0000 Received: from lilium.sigma-star.at ([109.75.188.150]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gYBSV-00054Y-HN for linux-mtd@lists.infradead.org; Sat, 15 Dec 2018 15:02:29 +0000 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id 2AD2018198DC4; Sat, 15 Dec 2018 16:02:15 +0100 (CET) From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH] ubifs: Get/put page when changing PG_private Date: Sat, 15 Dec 2018 16:01:30 +0100 Message-Id: <20181215150130.19381-1-richard@nod.at> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181215_070227_721902_0B0C62B1 X-CRM114-Status: GOOD ( 11.29 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zhangjun , Richard Weinberger , linux-kernel@vger.kernel.org, stable@vger.kernel.org, hsiangkao@mail.ru, linux-fsdevel@vger.kernel.org, kirill.shutemov@linux.intel.com Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The page migration code assumes that a page with PG_private set has its page count elevated by 1. UBIFS never did this and therefore the migration code was unable to migrate some pages owned by UBIFS. The lead to situations where the CMA memory allocator failed to allocate memory. Fix this by using get/put_page when changing PG_private. Cc: Cc: zhangjun Fixes: 4ac1c17b2044 ("UBIFS: Implement ->migratepage()") Reported-by: zhangjun Signed-off-by: Richard Weinberger Acked-by: Kirill A. Shutemov --- zhangjun, Please give this patch a try! Thanks, //richard --- fs/ubifs/file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 1b78f2e09218..abe940d0767c 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -582,6 +582,7 @@ static int ubifs_write_end(struct file *file, struct address_space *mapping, } if (!PagePrivate(page)) { + get_page(page); SetPagePrivate(page); atomic_long_inc(&c->dirty_pg_cnt); __set_page_dirty_nobuffers(page); @@ -959,6 +960,7 @@ static int do_writepage(struct page *page, int len) atomic_long_dec(&c->dirty_pg_cnt); ClearPagePrivate(page); ClearPageChecked(page); + put_page(page); kunmap(page); unlock_page(page); @@ -1318,6 +1320,7 @@ static void ubifs_invalidatepage(struct page *page, unsigned int offset, atomic_long_dec(&c->dirty_pg_cnt); ClearPagePrivate(page); ClearPageChecked(page); + put_page(page); } int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync) @@ -1487,6 +1490,8 @@ static int ubifs_migrate_page(struct address_space *mapping, if (PagePrivate(page)) { ClearPagePrivate(page); + put_page(page); + get_page(newpage); SetPagePrivate(newpage); } @@ -1513,6 +1518,7 @@ static int ubifs_releasepage(struct page *page, gfp_t unused_gfp_flags) ubifs_assert(c, 0); ClearPagePrivate(page); ClearPageChecked(page); + put_page(page); return 1; } @@ -1582,6 +1588,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf) else { if (!PageChecked(page)) ubifs_convert_page_budget(c); + get_page(page); SetPagePrivate(page); atomic_long_inc(&c->dirty_pg_cnt); __set_page_dirty_nobuffers(page);