Whamcloud - gitweb
LU-10753 osd-zfs: initialize obj attr correctly 62/40062/4
authorLai Siyao <lai.siyao@whamcloud.com>
Thu, 24 Sep 2020 16:05:15 +0000 (00:05 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 19 Oct 2020 03:13:44 +0000 (03:13 +0000)
mdt_thread_info.mti_attr is used to initialize object attr in create,
currently it's copied to object.oo_attr directly, but some fields
in mti_attr may contain bogus data because it's not cleared in each
use, though la_valid is correctly set, but la_flags is used without
checking la_valid in __mdd_permission_internal().

Another minor fix in osd_create(): set size/nlink to zero since they
are set in valid.

Test-Parameters: testlist=sanity env=ONLY=300,ONLY_REPEAT=100

Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: I64816b66a0b3c7aa50e62680d5251141697a8e0f
Reviewed-on: https://review.whamcloud.com/40062
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Olaf Faaland-LLNL <faaland1@llnl.gov>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdd/mdd_permission.c
lustre/osd-zfs/osd_object.c

index 0857889..148c120 100644 (file)
@@ -272,7 +272,8 @@ int __mdd_permission_internal(const struct lu_env *env, struct mdd_object *obj,
        /*
         * Nobody gets write access to an immutable file.
         */
-       if (mask & MAY_WRITE && la->la_flags & LUSTRE_IMMUTABLE_FL)
+       if ((mask & MAY_WRITE) && (la->la_valid & LA_FLAGS) &&
+           (la->la_flags & LUSTRE_IMMUTABLE_FL))
                RETURN(-EACCES);
 
        LASSERT(la != NULL);
index 0812a34..7f38fa4 100644 (file)
@@ -1954,6 +1954,8 @@ static int osd_create(const struct lu_env *env, struct dt_object *dt,
 
        /* we may fix some attributes, better do not change the source */
        obj->oo_attr = *attr;
+       obj->oo_attr.la_size = 0;
+       obj->oo_attr.la_nlink = 0;
        obj->oo_attr.la_valid |= LA_SIZE | LA_NLINK | LA_TYPE;
 
 #ifdef ZFS_PROJINHERIT