Whamcloud - gitweb
LU-10753 osd-zfs: initialize obj attr correctly 85/40585/3
authorLai Siyao <lai.siyao@whamcloud.com>
Thu, 24 Sep 2020 16:05:15 +0000 (00:05 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 4 Mar 2021 08:35:03 +0000 (08:35 +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.

Lustre-change: https://review.whamcloud.com/40062
Lustre-commit: cf395c2507e80717e7468456e9959d432b6accc8

Test-Parameters: testlist=sanity env=ONLY=300,ONLY_REPEAT=100
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: I64816b66a0b3c7aa50e62680d5251141697a8e0f
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Olaf Faaland-LLNL <faaland1@llnl.gov>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/40585
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/mdd/mdd_permission.c
lustre/osd-zfs/osd_object.c

index 01b30e1..40c73e4 100644 (file)
@@ -270,7 +270,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 02983ac..5b6c7a5 100644 (file)
@@ -1935,6 +1935,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