ZFS patches for FreeBSD.

Jung-uk Kim jkim at FreeBSD.org
Thu Nov 16 21:24:21 UTC 2006


On Thursday 16 November 2006 03:05 pm, Doug Ambrisko wrote:
> This is on i386:
>   one% grep memset zfs_20061117.patch
>   +       (void) memset(p, 0, n);
>   +       (void) memset(wp, 0, sizeof (*wp));
>   +       (void) memset(wp, 0, sizeof (*wp));
>   +zap_memset(void *a, int c, size_t n)
>   +       zap_memset(&l->l_phys->l_hdr, 0, sizeof (struct
> zap_leaf_header)); +       zap_memset(l->l_phys->l_hash, CHAIN_END,
> 2*ZAP_LEAF_HASH_NUMENTRIES(l)); +      
> zap_memset(l->l_phys->l_hash, CHAIN_END,
> 2*ZAP_LEAF_HASH_NUMENTRIES(l)); one%
>
>   In contrib/opensolaris/lib/libuutil/common/uu_alloc.c
>   +void *
>   +uu_zalloc(size_t n)
>   +{
>   +       void *p = malloc(n);
>   +
>   +       if (p == NULL) {
>   +               uu_set_error(UU_ERROR_SYSTEM);
>   +               return (NULL);
>   +       }
>   +
>   +       (void) memset(p, 0, n);
>   +
>   +       return (p);
>   +}
>   +
>
>   %nm dmu_objset.o | grep memset
>            U memset
>   %
>
> If I run it compile -E I see
>   static __inline void *
>   memset(void *b, int c, size_t len)
>   {
>    char *bb;
>
>    if (c == 0)
>     bzero(b, len);
>    else
>     for (bb = (char *)b; len--; )
>      *bb++ = c;
>    return (b);
>   }
>
> and nothing calling it unless it is what Max. is talking about.
> I don't see other stuff breaking.

It seems the memset() is not used in the kernel part.  However, there 
are at least three places, which does 'struct foo bar = { 0 }':

%grep '{ 0 }' zfs_20061117_sys.patch 
+       struct oscarg oa = { 0 };
+       struct snaparg sn = { 0 };
+       zfs_create_data_t cbdata = { 0 };

(Note: zfs_20061117_sys.patch is extracted from the original patch.)

The first two are from dmu_objset_create() and dmu_objset_snapshot() 
in sys/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c and that is 
what you saw.  The third one is from zfs_ioc_create() in 
sys/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c.

FYI...

Jung-uk Kim


More information about the freebsd-fs mailing list