From patchwork Fri Oct 22 19:03:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 12578627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB9F7C433EF for ; Fri, 22 Oct 2021 19:03:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB22161038 for ; Fri, 22 Oct 2021 19:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233632AbhJVTFx (ORCPT ); Fri, 22 Oct 2021 15:05:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37406 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234184AbhJVTFm (ORCPT ); Fri, 22 Oct 2021 15:05:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634929404; 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=2S6oJwlfPgM0KHrem8D6g4TpVQs4AraDRlyJ1lrXgKQ=; b=VLe+tvP8EJ9mC3pM9X9IdXG6Svpalak6acB4VuFoK3vyGNKJfAljSfoGtOybxJVKmKRYhF wm+54cTZHoVqrsXKMABr4ti7D/19uTVtsXEYbUXROu+KaaUHUjqEMpYoyQ96t5DI4Qyq/b w5zOhZqrfcn0YMIgW57Dp6DiSneyuDM= 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-178-H0DDPO2xMH22v1Id_eQZCQ-1; Fri, 22 Oct 2021 15:03:23 -0400 X-MC-Unique: H0DDPO2xMH22v1Id_eQZCQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B31851006AA2; Fri, 22 Oct 2021 19:03:16 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D7D71346F; Fri, 22 Oct 2021 19:03:06 +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 v2 17/53] fscache: Add a function for a cache backend to note an I/O error From: David Howells To: linux-cachefs@redhat.com Cc: dhowells@redhat.com, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , Matthew Wilcox , Alexander Viro , Omar Sandoval , Linus Torvalds , 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: Fri, 22 Oct 2021 20:03:05 +0100 Message-ID: <163492938531.1038219.14390319135422534474.stgit@warthog.procyon.org.uk> In-Reply-To: <163492911924.1038219.13107463173777870713.stgit@warthog.procyon.org.uk> References: <163492911924.1038219.13107463173777870713.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Add a function to the backend API to note an I/O error in a cache. Signed-off-by: David Howells cc: linux-cachefs@redhat.com --- fs/fscache/cache.c | 20 ++++++++++++++++++++ include/linux/fscache-cache.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/fs/fscache/cache.c b/fs/fscache/cache.c index bed491c99834..bfe33104ba02 100644 --- a/fs/fscache/cache.c +++ b/fs/fscache/cache.c @@ -250,6 +250,26 @@ void fscache_end_cache_access(struct fscache_cache *cache, enum fscache_access_t wake_up_var(&cache->n_accesses); } +/** + * fscache_io_error - Note a cache I/O error + * @cache: The record describing the cache + * + * Note that an I/O error occurred in a cache and that it should no longer be + * used for anything. This also reports the error into the kernel log. + * + * See Documentation/filesystems/caching/backend-api.rst for a complete + * description. + */ +void fscache_io_error(struct fscache_cache *cache) +{ + if (fscache_set_cache_state_maybe(cache, + FSCACHE_CACHE_IS_ACTIVE, + FSCACHE_CACHE_GOT_IOERROR)) + pr_err("Cache '%s' stopped due to I/O error\n", + cache->name); +} +EXPORT_SYMBOL(fscache_io_error); + /** * fscache_withdraw_cache - Withdraw a cache from the active service * @cache: The cache cookie diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h index 558d4bbbe486..dfecabfd4a0e 100644 --- a/include/linux/fscache-cache.h +++ b/include/linux/fscache-cache.h @@ -97,6 +97,8 @@ extern void fscache_put_cache(struct fscache_cache *cache, enum fscache_cache_trace where); extern void fscache_withdraw_cache(struct fscache_cache *cache); +extern void fscache_io_error(struct fscache_cache *cache); + extern void fscache_end_volume_access(struct fscache_volume *volume, enum fscache_access_trace why);