From patchwork Tue Mar 23 22:17:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 406994 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAA2BC433DB for ; Tue, 23 Mar 2021 22:19:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 941F461879 for ; Tue, 23 Mar 2021 22:19:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233947AbhCWWSo (ORCPT ); Tue, 23 Mar 2021 18:18:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34891 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233859AbhCWWSD (ORCPT ); Tue, 23 Mar 2021 18:18:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616537880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wc1tHYEycG0FRmZQbIWHGSriJOssCKvxl09WyfLRD2g=; b=h8dv70+4B0gyucjZ5A/ieDHgUWGbx9riuFJssaupopCPC1mAUKoUQv6TFpUMS6Sf0X/URp CxnUC7N3EPgW8OJet5AMhAgAAr8nOnEQLqnK2RDzn7ccntI3ZlfYR6IJgHp5r6Uvf54COk uYEwWs64/q03h/YC0uNlU5V7+dz++QI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-UFUoV2jjOZ-xgD2r8roNeA-1; Tue, 23 Mar 2021 18:17:58 -0400 X-MC-Unique: UFUoV2jjOZ-xgD2r8roNeA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C47A71084D68; Tue, 23 Mar 2021 22:17:56 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-112-58.rdu2.redhat.com [10.10.112.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADF4460243; Tue, 23 Mar 2021 22:17:53 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH v5 02/28] mm: Add wait_on_page_writeback_killable() From: David Howells To: Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet Cc: "Matthew Wilcox (Oracle)" , Alexander Viro , Christoph Hellwig , linux-mm@kvack.org, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, dhowells@redhat.com, Jeff Layton , David Wysochanski , "Matthew Wilcox (Oracle)" , Alexander Viro , linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 23 Mar 2021 22:17:52 +0000 Message-ID: <161653787287.2770958.17679186162121211209.stgit@warthog.procyon.org.uk> In-Reply-To: <161653784755.2770958.11820491619308713741.stgit@warthog.procyon.org.uk> References: <161653784755.2770958.11820491619308713741.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Add a function to wait killably on the PG_writeback page flag. Signed-off-by: David Howells cc: Matthew Wilcox (Oracle) cc: Alexander Viro cc: Christoph Hellwig cc: linux-mm@kvack.org cc: linux-cachefs@redhat.com cc: linux-afs@lists.infradead.org cc: linux-nfs@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: ceph-devel@vger.kernel.org cc: v9fs-developer@lists.sourceforge.net cc: linux-fsdevel@vger.kernel.org --- include/linux/pagemap.h | 1 + mm/page-writeback.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 20225b067583..444155ae56c0 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -683,6 +683,7 @@ static inline int wait_on_page_locked_killable(struct page *page) int put_and_wait_on_page_locked(struct page *page, int state); void wait_on_page_writeback(struct page *page); +int wait_on_page_writeback_killable(struct page *page); extern void end_page_writeback(struct page *page); void wait_for_stable_page(struct page *page); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index eb34d204d4ee..b8bad275f94b 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2833,6 +2833,31 @@ void wait_on_page_writeback(struct page *page) } EXPORT_SYMBOL_GPL(wait_on_page_writeback); +/** + * Wait for a page to complete writeback + * @page: The page to wait on + * + * Wait for the writeback status of a page to clear or a fatal signal to occur. + * + * Return: + * - 0 on success. + * - -EINTR if a fatal signal was encountered. + */ +int wait_on_page_writeback_killable(struct page *page) +{ + int ret = 0; + + while (PageWriteback(page)) { + trace_wait_on_page_writeback(page, page_mapping(page)); + ret = wait_on_page_bit_killable(page, PG_writeback); + if (ret < 0) + break; + } + + return ret; +} +EXPORT_SYMBOL(wait_on_page_writeback_killable); + /** * wait_for_stable_page() - wait for writeback to finish, if necessary. * @page: The page to wait on.