From patchwork Wed May 31 12:45:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9756869 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 EDAE360390 for ; Wed, 31 May 2017 12:48:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2190201BD for ; Wed, 31 May 2017 12:48:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7187283BA; Wed, 31 May 2017 12:48:00 +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=unavailable 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 8A9D9201BD for ; Wed, 31 May 2017 12:48:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751391AbdEaMqD (ORCPT ); Wed, 31 May 2017 08:46:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54888 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751086AbdEaMqC (ORCPT ); Wed, 31 May 2017 08:46:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66E056548; Wed, 31 May 2017 12:46:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 66E056548 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jlayton@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 66E056548 Received: from tleilax.poochiereds.net (ovpn-120-5.rdu2.redhat.com [10.10.120.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 416A77FB83; Wed, 31 May 2017 12:46:00 +0000 (UTC) From: Jeff Layton To: Andrew Morton , Al Viro , Jan Kara , tytso@mit.edu, axboe@kernel.dk, mawilcox@microsoft.com, ross.zwisler@linux.intel.com, corbet@lwn.net Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v5 15/17] fs: add a write_one_page_since Date: Wed, 31 May 2017 08:45:38 -0400 Message-Id: <20170531124540.8782-16-jlayton@redhat.com> In-Reply-To: <20170531124540.8782-1-jlayton@redhat.com> References: <20170531124540.8782-1-jlayton@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 31 May 2017 12:46:01 +0000 (UTC) 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 Allow filesystems to pass in an errseq_t for a since value. Signed-off-by: Jeff Layton --- include/linux/mm.h | 2 ++ mm/page-writeback.c | 53 +++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index ca9c8b27cecb..c901d7313374 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -23,6 +23,7 @@ #include #include #include +#include struct mempolicy; struct anon_vma; @@ -2200,6 +2201,7 @@ extern int filemap_page_mkwrite(struct vm_fault *vmf); /* mm/page-writeback.c */ int __must_check write_one_page(struct page *page); +int __must_check write_one_page_since(struct page *page, errseq_t since); void task_dirty_inc(struct task_struct *tsk); /* readahead.c */ diff --git a/mm/page-writeback.c b/mm/page-writeback.c index e369e8ea2a29..63058e35c60d 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2365,19 +2365,10 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc) return ret; } -/** - * write_one_page - write out a single page and wait on I/O - * @page: the page to write - * - * The page must be locked by the caller and will be unlocked upon return. - * - * Note that the mapping's AS_EIO/AS_ENOSPC flags will be cleared when this - * function returns. - */ -int write_one_page(struct page *page) +static int __write_one_page(struct page *page) { struct address_space *mapping = page->mapping; - int ret = 0, ret2; + int ret; struct writeback_control wbc = { .sync_mode = WB_SYNC_ALL, .nr_to_write = 1, @@ -2394,16 +2385,54 @@ int write_one_page(struct page *page) wait_on_page_writeback(page); put_page(page); } else { + ret = 0; unlock_page(page); } + return ret; +} +/** + * write_one_page - write out a single page and wait on I/O + * @page: the page to write + * + * The page must be locked by the caller and will be unlocked upon return. + * + * Note that the mapping's AS_EIO/AS_ENOSPC flags will be cleared when this + * function returns. + */ +int write_one_page(struct page *page) +{ + int ret; + + ret = __write_one_page(page); if (!ret) - ret = filemap_check_errors(mapping); + ret = filemap_check_errors(page->mapping); return ret; } EXPORT_SYMBOL(write_one_page); /* + * write_one_page_since - write out a single page and wait on I/O + * @page: the page to write + * @since: previously sampled errseq_t + * + * The page must be locked by the caller and will be unlocked upon return. + * + * The caller should pass in a previously-sampled errseq_t. The mapping will + * be checked for errors since that point. + */ +int write_one_page_since(struct page *page, errseq_t since) +{ + int ret; + + ret = __write_one_page(page); + if (!ret) + ret = filemap_check_wb_err(page->mapping, since); + return ret; +} +EXPORT_SYMBOL(write_one_page_since); + +/* * For address_spaces which do not use buffers nor write back. */ int __set_page_dirty_no_writeback(struct page *page)