static struct dt_object_operations osd_obj_ops;
static struct lu_object_operations osd_lu_obj_ops;
-extern struct dt_body_operations osd_body_ops;
static struct dt_object_operations osd_obj_otable_it_ops;
-extern struct kmem_cache *osd_object_kmem;
-
static void
osd_object_sa_fini(struct osd_object *obj)
{
/*
* Retrieve the attributes of a DMU object
*/
-int __osd_object_attr_get(const struct lu_env *env, struct osd_device *o,
- struct osd_object *obj, struct lu_attr *la)
+static int __osd_object_attr_get(const struct lu_env *env, struct osd_device *o,
+ struct osd_object *obj, struct lu_attr *la)
{
struct osa_attr *osa = &osd_oti_get(env)->oti_osa;
sa_bulk_attr_t *bulk = osd_oti_get(env)->oti_attr_bulk;
dbi = (dmu_buf_impl_t *)db;
DB_DNODE_ENTER(dbi);
*dnp = DB_DNODE(dbi);
+ DB_DNODE_EXIT(dbi);
LASSERT(*dnp != NULL);
return 0;
/*
* Concurrency: shouldn't matter.
*/
-int osd_object_init0(const struct lu_env *env, struct osd_object *obj)
+static int osd_object_init0(const struct lu_env *env, struct osd_object *obj)
{
struct osd_device *osd = osd_obj2dev(obj);
const struct lu_fid *fid = lu_object_fid(&obj->oo_dt.do_lu);
const struct lu_fid *rfid = lu_object_fid(&obj->oo_dt.do_lu);
ENTRY;
- CLASSERT(sizeof(info->oti_buf) >= sizeof(*lma));
+ BUILD_BUG_ON(sizeof(info->oti_buf) < sizeof(*lma));
lma = (struct lustre_mdt_attrs *)info->oti_buf;
buf.lb_buf = lma;
buf.lb_len = sizeof(info->oti_buf);
return rc;
}
-static int osd_attr_get(const struct lu_env *env,
- struct dt_object *dt,
+static int osd_attr_get(const struct lu_env *env, struct dt_object *dt,
struct lu_attr *attr)
{
struct osd_object *obj = osd_dt_obj(dt);
read_lock(&obj->oo_attr_lock);
*attr = obj->oo_attr;
- if (obj->oo_lma_flags & LUSTRE_ORPHAN_FL)
+ if (obj->oo_lma_flags & LUSTRE_ORPHAN_FL) {
+ attr->la_valid |= LA_FLAGS;
attr->la_flags |= LUSTRE_ORPHAN_FL;
+ }
read_unlock(&obj->oo_attr_lock);
+ if (attr->la_valid & LA_FLAGS && attr->la_flags & LUSTRE_ORPHAN_FL)
+ CDEBUG(D_INFO, "%s: set orphan flag on "DFID" (%llx/%x)\n",
+ osd_obj2dev(obj)->od_svname,
+ PFID(lu_object_fid(&dt->do_lu)),
+ attr->la_valid, obj->oo_lma_flags);
/* with ZFS_DEBUG zrl_add_debug() called by DB_DNODE_ENTER()
* from within sa_object_size() can block on a mutex, so
if (attr && attr->la_valid & LA_UID) {
/* quota enforcement for user */
if (attr->la_uid != obj->oo_attr.la_uid) {
- rc = qsd_transfer(env, osd->od_quota_slave,
+ rc = qsd_transfer(env, osd_def_qsd(osd),
&oh->ot_quota_trans, USRQUOTA,
obj->oo_attr.la_uid, attr->la_uid,
bspace, &info->oti_qi, true);
if (attr && attr->la_valid & LA_GID) {
/* quota enforcement for group */
if (attr->la_gid != obj->oo_attr.la_gid) {
- rc = qsd_transfer(env, osd->od_quota_slave,
+ rc = qsd_transfer(env, osd_def_qsd(osd),
&oh->ot_quota_trans, GRPQUOTA,
obj->oo_attr.la_gid, attr->la_gid,
bspace, &info->oti_qi,
}
#ifdef ZFS_PROJINHERIT
if (attr && attr->la_valid & LA_PROJID) {
- if (!osd->od_projectused_dn)
- GOTO(out, rc = -EOPNOTSUPP);
-
- /* Usually, if project quota is upgradable for the device,
- * then the upgrade will be done before or when mount the
- * device. So when we come here, this project should have
- * project ID attribute already (that is zero by default).
- * Otherwise, there was something wrong during the former
- * upgrade, let's return failure to report that.
- *
- * Please note that, different from other attributes, you
- * can NOT simply set the project ID attribute under such
- * case, because adding (NOT change) project ID attribute
- * needs to change the object's attribute layout to match
- * zfs backend quota accounting requirement. */
- if (unlikely(!obj->oo_with_projid))
- GOTO(out, rc = -ENXIO);
-
/* quota enforcement for project */
if (attr->la_projid != obj->oo_attr.la_projid) {
- rc = qsd_transfer(env, osd->od_quota_slave,
+ if (!osd->od_projectused_dn)
+ GOTO(out, rc = -EOPNOTSUPP);
+
+ /* Usually, if project quota is upgradable for the
+ * device, then the upgrade will be done before or when
+ * mount the device. So when we come here, this project
+ * should have project ID attribute already (that is
+ * zero by default). Otherwise, there was something
+ * wrong during the former upgrade, let's return failure
+ * to report that.
+ *
+ * Please note that, different from other attributes,
+ * you can NOT simply set the project ID attribute under
+ * such case, because adding (NOT change) project ID
+ * attribute needs to change the object's attribute
+ * layout to match zfs backend quota accounting
+ * requirement. */
+ if (unlikely(!obj->oo_with_projid))
+ GOTO(out, rc = -ENXIO);
+
+ rc = qsd_transfer(env, osd_def_qsd(osd),
&oh->ot_quota_trans, PRJQUOTA,
obj->oo_attr.la_projid,
attr->la_projid, bspace,
rc = -zap_update(osd->od_os, zapid, buf, 8,
sizeof(*zde) / 8, zde, oh->ot_tx);
}
- up_read(&obj->oo_guard);
-
- RETURN(rc > 0 ? 0 : rc);
+ if (rc > 0)
+ rc = 0;
+ GOTO(out, rc);
}
/* Only allow set size for regular file */
if (valid & LA_FLAGS) {
struct lustre_mdt_attrs *lma;
struct lu_buf buf;
+ int size = 0;
if (la->la_flags & LUSTRE_LMA_FL_MASKS) {
LASSERT(!obj->oo_pfid_in_lma);
- CLASSERT(sizeof(info->oti_buf) >= sizeof(*lma));
+ BUILD_BUG_ON(sizeof(info->oti_buf) < sizeof(*lma));
lma = (struct lustre_mdt_attrs *)&info->oti_buf;
buf.lb_buf = lma;
buf.lb_len = sizeof(info->oti_buf);
- rc = osd_xattr_get(env, &obj->oo_dt, &buf,
- XATTR_NAME_LMA);
- if (rc > 0) {
+
+ /* Please do NOT call osd_xattr_get() directly, that
+ * will cause recursive down_read() on oo_guard. */
+ rc = osd_xattr_get_internal(env, obj, &buf,
+ XATTR_NAME_LMA, &size);
+ if (!rc && unlikely(size < sizeof(*lma))) {
+ rc = -EINVAL;
+ } else if (!rc) {
lma->lma_incompat =
le32_to_cpu(lma->lma_incompat);
lma->lma_incompat |=
if (valid & LA_PROJID) {
#ifdef ZFS_PROJINHERIT
- /* osd_declare_attr_set() must be called firstly.
- * If osd::od_projectused_dn is not set, then we
- * can not arrive at here. */
- LASSERT(osd->od_projectused_dn);
- LASSERT(obj->oo_with_projid);
+ if (osd->od_projectused_dn) {
+ LASSERT(obj->oo_with_projid);
- osa->projid = obj->oo_attr.la_projid = la->la_projid;
- SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_PROJID(osd), NULL,
- &osa->projid, 8);
-#else
- valid &= ~LA_PROJID;
+ osa->projid = obj->oo_attr.la_projid = la->la_projid;
+ SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_PROJID(osd), NULL,
+ &osa->projid, 8);
+ } else
#endif
+ valid &= ~LA_PROJID;
}
if (valid & LA_ATIME) {
* copy */
obj->oo_attr.la_flags = attrs_zfs2fs(osa->flags);
#ifdef ZFS_PROJINHERIT
- if (obj->oo_with_projid)
+ if (obj->oo_with_projid && osd->od_projectused_dn)
osa->flags |= ZFS_PROJID;
#endif
SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_FLAGS(osd), NULL,
switch (dof->dof_type) {
case DFT_DIR:
dt->do_index_ops = &osd_dir_ops;
+ /* fallthrough */
case DFT_INDEX:
/* for zap create */
dmu_tx_hold_zap(oh->ot_tx, DMU_NEW_OBJECT, FALSE, NULL);
struct lu_attr *la, uint64_t parent,
nvlist_t *xattr)
{
- sa_bulk_attr_t *bulk = osd_oti_get(env)->oti_attr_bulk;
- struct osa_attr *osa = &osd_oti_get(env)->oti_osa;
- uint64_t gen;
- uint64_t crtime[2];
- timestruc_t now;
- int cnt;
- int rc;
+ sa_bulk_attr_t *bulk = osd_oti_get(env)->oti_attr_bulk;
+ struct osa_attr *osa = &osd_oti_get(env)->oti_osa;
+ uint64_t gen;
+ uint64_t crtime[2];
+ inode_timespec_t now;
+ int cnt;
+ int rc;
char *dxattr = NULL;
size_t sa_size;
LASSERT(db);
LASSERT(dn->dn_handle);
DB_DNODE_ENTER(db);
- if (refcount_add(&db->db_holds, osd_obj_tag) == 1) {
- refcount_add(&dn->dn_holds, tag);
+ if (zfs_refcount_add(&db->db_holds, osd_obj_tag) == 1) {
+ zfs_refcount_add(&dn->dn_holds, osd_obj_tag);
atomic_inc_32(&dn->dn_dbufs_count);
}
*dnp = dn;
+ DB_DNODE_EXIT(db);
dbuf_read(db, NULL, DB_RF_MUST_SUCCEED | DB_RF_NOPREFETCH);
break;
}
osd->od_svname, rc);
return ERR_PTR(rc);
}
+ } else if ((fid_is_llog(fid))) {
+ rc = -dmu_object_set_blocksize(osd->od_os, dn->dn_object,
+ LLOG_MIN_CHUNK_SIZE, 0, oh->ot_tx);
+ if (unlikely(rc)) {
+ CERROR("%s: can't change blocksize: %d\n",
+ osd->od_svname, rc);
+ return ERR_PTR(rc);
+ }
}
return dn;
__u64 start, __u64 end)
{
struct osd_device *osd = osd_obj2dev(osd_dt_obj(dt));
+ struct dmu_buf_impl *db = osd_dt_obj(dt)->oo_dn->dn_dbuf;
+ uint64_t txg = 0;
ENTRY;
- /* XXX: no other option than syncing the whole filesystem until we
- * support ZIL. If the object tracked the txg that it was last
- * modified in, it could pass that txg here instead of "0". Maybe
- * the changes are already committed, so no wait is needed at all? */
- if (!osd->od_dt_dev.dd_rdonly) {
+ if (osd->od_dt_dev.dd_rdonly)
+ RETURN(0);
+
+ mutex_enter(&db->db_mtx);
+ if (db->db_last_dirty)
+ txg = db->db_last_dirty->dr_txg;
+ mutex_exit(&db->db_mtx);
+
+ if (txg) {
+ /* the object is dirty or being synced */
if (osd_object_sync_delay_us < 0)
- txg_wait_synced(dmu_objset_pool(osd->od_os), 0ULL);
+ txg_wait_synced(dmu_objset_pool(osd->od_os), txg);
else
udelay(osd_object_sync_delay_us);
}