From owner-freebsd-fs@freebsd.org Mon Jul 6 03:07:20 2015 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4560698ECB5 for ; Mon, 6 Jul 2015 03:07:20 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wg0-x230.google.com (mail-wg0-x230.google.com [IPv6:2a00:1450:400c:c00::230]) (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 DBD56100E; Mon, 6 Jul 2015 03:07:19 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by wguu7 with SMTP id u7so128415041wgu.3; Sun, 05 Jul 2015 20:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=YZ3+XgzANHejIquJdREkdlK+VMxG8PMdZTjy2YnYvUk=; b=qwa4R4ZD8upduQUCcXjads3+vYNvkhbzQcXeYXWiEFD5Yf8QFy2D+NUocWhHiFlP1g v/4W+9SMCOt/TwbGjA5u7btZ0IdBhUbjHTpJB0PTU3JzoNckTbvAfykVuEwqm333Hdw/ G+47l2WVgcAVkEF6C1ThkV6UPcezdHikWo/BTszxVe2T/+8nLXLj3zjFKaXk20tnHw+6 KRRlCJiPH5SccfTASr13u6+H+uqlXqXPsVdCWKEmiAFWDgjOzAmTTdXFm8mejA6XMgc3 CoMBZ0lqDShD19DPgvfDKk3mJP9SWmCibjB0fFXHU8S5Xm/VOZSwRdejjLgOvNF+NYGl Saqw== X-Received: by 10.194.78.110 with SMTP id a14mr96317113wjx.87.1436152038249; Sun, 05 Jul 2015 20:07:18 -0700 (PDT) Received: from localhost.localdomain (ip-89-102-11-63.net.upcbroadband.cz. [89.102.11.63]) by mx.google.com with ESMTPSA id df1sm44689075wib.12.2015.07.05.20.07.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jul 2015 20:07:17 -0700 (PDT) From: Mateusz Guzik To: freebsd-fs@freebsd.org Cc: kib@freebsd.org, rwatson@FreeBSD.org, Mateusz Guzik Subject: [PATCH 0/2] slightly cheaper file lookups + an idea Date: Mon, 6 Jul 2015 05:07:13 +0200 Message-Id: <1436152035-12564-1-git-send-email-mjguzik@gmail.com> X-Mailer: git-send-email 2.4.3 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2015 03:07:20 -0000 From: Mateusz Guzik First, 2 simple patches which imho should go in regardless of whether the idea below is accepted. The first one shuffles code around to make the second one easier, which removes a requirement to hold filedesc lock imposed by auditing. With that out of the way: filedesc lock is held so that fd_cdir and fd_rdir vnodes can be obtained for lookup purposes. In effect namei unnecessarily competes with code manipulating file descriptor table. With patches mentioned here at the very least we can decompose the filedesc lock into 2: one to protect fd_ cdir/jdir/rdir and the other one for the rest. However, I believe we should got a step further and split struct filedesc instead. Specifically, we can move aforementioned vnodes to a copy-on-write structure managed similarly to thread credentials. After such an action there is no lock to take during lookups. Further, since vnodes are guaranteed to be stable we don't have to vref+vrele any of them, apart from the case where the vnode in question is going to be returned. This will make chdir more expensive, but file lookups are way more frequent so it should be worth it. Thoughts? Mateusz Guzik (2): vfs: avoid spurious vref+vrele for absolute lookups audit: utilize vnode pointer found by namei instead of looking it up again sys/kern/vfs_lookup.c | 129 ++++++++++++++++++++---------------- sys/security/audit/audit.h | 14 ++++ sys/security/audit/audit_arg.c | 36 ++++++++++ sys/security/audit/audit_bsm_klib.c | 82 +++++++++++++++-------- sys/security/audit/audit_private.h | 2 + 5 files changed, 178 insertions(+), 85 deletions(-) -- 2.4.5