From patchwork Mon Jul 13 16:38:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 11660683 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E70CD6C1 for ; Mon, 13 Jul 2020 16:38:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE2F4206F5 for ; Mon, 13 Jul 2020 16:38:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i2egx+rJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730598AbgGMQiy (ORCPT ); Mon, 13 Jul 2020 12:38:54 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38715 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730496AbgGMQiy (ORCPT ); Mon, 13 Jul 2020 12:38:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594658333; 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=hBqsUy2masEpa+uY5TjuNpXWjnW0S3sDVF3PP2vI20s=; b=i2egx+rJwczMwQ2+YAxEZjpntPrvYj1vrK09xvsIUmlo0ImxbPAHUIXCN6l/jnTkJ9axfE yz2q87Y4spSknS7zzs8jSNXIPo9H1wTBmOuJ0r1luj2u/ADq+gddrS27Vsmyb9SBSafS48 1zqfXMJUN3te/2P3gc79+omdbivjCvY= 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-260-K7doxlJWMZ237TzMS3ZXzA-1; Mon, 13 Jul 2020 12:38:51 -0400 X-MC-Unique: K7doxlJWMZ237TzMS3ZXzA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E7B71080; Mon, 13 Jul 2020 16:38:50 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-112-113.rdu2.redhat.com [10.10.112.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id E089D6FDD1; Mon, 13 Jul 2020 16:38:44 +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 09/13] afs: Wait on PG_fscache before modifying/releasing a page From: David Howells To: Trond Myklebust , Anna Schumaker , Steve French , Alexander Viro , Matthew Wilcox Cc: Jeff Layton , Dave Wysochanski , dhowells@redhat.com, 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: Mon, 13 Jul 2020 17:38:44 +0100 Message-ID: <159465832417.1377938.3571599385208729791.stgit@warthog.procyon.org.uk> In-Reply-To: <159465821598.1377938.2046362270225008168.stgit@warthog.procyon.org.uk> References: <159465821598.1377938.2046362270225008168.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.22 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org PG_fscache is going to be used to indicate that a page is being written to the cache, and that the page should not be modified or released until it's finished. Make afs_invalidatepage() and afs_releasepage() wait for it. Signed-off-by: David Howells --- fs/afs/file.c | 7 +++++++ fs/afs/write.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/fs/afs/file.c b/fs/afs/file.c index 8baafe655433..2f9a7369b77b 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -580,6 +580,13 @@ static int afs_releasepage(struct page *page, gfp_t gfp_flags) /* deny if page is being written to the cache and the caller hasn't * elected to wait */ +#ifdef CONFIG_AFS_FSCACHE + if (PageFsCache(page)) { + if (!(gfp_flags & __GFP_DIRECT_RECLAIM) || !(gfp_flags & __GFP_FS)) + return false; + } +#endif + if (PagePrivate(page)) { priv = page_private(page); trace_afs_page_dirty(vnode, tracepoint_string("rel"), diff --git a/fs/afs/write.c b/fs/afs/write.c index d9de0dc877ca..73e2f4c93512 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -125,6 +125,10 @@ int afs_write_begin(struct file *file, struct address_space *mapping, SetPageUptodate(page); } +#ifdef CONFIG_AFS_FSCACHE + wait_on_page_fscache(page); +#endif + /* page won't leak in error case: it eventually gets cleaned off LRU */ *pagep = page; @@ -849,6 +853,11 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf) /* Wait for the page to be written to the cache before we allow it to * be modified. We then assume the entire page will need writing back. */ +#ifdef CONFIG_AFS_FSCACHE + if (PageFsCache(vmf->page) && + wait_on_page_bit_killable(vmf->page, PG_fscache) < 0) + return VM_FAULT_RETRY; +#endif if (PageWriteback(vmf->page) && wait_on_page_bit_killable(vmf->page, PG_writeback) < 0)