Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3084642pxb; Mon, 18 Oct 2021 07:58:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyC5fPQRnzo+GIi2EOT3LoCt4BgCW/tO4GPEiIMFaspzyLBn/iQfFjtLyqUcPSriuPG6mZQ X-Received: by 2002:a17:902:9882:b0:13e:1749:daae with SMTP id s2-20020a170902988200b0013e1749daaemr27566113plp.60.1634569097928; Mon, 18 Oct 2021 07:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634569097; cv=none; d=google.com; s=arc-20160816; b=wCNh/AqLHogo4/KT0TThbIvTTwSy97G+X5p3w0D868w2lFnq5mhjVVslAAeDvemsYK zWwrwSLVqxt6N5T/NAXryYGy9aIQ8UT/yBaMjnKdtkGqgC2LrMtYOaZb4Ekf9+y6perY gvBSP44A15H4HOJBrvtExKDvC60JdMKxlX25KH6uOLXs9LeON759uaX2t6D3giddYu8q oSrKANo/PqxSf2QqyJQeZYCbnWFAM+Q5xd7KtgImHhTqqcoxMTbVygRYz9dbzx0oDvNS +JnhMo7Y2vSQTgip2QzR/omWe62WJJaD82OysxQhGBTXHqXXZ2gPisJrbzGTs1P9lazE +drg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=GNPDlFd2NslhWdTLh2Oj9wTL+m4p3QmKel08TqL4wkc=; b=FTgFsbj2Mae0Ua/l8jbXblXCo3270uI++xhSgBo2DTUSg2oWMPE071y3/HRNuEtH8/ F/axaX7zUOlFHQ9eJTaCy15Pt6XLpN5F7PmfYf5GyMkUq+1jrBxo5jWN+RzUgT4JX+YD em9jPQMlYw5vQ9QQaNCJQWqEfSfye2M4CQkrwUhtFKadgbkQzcZkDF8wVifCeTGbWxvQ xkHVyBLl9T6BHte5FqbUDZ08ZbyPIzcJXZeafYqqFdhEe5GhJiflhODMIGDHudgLX7YF 9Xuw2Y/myrXQIx6tmiuGUI220Y/sXZ2gV0qRfXXwfHo83QstKpLivrV0WEWA/yBVTvpQ p8iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SX2R7w2K; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si25216736plg.431.2021.10.18.07.58.04; Mon, 18 Oct 2021 07:58:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SX2R7w2K; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232946AbhJRPAJ (ORCPT + 99 others); Mon, 18 Oct 2021 11:00:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54449 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232983AbhJRO75 (ORCPT ); Mon, 18 Oct 2021 10:59:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634569065; 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=GNPDlFd2NslhWdTLh2Oj9wTL+m4p3QmKel08TqL4wkc=; b=SX2R7w2KsRaEsYBV2LAYwL/zEctX3/0oOu2ccZB6UvbpH5RMAEk0YGmANs9Xzd4Rsrcyg2 9QuljYu2GLOC0xIQu+jTtO6rTYxHWGANVUq2frsR0r0FAF77K10xvq1UkZh7QzKpTSpmmX mZ9wuSmCvnuOZpADsITQodoPYlZ+TpI= 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-553-1kb8q-8UNbC0iJEAYxuwyg-1; Mon, 18 Oct 2021 10:57:39 -0400 X-MC-Unique: 1kb8q-8UNbC0iJEAYxuwyg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98DFE1006AA2; Mon, 18 Oct 2021 14:57:37 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 877E55D6D7; Mon, 18 Oct 2021 14:57:31 +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 27/67] cachefiles: trace: Log coherency checks 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: Mon, 18 Oct 2021 15:57:30 +0100 Message-ID: <163456905064.2614702.902644495518051262.stgit@warthog.procyon.org.uk> In-Reply-To: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> References: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add a cachefiles tracepoint that logs the result of coherency management when the coherency data on a file in the cache is checked or committed. Signed-off-by: David Howells --- fs/cachefiles/xattr.c | 44 +++++++++++++++++++++-------- include/trace/events/cachefiles.h | 56 +++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 12 deletions(-) diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c index 2f14618d9a36..bfb2f4d605af 100644 --- a/fs/cachefiles/xattr.c +++ b/fs/cachefiles/xattr.c @@ -53,12 +53,21 @@ int cachefiles_set_object_xattr(struct cachefiles_object *object, ret = vfs_setxattr(&init_user_ns, dentry, cachefiles_xattr_cache, buf, sizeof(struct cachefiles_xattr) + len, xattr_flags); - kfree(buf); - if (ret < 0 && ret != -ENOMEM) - cachefiles_io_error_obj( - object, - "Failed to set xattr with error %d", ret); + if (ret < 0) { + trace_cachefiles_coherency(object, file_inode(file)->i_ino, + 0, + cachefiles_coherency_set_fail); + if (ret != -ENOMEM) + cachefiles_io_error_obj( + object, + "Failed to set xattr with error %d", ret); + } else { + trace_cachefiles_coherency(object, file_inode(file)->i_ino, + 0, + cachefiles_coherency_set_ok); + } + kfree(buf); _leave(" = %d", ret); return ret; } @@ -72,21 +81,32 @@ int cachefiles_check_auxdata(struct cachefiles_object *object) struct dentry *dentry = object->file->f_path.dentry; unsigned int len = object->cookie->aux_len, tlen; const void *p = fscache_get_aux(object->cookie); - ssize_t ret; + enum cachefiles_coherency_trace why; + ssize_t xlen; + int ret = -ESTALE; tlen = sizeof(struct cachefiles_xattr) + len; buf = kmalloc(tlen, GFP_KERNEL); if (!buf) return -ENOMEM; - ret = vfs_getxattr(&init_user_ns, dentry, cachefiles_xattr_cache, buf, tlen); - if (ret == tlen && - buf->type == object->cookie->type && - memcmp(buf->data, p, len) == 0) + xlen = vfs_getxattr(&init_user_ns, dentry, cachefiles_xattr_cache, buf, tlen); + if (xlen != tlen) { + if (xlen == -EIO) + cachefiles_io_error_obj( + object, + "Failed to read aux with error %zd", xlen); + why = cachefiles_coherency_check_xattr; + } else if (buf->type != object->cookie->type) { + why = cachefiles_coherency_check_type; + } else if (memcmp(buf->data, p, len) != 0) { + why = cachefiles_coherency_check_aux; + } else { + why = cachefiles_coherency_check_ok; ret = 0; - else - ret = -ESTALE; + } + trace_cachefiles_coherency(object, file_inode(object->file)->i_ino, 0, why); kfree(buf); return ret; } diff --git a/include/trace/events/cachefiles.h b/include/trace/events/cachefiles.h index 10ad5305d1c5..6e9f6462833d 100644 --- a/include/trace/events/cachefiles.h +++ b/include/trace/events/cachefiles.h @@ -24,6 +24,19 @@ enum cachefiles_obj_ref_trace { cachefiles_obj_ref__nr_traces }; +enum cachefiles_coherency_trace { + cachefiles_coherency_check_aux, + cachefiles_coherency_check_content, + cachefiles_coherency_check_dirty, + cachefiles_coherency_check_len, + cachefiles_coherency_check_objsize, + cachefiles_coherency_check_ok, + cachefiles_coherency_check_type, + cachefiles_coherency_check_xattr, + cachefiles_coherency_set_fail, + cachefiles_coherency_set_ok, +}; + #endif /* @@ -47,6 +60,18 @@ enum cachefiles_obj_ref_trace { EM(cachefiles_obj_put_wait_retry, "PUT wait_retry") \ E_(cachefiles_obj_put_wait_timeo, "PUT wait_timeo") +#define cachefiles_coherency_traces \ + EM(cachefiles_coherency_check_aux, "BAD aux ") \ + EM(cachefiles_coherency_check_content, "BAD cont") \ + EM(cachefiles_coherency_check_dirty, "BAD dirt") \ + EM(cachefiles_coherency_check_len, "BAD len ") \ + EM(cachefiles_coherency_check_objsize, "BAD osiz") \ + EM(cachefiles_coherency_check_ok, "OK ") \ + EM(cachefiles_coherency_check_type, "BAD type") \ + EM(cachefiles_coherency_check_xattr, "BAD xatt") \ + EM(cachefiles_coherency_set_fail, "SET fail") \ + E_(cachefiles_coherency_set_ok, "SET ok ") + /* * Export enum symbols via userspace. */ @@ -57,6 +82,7 @@ enum cachefiles_obj_ref_trace { cachefiles_obj_kill_traces; cachefiles_obj_ref_traces; +cachefiles_coherency_traces; /* * Now redefine the EM() and E_() macros to map the enums to the strings that @@ -236,6 +262,36 @@ TRACE_EVENT(cachefiles_mark_inactive, __entry->obj, __entry->inode) ); +TRACE_EVENT(cachefiles_coherency, + TP_PROTO(struct cachefiles_object *obj, + ino_t ino, + int content, + enum cachefiles_coherency_trace why), + + TP_ARGS(obj, ino, content, why), + + /* Note that obj may be NULL */ + TP_STRUCT__entry( + __field(unsigned int, obj ) + __field(enum cachefiles_coherency_trace, why ) + __field(int, content ) + __field(u64, ino ) + ), + + TP_fast_assign( + __entry->obj = obj->debug_id; + __entry->why = why; + __entry->content = content; + __entry->ino = ino; + ), + + TP_printk("o=%08x %s i=%llx c=%u", + __entry->obj, + __print_symbolic(__entry->why, cachefiles_coherency_traces), + __entry->ino, + __entry->content) + ); + #endif /* _TRACE_CACHEFILES_H */ /* This part must be outside protection */