zfs_setextattr() synchronicity

Alexander Motin mav at FreeBSD.org
Fri Jul 4 02:41:38 UTC 2014


On 04.07.2014 04:01, Alexander Motin wrote:
> Doing some Samba benchmarks, creating many small files on ZFS, I've
> noticed that it's performance heavily depends on dedicated ZIL presence.
> Looking deeper I've noticed that most of time is spent in
> extattr_set_file() syscall. Deeper look brought me to zfs_vnops.c, where
> in zfs_setextattr() I found:
> 	VOP_WRITE(vp, ap->a_uio, IO_UNIT | IO_SYNC, ap->a_cred);
> 
> I guess that IO_SYNC here is what causes ZIL commit for every created
> file, when Samba sets some DOSATTRIB attribute.  I've tried to find that
> code in Solaris, but failed. Is it FreeBSD specific? Same time, looking
> on UFS code, I see that it does not synchronizes those calls by default.
> Same as not synchronized by default (unless sync=always is set)
> zfs_setattr() calls for ZFS. Why is zfs_setextattr() synchronized
> heavier then zfs_setattr()?

I've found that such single-line patch improves results of file creation
benchmark on Samba by several times:

--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
@@ -6710,7 +6710,7 @@ vop_setextattr {
        va.va_size = 0;
        error = VOP_SETATTR(vp, &va, ap->a_cred);
        if (error == 0)
-               VOP_WRITE(vp, ap->a_uio, IO_UNIT | IO_SYNC, ap->a_cred);
+               VOP_WRITE(vp, ap->a_uio, IO_UNIT, ap->a_cred);

        VOP_UNLOCK(vp, 0);
        vn_close(vp, flags, ap->a_cred, td);

Can anybody tell me why setting extended attributes on ZFS require
zil_commit(), while otherwise it is possible to create and write files,
change their permissions, etc. without ever doing zil_commit(). It looks
at least strange to me.

-- 
Alexander Motin


More information about the freebsd-fs mailing list