From owner-freebsd-fs@freebsd.org Mon Jul 6 03:05:39 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 2968998EC05 for ; Mon, 6 Jul 2015 03:05:39 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wi0-x231.google.com (mail-wi0-x231.google.com [IPv6:2a00:1450:400c:c05::231]) (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 B2E351D3D; Mon, 6 Jul 2015 03:05:38 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by wifm2 with SMTP id m2so16891959wif.1; Sun, 05 Jul 2015 20:05:36 -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=wFByKVPP/+6+YrPPH1gMmA6mmKasBxGkYYp6ibOqyCH9JfQzRzitOLmWgiP9hdygDU ZDOhvlKj+fstWuEHRqZGPzYSNxKndys/a6EP+YSpTtP7BpgxT1XqRENGPCV21TAKy5SR 13pYOChcHkcro/90J6RAg0Xzs6nkPylpLh0GsDIbqA9x4JFUWGrxJAYT9W5WFy8gXiO0 99IMeKrzr6+iMbs9+EZzJ43WswulezLyI3BRv6UW1jDpuo0rP6zvSHOX4B/s7FvrlrK8 7UzEDi8C8318/7HAoyv7qwmOXPPtboiN17+3JvSxYS3F8HNZvYI9AfMVdZUMxryaapCC 1D8g== X-Received: by 10.180.83.40 with SMTP id n8mr48772872wiy.57.1436151936892; Sun, 05 Jul 2015 20:05:36 -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 pd7sm25571851wjb.27.2015.07.05.20.05.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jul 2015 20:05:35 -0700 (PDT) From: Mateusz Guzik To: freebsd-fs@freebsd.org Cc: kib@freesd.org, rwatson@FreeBSD.org, Mateusz Guzik Subject: [PATCH 0/2] slightly cheaper file lookups + an idea Date: Mon, 6 Jul 2015 05:05:30 +0200 Message-Id: <1436151932-12514-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:05:39 -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