From owner-svn-src-all@freebsd.org Thu Jun 28 01:58:40 2018 Return-Path: Delivered-To: svn-src-all@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 C47B210288BD for ; Thu, 28 Jun 2018 01:58:40 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x232.google.com (mail-it0-x232.google.com [IPv6:2607:f8b0:4001:c0b::232]) (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 4F229801C9 for ; Thu, 28 Jun 2018 01:58:40 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x232.google.com with SMTP id 76-v6so10386175itx.4 for ; Wed, 27 Jun 2018 18:58:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=+2FQXYjqSn368aMueJWAwe/PnKhCJnEKWknA1mb2h+c=; b=Asx5CroqcJ9YaDk5yX2sjzt7swF+jNIYSOKmQbCtC/LXHIqe+sU6BSgVbxaPwsK28x HsJi1t6UOtLIDGgF1ZFzQhoHCogK/P15bGPduz4YMMbL/ojrjYOlR9x6gOOi4IxwvV5p Sn7QxOfgEKp88y9RcmbW6EtQcJMdydjY4jlnDtEZ08ORKr0+7TnkdBq6rk+osVE9tHvP oYpZlSY9Tre6PR2dIYkULHPu5SbPp93mJk0hHqXSiQTEGkhVSgYwNOpMdIkZya7dm1A7 ZU9mYXKlz9/zSiPxKZuopxGqgV1Xgi/zW2nqDt2EVy8+03EO8ZavOuQITMWeMTua4Z9f LMcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=+2FQXYjqSn368aMueJWAwe/PnKhCJnEKWknA1mb2h+c=; b=GZj5eQil6FwmIgwzWHmUBBmNMiEHSypP5wnLqb+SVfyKxMf0a0j7pkheU9an10Nhb9 RTsl9oOVK3e5W1V+gVAcM6ct/QuyMRVx4yujMnY+jPZHUbKNmJHMci2HwWUkPGhNZdzf hASI5XkIc4Ja+HsuyX2GdrvcX6PCwyqEiRFcP5xYJlZY3jKDRw1nddxO9Nf6DtHHYjbK tWbK4wMdtK8L6GQrNdvz0gnn1LTEi4MrkrYnnMs7x1dW49IFZt7kbA8T/Psg3owTq8B3 /C/7GMFshj8gYX/papVfrJ6CZKXYh58ASbLVEj9FFCPjyt9rEJuUkLUhDBkF9PTgp8Ld 3IDw== X-Gm-Message-State: APt69E2931K0VigK/UNEyx6lDxa3W0iWzE8O27/4sESzFHoNeFzcFKnV NFK1p6JhtHqXUr08hgrcc1r3MzCIYuoARdmPlzQMvw== X-Google-Smtp-Source: ADUXVKItvonLGMWGnrbE8mwmdpqiM1wdMd6PsGuHTL7ZVOelch++iRIkZYQ11CcdG9LOaLP/L87Q4LsrXJ/w35JB8qE= X-Received: by 2002:a24:e55:: with SMTP id 82-v6mr6678544ite.1.1530151119594; Wed, 27 Jun 2018 18:58:39 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 2002:a4f:5945:0:0:0:0:0 with HTTP; Wed, 27 Jun 2018 18:58:39 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: <16B9F36D-E92A-4FEC-B096-5E24A4E180FC@FreeBSD.org> References: <201806270411.w5R4B9ZB078994@repo.freebsd.org> <20180627235216.GO1165@FreeBSD.org> <16B9F36D-E92A-4FEC-B096-5E24A4E180FC@FreeBSD.org> From: Warner Losh Date: Wed, 27 Jun 2018 19:58:39 -0600 X-Google-Sender-Auth: bezgI_KnQRx82Q1kTtb7Rp73ETA Message-ID: Subject: Re: svn commit: r335690 - head/sys/kern To: Devin Teske Cc: Gleb Smirnoff , Warner Losh , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2018 01:58:41 -0000 On Wed, Jun 27, 2018 at 7:49 PM, Devin Teske wrote: > > On Jun 27, 2018, at 5:59 PM, Warner Losh wrote: > > > > On Wed, Jun 27, 2018 at 5:52 PM, Gleb Smirnoff > wrote: > >> On Wed, Jun 27, 2018 at 04:11:09AM +0000, Warner Losh wrote: >> W> Author: imp >> W> Date: Wed Jun 27 04:11:09 2018 >> W> New Revision: 335690 >> W> URL: https://svnweb.freebsd.org/changeset/base/335690 >> W> >> W> Log: >> W> Fix devctl generation for core files. >> W> >> W> We have a problem with vn_fullpath_global when the file exists. Work >> W> around it by printing the full path if the core file name starts >> with /, >> W> or current working directory followed by the filename if not. >> >> Is this going to work when a core is dumped not at current working >> directory, >> but at absolute path? e.g. kern.corefile=/var/log/cores/%N.core >> > > Yes. That works. > > >> Looks like the vn_fullpath_global needs to be fixed rather than problem >> workarounded. >> > > It can't be fixed reliably. FreeBSD does not and cannot map a vnode to a > name. The only reason we're able to at all is due to the name cache. And > when we recreate a file, we invalidate the name cache. And even if we fixed > that, there's no guarantee the name cache won't get flushed before we > translate the name.... Linux can do this because it keeps the path name > associated with the inode. FreeBSD simply doesn't. > > > They said it couldn't be done, but I personally have done it ... > > I map vnodes to full paths in dwatch. It's not impossible, just > implausibly hard. > > I derived my formula by reading the C code which was very twisty-turny and > rather hard to read at times (and I have been using C since 1998 on > everything from AIX and OSF/1 to HP/UX, Cygwin, MinGW, FreeBSD, countless > Linux-like things, IRIX, and a God-awful remainder of many others; the > vnode code was an adventure to say the least). > > You're welcome to see how it's done in /usr/libexec/dwatch/vop_create > > I load up a clause-local variable named "path" with a path constructed > from a pointer to a vnode structure argument to VOP_CREATE(9). > > The D code could easily be rewritten back into C to walk the vnode to > completion (compared to the D code which is bounded by depth-limit since > DTrace doesn't provide loops; so you have to, as I have done, use a > higher-level language wrapper to repeat the code to some desired limit; > dwatch defaulting to 64 for directory depth limit). > > Compared this, say, to vfssnoop.d from Chapter 5 of the DTrace book which > utilizes the vfs:namei:lookup: probes. My approach in dwatch is far more > accurate, produces full paths, and I've benchmarked it at lower overhead > with better results. > > Maybe some of this can be useful? If not, just ignore me. > IMHO, there's no benefit from the crazy hoops than the super simple heuristic I did: if the path starts with / print it. If the path doesn't print cwd / and then the path. I look forward to seeing your conversion of the D to C that works, even when there's namespace cache pressure. Warner