o Change the default from using IO_SYNC on EA set and delete operations

to not using IO_SYNC.  Expose a sysctl (debug.ufs_extattr_sync) for
  enabling the use of IO_SYNC.

    - Use of IO_SYNC substantially degrades ACL performance when a
      default ACL is set on a directory, as there are four synchronous
      writes initiated to define both supporting EAs for new
      sub-directories, and to set the data; two for new files.  Later, this
      may be optimized to two writes for sub-directories, one for new
      files.

    - IO_SYNC does not substantially improve consistency properties due
      to the poor consistency properties of existing permissions (which
      ACLs are a superset of), due to interaction with soft updates,
      and due to differences in handling consistency for data and file
      system meta-data.

    - In macro-benchmarks, this reduces the overhead of setting default
      ACLs down to the same overhead as enabling ACLs on a file system
      and not using them.  Enabling ACLs still introduces a small
      overhead (I measure 7% on a -j 2 buildworld with pre-allocated
      EA backing store, but this is not rigorous testing, nor in any way
      optimized).

    - The sysctl will probably change to another administration method
      (or at least, a better name) in the near future, but consistency
      properties of EAs are still being worked out.  The toggle is defined
      right now to allow easier performance analysis and exploration
      of possible guarantees.

Obtained from:	TrustedBSD Project
This commit is contained in:
rwatson 2001-04-03 04:09:53 +00:00
parent 6b1d9a0a8b
commit b5bd10c9da

View File

@ -41,6 +41,7 @@
#include <sys/lock.h>
#include <sys/dirent.h>
#include <sys/extattr.h>
#include <sys/sysctl.h>
#include <vm/vm_zone.h>
@ -59,6 +60,10 @@
static MALLOC_DEFINE(M_UFS_EXTATTR, "ufs_extattr", "ufs extended attribute");
static int ufs_extattr_sync = 0;
SYSCTL_INT(_debug, OID_AUTO, ufs_extattr_sync, CTLFLAG_RW, &ufs_extattr_sync,
0, "");
static int ufs_extattr_valid_attrname(const char *attrname);
static int ufs_extattr_credcheck(struct vnode *vp,
struct ufs_extattr_list_entry *uele, struct ucred *cred, struct proc *p,
@ -1018,7 +1023,7 @@ ufs_extattr_set(struct vnode *vp, int attrnamespace, const char *name,
struct ufsmount *ump = VFSTOUFS(mp);
struct inode *ip = VTOI(vp);
off_t base_offset;
int error = 0;
int error = 0, ioflag;
if (vp->v_mount->mnt_flag & MNT_RDONLY)
return (EROFS);
@ -1080,8 +1085,11 @@ ufs_extattr_set(struct vnode *vp, int attrnamespace, const char *name,
vn_lock(attribute->uele_backing_vnode,
LK_EXCLUSIVE | LK_NOPAUSE | LK_RETRY, p);
error = VOP_WRITE(attribute->uele_backing_vnode, &local_aio,
IO_NODELOCKED | IO_SYNC, ump->um_extattr.uepm_ucred);
ioflag = IO_NODELOCKED;
if (ufs_extattr_sync)
ioflag |= IO_SYNC;
error = VOP_WRITE(attribute->uele_backing_vnode, &local_aio, ioflag,
ump->um_extattr.uepm_ucred);
if (error)
goto vopunlock_exit;
@ -1094,9 +1102,12 @@ ufs_extattr_set(struct vnode *vp, int attrnamespace, const char *name,
* Write out user data.
*/
uio->uio_offset = base_offset + sizeof(struct ufs_extattr_header);
error = VOP_WRITE(attribute->uele_backing_vnode, uio,
IO_NODELOCKED | IO_SYNC, ump->um_extattr.uepm_ucred);
ioflag = IO_NODELOCKED;
if (ufs_extattr_sync)
ioflag |= IO_SYNC;
error = VOP_WRITE(attribute->uele_backing_vnode, uio, ioflag,
ump->um_extattr.uepm_ucred);
vopunlock_exit:
uio->uio_offset = 0;
@ -1123,7 +1134,7 @@ ufs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name,
struct ufsmount *ump = VFSTOUFS(mp);
struct inode *ip = VTOI(vp);
off_t base_offset;
int error = 0;
int error = 0, ioflag;
if (vp->v_mount->mnt_flag & MNT_RDONLY)
return (EROFS);
@ -1211,8 +1222,11 @@ ufs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name,
local_aio.uio_offset = base_offset;
local_aio.uio_resid = sizeof(struct ufs_extattr_header);
error = VOP_WRITE(attribute->uele_backing_vnode, &local_aio,
IO_NODELOCKED | IO_SYNC, ump->um_extattr.uepm_ucred);
ioflag = IO_NODELOCKED;
if (ufs_extattr_sync)
ioflag |= IO_SYNC;
error = VOP_WRITE(attribute->uele_backing_vnode, &local_aio, ioflag,
ump->um_extattr.uepm_ucred);
if (error)
goto vopunlock_exit;