From: Nathaniel Clark Date: Mon, 16 Sep 2013 17:00:46 +0000 (-0400) Subject: LU-3938 osd-zfs: Account for ZAP when shrinking an xattr X-Git-Tag: 2.4.93~26 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=c6dd479164dcb32d401bb203983f6d4840d5268b LU-3938 osd-zfs: Account for ZAP when shrinking an xattr When an xattr is too big for SA it is put in the ZAP, if it is replaced with one that fits in SA, the one in ZAP should be removed, otherwise the object will end up with two xattrs with the same name, and everything gets confused. Signed-off-by: Nathaniel Clark Change-Id: I5d33b9e505c751ec01811217377656171553659d Reviewed-on: http://review.whamcloud.com/7671 Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Tested-by: Hudson Tested-by: Maloo --- diff --git a/lustre/osd-zfs/osd_xattr.c b/lustre/osd-zfs/osd_xattr.c index 14f5256..2900fb6 100644 --- a/lustre/osd-zfs/osd_xattr.c +++ b/lustre/osd-zfs/osd_xattr.c @@ -437,6 +437,20 @@ int __osd_sa_xattr_set(const struct lu_env *env, struct osd_object *obj, return rc; } + /* Ensure xattr doesn't exist in ZAP */ + if (obj->oo_xattr != ZFS_NO_OBJECT) { + udmu_objset_t *uos = &osd_obj2dev(obj)->od_objset; + uint64_t xa_data_obj; + rc = -zap_lookup(uos->os, obj->oo_xattr, + name, 8, 1, &xa_data_obj); + if (rc == 0) { + rc = __osd_object_free(uos, xa_data_obj, oh->ot_tx); + if (rc == 0) + zap_remove(uos->os, obj->oo_xattr, + name, oh->ot_tx); + } + } + rc = -nvlist_add_byte_array(obj->oo_sa_xattr, name, (uchar_t *)buf->lb_buf, buf->lb_len); if (rc)