* Use is subject to license terms.
*/
/*
- * Copyright (c) 2011, 2012 Whamcloud, Inc.
+ * Copyright (c) 2012, Intel Corporation.
* Use is subject to license terms.
*/
/*
LASSERT(osd_invariant(obj));
LASSERT(dt_object_exists(dt));
- cfs_down(&obj->oo_guard);
+ down(&obj->oo_guard);
rc = __osd_xattr_get(env, obj, buf, name, &size);
- cfs_up(&obj->oo_guard);
+ up(&obj->oo_guard);
if (rc == -ENOENT)
rc = -ENODATA;
LASSERT(handle != NULL);
oh = container_of0(handle, struct osd_thandle, ot_super);
- cfs_down(&obj->oo_guard);
+ down(&obj->oo_guard);
__osd_xattr_declare_set(env, obj, buf->lb_len, name, oh);
- cfs_up(&obj->oo_guard);
+ up(&obj->oo_guard);
RETURN(0);
}
return rc;
}
-static int
+int
__osd_xattr_set(const struct lu_env *env, struct osd_object *obj,
const struct lu_buf *buf, const char *name, int fl,
struct osd_thandle *oh)
}
int osd_xattr_set(const struct lu_env *env, struct dt_object *dt,
- const struct lu_buf *buf, const char *name, int fl,
- struct thandle *handle, struct lustre_capa *capa)
+ const struct lu_buf *buf, const char *name, int fl,
+ struct thandle *handle, struct lustre_capa *capa)
{
struct osd_object *obj = osd_dt_obj(dt);
struct osd_thandle *oh;
oh = container_of0(handle, struct osd_thandle, ot_super);
- cfs_down(&obj->oo_guard);
+ down(&obj->oo_guard);
CDEBUG(D_INODE, "Setting xattr %s with size %d\n",
name, (int)buf->lb_len);
- rc = __osd_sa_xattr_set(env, obj, buf, name, fl, oh);
- /* place xattr in dnode if SA is full */
- if (rc == -EFBIG)
- rc = __osd_xattr_set(env, obj, buf, name, fl, oh);
- cfs_up(&obj->oo_guard);
+ rc = osd_xattr_set_internal(env, obj, buf, name, fl, oh, capa);
+ up(&obj->oo_guard);
RETURN(rc);
}
LASSERT(oh->ot_tx != NULL);
LASSERT(obj->oo_db != NULL);
- cfs_down(&obj->oo_guard);
+ down(&obj->oo_guard);
__osd_xattr_declare_del(env, obj, name, oh);
- cfs_up(&obj->oo_guard);
+ up(&obj->oo_guard);
RETURN(0);
}
return rc;
if (obj->oo_xattr == ZFS_NO_OBJECT)
- return rc;
+ return 0;
rc = -zap_lookup(uos->os, obj->oo_xattr, name, sizeof(uint64_t), 1,
&xa_data_obj);
oh = container_of0(handle, struct osd_thandle, ot_super);
LASSERT(oh->ot_tx != NULL);
- cfs_down(&obj->oo_guard);
+ down(&obj->oo_guard);
rc = __osd_xattr_del(env, obj, name, oh);
- cfs_up(&obj->oo_guard);
+ up(&obj->oo_guard);
RETURN(rc);
}
while ((nvp = nvlist_next_nvpair(obj->oo_sa_xattr, nvp)) != NULL) {
len = strlen(nvpair_name(nvp));
- if (len >= remain)
- return -ERANGE;
-
- memcpy(lb->lb_buf, nvpair_name(nvp), len);
- lb->lb_buf += len;
- *((char *)lb->lb_buf) = '\0';
- lb->lb_buf++;
- remain -= len + 1;
+ if (lb->lb_buf != NULL) {
+ if (len + 1 > remain)
+ return -ERANGE;
+
+ memcpy(lb->lb_buf, nvpair_name(nvp), len);
+ lb->lb_buf += len;
+ *((char *)lb->lb_buf) = '\0';
+ lb->lb_buf++;
+ remain -= len + 1;
+ }
counted += len + 1;
}
return counted;
LASSERT(osd_invariant(obj));
LASSERT(dt_object_exists(dt));
- cfs_down(&obj->oo_guard);
+ down(&obj->oo_guard);
rc = osd_sa_xattr_list(env, obj, lb);
if (rc < 0)
while ((rc = -udmu_zap_cursor_retrieve_key(env, zc, oti->oti_key,
MAXNAMELEN)) == 0) {
rc = strlen(oti->oti_key);
- if (rc >= remain)
- GOTO(out_fini, rc = -ERANGE);
-
- memcpy(lb->lb_buf, oti->oti_key, rc);
- lb->lb_buf += rc;
- *((char *)lb->lb_buf) = '\0';
- lb->lb_buf++;
- remain -= rc + 1;
+ if (lb->lb_buf != NULL) {
+ if (rc + 1 > remain)
+ RETURN(-ERANGE);
+
+ memcpy(lb->lb_buf, oti->oti_key, rc);
+ lb->lb_buf += rc;
+ *((char *)lb->lb_buf) = '\0';
+ lb->lb_buf++;
+ remain -= rc + 1;
+ }
counted += rc + 1;
zap_cursor_advance(zc);
out_fini:
udmu_zap_cursor_fini(zc);
out:
- cfs_up(&obj->oo_guard);
+ up(&obj->oo_guard);
RETURN(rc);
}