aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/vnode.h
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-08-07 23:06:40 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-08-07 23:06:40 +0000
commit51ea7bea910148ae6cf40c57de0cd3b120d542e3 (patch)
treebf5eda7ce6fe5b88a48f7b4889b50337b4c5667b /sys/sys/vnode.h
parent1e5d733503521375eb5372079366329936365f6f (diff)
downloadsrc-51ea7bea910148ae6cf40c57de0cd3b120d542e3.tar.gz
src-51ea7bea910148ae6cf40c57de0cd3b120d542e3.zip
vfs: add VOP_STAT
The current scheme of calling VOP_GETATTR adds avoidable overhead. An example with tmpfs doing fstat (ops/s): before: 7488958 after: 7913833 Reviewed by: kib (previous version) Differential Revision: https://reviews.freebsd.org/D25910
Notes
Notes: svn path=/head/; revision=364044
Diffstat (limited to 'sys/sys/vnode.h')
-rw-r--r--sys/sys/vnode.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index 5d9e3496d12e..87c01a962064 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -737,8 +737,6 @@ int vn_rdwr_inchunks(enum uio_rw rw, struct vnode *vp, void *base,
struct thread *td);
int vn_rlimit_fsize(const struct vnode *vn, const struct uio *uio,
struct thread *td);
-int vn_stat(struct vnode *vp, struct stat *sb, struct ucred *active_cred,
- struct ucred *file_cred, struct thread *td);
int vn_start_write(struct vnode *vp, struct mount **mpp, int flags);
int vn_start_secondary_write(struct vnode *vp, struct mount **mpp,
int flags);
@@ -893,6 +891,22 @@ void vop_need_inactive_debugpost(void *a, int rc);
void vop_rename_fail(struct vop_rename_args *ap);
+#define vop_stat_helper_pre(ap) ({ \
+ int _error; \
+ AUDIT_ARG_VNODE1(ap->a_vp); \
+ _error = mac_vnode_check_stat(ap->a_active_cred, ap->a_file_cred, ap->a_vp);\
+ if (__predict_true(_error == 0)) \
+ bzero(ap->a_sb, sizeof(*ap->a_sb)); \
+ _error; \
+})
+
+#define vop_stat_helper_post(ap, error) ({ \
+ int _error = (error); \
+ if (priv_check_cred_vfs_generation(ap->a_td->td_ucred)) \
+ ap->a_sb->st_gen = 0; \
+ _error; \
+})
+
#define VOP_WRITE_PRE(ap) \
struct vattr va; \
int error; \