X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-zfs%2Fosd_object.c;h=730671ac2c96a13eb2e7df95d4fc42aa5541ab7e;hb=3fc039a99f41725798d157a422174005a49200c8;hp=7fa7cb26ed4bd284ebe9ef5623509c274fc74ed6;hpb=11db1a551172f596d1d284e8496530f9ce24ac81;p=fs%2Flustre-release.git diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 7fa7cb2..730671a 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -286,7 +286,7 @@ struct lu_object *osd_object_alloc(const struct lu_env *env, { struct osd_object *mo; - OBD_SLAB_ALLOC_PTR_GFP(mo, osd_object_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(mo, osd_object_kmem, GFP_NOFS); if (mo != NULL) { struct lu_object *l; @@ -339,7 +339,7 @@ int osd_object_init0(const struct lu_env *env, struct osd_object *obj) */ obj->oo_dt.do_lu.lo_header->loh_attr |= obj->oo_attr.la_mode & S_IFMT; - cfs_mb(); + smp_mb(); obj->oo_dt.do_lu.lo_header->loh_attr |= LOHA_EXISTS; RETURN(0); @@ -874,7 +874,10 @@ static int osd_declare_attr_set(const struct lu_env *env, oh = container_of0(handle, struct osd_thandle, ot_super); LASSERT(obj->oo_sa_hdl != NULL); + LASSERT(oh->ot_tx != NULL); dmu_tx_hold_sa(oh->ot_tx, obj->oo_sa_hdl, 0); + if (oh->ot_tx->tx_err != 0) + RETURN(-oh->ot_tx->tx_err); sa_object_size(obj->oo_sa_hdl, &blksize, &bspace); bspace = toqb(bspace * blksize); @@ -930,6 +933,7 @@ static int osd_attr_set(const struct lu_env *env, struct dt_object *dt, struct osd_thandle *oh; struct osa_attr *osa = &osd_oti_get(env)->oti_osa; sa_bulk_attr_t *bulk; + __u64 valid = la->la_valid; int cnt; int rc = 0; @@ -944,7 +948,11 @@ static int osd_attr_set(const struct lu_env *env, struct dt_object *dt, transaction group. */ LASSERT(oh->ot_tx->tx_txg != 0); - if (la->la_valid == 0) + /* Only allow set size for regular file */ + if (!S_ISREG(dt->do_lu.lo_header->loh_attr)) + valid &= ~(LA_SIZE | LA_BLOCKS); + + if (valid == 0) RETURN(0); OBD_ALLOC(bulk, sizeof(sa_bulk_attr_t) * 10); @@ -952,7 +960,7 @@ static int osd_attr_set(const struct lu_env *env, struct dt_object *dt, RETURN(-ENOMEM); /* do both accounting updates outside oo_attr_lock below */ - if ((la->la_valid & LA_UID) && (la->la_uid != obj->oo_attr.la_uid)) { + if ((valid & LA_UID) && (la->la_uid != obj->oo_attr.la_uid)) { /* Update user accounting. Failure isn't fatal, but we still * log an error message */ rc = -zap_increment_int(osd->od_objset.os, osd->od_iusr_oid, @@ -967,7 +975,7 @@ static int osd_attr_set(const struct lu_env *env, struct dt_object *dt, "%d (%d)\n", osd->od_svname, obj->oo_attr.la_uid, rc); } - if ((la->la_valid & LA_GID) && (la->la_gid != obj->oo_attr.la_gid)) { + if ((valid & LA_GID) && (la->la_gid != obj->oo_attr.la_gid)) { /* Update group accounting. Failure isn't fatal, but we still * log an error message */ rc = -zap_increment_int(osd->od_objset.os, osd->od_igrp_oid, @@ -985,22 +993,22 @@ static int osd_attr_set(const struct lu_env *env, struct dt_object *dt, write_lock(&obj->oo_attr_lock); cnt = 0; - if (la->la_valid & LA_ATIME) { + if (valid & LA_ATIME) { osa->atime[0] = obj->oo_attr.la_atime = la->la_atime; SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_ATIME(uos), NULL, osa->atime, 16); } - if (la->la_valid & LA_MTIME) { + if (valid & LA_MTIME) { osa->mtime[0] = obj->oo_attr.la_mtime = la->la_mtime; SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_MTIME(uos), NULL, osa->mtime, 16); } - if (la->la_valid & LA_CTIME) { + if (valid & LA_CTIME) { osa->ctime[0] = obj->oo_attr.la_ctime = la->la_ctime; SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_CTIME(uos), NULL, osa->ctime, 16); } - if (la->la_valid & LA_MODE) { + if (valid & LA_MODE) { /* mode is stored along with type, so read it first */ obj->oo_attr.la_mode = (obj->oo_attr.la_mode & S_IFMT) | (la->la_mode & ~S_IFMT); @@ -1008,22 +1016,22 @@ static int osd_attr_set(const struct lu_env *env, struct dt_object *dt, SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_MODE(uos), NULL, &osa->mode, 8); } - if (la->la_valid & LA_SIZE) { + if (valid & LA_SIZE) { osa->size = obj->oo_attr.la_size = la->la_size; SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_SIZE(uos), NULL, &osa->size, 8); } - if (la->la_valid & LA_NLINK) { + if (valid & LA_NLINK) { osa->nlink = obj->oo_attr.la_nlink = la->la_nlink; SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_LINKS(uos), NULL, &osa->nlink, 8); } - if (la->la_valid & LA_RDEV) { + if (valid & LA_RDEV) { osa->rdev = obj->oo_attr.la_rdev = la->la_rdev; SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_RDEV(uos), NULL, &osa->rdev, 8); } - if (la->la_valid & LA_FLAGS) { + if (valid & LA_FLAGS) { osa->flags = attrs_fs2zfs(la->la_flags); /* many flags are not supported by zfs, so ensure a good cached * copy */ @@ -1031,17 +1039,17 @@ static int osd_attr_set(const struct lu_env *env, struct dt_object *dt, SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_FLAGS(uos), NULL, &osa->flags, 8); } - if (la->la_valid & LA_UID) { + if (valid & LA_UID) { osa->uid = obj->oo_attr.la_uid = la->la_uid; SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_UID(uos), NULL, &osa->uid, 8); } - if (la->la_valid & LA_GID) { + if (valid & LA_GID) { osa->gid = obj->oo_attr.la_gid = la->la_gid; SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_GID(uos), NULL, &osa->gid, 8); } - obj->oo_attr.la_valid |= la->la_valid; + obj->oo_attr.la_valid |= valid; write_unlock(&obj->oo_attr_lock); rc = osd_object_sa_bulk_update(obj, bulk, cnt, oh); @@ -1058,7 +1066,7 @@ static int osd_attr_set(const struct lu_env *env, struct dt_object *dt, static void osd_ah_init(const struct lu_env *env, struct dt_allocation_hint *ah, struct dt_object *parent, struct dt_object *child, - cfs_umode_t child_mode) + umode_t child_mode) { LASSERT(ah); @@ -1223,10 +1231,6 @@ int __osd_object_create(const struct lu_env *env, udmu_objset_t *uos, int rc; LASSERT(tag); - spin_lock(&uos->lock); - uos->objects++; - spin_unlock(&uos->lock); - /* Assert that the transaction has been assigned to a transaction group. */ LASSERT(tx->tx_txg != 0); @@ -1235,14 +1239,24 @@ int __osd_object_create(const struct lu_env *env, udmu_objset_t *uos, oid = dmu_object_alloc(uos->os, DMU_OT_PLAIN_FILE_CONTENTS, 0, DMU_OT_SA, DN_MAX_BONUSLEN, tx); rc = -sa_buf_hold(uos->os, oid, tag, dbp); - if (rc) - return rc; + LASSERTF(rc == 0, "sa_buf_hold "LPU64" failed: %d\n", oid, rc); LASSERT(la->la_valid & LA_MODE); la->la_size = 0; la->la_nlink = 1; - return __osd_attr_init(env, uos, oid, tx, la, parent); + rc = __osd_attr_init(env, uos, oid, tx, la, parent); + if (rc != 0) { + sa_buf_rele(*dbp, tag); + *dbp = NULL; + dmu_object_free(uos->os, oid, tx); + return rc; + } + + spin_lock(&uos->lock); + uos->objects++; + spin_unlock(&uos->lock); + return 0; } /* @@ -1430,7 +1444,7 @@ static inline int osd_init_lma(const struct lu_env *env, struct osd_object *obj, struct lu_buf buf; int rc; - lustre_lma_init(lma, fid, 0); + lustre_lma_init(lma, fid, 0, 0); lustre_lma_swab(lma); buf.lb_buf = lma; buf.lb_len = sizeof(*lma); @@ -1488,7 +1502,7 @@ static int osd_object_create(const struct lu_env *env, struct dt_object *dt, db = osd_create_type_f(dof->dof_type)(env, osd, attr, zapid, oh); if (IS_ERR(db)) - GOTO(out, rc = PTR_ERR(th)); + GOTO(out, rc = PTR_ERR(db)); zde->zde_pad = 0; zde->zde_dnode = db->db_object; @@ -1748,13 +1762,16 @@ static struct obd_capa *osd_capa_get(const struct lu_env *env, RETURN(oc); } -static int osd_object_sync(const struct lu_env *env, struct dt_object *dt) +static int osd_object_sync(const struct lu_env *env, struct dt_object *dt, + __u64 start, __u64 end) { struct osd_device *osd = osd_obj2dev(osd_dt_obj(dt)); ENTRY; /* XXX: no other option than syncing the whole filesystem until we - * support ZIL */ + * 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? */ txg_wait_synced(dmu_objset_pool(osd->od_objset.os), 0ULL); RETURN(0);