From patchwork Mon Nov 2 13:50:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11873921 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 05FB2921 for ; Mon, 2 Nov 2020 13:51:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2533223BF for ; Mon, 2 Nov 2020 13:51:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gvWG2sry" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725933AbgKBNvf (ORCPT ); Mon, 2 Nov 2020 08:51:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45618 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725923AbgKBNuS (ORCPT ); Mon, 2 Nov 2020 08:50:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604325017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=olmwqf6JsIgz86urssgtccQehcjB82mMIquC/xJmX1Y=; b=gvWG2sryCvamBT0g7sjsIHxTMcgs1Vo+tsT7YqGG5dNynkvVwYhHD70v/QgkW+hs1RgF4o weMLaCNX+JKNJ+GO+KGP8o+aLG05Gg7nnsC7kIPm3snsERPQajAeaCerqu4oZAV4mej+Qj Sp4Mbpi5nUAFET+9GVzY+SWpUS48X4A= 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-435-KvOOZk7QOyOIQAxgZRGY8A-1; Mon, 02 Nov 2020 08:50:15 -0500 X-MC-Unique: KvOOZk7QOyOIQAxgZRGY8A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72063805F12; Mon, 2 Nov 2020 13:50:14 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-255.rdu2.redhat.com [10.10.113.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 070DB5DA6B; Mon, 2 Nov 2020 13:50:13 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 01/11] NFSv4: Improve nfs4_readdir tracepoint by adding additional fields Date: Mon, 2 Nov 2020 08:50:01 -0500 Message-Id: <1604325011-29427-2-git-send-email-dwysocha@redhat.com> In-Reply-To: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> References: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When tracing NFSv4 readdir there are fields beyond the inode based information that are useful, such as the cookie, count, and whether readdirplus is enabled. Add these fields to the nfs4_readdir tracepoint which executes after a NFS4 readdir completes. Signed-off-by: Dave Wysochanski --- fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4trace.h | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 6e95c85fe395..4f324ad5c5b0 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -4983,7 +4983,7 @@ static int nfs4_proc_readdir(struct dentry *dentry, const struct cred *cred, do { err = _nfs4_proc_readdir(dentry, cred, cookie, pages, count, plus); - trace_nfs4_readdir(d_inode(dentry), err); + trace_nfs4_readdir(d_inode(dentry), cookie, count, plus, err); err = nfs4_handle_exception(NFS_SERVER(d_inode(dentry)), err, &exception); } while (exception.retry); diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h index b4f852d4d099..c62e46451b16 100644 --- a/fs/nfs/nfs4trace.h +++ b/fs/nfs/nfs4trace.h @@ -1449,9 +1449,51 @@ DEFINE_NFS4_INODE_EVENT(nfs4_access); DEFINE_NFS4_INODE_EVENT(nfs4_readlink); -DEFINE_NFS4_INODE_EVENT(nfs4_readdir); DEFINE_NFS4_INODE_EVENT(nfs4_get_acl); DEFINE_NFS4_INODE_EVENT(nfs4_set_acl); + +TRACE_EVENT(nfs4_readdir, + TP_PROTO( + const struct inode *inode, + u64 cookie, + unsigned int count, + bool plus, + int error + ), + + TP_ARGS(inode, cookie, count, plus, error), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(u32, fhandle) + __field(u64, fileid) + __field(unsigned long, error) + __field(u64, cookie) + __field(u64, count) + __field(bool, plus) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->fileid = NFS_FILEID(inode); + __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); + __entry->error = error < 0 ? -error : 0; + __entry->cookie = cookie; + __entry->count = count; + __entry->plus = plus; + ), + + TP_printk( + "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x cookie=0x%08llx count=%llu plus=%s", + -__entry->error, + show_nfsv4_errors(__entry->error), + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long long)__entry->fileid, + __entry->fhandle, __entry->cookie, + __entry->count, __entry->plus ? "true" : "false" + ) +); + #ifdef CONFIG_NFS_V4_SECURITY_LABEL DEFINE_NFS4_INODE_EVENT(nfs4_get_security_label); DEFINE_NFS4_INODE_EVENT(nfs4_set_security_label); From patchwork Mon Nov 2 13:50:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11873919 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 63FC092C for ; Mon, 2 Nov 2020 13:51:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41A53223C7 for ; Mon, 2 Nov 2020 13:51:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XBnBADNx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725797AbgKBNvd (ORCPT ); Mon, 2 Nov 2020 08:51:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:24673 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725927AbgKBNuT (ORCPT ); Mon, 2 Nov 2020 08:50:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604325017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=MeH4WQdTlQCh8nJjD9N4/seSFRiZo6NmrVULAUIRh7g=; b=XBnBADNxKWndU9cHl9BkKPZyZEY8mJm1Kc4kMn3XHoIuq0C0sA7dw/w9moOXotYdnyhfI6 LroPj4mx3ylAWWZ/fQe6dOa7I6M5Fd2mHNogCrY0jfDGGCMM6x8rXZSMlNLLasE6uZUhSG 0l0cqI42Jx0jNK0YHWFlugSNhPOcA40= 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-330-XNcaEiCEN6m1i3T_LW0wTA-1; Mon, 02 Nov 2020 08:50:16 -0500 X-MC-Unique: XNcaEiCEN6m1i3T_LW0wTA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E835FA4206B; Mon, 2 Nov 2020 13:50:14 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-255.rdu2.redhat.com [10.10.113.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F8385D9DD; Mon, 2 Nov 2020 13:50:14 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 02/11] NFS: Replace dfprintk statements with trace events in nfs_readdir Date: Mon, 2 Nov 2020 08:50:02 -0500 Message-Id: <1604325011-29427-3-git-send-email-dwysocha@redhat.com> In-Reply-To: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> References: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Remove a couple dfprintks in nfs_readdir and replace them with trace events on entry/exit that contain more information. Signed-off-by: Dave Wysochanski --- fs/nfs/dir.c | 7 +++-- fs/nfs/nfstrace.h | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index cb52db9a0cfb..116493e66922 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -900,9 +900,9 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) *desc = &my_desc; int res = 0; - dfprintk(FILE, "NFS: readdir(%pD2) starting at cookie %llu\n", - file, (long long)ctx->pos); nfs_inc_stats(inode, NFSIOS_VFSGETDENTS); + trace_nfs_readdir_enter(inode, ctx->pos, dir_ctx->dir_cookie, + NFS_SERVER(inode)->dtsize, my_desc.plus); /* * ctx->pos points to the dirent entry number. @@ -949,7 +949,8 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) out: if (res > 0) res = 0; - dfprintk(FILE, "NFS: readdir(%pD2) returns %d\n", file, res); + trace_nfs_readdir_exit(inode, ctx->pos, dir_ctx->dir_cookie, + NFS_SERVER(inode)->dtsize, my_desc.plus, res); return res; } diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index 5a59dcdce0b2..6bbe0aa221f2 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -668,6 +668,90 @@ DEFINE_NFS_DIRECTORY_EVENT(nfs_symlink_enter); DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_symlink_exit); +TRACE_EVENT(nfs_readdir_enter, + TP_PROTO( + const struct inode *inode, + u64 cookie, + u64 dir_cookie, + unsigned int count, + bool plus + ), + + TP_ARGS(inode, cookie, dir_cookie, count, plus), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(u32, fhandle) + __field(u64, fileid) + __field(u64, cookie) + __field(u64, dir_cookie) + __field(u64, count) + __field(bool, plus) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->fileid = NFS_FILEID(inode); + __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); + __entry->cookie = cookie; + __entry->dir_cookie = dir_cookie; + __entry->count = count; + __entry->plus = plus; + ), + + TP_printk( + "fileid=%02x:%02x:%llu fhandle=0x%08x cookie=0x%08llx dir_cookie=0x%08llx count=%llu plus=%s", + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long long)__entry->fileid, + __entry->fhandle, __entry->cookie, __entry->dir_cookie, + __entry->count, __entry->plus ? "true" : "false" + ) +); + +TRACE_EVENT(nfs_readdir_exit, + TP_PROTO( + const struct inode *inode, + u64 cookie, + u64 dir_cookie, + unsigned int count, + bool plus, + int error + ), + + TP_ARGS(inode, cookie, dir_cookie, count, plus, error), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(u32, fhandle) + __field(u64, fileid) + __field(unsigned long, error) + __field(u64, cookie) + __field(u64, dir_cookie) + __field(u64, count) + __field(bool, plus) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->fileid = NFS_FILEID(inode); + __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); + __entry->error = error; + __entry->cookie = cookie; + __entry->dir_cookie = dir_cookie; + __entry->count = count; + __entry->plus = plus; + ), + + TP_printk( + "error=%ld fileid=%02x:%02x:%llu fhandle=0x%08x cookie=0x%08llx dir_cookie=0x%08llx count=%llu plus=%s", + __entry->error, + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long long)__entry->fileid, + __entry->fhandle, __entry->cookie, __entry->dir_cookie, + __entry->count, __entry->plus ? "true" : "false" + ) +); + TRACE_EVENT(nfs_link_enter, TP_PROTO( const struct inode *inode, From patchwork Mon Nov 2 13:50:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11873923 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 3C6631130 for ; Mon, 2 Nov 2020 13:51:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17EA9223BF for ; Mon, 2 Nov 2020 13:51:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IOUogRT4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725968AbgKBNvf (ORCPT ); Mon, 2 Nov 2020 08:51:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38642 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbgKBNuT (ORCPT ); Mon, 2 Nov 2020 08:50:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604325017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=IflCTAsCltnUeNlhT1ftLYsSS43K+h1sSKXdsRM3zSA=; b=IOUogRT4bmLyIYCqBtFrTznLhcNttAm3Rx8T17FLr0w5kldhlikW0n9KVuJu46T5oqVKFz 2j8hJrrugUP4KeVd/C1B2cEOthf2G3QMDo68Dba0OAHzWbPtbcKwtaUxYqg19t5YfdpxkZ zM1x5ySyjuYAQELKKzTLtmDvmUfyA8A= 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-265-pYHksQS-Nj6ZCIx-up-inQ-1; Mon, 02 Nov 2020 08:50:16 -0500 X-MC-Unique: pYHksQS-Nj6ZCIx-up-inQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C23557097; Mon, 2 Nov 2020 13:50:15 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-255.rdu2.redhat.com [10.10.113.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 128BC5D9DD; Mon, 2 Nov 2020 13:50:15 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 03/11] NFS: Move nfs_readdir_descriptor_t into internal header Date: Mon, 2 Nov 2020 08:50:03 -0500 Message-Id: <1604325011-29427-4-git-send-email-dwysocha@redhat.com> In-Reply-To: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> References: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org In preparation for readdir tracing involving nfs_readdir_descriptor_t move the definition into the "internal.h" header file, and ensure internal.h is included before nfstrace.h to avoid build problems. Signed-off-by: Dave Wysochanski --- fs/nfs/dir.c | 18 ------------------ fs/nfs/internal.h | 18 ++++++++++++++++++ fs/nfs/nfs3xdr.c | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 116493e66922..145393188f6a 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -144,24 +144,6 @@ struct nfs_cache_array { struct nfs_cache_array_entry array[]; }; -typedef struct { - struct file *file; - struct page *page; - struct dir_context *ctx; - unsigned long page_index; - u64 *dir_cookie; - u64 last_cookie; - loff_t current_index; - loff_t prev_index; - - unsigned long dir_verifier; - unsigned long timestamp; - unsigned long gencount; - unsigned int cache_entry_index; - bool plus; - bool eof; -} nfs_readdir_descriptor_t; - static void nfs_readdir_init_array(struct page *page) { diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 6673a77884d9..68ade987370d 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -62,6 +62,24 @@ static inline bool nfs_lookup_is_soft_revalidate(const struct dentry *dentry) */ #define NFS_MAX_READDIR_PAGES 8 +typedef struct { + struct file *file; + struct page *page; + struct dir_context *ctx; + unsigned long page_index; + u64 *dir_cookie; + u64 last_cookie; + loff_t current_index; + loff_t prev_index; + + unsigned long dir_verifier; + unsigned long timestamp; + unsigned long gencount; + unsigned int cache_entry_index; + bool plus; + bool eof; +} nfs_readdir_descriptor_t; + struct nfs_client_initdata { unsigned long init_flags; const char *hostname; /* Hostname of the server */ diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c index 69971f6c840d..972759325de0 100644 --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c @@ -21,8 +21,8 @@ #include #include #include -#include "nfstrace.h" #include "internal.h" +#include "nfstrace.h" #define NFSDBG_FACILITY NFSDBG_XDR From patchwork Mon Nov 2 13:50:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11873917 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 C86F2921 for ; Mon, 2 Nov 2020 13:51:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A71C2223BD for ; Mon, 2 Nov 2020 13:51:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cFr5wC3P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725972AbgKBNvc (ORCPT ); Mon, 2 Nov 2020 08:51:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50774 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725940AbgKBNuU (ORCPT ); Mon, 2 Nov 2020 08:50:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604325018; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=HnkXIkWkSO1sjzbcqpAshdTprsfO8JyCeJtXHZkA5qI=; b=cFr5wC3PKd/PwO2P89JrZNAijPIMlrseOM44Slq1dGxEqNyy9ilPk7AzsSQU+Mc13UOnXQ pZkzRhHC8PAp9ePKBOIbfp4R/0mHqM6Y5HAawfQsbqopjD3OJnxpBuZmjkirAJcCIbjVfF IXXSmCLd89RU3Xpf6pJVopTzbaL5ie4= 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-269-txq02oJYNduriAKhY-L3Yg-1; Mon, 02 Nov 2020 08:50:17 -0500 X-MC-Unique: txq02oJYNduriAKhY-L3Yg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E402A191E2A0; Mon, 2 Nov 2020 13:50:15 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-255.rdu2.redhat.com [10.10.113.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A3D25D9DD; Mon, 2 Nov 2020 13:50:15 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 04/11] NFS: Add tracepoints for functions involving nfs_readdir_descriptor_t Date: Mon, 2 Nov 2020 08:50:04 -0500 Message-Id: <1604325011-29427-5-git-send-email-dwysocha@redhat.com> In-Reply-To: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> References: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add more tracepoints in the NFS readdir code to trace functions which change members of nfs_readdir_descriptor_t. In the process, remove two more dfprintks inside uncached_readdir(). Signed-off-by: Dave Wysochanski Reported-by: kernel test robot --- fs/nfs/dir.c | 10 +++--- fs/nfs/nfstrace.h | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 4 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 145393188f6a..227cddc12983 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -329,6 +329,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc) struct nfs_cache_array *array; int status; + trace_nfs_readdir_search_array_enter(desc); array = kmap(desc->page); if (*desc->dir_cookie == 0) @@ -342,6 +343,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc) desc->page_index++; } kunmap(desc->page); + trace_nfs_readdir_search_array_exit(desc, status); return status; } @@ -762,6 +764,7 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc) { int res; + trace_nfs_readdir_search_pagecache_enter(desc); if (desc->page_index == 0) { desc->current_index = 0; desc->prev_index = 0; @@ -770,6 +773,7 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc) do { res = find_and_lock_cache_page(desc); } while (res == -EAGAIN); + trace_nfs_readdir_search_pagecache_exit(desc, res); return res; } @@ -835,8 +839,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc) struct inode *inode = file_inode(desc->file); struct nfs_open_dir_context *ctx = desc->file->private_data; - dfprintk(DIRCACHE, "NFS: uncached_readdir() searching for cookie %Lu\n", - (unsigned long long)*desc->dir_cookie); + trace_nfs_uncached_readdir_enter(desc); page = alloc_page(GFP_HIGHUSER); if (!page) { @@ -859,8 +862,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc) nfs_readdir_clear_array(desc->page); cache_page_release(desc); out: - dfprintk(DIRCACHE, "NFS: %s: returns %d\n", - __func__, status); + trace_nfs_uncached_readdir_exit(desc, status); return status; } diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index 6bbe0aa221f2..e6a946b83330 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -752,6 +752,108 @@ ) ); +DECLARE_EVENT_CLASS(nfs_readdir_descriptor_event_enter, + TP_PROTO( + const nfs_readdir_descriptor_t *desc + ), + + TP_ARGS(desc), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(u64, fileid) + __field(u32, fhandle) + __field(u64, dir_cookie) + __field(u64, page_index) + __field(u64, last_cookie) + __field(u64, current_index) + __field(u64, prev_index) + ), + + TP_fast_assign( + __entry->dev = file_inode(desc->file)->i_sb->s_dev; + __entry->fileid = NFS_FILEID(file_inode(desc->file)); + __entry->fhandle = nfs_fhandle_hash(NFS_FH(file_inode(desc->file))); + __entry->dir_cookie = *desc->dir_cookie; + __entry->page_index = desc->page_index; + __entry->last_cookie = desc->last_cookie; + __entry->current_index = desc->current_index; + __entry->prev_index = desc->prev_index; + ), + + TP_printk( + "fileid=%02x:%02x:%llu fhandle=0x%08x dir_cookie=0x%08llx last_cookie=0x%08llx page_index=0x%08llx current_index=0x%08llu prev_index=0x%08llu", + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long long)__entry->fileid, __entry->fhandle, + __entry->dir_cookie, __entry->last_cookie, __entry->page_index, + __entry->current_index, __entry->prev_index + ) +); + +#define DEFINE_NFS_READDIR_DESCRIPTOR_EVENT(name) \ + DEFINE_EVENT(nfs_readdir_descriptor_event_enter, name, \ + TP_PROTO( \ + const nfs_readdir_descriptor_t *desc \ + ), \ + TP_ARGS(desc)) + +DECLARE_EVENT_CLASS(nfs_readdir_descriptor_event_exit, + TP_PROTO( + const nfs_readdir_descriptor_t *desc, + int error + ), + + TP_ARGS(desc, error), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(u64, fileid) + __field(u32, fhandle) + __field(u64, dir_cookie) + __field(unsigned long, error) + __field(u64, page_index) + __field(u64, last_cookie) + __field(u64, current_index) + __field(u64, prev_index) + ), + + TP_fast_assign( + __entry->dev = file_inode(desc->file)->i_sb->s_dev; + __entry->fileid = NFS_FILEID(file_inode(desc->file)); + __entry->fhandle = nfs_fhandle_hash(NFS_FH(file_inode(desc->file))); + __entry->dir_cookie = *desc->dir_cookie; + __entry->error = error; + __entry->page_index = desc->page_index; + __entry->last_cookie = desc->last_cookie; + __entry->current_index = desc->current_index; + __entry->prev_index = desc->prev_index; + ), + + TP_printk( + "error=%ld fileid=%02x:%02x:%llu fhandle=0x%08x dir_cookie=0x%08llx last_cookie=0x%08llx page_index=0x%08llx current_index=0x%08llu prev_index=0x%08llu", + __entry->error, + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long long)__entry->fileid, __entry->fhandle, + __entry->dir_cookie, __entry->last_cookie, __entry->page_index, + __entry->current_index, __entry->prev_index + ) +); + +#define DEFINE_NFS_READDIR_DESCRIPTOR_EVENT_EXIT(name) \ + DEFINE_EVENT(nfs_readdir_descriptor_event_exit, name, \ + TP_PROTO( \ + const nfs_readdir_descriptor_t *desc, \ + int error \ + ), \ + TP_ARGS(desc, error)) + +DEFINE_NFS_READDIR_DESCRIPTOR_EVENT(nfs_uncached_readdir_enter); +DEFINE_NFS_READDIR_DESCRIPTOR_EVENT_EXIT(nfs_uncached_readdir_exit); +DEFINE_NFS_READDIR_DESCRIPTOR_EVENT(nfs_readdir_search_pagecache_enter); +DEFINE_NFS_READDIR_DESCRIPTOR_EVENT_EXIT(nfs_readdir_search_pagecache_exit); +DEFINE_NFS_READDIR_DESCRIPTOR_EVENT(nfs_readdir_search_array_enter); +DEFINE_NFS_READDIR_DESCRIPTOR_EVENT_EXIT(nfs_readdir_search_array_exit); + TRACE_EVENT(nfs_link_enter, TP_PROTO( const struct inode *inode, From patchwork Mon Nov 2 13:50:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11873925 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 41762921 for ; Mon, 2 Nov 2020 13:51:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19B80223BD for ; Mon, 2 Nov 2020 13:51:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dgp36B/j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725911AbgKBNve (ORCPT ); Mon, 2 Nov 2020 08:51:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23658 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725968AbgKBNuU (ORCPT ); Mon, 2 Nov 2020 08:50:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604325019; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=4Cx6K3ggHUBx5scQPf00PZiwB8K7VLCXD77JJTECjB0=; b=dgp36B/jWz0Qd32quPUcqO7bHxEnUSsOS7vEZ9hJh+s7K7N+0towqxxJcI9dj0vW7pmpNw SvguLO1nZD1HCMpxRbj8S2okIDbI+r0s5So0V5bubdSzZJ39AfUApbHQPTZHP37ZCfr0d5 ioaX1eemXBGT9cqDFSLNZemytavx+Bs= 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-309-LV8o6bEGOj-WUJ0SGxxqMw-1; Mon, 02 Nov 2020 08:50:17 -0500 X-MC-Unique: LV8o6bEGOj-WUJ0SGxxqMw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 674F8A42052; Mon, 2 Nov 2020 13:50:16 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-255.rdu2.redhat.com [10.10.113.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E34C5D9DD; Mon, 2 Nov 2020 13:50:15 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 05/11] NFS: Add tracepoints for opendir, closedir, fsync_dir and llseek_dir Date: Mon, 2 Nov 2020 08:50:05 -0500 Message-Id: <1604325011-29427-6-git-send-email-dwysocha@redhat.com> In-Reply-To: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> References: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add a few more directory operation tracepoints and remove a few more dfprintks. Signed-off-by: Dave Wysochanski --- fs/nfs/dir.c | 10 +++++--- fs/nfs/nfstrace.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 227cddc12983..e4cd9789ebb5 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -109,7 +109,7 @@ static void put_nfs_open_dir_context(struct inode *dir, struct nfs_open_dir_cont int res = 0; struct nfs_open_dir_context *ctx; - dfprintk(FILE, "NFS: open dir(%pD2)\n", filp); + trace_nfs_opendir_enter(file_inode(filp), file_dentry(filp)); nfs_inc_stats(inode, NFSIOS_VFSOPEN); @@ -120,13 +120,16 @@ static void put_nfs_open_dir_context(struct inode *dir, struct nfs_open_dir_cont } filp->private_data = ctx; out: + trace_nfs_opendir_exit(file_inode(filp), file_dentry(filp), res); return res; } static int nfs_closedir(struct inode *inode, struct file *filp) { + trace_nfs_closedir_enter(file_inode(filp), file_dentry(filp)); put_nfs_open_dir_context(file_inode(filp), filp->private_data); + trace_nfs_closedir_exit(file_inode(filp), file_dentry(filp), 0); return 0; } @@ -943,8 +946,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence) struct inode *inode = file_inode(filp); struct nfs_open_dir_context *dir_ctx = filp->private_data; - dfprintk(FILE, "NFS: llseek dir(%pD2, %lld, %d)\n", - filp, offset, whence); + trace_nfs_llseek_dir_enter(inode, offset, whence); switch (whence) { default: @@ -985,7 +987,7 @@ static int nfs_fsync_dir(struct file *filp, loff_t start, loff_t end, { struct inode *inode = file_inode(filp); - dfprintk(FILE, "NFS: fsync dir(%pD2) datasync %d\n", filp, datasync); + trace_nfs_fsync_dir_enter(inode, start, end, datasync); inode_lock(inode); nfs_inc_stats(inode, NFSIOS_VFSFSYNC); diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index e6a946b83330..0ed330f323bb 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -667,6 +667,79 @@ DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_unlink_exit); DEFINE_NFS_DIRECTORY_EVENT(nfs_symlink_enter); DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_symlink_exit); +DEFINE_NFS_DIRECTORY_EVENT(nfs_opendir_enter); +DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_opendir_exit); +DEFINE_NFS_DIRECTORY_EVENT(nfs_closedir_enter); +DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_closedir_exit); + +TRACE_EVENT(nfs_llseek_dir_enter, + TP_PROTO( + const struct inode *inode, + u64 offset, + int whence + ), + + TP_ARGS(inode, offset, whence), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(u32, fhandle) + __field(u64, fileid) + __field(u64, offset) + __field(unsigned long, whence) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->fileid = NFS_FILEID(inode); + __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); + __entry->offset = offset; + __entry->whence = whence; + ), + + TP_printk( + "fileid=%02x:%02x:%llu handle=0x%08x offset=0x%08llx whence=%lu", + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long long)__entry->fileid, + __entry->fhandle, __entry->offset, __entry->whence + ) +); + +TRACE_EVENT(nfs_fsync_dir_enter, + TP_PROTO( + const struct inode *inode, + u64 start, + u64 end, + int datasync + ), + + TP_ARGS(inode, start, end, datasync), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(u32, fhandle) + __field(u64, fileid) + __field(u64, start) + __field(u64, end) + __field(unsigned long, datasync) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->fileid = NFS_FILEID(inode); + __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); + __entry->start = start; + __entry->end = end; + __entry->datasync = datasync; + ), + + TP_printk( + "fileid=%02x:%02x:%llu handle=0x%08x start=0x%08llx end=0x%08llx datasync=%lu", + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long long)__entry->fileid, + __entry->fhandle, __entry->start, __entry->end, __entry->datasync + ) +); TRACE_EVENT(nfs_readdir_enter, TP_PROTO( From patchwork Mon Nov 2 13:50:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11873915 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 96CA31130 for ; Mon, 2 Nov 2020 13:51:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6333F223AB for ; Mon, 2 Nov 2020 13:51:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="feKrbNmb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725973AbgKBNvc (ORCPT ); Mon, 2 Nov 2020 08:51:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37278 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgKBNuU (ORCPT ); Mon, 2 Nov 2020 08:50:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604325019; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=AT49TBC/qONh0mFaANQBF4Wz/J/y8viuZKlidItHO8Q=; b=feKrbNmbnugvCmFh41l3UAEHpxjHIi194tXKFrPiPprbssPxo5jRW4ZYC31YLpQPuD3sr4 MEQCpRL0o9sPvrqgClXhSqE+SlZ8bvr2yGRcMhxDW0lnEI4EgSxSdB5NuViePIR1sHjIV0 SdSGh6pv7wCydi6tA4iVAF+0JYpPreE= 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-345-sV-g7fXCMXCgJKMVUzkERg-1; Mon, 02 Nov 2020 08:50:18 -0500 X-MC-Unique: sV-g7fXCMXCgJKMVUzkERg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDC7F5719E; Mon, 2 Nov 2020 13:50:16 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-255.rdu2.redhat.com [10.10.113.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84F065D9DD; Mon, 2 Nov 2020 13:50:16 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 06/11] NFS: Add tracepoints for nfs_readdir_xdr_filler enter and exit Date: Mon, 2 Nov 2020 08:50:06 -0500 Message-Id: <1604325011-29427-7-git-send-email-dwysocha@redhat.com> In-Reply-To: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> References: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add tracepoints for entry and exit to nfs_readdir_xdr_filler. Note the exit trace event captures the results of over the wire READDIR operations, regardless of NFS version. Signed-off-by: Dave Wysochanski --- fs/nfs/dir.c | 2 ++ fs/nfs/nfstrace.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index e4cd9789ebb5..d1e9ba28c4a0 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -361,6 +361,7 @@ int nfs_readdir_xdr_filler(struct page **pages, nfs_readdir_descriptor_t *desc, int error; again: + trace_nfs_readdir_xdr_filler_enter(desc); timestamp = jiffies; gencount = nfs_inc_attr_generation_counter(); desc->dir_verifier = nfs_save_change_attribute(inode); @@ -379,6 +380,7 @@ int nfs_readdir_xdr_filler(struct page **pages, nfs_readdir_descriptor_t *desc, desc->timestamp = timestamp; desc->gencount = gencount; error: + trace_nfs_readdir_xdr_filler_exit(desc, error); return error; } diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index 0ed330f323bb..5dbadd2718e3 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -926,6 +926,8 @@ DEFINE_NFS_READDIR_DESCRIPTOR_EVENT_EXIT(nfs_readdir_search_pagecache_exit); DEFINE_NFS_READDIR_DESCRIPTOR_EVENT(nfs_readdir_search_array_enter); DEFINE_NFS_READDIR_DESCRIPTOR_EVENT_EXIT(nfs_readdir_search_array_exit); +DEFINE_NFS_READDIR_DESCRIPTOR_EVENT(nfs_readdir_xdr_filler_enter); +DEFINE_NFS_READDIR_DESCRIPTOR_EVENT_EXIT(nfs_readdir_xdr_filler_exit); TRACE_EVENT(nfs_link_enter, TP_PROTO( From patchwork Mon Nov 2 13:50:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11873911 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 EE76092C for ; Mon, 2 Nov 2020 13:51:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D3085223AB for ; Mon, 2 Nov 2020 13:51:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KyluO8l8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725838AbgKBNvb (ORCPT ); Mon, 2 Nov 2020 08:51:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45102 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbgKBNuV (ORCPT ); Mon, 2 Nov 2020 08:50:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604325020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=VxPTrUye+bYbghXaNfiAm7OUF6lNMht9A5/loK+xyYc=; b=KyluO8l85fmBHUO6iP16+U9hT+7oK3HL26TY3DPT/8Qq58Jwt1RFHuV1oYp3u+MX1CKu8I 2y4jN27Pf1LBzybdDnE7AiKscaTXxygUNAmdggNPORi14MvpGsgYqvxuzgSUWD8Cfbet0O 6u5qFNG6T/ECNqFMGhwwE9/ho8Wtawo= 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-443-y8Zfj4AxNnqW1DllDxNRng-1; Mon, 02 Nov 2020 08:50:18 -0500 X-MC-Unique: y8Zfj4AxNnqW1DllDxNRng-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6076157208; Mon, 2 Nov 2020 13:50:17 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-255.rdu2.redhat.com [10.10.113.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0778D5D9DD; Mon, 2 Nov 2020 13:50:16 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 07/11] NFS: Add tracepoint to entry and exit of nfs_do_filldir Date: Mon, 2 Nov 2020 08:50:07 -0500 Message-Id: <1604325011-29427-8-git-send-email-dwysocha@redhat.com> In-Reply-To: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> References: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add tracepoints to nfs_do_filldir and remove one more dfprintk. Signed-off-by: Dave Wysochanski --- fs/nfs/dir.c | 4 ++-- fs/nfs/nfstrace.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index d1e9ba28c4a0..d8c3c3fdea75 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -794,6 +794,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc) struct nfs_cache_array *array = NULL; struct nfs_open_dir_context *ctx = file->private_data; + trace_nfs_do_filldir_enter(desc); array = kmap(desc->page); for (i = desc->cache_entry_index; i < array->size; i++) { struct nfs_cache_array_entry *ent; @@ -819,8 +820,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc) desc->eof = true; kunmap(desc->page); - dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n", - (unsigned long long)*desc->dir_cookie, res); + trace_nfs_do_filldir_exit(desc, res); return res; } diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index 5dbadd2718e3..e28551f70eab 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -928,6 +928,8 @@ DEFINE_NFS_READDIR_DESCRIPTOR_EVENT_EXIT(nfs_readdir_search_array_exit); DEFINE_NFS_READDIR_DESCRIPTOR_EVENT(nfs_readdir_xdr_filler_enter); DEFINE_NFS_READDIR_DESCRIPTOR_EVENT_EXIT(nfs_readdir_xdr_filler_exit); +DEFINE_NFS_READDIR_DESCRIPTOR_EVENT(nfs_do_filldir_enter); +DEFINE_NFS_READDIR_DESCRIPTOR_EVENT_EXIT(nfs_do_filldir_exit); TRACE_EVENT(nfs_link_enter, TP_PROTO( From patchwork Mon Nov 2 13:50:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11873913 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 1F6DB921 for ; Mon, 2 Nov 2020 13:51:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 040CA223AB for ; Mon, 2 Nov 2020 13:51:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="feQkT0Kp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725852AbgKBNvb (ORCPT ); Mon, 2 Nov 2020 08:51:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27156 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725973AbgKBNuW (ORCPT ); Mon, 2 Nov 2020 08:50:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604325020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=XrU0bFlBCj1V1T9Ebc6GurMHRM5nMTXgiahapsaXOSg=; b=feQkT0KpFTX5edz5UOY3H+FXaQj2lwfkIiMYbL91R29RQGS43dsMKQy8t6MY99lMG2qiTN 6t2UEG1HxDqXUUMFLlJTTVij0+Io0MYsijuHMcwc7TTi77iR3hU5atvKGKVUmnu5qbyyN0 2mr3JUh/IMNa13lf4Yi26vhX8BxnWOI= 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-391-tvnBCHvmOu2yLV3w93J5_Q-1; Mon, 02 Nov 2020 08:50:19 -0500 X-MC-Unique: tvnBCHvmOu2yLV3w93J5_Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE7918030BB; Mon, 2 Nov 2020 13:50:17 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-255.rdu2.redhat.com [10.10.113.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7EDA95DA6B; Mon, 2 Nov 2020 13:50:17 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 08/11] NFS: Replace LOOKUPCACHE dfprintk statements with tracepoints Date: Mon, 2 Nov 2020 08:50:08 -0500 Message-Id: <1604325011-29427-9-git-send-email-dwysocha@redhat.com> In-Reply-To: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> References: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Remove all the LOOKUPCACHE dfprintk statements in favor of tracepoints based on existing tracing templates DEFINE_NFS_LOOKUP_EVENT and DEFINE_NFS_LOOKUP_EVENT_DONE. Signed-off-by: Dave Wysochanski --- fs/nfs/dir.c | 27 ++++++++++++--------------- fs/nfs/nfstrace.h | 8 ++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index d8c3c3fdea75..52e06c8fc7cd 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1226,8 +1226,7 @@ int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry, { switch (error) { case 1: - dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) is valid\n", - __func__, dentry); + trace_nfs_lookup_revalidate_done_valid(dir, dentry, 0); return 1; case 0: nfs_mark_for_revalidate(dir); @@ -1243,12 +1242,10 @@ int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry, if (IS_ROOT(dentry)) return 1; } - dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) is invalid\n", - __func__, dentry); + trace_nfs_lookup_revalidate_done_invalid(dir, dentry, 0); return 0; } - dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) lookup returned error %d\n", - __func__, dentry, error); + trace_nfs_lookup_revalidate_done_exit(dir, dentry, 0, error); return error; } @@ -1344,12 +1341,14 @@ int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry, nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE); inode = d_inode(dentry); - if (!inode) + if (!inode) { + trace_nfs_lookup_revalidate_negative_inode(dir, dentry, + flags); return nfs_lookup_revalidate_negative(dir, dentry, flags); + } if (is_bad_inode(inode)) { - dfprintk(LOOKUPCACHE, "%s: %pd2 has dud inode\n", - __func__, dentry); + trace_nfs_lookup_revalidate_bad_inode(dir, dentry, flags); goto out_bad; } @@ -1436,20 +1435,18 @@ static int nfs_weak_revalidate(struct dentry *dentry, unsigned int flags) * eventually need to do something more here. */ if (!inode) { - dfprintk(LOOKUPCACHE, "%s: %pd2 has negative inode\n", - __func__, dentry); + trace_nfs_weak_revalidate_negative_inode(inode, dentry, + flags); return 1; } if (is_bad_inode(inode)) { - dfprintk(LOOKUPCACHE, "%s: %pd2 has dud inode\n", - __func__, dentry); + trace_nfs_weak_revalidate_bad_inode(inode, dentry, flags); return 0; } error = nfs_lookup_verify_inode(inode, flags); - dfprintk(LOOKUPCACHE, "NFS: %s: inode %lu is %s\n", - __func__, inode->i_ino, error ? "invalid" : "valid"); + trace_nfs_weak_revalidate_exit(inode, dentry, flags, error); return !error; } diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index e28551f70eab..06b301da85a2 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -386,6 +386,14 @@ DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_exit); DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_enter); DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_revalidate_exit); +DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_negative_inode); +DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_bad_inode); +DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_done_valid); +DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_done_invalid); +DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_revalidate_done_exit); +DEFINE_NFS_LOOKUP_EVENT(nfs_weak_revalidate_negative_inode); +DEFINE_NFS_LOOKUP_EVENT(nfs_weak_revalidate_bad_inode); +DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_weak_revalidate_exit); TRACE_DEFINE_ENUM(O_WRONLY); TRACE_DEFINE_ENUM(O_RDWR); From patchwork Mon Nov 2 13:50:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11873909 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 1F897921 for ; Mon, 2 Nov 2020 13:51:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0248A223AB for ; Mon, 2 Nov 2020 13:51:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TBFfHaiN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726004AbgKBNvN (ORCPT ); Mon, 2 Nov 2020 08:51:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21487 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbgKBNuX (ORCPT ); Mon, 2 Nov 2020 08:50:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604325021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=IZ47d1H0gytXpNJeA5cQUDK26rE4BJEUPe2+VS9t4YE=; b=TBFfHaiNjjYzmSV3banB3ccsXsgef2v20ueGDh8ApVLsxmRKMi3X5r/Tyd596VtFRcwGzx k+Go8EBMJMclwUhdPsZbpiyzR+zo+oS3fn2IyJY6JxYIIl/veWBPeiT/RE6rwgbEjj1Kcr TlvAYTrWScyHjgYAn4bb5trA3PQMzRY= 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-13-6tCrBYVrNPu1GM9MTK_cZA-1; Mon, 02 Nov 2020 08:50:20 -0500 X-MC-Unique: 6tCrBYVrNPu1GM9MTK_cZA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6CFCE1921FD5; Mon, 2 Nov 2020 13:50:18 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-255.rdu2.redhat.com [10.10.113.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 059985DA71; Mon, 2 Nov 2020 13:50:17 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 09/11] NFS: Improve performance of listing directories being modified Date: Mon, 2 Nov 2020 08:50:09 -0500 Message-Id: <1604325011-29427-10-git-send-email-dwysocha@redhat.com> In-Reply-To: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> References: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org A process can hang forever to 'ls -l' a directory while the directory is being modified such as another NFS client adding files to the directory. The problem is seen specifically with larger directories (I tested with 1 million) and/or slower NFS server responses to READDIR. If a combination of the NFS directory size, the NFS server responses to READDIR is such that the 'ls' process gets partially through the listing before the attribute cache expires (time exceeds acdirmax), we drop the pagecache and have to re-fill it, and as a result, the process may never complete. One could argue for larger directories the acdirmin/acdirmax should be increased, but it's not always possible to tune this effectively. The root cause of this problem is due to how the NFS readdir cache currently works. The main search function, readdir_search_pagecache(), always starts searching at page_index and cookie == 0, and for any page not in the cache, fills in the page with entries obtained in a READDIR NFS call. If a page already exists, we proceed to nfs_readdir_search_for_cookie(), which searches for the cookie (pos) of the readdir call. The search is O(n), where n is the directory size before the cookie in question is found, and every entry to nfs_readdir() pays this penalty, irrespective of the current directory position (dir_context.pos). The search is expensive due to the opaque nature of readdir cookies, and the fact that no mapping (hash) exists from cookies to pages. In the case of a directory being modified, the above behavior can become an excessive penalty, since the same process is forced to fill pages it may be no longer interested in (the entries were passed in a previous nfs_readdir call), and this can essentially lead no forward progress. To fix this problem, at the end of nfs_readdir(), save the page_index corresponding to the directory position (cookie) inside the process's nfs_open_dir_context. Then at the next entry of nfs_readdir(), use the saved page_index as the starting search point rather than starting at page_index == 0. Not only does this fix the problem of listing a directory being modified, it also significantly improves performance in the unmodified case since no extra search penalty is paid at each entry to nfs_readdir(). In the case of lseek, since there is no hash or other mapping from a cookie value to the page->index, just reset nfs_open_dir_context.page_index to 0, which will reset the search to the old behavior. Signed-off-by: Dave Wysochanski --- fs/nfs/dir.c | 8 +++++++- include/linux/nfs_fs.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 52e06c8fc7cd..b266f505b521 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -78,6 +78,7 @@ static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir ctx->attr_gencount = nfsi->attr_gencount; ctx->dir_cookie = 0; ctx->dup_cookie = 0; + ctx->page_index = 0; ctx->cred = get_cred(cred); spin_lock(&dir->i_lock); if (list_empty(&nfsi->open_files) && @@ -763,7 +764,7 @@ int find_and_lock_cache_page(nfs_readdir_descriptor_t *desc) return res; } -/* Search for desc->dir_cookie from the beginning of the page cache */ +/* Search for desc->dir_cookie starting at desc->page_index */ static inline int readdir_search_pagecache(nfs_readdir_descriptor_t *desc) { @@ -885,6 +886,8 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) .ctx = ctx, .dir_cookie = &dir_ctx->dir_cookie, .plus = nfs_use_readdirplus(inode, ctx), + .page_index = dir_ctx->page_index, + .last_cookie = nfs_readdir_use_cookie(file) ? ctx->pos : 0, }, *desc = &my_desc; int res = 0; @@ -938,6 +941,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) out: if (res > 0) res = 0; + dir_ctx->page_index = desc->page_index; trace_nfs_readdir_exit(inode, ctx->pos, dir_ctx->dir_cookie, NFS_SERVER(inode)->dtsize, my_desc.plus, res); return res; @@ -975,6 +979,8 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence) else dir_ctx->dir_cookie = 0; dir_ctx->duped = 0; + /* Force readdir_search_pagecache to start over */ + dir_ctx->page_index = 0; } inode_unlock(inode); return offset; diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index a2c6455ea3fa..0e55c0154ccd 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -93,6 +93,7 @@ struct nfs_open_dir_context { __u64 dir_cookie; __u64 dup_cookie; signed char duped; + unsigned long page_index; }; /* From patchwork Mon Nov 2 13:50:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11873903 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 8BEBC92C for ; Mon, 2 Nov 2020 13:51:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67CC3223BD for ; Mon, 2 Nov 2020 13:51:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i2IQmrHk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726015AbgKBNvN (ORCPT ); Mon, 2 Nov 2020 08:51:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34896 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725975AbgKBNuX (ORCPT ); Mon, 2 Nov 2020 08:50:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604325022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=A5QAluO9jJjtQ1kbWIac7ykdsGFp0O5j0QiLabMsVe8=; b=i2IQmrHkmvam9nHLZfgKp0fGxK4Irli8Ua8e1Ta1UYBw8Q7ym1Z2Toiehj/Qs3nOt8gLbu TsbK7bkB7Ydg0iP9MM2wBDhxVIY0HwjjrYf/N3mzMZDq6iQtjJf54vYxvg08KntP7dLqJE hxTKXJLAMURggcn23H+u5sduF1I2V/o= 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-381-vPWh2UqRN8q4CSiGzlSgpA-1; Mon, 02 Nov 2020 08:50:20 -0500 X-MC-Unique: vPWh2UqRN8q4CSiGzlSgpA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DFE361099F7D; Mon, 2 Nov 2020 13:50:18 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-255.rdu2.redhat.com [10.10.113.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 832235D9DD; Mon, 2 Nov 2020 13:50:18 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 10/11] NFS: Add page_index to nfs_readdir enter and exit tracepoints Date: Mon, 2 Nov 2020 08:50:10 -0500 Message-Id: <1604325011-29427-11-git-send-email-dwysocha@redhat.com> In-Reply-To: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> References: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add nfs_open_dir_context.page_index to enter and exit tracepoints since this affects searching the cache. Signed-off-by: Dave Wysochanski --- fs/nfs/dir.c | 2 ++ fs/nfs/nfstrace.h | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index b266f505b521..cbd74cbdbb9f 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -894,6 +894,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) nfs_inc_stats(inode, NFSIOS_VFSGETDENTS); trace_nfs_readdir_enter(inode, ctx->pos, dir_ctx->dir_cookie, + dir_ctx->page_index, NFS_SERVER(inode)->dtsize, my_desc.plus); /* @@ -943,6 +944,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) res = 0; dir_ctx->page_index = desc->page_index; trace_nfs_readdir_exit(inode, ctx->pos, dir_ctx->dir_cookie, + dir_ctx->page_index, NFS_SERVER(inode)->dtsize, my_desc.plus, res); return res; } diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index 06b301da85a2..12869b0c3f70 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -754,11 +754,12 @@ const struct inode *inode, u64 cookie, u64 dir_cookie, + unsigned long page_index, unsigned int count, bool plus ), - TP_ARGS(inode, cookie, dir_cookie, count, plus), + TP_ARGS(inode, cookie, dir_cookie, page_index, count, plus), TP_STRUCT__entry( __field(dev_t, dev) @@ -766,6 +767,7 @@ __field(u64, fileid) __field(u64, cookie) __field(u64, dir_cookie) + __field(unsigned long, page_index) __field(u64, count) __field(bool, plus) ), @@ -776,15 +778,16 @@ __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); __entry->cookie = cookie; __entry->dir_cookie = dir_cookie; + __entry->page_index = page_index; __entry->count = count; __entry->plus = plus; ), TP_printk( - "fileid=%02x:%02x:%llu fhandle=0x%08x cookie=0x%08llx dir_cookie=0x%08llx count=%llu plus=%s", + "fileid=%02x:%02x:%llu fhandle=0x%08x cookie=0x%08llx dir_cookie=0x%08llx page_index=0x%08lx count=%llu plus=%s", MAJOR(__entry->dev), MINOR(__entry->dev), - (unsigned long long)__entry->fileid, - __entry->fhandle, __entry->cookie, __entry->dir_cookie, + (unsigned long long)__entry->fileid, __entry->fhandle, + __entry->cookie, __entry->dir_cookie, __entry->page_index, __entry->count, __entry->plus ? "true" : "false" ) ); @@ -794,12 +797,13 @@ const struct inode *inode, u64 cookie, u64 dir_cookie, + unsigned long page_index, unsigned int count, bool plus, int error ), - TP_ARGS(inode, cookie, dir_cookie, count, plus, error), + TP_ARGS(inode, cookie, dir_cookie, page_index, count, plus, error), TP_STRUCT__entry( __field(dev_t, dev) @@ -808,6 +812,7 @@ __field(unsigned long, error) __field(u64, cookie) __field(u64, dir_cookie) + __field(unsigned long, page_index) __field(u64, count) __field(bool, plus) ), @@ -819,16 +824,17 @@ __entry->error = error; __entry->cookie = cookie; __entry->dir_cookie = dir_cookie; + __entry->page_index = page_index; __entry->count = count; __entry->plus = plus; ), TP_printk( - "error=%ld fileid=%02x:%02x:%llu fhandle=0x%08x cookie=0x%08llx dir_cookie=0x%08llx count=%llu plus=%s", + "error=%ld fileid=%02x:%02x:%llu fhandle=0x%08x cookie=0x%08llx dir_cookie=0x%08llx page_index=0x%08lx count=%llu plus=%s", __entry->error, MAJOR(__entry->dev), MINOR(__entry->dev), - (unsigned long long)__entry->fileid, - __entry->fhandle, __entry->cookie, __entry->dir_cookie, + (unsigned long long)__entry->fileid, __entry->fhandle, + __entry->cookie, __entry->dir_cookie, __entry->page_index, __entry->count, __entry->plus ? "true" : "false" ) ); From patchwork Mon Nov 2 13:50:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11873907 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 7D83E921 for ; Mon, 2 Nov 2020 13:51:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C0E0223BF for ; Mon, 2 Nov 2020 13:51:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NUNC+PPU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726021AbgKBNvO (ORCPT ); Mon, 2 Nov 2020 08:51:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:29956 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbgKBNuZ (ORCPT ); Mon, 2 Nov 2020 08:50:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604325024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=RZvZSydwz/5QL+VCmevCndZgN+O/mqIZB0qW8LBfxLs=; b=NUNC+PPUiCX8E7qc7WaG93dVbG0yzHSWqgNeNrAZcKlzKDbA384UZqAsGtSfO6rD14WGms zII3eCFNDr81MO6JBa1gmc6T4iz6QmqVD3HdMugo/r1jGAmmcanAzHNU03s8SPXoJongSL /NLBrXXxsDai3TIa3cvgTnNewdTc19s= 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-508-HtZG3wlVP-KaksBlcyCMcw-1; Mon, 02 Nov 2020 08:50:20 -0500 X-MC-Unique: HtZG3wlVP-KaksBlcyCMcw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77A8110A0BA8; Mon, 2 Nov 2020 13:50:19 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-255.rdu2.redhat.com [10.10.113.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09C5F5DEBD; Mon, 2 Nov 2020 13:50:18 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 11/11] NFS: Bring back nfs_dir_mapping_need_revalidate() in nfs_readdir() Date: Mon, 2 Nov 2020 08:50:11 -0500 Message-Id: <1604325011-29427-12-git-send-email-dwysocha@redhat.com> In-Reply-To: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> References: <1604325011-29427-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org commit 79f687a3de9e ("NFS: Fix a performance regression in readdir") removed nfs_dir_mapping_need_revalidate() in an attempt to fix a performance regression, but had the effect that with NFSv3 the pagecache would never expire while a process was reading a directory. An earlier patch addressed this problem by allowing the pagecache to expire but the current process to continue using the last cookie returned by the server when searching the pagecache, rather than always starting at 0. Thus, bring back nfs_dir_mapping_need_revalidate() so that nfsi->cache_validity & NFS_INO_INVALID_DATA will be seen and nfs_revalidate_mapping() will be called with NFSv3 as well, making it behave the same as NFSv4. Signed-off-by: Dave Wysochanski --- fs/nfs/dir.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index cbd74cbdbb9f..aeb086fb3d0a 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -872,6 +872,17 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc) return status; } +static bool nfs_dir_mapping_need_revalidate(struct inode *dir) +{ + struct nfs_inode *nfsi = NFS_I(dir); + + if (nfs_attribute_cache_expired(dir)) + return true; + if (nfsi->cache_validity & NFS_INO_INVALID_DATA) + return true; + return false; +} + /* The file offset position represents the dirent entry number. A last cookie cache takes care of the common case of reading the whole directory. @@ -903,7 +914,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) * to either find the entry with the appropriate number or * revalidate the cookie. */ - if (ctx->pos == 0 || nfs_attribute_cache_expired(inode)) + if (ctx->pos == 0 || nfs_dir_mapping_need_revalidate(inode)) res = nfs_revalidate_mapping(inode, file->f_mapping); if (res < 0) goto out;