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 <nathaniel.l.clark@intel.com>
Change-Id: I5d33b9e505c751ec01811217377656171553659d
Reviewed-on: http://review.whamcloud.com/7671
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
+ /* 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)
rc = -nvlist_add_byte_array(obj->oo_sa_xattr, name,
(uchar_t *)buf->lb_buf, buf->lb_len);
if (rc)