From owner-svn-src-head@freebsd.org Wed Jun 20 15:05:21 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D5E6B101DBA6; Wed, 20 Jun 2018 15:05:20 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-it0-f41.google.com (mail-it0-f41.google.com [209.85.214.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7592B7E24B; Wed, 20 Jun 2018 15:05:20 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-it0-f41.google.com with SMTP id a3-v6so112792itd.0; Wed, 20 Jun 2018 08:05:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=2AY7jskXb2j9CT2ehQKDTdL7wt3ry/1lU0Zu8g9U0+8=; b=NJ0e/OkU00a6TWON6IazLEDyFRHHE4Dr4P6zNmVg44CO2xKXhuGAKIDIuyu3rhn0As UvOOq6510gwhPBgZoarn86Cnf6+tDXCivFq1kfv60PYf2wf2h+uKaJ1Az6yMxauLnNoz tThu1a7mM7akfGw2JnShP7PeINQ0vJHBFQqmjQ9+e3VHlPj35OI6JEBW5Oc5Y0d7D2SS TmtDVpwTILERbF4y6jSCIFksrb5gT91A3N8c68qMFLQ0wqUIYc/xQdridWy81xX9wPJ0 ySEPFO028E9tSYOkr2xGxnseIX8ZVwnW+IYRSr8Q+WY2DO4BFBrMwrBUckq9mtc4DM/U lmzg== X-Gm-Message-State: APt69E0XI+0IwMCOos2oPgEbSObKs0iovj3KZgSsxef7F/YPhFpjfYxg ZJM7HzOyST5qnG6kJsMSjdzeTBQO X-Google-Smtp-Source: ADUXVKLKW6kCbWj0RXz3HSyPzA2uRUsJJ0SO5MHZJZmZl+pMP9APGT/NWPn9A73F8sYwkVYOZGM9yw== X-Received: by 2002:a24:6041:: with SMTP id i62-v6mr1974756itc.153.1529507113727; Wed, 20 Jun 2018 08:05:13 -0700 (PDT) Received: from mail-it0-f41.google.com (mail-it0-f41.google.com. [209.85.214.41]) by smtp.gmail.com with ESMTPSA id f3-v6sm1006999iob.49.2018.06.20.08.05.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 08:05:13 -0700 (PDT) Received: by mail-it0-f41.google.com with SMTP id a3-v6so112676itd.0; Wed, 20 Jun 2018 08:05:13 -0700 (PDT) X-Received: by 2002:a24:ed4a:: with SMTP id r71-v6mr1867022ith.53.1529507113089; Wed, 20 Jun 2018 08:05:13 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 2002:a02:5995:0:0:0:0:0 with HTTP; Wed, 20 Jun 2018 08:05:12 -0700 (PDT) In-Reply-To: <201806200834.w5K8YThd082989@repo.freebsd.org> References: <201806200834.w5K8YThd082989@repo.freebsd.org> From: Conrad Meyer Date: Wed, 20 Jun 2018 08:05:12 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r335437 - in head: share/man/man4 sys/kern To: "Bjoern A. Zeeb" Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2018 15:05:21 -0000 Hi Bjoern, It might be nice to be explicit that the vnode was not in the namecache (in the ddb output) rather than failing silently. The name of the ddb method does not suggest that only entries in the namecache may be found, and users (developers :)) do not always read manual pages thoroughly. All the best, Conrad On Wed, Jun 20, 2018 at 1:34 AM, Bjoern A. Zeeb wrote: > Author: bz > Date: Wed Jun 20 08:34:29 2018 > New Revision: 335437 > URL: https://svnweb.freebsd.org/changeset/base/335437 > > Log: > Sometimes it is helpful to get the path for a vnode. > Implement a ddb function walking the namecache to do this. > > Reviewed by: jhb, mjg > Inspired by: gdb macro from jhb (old version) > Sponsored by: iXsystems, Inc. > Differential Revision: https://reviews.freebsd.org/D14898 > > Modified: > head/share/man/man4/ddb.4 > head/sys/kern/vfs_cache.c > > Modified: head/share/man/man4/ddb.4 > ============================================================================== > --- head/share/man/man4/ddb.4 Wed Jun 20 07:02:19 2018 (r335436) > +++ head/share/man/man4/ddb.4 Wed Jun 20 08:34:29 2018 (r335437) > @@ -60,7 +60,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd August 24, 2017 > +.Dd June 20, 2018 > .Dt DDB 4 > .Os > .Sh NAME > @@ -1121,6 +1121,11 @@ header file. > .Pp > .It Ic show Cm vnodebufs Ar addr > Shows clean/dirty buffer lists of the vnode located at > +.Ar addr . > +.\" > +.Pp > +.It Ic show Cm vpath Ar addr > +Walk the namecache to lookup the pathname of the vnode located at > .Ar addr . > .\" > .Pp > > Modified: head/sys/kern/vfs_cache.c > ============================================================================== > --- head/sys/kern/vfs_cache.c Wed Jun 20 07:02:19 2018 (r335436) > +++ head/sys/kern/vfs_cache.c Wed Jun 20 08:34:29 2018 (r335437) > @@ -37,6 +37,7 @@ > #include > __FBSDID("$FreeBSD$"); > > +#include "opt_ddb.h" > #include "opt_ktrace.h" > > #include > @@ -62,6 +63,10 @@ __FBSDID("$FreeBSD$"); > #include > #endif > > +#ifdef DDB > +#include > +#endif > + > #include > > SDT_PROVIDER_DECLARE(vfs); > @@ -2529,3 +2534,54 @@ out: > free(fbuf, M_TEMP); > return (error); > } > + > +#ifdef DDB > +static void > +db_print_vpath(struct vnode *vp) > +{ > + > + while (vp != NULL) { > + db_printf("%p: ", vp); > + if (vp == rootvnode) { > + db_printf("/"); > + vp = NULL; > + } else { > + if (vp->v_vflag & VV_ROOT) { > + db_printf(""); > + vp = vp->v_mount->mnt_vnodecovered; > + } else { > + struct namecache *ncp; > + char *ncn; > + int i; > + > + ncp = TAILQ_FIRST(&vp->v_cache_dst); > + if (ncp != NULL) { > + ncn = ncp->nc_name; > + for (i = 0; i < ncp->nc_nlen; i++) > + db_printf("%c", *ncn++); > + vp = ncp->nc_dvp; > + } else { > + vp = NULL; > + } > + } > + } > + db_printf("\n"); > + } > + > + return; > +} > + > +DB_SHOW_COMMAND(vpath, db_show_vpath) > +{ > + struct vnode *vp; > + > + if (!have_addr) { > + db_printf("usage: show vpath \n"); > + return; > + } > + > + vp = (struct vnode *)addr; > + db_print_vpath(vp); > +} > + > +#endif >