Date: Tue, 8 Oct 2019 11:27:48 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353304 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <201910081127.x98BRm1W025291@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Tue Oct 8 11:27:48 2019 New Revision: 353304 URL: https://svnweb.freebsd.org/changeset/base/353304 Log: zfs: use atomic_load_64 to read atomic variable in dmu_object_alloc_impl As long as we support ZFS on 32-bit platforms we should do this for all 64-bit variables that are modified in a lockless fashion using atomic operations. Otherwise, there is a risk of a reading a torn value. Here is a rationale for why I am doing this in dmu_object_alloc_impl: - it's very recent code - the code deals with object IDs and a number of objects in a file system can overflow 32 bits - incorrect allocation of an object ID may result in hard to debug problems - fixing all plain reads of 64-bit atomic variables is not a trivial undertaking to do in one shot, so I chose to do it incrementally MFC after: 3 weeks X-MFC after: r353301, r353176 Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c Tue Oct 8 11:07:16 2019 (r353303) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c Tue Oct 8 11:27:48 2019 (r353304) @@ -76,7 +76,11 @@ dmu_object_alloc_impl(objset_t *os, dmu_object_type_t if (dnodes_per_chunk > L1_dnode_count) dnodes_per_chunk = L1_dnode_count; +#ifdef __FreeBSD__ + object = atomic_load_64(cpuobj); +#else object = *cpuobj; +#endif for (;;) { /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910081127.x98BRm1W025291>