Whamcloud - gitweb
LU-3938 osd-zfs: Account for ZAP when shrinking an xattr 71/7671/2
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Mon, 16 Sep 2013 17:00:46 +0000 (13:00 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 23 Sep 2013 00:12:57 +0000 (00:12 +0000)
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>
lustre/osd-zfs/osd_xattr.c

index 14f5256..2900fb6 100644 (file)
@@ -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)