From 434eeba4d33d9ddd871cff080d51534081bb3d30 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Thu, 10 Mar 2016 10:33:11 -0700 Subject: [PATCH] LU-8589 osd: remove "object" from method function names Remove "object_" from various OSD API dt_object_operations method functions (create, destroy, {read,write}_{lock,unlock}, write_locked, ref_add, ref_del, and declare_ variants of same) to match the actual method names so the code is easier to trace. Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: I18860bc965f958d6ba2e595882e7e56ca00cab07 Reviewed-on: https://review.whamcloud.com/22542 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- lustre/include/dt_object.h | 6 +- lustre/include/lustre_update.h | 25 +-- lustre/lod/lod_internal.h | 133 +++++-------- lustre/lod/lod_object.c | 408 +++++++++++++++++--------------------- lustre/lod/lod_qos.c | 6 +- lustre/lod/lod_sub_object.c | 139 ++++++------- lustre/mdd/mdd_dir.c | 116 +++++------ lustre/mdd/mdd_internal.h | 24 +-- lustre/mdd/mdd_object.c | 37 ++-- lustre/mdd/mdd_orphans.c | 34 ++-- lustre/mdt/mdt_open.c | 38 ++-- lustre/mdt/mdt_reint.c | 4 +- lustre/ofd/ofd_fmd.c | 2 +- lustre/ofd/ofd_internal.h | 2 +- lustre/ofd/ofd_obd.c | 4 +- lustre/ofd/ofd_objects.c | 2 +- lustre/osd-ldiskfs/osd_handler.c | 331 +++++++++++-------------------- lustre/osd-ldiskfs/osd_internal.h | 26 +-- lustre/osd-zfs/osd_internal.h | 2 +- lustre/osd-zfs/osd_object.c | 101 +++++----- lustre/osp/osp_internal.h | 15 +- lustre/osp/osp_md_object.c | 74 ++++--- lustre/osp/osp_object.c | 41 ++-- lustre/osp/osp_precreate.c | 2 +- lustre/osp/osp_trans.c | 2 +- lustre/target/out_lib.c | 7 +- lustre/target/update_records.c | 8 +- 27 files changed, 683 insertions(+), 906 deletions(-) diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index f8e63c6..c79cc02 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -966,10 +966,8 @@ struct dt_object_operations { * \retval 0 on success * \retval negative negated errno on error */ - int (*do_object_sync)(const struct lu_env *env, - struct dt_object *obj, - __u64 start, - __u64 end); + int (*do_object_sync)(const struct lu_env *env, struct dt_object *obj, + __u64 start, __u64 end); /** * Lock object. diff --git a/lustre/include/lustre_update.h b/lustre/include/lustre_update.h index 25375cb..bed00f9 100644 --- a/lustre/include/lustre_update.h +++ b/lustre/include/lustre_update.h @@ -421,10 +421,8 @@ int out_create_pack(const struct lu_env *env, struct object_update *update, size_t *max_update_size, const struct lu_fid *fid, const struct lu_attr *attr, struct dt_allocation_hint *hint, struct dt_object_format *dof); -int out_object_destroy_pack(const struct lu_env *env, - struct object_update *update, - size_t *max_update_size, - const struct lu_fid *fid); +int out_destroy_pack(const struct lu_env *env, struct object_update *update, + size_t *max_update_size, const struct lu_fid *fid); int out_index_delete_pack(const struct lu_env *env, struct object_update *update, size_t *max_update_size, const struct lu_fid *fid, const struct dt_key *key); @@ -519,8 +517,8 @@ size_t update_records_ref_add_size(const struct lu_env *env, const struct lu_fid *fid); size_t update_records_ref_del_size(const struct lu_env *env, const struct lu_fid *fid); -size_t update_records_object_destroy_size(const struct lu_env *env, - const struct lu_fid *fid); +size_t update_records_destroy_size(const struct lu_env *env, + const struct lu_fid *fid); size_t update_records_index_insert_size(const struct lu_env *env, const struct lu_fid *fid, const struct dt_rec *rec, @@ -580,14 +578,13 @@ int update_records_ref_del_pack(const struct lu_env *env, unsigned int *param_count, size_t *max_param_size, const struct lu_fid *fid); -int update_records_object_destroy_pack(const struct lu_env *env, - struct update_ops *ops, - unsigned int *op_count, - size_t *max_ops_size, - struct update_params *params, - unsigned int *param_count, - size_t *max_param_size, - const struct lu_fid *fid); +int update_records_destroy_pack(const struct lu_env *env, + struct update_ops *ops, unsigned int *op_count, + size_t *max_ops_size, + struct update_params *params, + unsigned int *param_count, + size_t *max_param_size, + const struct lu_fid *fid); int update_records_index_insert_pack(const struct lu_env *env, struct update_ops *ops, unsigned int *op_count, diff --git a/lustre/lod/lod_internal.h b/lustre/lod/lod_internal.h index c88439e..03c19cc 100644 --- a/lustre/lod/lod_internal.h +++ b/lustre/lod/lod_internal.h @@ -644,10 +644,10 @@ extern struct dt_object_operations lod_obj_ops; extern struct lu_object_operations lod_lu_obj_ops; int lod_load_lmv_shards(const struct lu_env *env, struct lod_object *lo, struct lu_buf *buf, bool resize); -int lod_declare_striped_object(const struct lu_env *env, struct dt_object *dt, +int lod_declare_striped_create(const struct lu_env *env, struct dt_object *dt, struct lu_attr *attr, const struct lu_buf *lovea, struct thandle *th); -int lod_striping_create(const struct lu_env *env, struct dt_object *dt, +int lod_striped_create(const struct lu_env *env, struct dt_object *dt, struct lu_attr *attr, struct dt_object_format *dof, struct thandle *th); void lod_object_free_striping(const struct lu_env *env, struct lod_object *lo); @@ -661,84 +661,59 @@ struct thandle *lod_sub_get_thandle(const struct lu_env *env, struct thandle *th, const struct dt_object *sub_obj, bool *record_update); -int lod_sub_object_declare_create(const struct lu_env *env, - struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th); -int lod_sub_object_create(const struct lu_env *env, struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th); -int lod_sub_object_declare_ref_add(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th); -int lod_sub_object_ref_add(const struct lu_env *env, struct dt_object *dt, - struct thandle *th); -int lod_sub_object_declare_ref_del(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th); -int lod_sub_object_ref_del(const struct lu_env *env, struct dt_object *dt, - struct thandle *th); -int lod_sub_object_declare_destroy(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th); -int lod_sub_object_destroy(const struct lu_env *env, struct dt_object *dt, - struct thandle *th); -int lod_sub_object_declare_insert(const struct lu_env *env, - struct dt_object *dt, - const struct dt_rec *rec, - const struct dt_key *key, - struct thandle *th); -int lod_sub_object_index_insert(const struct lu_env *env, struct dt_object *dt, - const struct dt_rec *rec, - const struct dt_key *key, struct thandle *th, - int ign); -int lod_sub_object_declare_delete(const struct lu_env *env, - struct dt_object *dt, - const struct dt_key *key, - struct thandle *th); -int lod_sub_object_delete(const struct lu_env *env, struct dt_object *dt, - const struct dt_key *name, struct thandle *th); -int lod_sub_object_declare_xattr_set(const struct lu_env *env, - struct dt_object *dt, - const struct lu_buf *buf, - const char *name, int fl, - struct thandle *th); -int lod_sub_object_xattr_set(const struct lu_env *env, struct dt_object *dt, - const struct lu_buf *buf, const char *name, int fl, - struct thandle *th); -int lod_sub_object_declare_attr_set(const struct lu_env *env, - struct dt_object *dt, - const struct lu_attr *attr, - struct thandle *th); -int lod_sub_object_attr_set(const struct lu_env *env, - struct dt_object *dt, - const struct lu_attr *attr, +int lod_sub_declare_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, + struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th); +int lod_sub_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th); +int lod_sub_declare_ref_add(const struct lu_env *env, struct dt_object *dt, struct thandle *th); -int lod_sub_object_declare_xattr_del(const struct lu_env *env, - struct dt_object *dt, - const char *name, - struct thandle *th); -int lod_sub_object_xattr_del(const struct lu_env *env, - struct dt_object *dt, - const char *name, - struct thandle *th); -int lod_sub_object_declare_write(const struct lu_env *env, - struct dt_object *dt, - const struct lu_buf *buf, loff_t pos, - struct thandle *th); -ssize_t lod_sub_object_write(const struct lu_env *env, struct dt_object *dt, - const struct lu_buf *buf, loff_t *pos, - struct thandle *th, int rq); -int lod_sub_object_declare_punch(const struct lu_env *env, - struct dt_object *dt, - __u64 start, __u64 end, - struct thandle *th); -int lod_sub_object_punch(const struct lu_env *env, struct dt_object *dt, - __u64 start, __u64 end, struct thandle *th); +int lod_sub_ref_add(const struct lu_env *env, struct dt_object *dt, + struct thandle *th); +int lod_sub_declare_ref_del(const struct lu_env *env, struct dt_object *dt, + struct thandle *th); +int lod_sub_ref_del(const struct lu_env *env, struct dt_object *dt, + struct thandle *th); +int lod_sub_declare_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th); +int lod_sub_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th); +int lod_sub_declare_insert(const struct lu_env *env, struct dt_object *dt, + const struct dt_rec *rec, const struct dt_key *key, + struct thandle *th); +int lod_sub_insert(const struct lu_env *env, struct dt_object *dt, + const struct dt_rec *rec, const struct dt_key *key, + struct thandle *th, int ign); +int lod_sub_declare_delete(const struct lu_env *env, struct dt_object *dt, + const struct dt_key *key, struct thandle *th); +int lod_sub_delete(const struct lu_env *env, struct dt_object *dt, + const struct dt_key *name, struct thandle *th); +int lod_sub_declare_xattr_set(const struct lu_env *env, struct dt_object *dt, + const struct lu_buf *buf, const char *name, + int fl, struct thandle *th); +int lod_sub_xattr_set(const struct lu_env *env, struct dt_object *dt, + const struct lu_buf *buf, const char *name, int fl, + struct thandle *th); +int lod_sub_declare_attr_set(const struct lu_env *env, struct dt_object *dt, + const struct lu_attr *attr, struct thandle *th); +int lod_sub_attr_set(const struct lu_env *env, struct dt_object *dt, + const struct lu_attr *attr, struct thandle *th); +int lod_sub_declare_xattr_del(const struct lu_env *env, struct dt_object *dt, + const char *name, struct thandle *th); +int lod_sub_xattr_del(const struct lu_env *env, struct dt_object *dt, + const char *name, struct thandle *th); +int lod_sub_declare_write(const struct lu_env *env, struct dt_object *dt, + const struct lu_buf *buf, loff_t pos, + struct thandle *th); +ssize_t lod_sub_write(const struct lu_env *env, struct dt_object *dt, + const struct lu_buf *buf, loff_t *pos, + struct thandle *th, int rq); +int lod_sub_declare_punch(const struct lu_env *env, struct dt_object *dt, + __u64 start, __u64 end, struct thandle *th); +int lod_sub_punch(const struct lu_env *env, struct dt_object *dt, + __u64 start, __u64 end, struct thandle *th); int lod_sub_prep_llog(const struct lu_env *env, struct lod_device *lod, struct dt_device *dt, int index); diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index 7b02db6..52537b6 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -68,8 +68,8 @@ static const struct dt_body_operations lod_body_ops; * * \see dt_index_operations::dio_lookup() in the API description for details. */ -static int lod_index_lookup(const struct lu_env *env, struct dt_object *dt, - struct dt_rec *rec, const struct dt_key *key) +static int lod_lookup(const struct lu_env *env, struct dt_object *dt, + struct dt_rec *rec, const struct dt_key *key) { struct dt_object *next = dt_object_child(dt); return next->do_index_ops->dio_lookup(env, next, rec, key); @@ -83,14 +83,11 @@ static int lod_index_lookup(const struct lu_env *env, struct dt_object *dt, * \see dt_index_operations::dio_declare_insert() in the API description * for details. */ -static int lod_declare_index_insert(const struct lu_env *env, - struct dt_object *dt, - const struct dt_rec *rec, - const struct dt_key *key, - struct thandle *th) +static int lod_declare_insert(const struct lu_env *env, struct dt_object *dt, + const struct dt_rec *rec, + const struct dt_key *key, struct thandle *th) { - return lod_sub_object_declare_insert(env, dt_object_child(dt), - rec, key, th); + return lod_sub_declare_insert(env, dt_object_child(dt), rec, key, th); } /** @@ -100,15 +97,11 @@ static int lod_declare_index_insert(const struct lu_env *env, * * \see dt_index_operations::dio_insert() in the API description for details. */ -static int lod_index_insert(const struct lu_env *env, - struct dt_object *dt, - const struct dt_rec *rec, - const struct dt_key *key, - struct thandle *th, - int ign) +static int lod_insert(const struct lu_env *env, struct dt_object *dt, + const struct dt_rec *rec, const struct dt_key *key, + struct thandle *th, int ign) { - return lod_sub_object_index_insert(env, dt_object_child(dt), rec, key, - th, ign); + return lod_sub_insert(env, dt_object_child(dt), rec, key, th, ign); } /** @@ -119,13 +112,10 @@ static int lod_index_insert(const struct lu_env *env, * \see dt_index_operations::dio_declare_delete() in the API description * for details. */ -static int lod_declare_index_delete(const struct lu_env *env, - struct dt_object *dt, - const struct dt_key *key, - struct thandle *th) +static int lod_declare_delete(const struct lu_env *env, struct dt_object *dt, + const struct dt_key *key, struct thandle *th) { - return lod_sub_object_declare_delete(env, dt_object_child(dt), key, - th); + return lod_sub_declare_delete(env, dt_object_child(dt), key, th); } /** @@ -135,12 +125,10 @@ static int lod_declare_index_delete(const struct lu_env *env, * * \see dt_index_operations::dio_delete() in the API description for details. */ -static int lod_index_delete(const struct lu_env *env, - struct dt_object *dt, - const struct dt_key *key, - struct thandle *th) +static int lod_delete(const struct lu_env *env, struct dt_object *dt, + const struct dt_key *key, struct thandle *th) { - return lod_sub_object_delete(env, dt_object_child(dt), key, th); + return lod_sub_delete(env, dt_object_child(dt), key, th); } /** @@ -358,11 +346,11 @@ static int lod_it_key_rec(const struct lu_env *env, const struct dt_it *di, } static struct dt_index_operations lod_index_ops = { - .dio_lookup = lod_index_lookup, - .dio_declare_insert = lod_declare_index_insert, - .dio_insert = lod_index_insert, - .dio_declare_delete = lod_declare_index_delete, - .dio_delete = lod_index_delete, + .dio_lookup = lod_lookup, + .dio_declare_insert = lod_declare_insert, + .dio_insert = lod_insert, + .dio_declare_delete = lod_declare_delete, + .dio_delete = lod_delete, .dio_it = { .init = lod_it_init, .fini = lod_it_fini, @@ -727,11 +715,11 @@ static int lod_striped_it_load(const struct lu_env *env, } static struct dt_index_operations lod_striped_index_ops = { - .dio_lookup = lod_index_lookup, - .dio_declare_insert = lod_declare_index_insert, - .dio_insert = lod_index_insert, - .dio_declare_delete = lod_declare_index_delete, - .dio_delete = lod_index_delete, + .dio_lookup = lod_lookup, + .dio_declare_insert = lod_declare_insert, + .dio_insert = lod_insert, + .dio_declare_delete = lod_declare_delete, + .dio_delete = lod_delete, .dio_it = { .init = lod_striped_it_init, .fini = lod_striped_it_fini, @@ -994,8 +982,8 @@ static int lod_index_try(const struct lu_env *env, struct dt_object *dt, * * \see dt_object_operations::do_read_lock() in the API description for details. */ -static void lod_object_read_lock(const struct lu_env *env, - struct dt_object *dt, unsigned role) +static void lod_read_lock(const struct lu_env *env, struct dt_object *dt, + unsigned role) { dt_read_lock(env, dt_object_child(dt), role); } @@ -1006,8 +994,8 @@ static void lod_object_read_lock(const struct lu_env *env, * \see dt_object_operations::do_write_lock() in the API description for * details. */ -static void lod_object_write_lock(const struct lu_env *env, - struct dt_object *dt, unsigned role) +static void lod_write_lock(const struct lu_env *env, struct dt_object *dt, + unsigned role) { dt_write_lock(env, dt_object_child(dt), role); } @@ -1018,8 +1006,7 @@ static void lod_object_write_lock(const struct lu_env *env, * \see dt_object_operations::do_read_unlock() in the API description for * details. */ -static void lod_object_read_unlock(const struct lu_env *env, - struct dt_object *dt) +static void lod_read_unlock(const struct lu_env *env, struct dt_object *dt) { dt_read_unlock(env, dt_object_child(dt)); } @@ -1030,8 +1017,7 @@ static void lod_object_read_unlock(const struct lu_env *env, * \see dt_object_operations::do_write_unlock() in the API description for * details. */ -static void lod_object_write_unlock(const struct lu_env *env, - struct dt_object *dt) +static void lod_write_unlock(const struct lu_env *env, struct dt_object *dt) { dt_write_unlock(env, dt_object_child(dt)); } @@ -1042,8 +1028,7 @@ static void lod_object_write_unlock(const struct lu_env *env, * \see dt_object_operations::do_write_locked() in the API description for * details. */ -static int lod_object_write_locked(const struct lu_env *env, - struct dt_object *dt) +static int lod_write_locked(const struct lu_env *env, struct dt_object *dt) { return dt_write_locked(env, dt_object_child(dt)); } @@ -1099,10 +1084,9 @@ lod_obj_stripe_attr_set_cb(const struct lu_env *env, struct lod_object *lo, int stripe_idx, struct lod_obj_stripe_cb_data *data) { if (data->locd_declare) - return lod_sub_object_declare_attr_set(env, dt, - data->locd_attr, th); - else - return lod_sub_object_attr_set(env, dt, data->locd_attr, th); + return lod_sub_declare_attr_set(env, dt, data->locd_attr, th); + + return lod_sub_attr_set(env, dt, data->locd_attr, th); } /** @@ -1126,7 +1110,7 @@ static int lod_declare_attr_set(const struct lu_env *env, /* * declare setattr on the local object */ - rc = lod_sub_object_declare_attr_set(env, next, attr, th); + rc = lod_sub_declare_attr_set(env, next, attr, th); if (rc) RETURN(rc); @@ -1170,9 +1154,8 @@ static int lod_declare_attr_set(const struct lu_env *env, for (i = 0; i < lo->ldo_dir_stripenr; i++) { if (lo->ldo_stripe[i] == NULL) continue; - rc = lod_sub_object_declare_attr_set(env, - lo->ldo_stripe[i], attr, - th); + rc = lod_sub_declare_attr_set(env, lo->ldo_stripe[i], + attr, th); if (rc != 0) RETURN(rc); } @@ -1193,8 +1176,7 @@ static int lod_declare_attr_set(const struct lu_env *env, RETURN(0); if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LOST_STRIPE)) { - rc = lod_sub_object_declare_xattr_del(env, next, - XATTR_NAME_LOV, th); + rc = lod_sub_declare_xattr_del(env, next, XATTR_NAME_LOV, th); RETURN(rc); } @@ -1205,9 +1187,8 @@ static int lod_declare_attr_set(const struct lu_env *env, buf->lb_buf = info->lti_ea_store; buf->lb_len = info->lti_ea_store_size; - rc = lod_sub_object_declare_xattr_set(env, next, buf, - XATTR_NAME_LOV, - LU_XATTR_REPLACE, th); + rc = lod_sub_declare_xattr_set(env, next, buf, XATTR_NAME_LOV, + LU_XATTR_REPLACE, th); } RETURN(rc); @@ -1234,7 +1215,7 @@ static int lod_attr_set(const struct lu_env *env, /* * apply changes to the local object */ - rc = lod_sub_object_attr_set(env, next, attr, th); + rc = lod_sub_attr_set(env, next, attr, th); if (rc) RETURN(rc); @@ -1266,8 +1247,7 @@ static int lod_attr_set(const struct lu_env *env, if ((dt_object_exists(lo->ldo_stripe[i]) == 0)) continue; - rc = lod_sub_object_attr_set(env, lo->ldo_stripe[i], - attr, th); + rc = lod_sub_attr_set(env, lo->ldo_stripe[i], attr, th); if (rc != 0) break; } @@ -1288,7 +1268,7 @@ static int lod_attr_set(const struct lu_env *env, RETURN(0); if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LOST_STRIPE)) { - rc = lod_sub_object_xattr_del(env, next, XATTR_NAME_LOV, th); + rc = lod_sub_xattr_del(env, next, XATTR_NAME_LOV, th); RETURN(rc); } @@ -1328,8 +1308,8 @@ static int lod_attr_set(const struct lu_env *env, fid_to_ostid(fid, oi); ostid_cpu_to_le(oi, &objs->l_ost_oi); - rc = lod_sub_object_xattr_set(env, next, buf, XATTR_NAME_LOV, - LU_XATTR_REPLACE, th); + rc = lod_sub_xattr_set(env, next, buf, XATTR_NAME_LOV, + LU_XATTR_REPLACE, th); } else if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_BAD_PFL_RANGE)) { struct lod_thread_info *info = lod_env_info(env); struct lu_buf *buf = &info->lti_buf; @@ -1351,8 +1331,8 @@ static int lod_attr_set(const struct lu_env *env, le64_add_cpu(&lcme->lcme_extent.e_start, 1); le64_add_cpu(&lcme->lcme_extent.e_end, -1); - rc = lod_sub_object_xattr_set(env, next, buf, XATTR_NAME_LOV, - LU_XATTR_REPLACE, th); + rc = lod_sub_xattr_set(env, next, buf, XATTR_NAME_LOV, + LU_XATTR_REPLACE, th); } RETURN(rc); @@ -1701,31 +1681,29 @@ static int lod_dir_declare_create_stripes(const struct lu_env *env, struct linkea_data ldata = { NULL }; struct lu_buf linkea_buf; - rc = lod_sub_object_declare_create(env, dto, attr, NULL, - dof, th); + rc = lod_sub_declare_create(env, dto, attr, NULL, dof, th); if (rc != 0) GOTO(out, rc); if (!dt_try_as_dir(env, dto)) GOTO(out, rc = -EINVAL); - rc = lod_sub_object_declare_ref_add(env, dto, th); + rc = lod_sub_declare_ref_add(env, dto, th); if (rc != 0) GOTO(out, rc); rec->rec_fid = lu_object_fid(&dto->do_lu); - rc = lod_sub_object_declare_insert(env, dto, - (const struct dt_rec *)rec, - (const struct dt_key *)dot, th); + rc = lod_sub_declare_insert(env, dto, + (const struct dt_rec *)rec, + (const struct dt_key *)dot, th); if (rc != 0) GOTO(out, rc); /* master stripe FID will be put to .. */ rec->rec_fid = lu_object_fid(&dt->do_lu); - rc = lod_sub_object_declare_insert(env, dto, - (const struct dt_rec *)rec, - (const struct dt_key *)dotdot, - th); + rc = lod_sub_declare_insert(env, dto, + (const struct dt_rec *)rec, + (const struct dt_key *)dotdot, th); if (rc != 0) GOTO(out, rc); @@ -1738,8 +1716,8 @@ static int lod_dir_declare_create_stripes(const struct lu_env *env, else slave_lmm->lmv_master_mdt_index = cpu_to_le32(i); - rc = lod_sub_object_declare_xattr_set(env, dto, - &slave_lmv_buf, XATTR_NAME_LMV, 0, th); + rc = lod_sub_declare_xattr_set(env, dto, &slave_lmv_buf, + XATTR_NAME_LMV, 0, th); if (rc != 0) GOTO(out, rc); } @@ -1760,27 +1738,26 @@ static int lod_dir_declare_create_stripes(const struct lu_env *env, linkea_buf.lb_buf = ldata.ld_buf->lb_buf; linkea_buf.lb_len = ldata.ld_leh->leh_len; - rc = lod_sub_object_declare_xattr_set(env, dto, &linkea_buf, - XATTR_NAME_LINK, 0, th); + rc = lod_sub_declare_xattr_set(env, dto, &linkea_buf, + XATTR_NAME_LINK, 0, th); if (rc != 0) GOTO(out, rc); rec->rec_fid = lu_object_fid(&dto->do_lu); - rc = lod_sub_object_declare_insert(env, dt_object_child(dt), - (const struct dt_rec *)rec, - (const struct dt_key *)stripe_name, - th); + rc = lod_sub_declare_insert(env, dt_object_child(dt), + (const struct dt_rec *)rec, + (const struct dt_key *)stripe_name, + th); if (rc != 0) GOTO(out, rc); - rc = lod_sub_object_declare_ref_add(env, dt_object_child(dt), - th); + rc = lod_sub_declare_ref_add(env, dt_object_child(dt), th); if (rc != 0) GOTO(out, rc); } - rc = lod_sub_object_declare_xattr_set(env, dt_object_child(dt), - &lmv_buf, XATTR_NAME_LMV, 0, th); + rc = lod_sub_declare_xattr_set(env, dt_object_child(dt), + &lmv_buf, XATTR_NAME_LMV, 0, th); if (rc != 0) GOTO(out, rc); out: @@ -2047,7 +2024,7 @@ static int lod_dir_declare_xattr_set(const struct lu_env *env, RETURN(rc); } - rc = lod_sub_object_declare_xattr_set(env, next, buf, name, fl, th); + rc = lod_sub_declare_xattr_set(env, next, buf, name, fl, th); if (rc != 0) RETURN(rc); @@ -2069,8 +2046,8 @@ static int lod_dir_declare_xattr_set(const struct lu_env *env, for (i = 0; i < lo->ldo_dir_stripenr; i++) { LASSERT(lo->ldo_stripe[i]); - rc = lod_sub_object_declare_xattr_set(env, lo->ldo_stripe[i], - buf, name, fl, th); + rc = lod_sub_declare_xattr_set(env, lo->ldo_stripe[i], + buf, name, fl, th); if (rc != 0) break; } @@ -2103,12 +2080,11 @@ lod_obj_stripe_replace_parent_fid_cb(const struct lu_env *env, ff->ff_parent.f_ver = stripe_idx; fid_cpu_to_le(&ff->ff_parent, &ff->ff_parent); if (data->locd_declare) - rc = lod_sub_object_declare_xattr_set(env, dt, buf, - XATTR_NAME_FID, - LU_XATTR_REPLACE, th); + rc = lod_sub_declare_xattr_set(env, dt, buf, XATTR_NAME_FID, + LU_XATTR_REPLACE, th); else - rc = lod_sub_object_xattr_set(env, dt, buf, XATTR_NAME_FID, - LU_XATTR_REPLACE, th); + rc = lod_sub_xattr_set(env, dt, buf, XATTR_NAME_FID, + LU_XATTR_REPLACE, th); return rc; } @@ -2128,9 +2104,9 @@ lod_obj_stripe_replace_parent_fid_cb(const struct lu_env *env, * \retval 0 if reset succeeds * \retval negative errno if reset fails */ -static int lod_object_replace_parent_fid(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th, bool declare) +static int lod_replace_parent_fid(const struct lu_env *env, + struct dt_object *dt, + struct thandle *th, bool declare) { struct lod_object *lo = lod_dt_obj(dt); struct lod_thread_info *info = lod_env_info(env); @@ -2315,7 +2291,7 @@ static int lod_declare_layout_add(const struct lu_env *env, * later when generating component ID for the new components */ info->lti_buf.lb_len = lod_comp_md_size(lo, false); - rc = lod_sub_object_declare_xattr_set(env, next, &info->lti_buf, + rc = lod_sub_declare_xattr_set(env, next, &info->lti_buf, XATTR_NAME_LOV, 0, th); if (rc) GOTO(error, rc); @@ -2408,8 +2384,8 @@ static int lod_declare_layout_set(const struct lu_env *env, lod_obj_inc_layout_gen(lo); info->lti_buf.lb_len = lod_comp_md_size(lo, false); - rc = lod_sub_object_declare_xattr_set(env, dt, &info->lti_buf, - XATTR_NAME_LOV, 0, th); + rc = lod_sub_declare_xattr_set(env, dt, &info->lti_buf, + XATTR_NAME_LOV, 0, th); RETURN(rc); } @@ -2511,7 +2487,7 @@ static int lod_declare_layout_del(const struct lu_env *env, if (obj == NULL) continue; - rc = lod_sub_object_declare_destroy(env, obj, th); + rc = lod_sub_declare_destroy(env, obj, th); if (rc) RETURN(rc); } @@ -2526,17 +2502,16 @@ static int lod_declare_layout_del(const struct lu_env *env, memset(attr, 0, sizeof(*attr)); attr->la_valid = LA_SIZE; - rc = lod_sub_object_declare_attr_set(env, next, attr, th); + rc = lod_sub_declare_attr_set(env, next, attr, th); if (rc) RETURN(rc); if (left > 0) { info->lti_buf.lb_len = lod_comp_md_size(lo, false); - rc = lod_sub_object_declare_xattr_set(env, next, &info->lti_buf, - XATTR_NAME_LOV, 0, th); + rc = lod_sub_declare_xattr_set(env, next, &info->lti_buf, + XATTR_NAME_LOV, 0, th); } else { - rc = lod_sub_object_declare_xattr_del(env, next, XATTR_NAME_LOV, - th); + rc = lod_sub_declare_xattr_del(env, next, XATTR_NAME_LOV, th); } RETURN(rc); @@ -2656,7 +2631,7 @@ static int lod_declare_xattr_set(const struct lu_env *env, attr->la_valid = LA_TYPE | LA_MODE; attr->la_mode = S_IFREG; } - rc = lod_declare_striped_object(env, dt, attr, buf, th); + rc = lod_declare_striped_create(env, dt, attr, buf, th); } else if (S_ISREG(mode) && strlen(name) > strlen(XATTR_LUSTRE_LOV) + 1 && strncmp(name, XATTR_LUSTRE_LOV, @@ -2672,10 +2647,9 @@ static int lod_declare_xattr_set(const struct lu_env *env, } else if (S_ISDIR(mode)) { rc = lod_dir_declare_xattr_set(env, dt, buf, name, fl, th); } else if (strcmp(name, XATTR_NAME_FID) == 0) { - rc = lod_object_replace_parent_fid(env, dt, th, true); + rc = lod_replace_parent_fid(env, dt, th, true); } else { - rc = lod_sub_object_declare_xattr_set(env, next, buf, name, - fl, th); + rc = lod_sub_declare_xattr_set(env, next, buf, name, fl, th); } RETURN(rc); @@ -2708,7 +2682,7 @@ static int lod_xattr_set_internal(const struct lu_env *env, int i; ENTRY; - rc = lod_sub_object_xattr_set(env, next, buf, name, fl, th); + rc = lod_sub_xattr_set(env, next, buf, name, fl, th); if (rc != 0 || !S_ISDIR(dt->do_lu.lo_header->loh_attr)) RETURN(rc); @@ -2722,8 +2696,8 @@ static int lod_xattr_set_internal(const struct lu_env *env, for (i = 0; i < lo->ldo_dir_stripenr; i++) { LASSERT(lo->ldo_stripe[i]); - rc = lod_sub_object_xattr_set(env, lo->ldo_stripe[i], buf, name, - fl, th); + rc = lod_sub_xattr_set(env, lo->ldo_stripe[i], buf, name, + fl, th); if (rc != 0) break; } @@ -2754,7 +2728,7 @@ static int lod_xattr_del_internal(const struct lu_env *env, int i; ENTRY; - rc = lod_sub_object_xattr_del(env, next, name, th); + rc = lod_sub_xattr_del(env, next, name, th); if (rc != 0 || !S_ISDIR(dt->do_lu.lo_header->loh_attr)) RETURN(rc); @@ -2764,8 +2738,7 @@ static int lod_xattr_del_internal(const struct lu_env *env, for (i = 0; i < lo->ldo_dir_stripenr; i++) { LASSERT(lo->ldo_stripe[i]); - rc = lod_sub_object_xattr_del(env, lo->ldo_stripe[i], name, - th); + rc = lod_sub_xattr_del(env, lo->ldo_stripe[i], name, th); if (rc != 0) break; } @@ -2974,28 +2947,26 @@ static int lod_xattr_set_lmv(const struct lu_env *env, struct dt_object *dt, dto = lo->ldo_stripe[i]; dt_write_lock(env, dto, MOR_TGT_CHILD); - rc = lod_sub_object_create(env, dto, attr, NULL, dof, - th); + rc = lod_sub_create(env, dto, attr, NULL, dof, th); if (rc != 0) { dt_write_unlock(env, dto); GOTO(out, rc); } - rc = lod_sub_object_ref_add(env, dto, th); + rc = lod_sub_ref_add(env, dto, th); dt_write_unlock(env, dto); if (rc != 0) GOTO(out, rc); rec->rec_fid = lu_object_fid(&dto->do_lu); - rc = lod_sub_object_index_insert(env, dto, - (const struct dt_rec *)rec, - (const struct dt_key *)dot, th, 0); + rc = lod_sub_insert(env, dto, (const struct dt_rec *)rec, + (const struct dt_key *)dot, th, 0); if (rc != 0) GOTO(out, rc); rec->rec_fid = lu_object_fid(&dt->do_lu); - rc = lod_sub_object_index_insert(env, dto, (struct dt_rec *)rec, - (const struct dt_key *)dotdot, th, 0); + rc = lod_sub_insert(env, dto, (struct dt_rec *)rec, + (const struct dt_key *)dotdot, th, 0); if (rc != 0) GOTO(out, rc); @@ -3009,8 +2980,8 @@ static int lod_xattr_set_lmv(const struct lu_env *env, struct dt_object *dt, slave_lmm->lmv_master_mdt_index = cpu_to_le32(i); - rc = lod_sub_object_xattr_set(env, dto, &slave_lmv_buf, - XATTR_NAME_LMV, fl, th); + rc = lod_sub_xattr_set(env, dto, &slave_lmv_buf, + XATTR_NAME_LMV, fl, th); if (rc != 0) GOTO(out, rc); } @@ -3031,26 +3002,26 @@ static int lod_xattr_set_lmv(const struct lu_env *env, struct dt_object *dt, linkea_buf.lb_buf = ldata.ld_buf->lb_buf; linkea_buf.lb_len = ldata.ld_leh->leh_len; - rc = lod_sub_object_xattr_set(env, dto, &linkea_buf, - XATTR_NAME_LINK, 0, th); + rc = lod_sub_xattr_set(env, dto, &linkea_buf, + XATTR_NAME_LINK, 0, th); if (rc != 0) GOTO(out, rc); rec->rec_fid = lu_object_fid(&dto->do_lu); - rc = lod_sub_object_index_insert(env, dt_object_child(dt), - (const struct dt_rec *)rec, - (const struct dt_key *)stripe_name, th, 0); + rc = lod_sub_insert(env, dt_object_child(dt), + (const struct dt_rec *)rec, + (const struct dt_key *)stripe_name, th, 0); if (rc != 0) GOTO(out, rc); - rc = lod_sub_object_ref_add(env, dt_object_child(dt), th); + rc = lod_sub_ref_add(env, dt_object_child(dt), th); if (rc != 0) GOTO(out, rc); } if (!OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LOST_MASTER_LMV)) - rc = lod_sub_object_xattr_set(env, dt_object_child(dt), - &lmv_buf, XATTR_NAME_LMV, fl, th); + rc = lod_sub_xattr_set(env, dt_object_child(dt), + &lmv_buf, XATTR_NAME_LMV, fl, th); out: if (slave_lmm != NULL) OBD_FREE_PTR(slave_lmm); @@ -3245,7 +3216,7 @@ static int lod_generate_and_set_lovea(const struct lu_env *env, if (lo->ldo_comp_cnt == 0) { lod_object_free_striping(env, lo); - rc = lod_sub_object_xattr_del(env, next, XATTR_NAME_LOV, th); + rc = lod_sub_xattr_del(env, next, XATTR_NAME_LOV, th); RETURN(rc); } @@ -3263,8 +3234,8 @@ static int lod_generate_and_set_lovea(const struct lu_env *env, info->lti_buf.lb_buf = lmm; info->lti_buf.lb_len = lmm_size; - rc = lod_sub_object_xattr_set(env, next, &info->lti_buf, - XATTR_NAME_LOV, 0, th); + rc = lod_sub_xattr_set(env, next, &info->lti_buf, + XATTR_NAME_LOV, 0, th); RETURN(rc); } @@ -3308,7 +3279,7 @@ static int lod_layout_del(const struct lu_env *env, struct dt_object *dt, if (obj == NULL) continue; - rc = lod_sub_object_destroy(env, obj, th); + rc = lod_sub_destroy(env, obj, th); if (rc) GOTO(out, rc); @@ -3356,7 +3327,7 @@ static int lod_layout_del(const struct lu_env *env, struct dt_object *dt, if (attr->la_size > 0) { attr->la_size = 0; attr->la_valid = LA_SIZE; - rc = lod_sub_object_attr_set(env, next, attr, th); + rc = lod_sub_attr_set(env, next, attr, th); if (rc) GOTO(out, rc); } @@ -3401,8 +3372,7 @@ static int lod_xattr_set(const struct lu_env *env, if (lmm != NULL && le32_to_cpu(lmm->lmv_hash_type) & LMV_HASH_FLAG_MIGRATION) - rc = lod_sub_object_xattr_set(env, next, buf, name, fl, - th); + rc = lod_sub_xattr_set(env, next, buf, name, fl, th); else rc = lod_dir_striping_create(env, dt, NULL, NULL, th); @@ -3432,15 +3402,14 @@ static int lod_xattr_set(const struct lu_env *env, /* free stripes, then update disk */ lod_object_free_striping(env, lod_dt_obj(dt)); - rc = lod_sub_object_xattr_set(env, next, buf, name, - fl, th); + rc = lod_sub_xattr_set(env, next, buf, name, fl, th); } else if (dt_object_remote(dt)) { /* This only happens during migration, see * mdd_migrate_create(), in which Master MDT will * create a remote target object, and only set * (migrating) stripe EA on the remote object, * and does not need creating each stripes. */ - rc = lod_sub_object_xattr_set(env, next, buf, name, + rc = lod_sub_xattr_set(env, next, buf, name, fl, th); } else if (strcmp(name, XATTR_LUSTRE_LOV".del") == 0) { /* delete component(s) */ @@ -3461,11 +3430,11 @@ static int lod_xattr_set(const struct lu_env *env, !strcmp(name, XATTR_NAME_LOV), !lod_dt_obj(dt)->ldo_comp_cached)); - rc = lod_striping_create(env, dt, NULL, NULL, th); + rc = lod_striped_create(env, dt, NULL, NULL, th); } RETURN(rc); } else if (strcmp(name, XATTR_NAME_FID) == 0) { - rc = lod_object_replace_parent_fid(env, dt, th, false); + rc = lod_replace_parent_fid(env, dt, th, false); RETURN(rc); } @@ -3491,8 +3460,7 @@ static int lod_declare_xattr_del(const struct lu_env *env, int i; ENTRY; - rc = lod_sub_object_declare_xattr_del(env, dt_object_child(dt), - name, th); + rc = lod_sub_declare_xattr_del(env, dt_object_child(dt), name, th); if (rc != 0) RETURN(rc); @@ -3509,8 +3477,8 @@ static int lod_declare_xattr_del(const struct lu_env *env, for (i = 0; i < lo->ldo_dir_stripenr; i++) { LASSERT(lo->ldo_stripe[i]); - rc = lod_sub_object_declare_xattr_del(env, lo->ldo_stripe[i], - name, th); + rc = lod_sub_declare_xattr_del(env, lo->ldo_stripe[i], + name, th); if (rc != 0) break; } @@ -3538,7 +3506,7 @@ static int lod_xattr_del(const struct lu_env *env, struct dt_object *dt, if (!strcmp(name, XATTR_NAME_LOV)) lod_object_free_striping(env, lod_dt_obj(dt)); - rc = lod_sub_object_xattr_del(env, next, name, th); + rc = lod_sub_xattr_del(env, next, name, th); if (rc != 0 || !S_ISDIR(dt->do_lu.lo_header->loh_attr)) RETURN(rc); @@ -3548,7 +3516,7 @@ static int lod_xattr_del(const struct lu_env *env, struct dt_object *dt, for (i = 0; i < lo->ldo_dir_stripenr; i++) { LASSERT(lo->ldo_stripe[i]); - rc = lod_sub_object_xattr_del(env, lo->ldo_stripe[i], name, th); + rc = lod_sub_xattr_del(env, lo->ldo_stripe[i], name, th); if (rc != 0) break; } @@ -4129,7 +4097,7 @@ static int lod_declare_init_size(const struct lu_env *env, attr->la_valid = LA_SIZE; attr->la_size = size; - rc = lod_sub_object_declare_attr_set(env, objects[stripe], attr, th); + rc = lod_sub_declare_attr_set(env, objects[stripe], attr, th); RETURN(rc); } @@ -4153,7 +4121,7 @@ static int lod_declare_init_size(const struct lu_env *env, * \retval 0 on success * \retval negative if failed */ -int lod_declare_striped_object(const struct lu_env *env, struct dt_object *dt, +int lod_declare_striped_create(const struct lu_env *env, struct dt_object *dt, struct lu_attr *attr, const struct lu_buf *lovea, struct thandle *th) { @@ -4186,8 +4154,8 @@ int lod_declare_striped_object(const struct lu_env *env, struct dt_object *dt, info->lti_buf = *lovea; } - rc = lod_sub_object_declare_xattr_set(env, next, &info->lti_buf, - XATTR_NAME_LOV, 0, th); + rc = lod_sub_declare_xattr_set(env, next, &info->lti_buf, + XATTR_NAME_LOV, 0, th); if (rc) GOTO(out, rc); @@ -4219,12 +4187,10 @@ out: * \see dt_object_operations::do_declare_create() in the API description * for details. */ -static int lod_declare_object_create(const struct lu_env *env, - struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th) +static int lod_declare_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, + struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th) { struct dt_object *next = dt_object_child(dt); struct lod_object *lo = lod_dt_obj(dt); @@ -4238,7 +4204,7 @@ static int lod_declare_object_create(const struct lu_env *env, /* * first of all, we declare creation of local object */ - rc = lod_sub_object_declare_create(env, next, attr, hint, dof, th); + rc = lod_sub_declare_create(env, next, attr, hint, dof, th); if (rc != 0) GOTO(out, rc); @@ -4256,7 +4222,7 @@ static int lod_declare_object_create(const struct lu_env *env, * to use striping, then ->declare_create() behaving differently * should be cleaned */ if (dof->u.dof_reg.striped != 0) - rc = lod_declare_striped_object(env, dt, attr, + rc = lod_declare_striped_create(env, dt, attr, NULL, th); } else if (dof->dof_type == DFT_DIR) { struct seq_server_site *ss; @@ -4340,9 +4306,9 @@ out: * \retval 0 on success * \retval negative if failed */ -int lod_striping_create(const struct lu_env *env, struct dt_object *dt, - struct lu_attr *attr, struct dt_object_format *dof, - struct thandle *th) +int lod_striped_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, struct dt_object_format *dof, + struct thandle *th) { struct lod_layout_component *lod_comp; struct lod_object *lo = lod_dt_obj(dt); @@ -4368,8 +4334,7 @@ int lod_striping_create(const struct lu_env *env, struct dt_object *dt, for (j = 0; j < lod_comp->llc_stripenr; j++) { struct dt_object *object = lod_comp->llc_stripe[j]; LASSERT(object != NULL); - rc = lod_sub_object_create(env, object, attr, NULL, - dof, th); + rc = lod_sub_create(env, object, attr, NULL, dof, th); if (rc) break; } @@ -4396,24 +4361,22 @@ int lod_striping_create(const struct lu_env *env, struct dt_object *dt, * * \see dt_object_operations::do_create() in the API description for details. */ -static int lod_object_create(const struct lu_env *env, struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, struct thandle *th) +static int lod_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th) { int rc; ENTRY; /* create local object */ - rc = lod_sub_object_create(env, dt_object_child(dt), attr, hint, dof, - th); + rc = lod_sub_create(env, dt_object_child(dt), attr, hint, dof, th); if (rc != 0) RETURN(rc); if (S_ISREG(dt->do_lu.lo_header->loh_attr) && lod_obj_is_striped(dt) && dof->u.dof_reg.striped != 0) { LASSERT(lod_dt_obj(dt)->ldo_comp_cached == 0); - rc = lod_striping_create(env, dt, attr, dof, th); + rc = lod_striped_create(env, dt, attr, dof, th); } RETURN(rc); @@ -4425,10 +4388,10 @@ lod_obj_stripe_destroy_cb(const struct lu_env *env, struct lod_object *lo, int stripe_idx, struct lod_obj_stripe_cb_data *data) { if (data->locd_declare) - return lod_sub_object_declare_destroy(env, dt, th); + return lod_sub_declare_destroy(env, dt, th); else if (!OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LOST_SPEOBJ) || stripe_idx == cfs_fail_val) - return lod_sub_object_destroy(env, dt, th); + return lod_sub_destroy(env, dt, th); else return 0; } @@ -4444,9 +4407,8 @@ lod_obj_stripe_destroy_cb(const struct lu_env *env, struct lod_object *lo, * \see dt_object_operations::do_declare_destroy() in the API description * for details. */ -static int lod_declare_object_destroy(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th) +static int lod_declare_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct dt_object *next = dt_object_child(dt); struct lod_object *lo = lod_dt_obj(dt); @@ -4472,14 +4434,14 @@ static int lod_declare_object_destroy(const struct lu_env *env, RETURN(rc); for (i = 0; i < lo->ldo_dir_stripenr; i++) { - rc = lod_sub_object_declare_ref_del(env, next, th); + rc = lod_sub_declare_ref_del(env, next, th); if (rc != 0) RETURN(rc); snprintf(stripe_name, sizeof(info->lti_key), DFID":%d", PFID(lu_object_fid(&lo->ldo_stripe[i]->do_lu)), i); - rc = lod_sub_object_declare_delete(env, next, + rc = lod_sub_declare_delete(env, next, (const struct dt_key *)stripe_name, th); if (rc != 0) RETURN(rc); @@ -4489,7 +4451,7 @@ static int lod_declare_object_destroy(const struct lu_env *env, /* * we declare destroy for the local object */ - rc = lod_sub_object_declare_destroy(env, next, th); + rc = lod_sub_declare_destroy(env, next, th); if (rc) RETURN(rc); @@ -4506,11 +4468,11 @@ static int lod_declare_object_destroy(const struct lu_env *env, if (lo->ldo_stripe[i] == NULL) continue; - rc = lod_sub_object_declare_ref_del(env, - lo->ldo_stripe[i], th); + rc = lod_sub_declare_ref_del(env, lo->ldo_stripe[i], + th); - rc = lod_sub_object_declare_destroy(env, - lo->ldo_stripe[i], th); + rc = lod_sub_declare_destroy(env, lo->ldo_stripe[i], + th); if (rc != 0) break; } @@ -4534,8 +4496,8 @@ static int lod_declare_object_destroy(const struct lu_env *env, * * \see dt_object_operations::do_destroy() in the API description for details. */ -static int lod_object_destroy(const struct lu_env *env, - struct dt_object *dt, struct thandle *th) +static int lod_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct dt_object *next = dt_object_child(dt); struct lod_object *lo = lod_dt_obj(dt); @@ -4553,7 +4515,7 @@ static int lod_object_destroy(const struct lu_env *env, RETURN(rc); for (i = 0; i < lo->ldo_dir_stripenr; i++) { - rc = lod_sub_object_ref_del(env, next, th); + rc = lod_sub_ref_del(env, next, th); if (rc != 0) RETURN(rc); @@ -4565,14 +4527,14 @@ static int lod_object_destroy(const struct lu_env *env, PFID(lu_object_fid(&dt->do_lu)), stripe_name, PFID(lu_object_fid(&lo->ldo_stripe[i]->do_lu))); - rc = lod_sub_object_delete(env, next, + rc = lod_sub_delete(env, next, (const struct dt_key *)stripe_name, th); if (rc != 0) RETURN(rc); } } - rc = lod_sub_object_destroy(env, next, th); + rc = lod_sub_destroy(env, next, th); if (rc != 0) RETURN(rc); @@ -4592,14 +4554,14 @@ static int lod_object_destroy(const struct lu_env *env, i == cfs_fail_val) { dt_write_lock(env, lo->ldo_stripe[i], MOR_TGT_CHILD); - rc = lod_sub_object_ref_del(env, - lo->ldo_stripe[i], th); + rc = lod_sub_ref_del(env, lo->ldo_stripe[i], + th); dt_write_unlock(env, lo->ldo_stripe[i]); if (rc != 0) break; - rc = lod_sub_object_destroy(env, - lo->ldo_stripe[i], th); + rc = lod_sub_destroy(env, lo->ldo_stripe[i], + th); if (rc != 0) break; } @@ -4624,7 +4586,7 @@ static int lod_object_destroy(const struct lu_env *env, static int lod_declare_ref_add(const struct lu_env *env, struct dt_object *dt, struct thandle *th) { - return lod_sub_object_declare_ref_add(env, dt_object_child(dt), th); + return lod_sub_declare_ref_add(env, dt_object_child(dt), th); } /** @@ -4635,7 +4597,7 @@ static int lod_declare_ref_add(const struct lu_env *env, static int lod_ref_add(const struct lu_env *env, struct dt_object *dt, struct thandle *th) { - return lod_sub_object_ref_add(env, dt_object_child(dt), th); + return lod_sub_ref_add(env, dt_object_child(dt), th); } /** @@ -4647,7 +4609,7 @@ static int lod_ref_add(const struct lu_env *env, static int lod_declare_ref_del(const struct lu_env *env, struct dt_object *dt, struct thandle *th) { - return lod_sub_object_declare_ref_del(env, dt_object_child(dt), th); + return lod_sub_declare_ref_del(env, dt_object_child(dt), th); } /** @@ -4658,7 +4620,7 @@ static int lod_declare_ref_del(const struct lu_env *env, static int lod_ref_del(const struct lu_env *env, struct dt_object *dt, struct thandle *th) { - return lod_sub_object_ref_del(env, dt_object_child(dt), th); + return lod_sub_ref_del(env, dt_object_child(dt), th); } /** @@ -4991,8 +4953,8 @@ static int lod_declare_layout_change(const struct lu_env *env, if (!rc) { info->lti_buf.lb_len = lod_comp_md_size(lo, false); - rc = lod_sub_object_declare_xattr_set(env, next, &info->lti_buf, - XATTR_NAME_LOV, 0, th); + rc = lod_sub_declare_xattr_set(env, next, &info->lti_buf, + XATTR_NAME_LOV, 0, th); } out: if (rc) @@ -5013,15 +4975,15 @@ static int lod_layout_change(const struct lu_env *env, struct dt_object *dt, { struct lu_attr *attr = &lod_env_info(env)->lti_attr; - RETURN(lod_striping_create(env, dt, attr, NULL, th)); + RETURN(lod_striped_create(env, dt, attr, NULL, th)); } struct dt_object_operations lod_obj_ops = { - .do_read_lock = lod_object_read_lock, - .do_write_lock = lod_object_write_lock, - .do_read_unlock = lod_object_read_unlock, - .do_write_unlock = lod_object_write_unlock, - .do_write_locked = lod_object_write_locked, + .do_read_lock = lod_read_lock, + .do_write_lock = lod_write_lock, + .do_read_unlock = lod_read_unlock, + .do_write_unlock = lod_write_unlock, + .do_write_locked = lod_write_locked, .do_attr_get = lod_attr_get, .do_declare_attr_set = lod_declare_attr_set, .do_attr_set = lod_attr_set, @@ -5032,10 +4994,10 @@ struct dt_object_operations lod_obj_ops = { .do_xattr_del = lod_xattr_del, .do_xattr_list = lod_xattr_list, .do_ah_init = lod_ah_init, - .do_declare_create = lod_declare_object_create, - .do_create = lod_object_create, - .do_declare_destroy = lod_declare_object_destroy, - .do_destroy = lod_object_destroy, + .do_declare_create = lod_declare_create, + .do_create = lod_create, + .do_declare_destroy = lod_declare_destroy, + .do_destroy = lod_destroy, .do_index_try = lod_index_try, .do_declare_ref_add = lod_declare_ref_add, .do_ref_add = lod_ref_add, @@ -5072,8 +5034,7 @@ static ssize_t lod_declare_write(const struct lu_env *env, const struct lu_buf *buf, loff_t pos, struct thandle *th) { - return lod_sub_object_declare_write(env, dt_object_child(dt), buf, pos, - th); + return lod_sub_declare_write(env, dt_object_child(dt), buf, pos, th); } /** @@ -5085,7 +5046,7 @@ static ssize_t lod_write(const struct lu_env *env, struct dt_object *dt, const struct lu_buf *buf, loff_t *pos, struct thandle *th, int iq) { - return lod_sub_object_write(env, dt_object_child(dt), buf, pos, th, iq); + return lod_sub_write(env, dt_object_child(dt), buf, pos, th, iq); } static int lod_declare_punch(const struct lu_env *env, struct dt_object *dt, @@ -5094,8 +5055,7 @@ static int lod_declare_punch(const struct lu_env *env, struct dt_object *dt, if (dt_object_remote(dt)) return -ENOTSUPP; - return lod_sub_object_declare_punch(env, dt_object_child(dt), start, - end, th); + return lod_sub_declare_punch(env, dt_object_child(dt), start, end, th); } static int lod_punch(const struct lu_env *env, struct dt_object *dt, @@ -5104,7 +5064,7 @@ static int lod_punch(const struct lu_env *env, struct dt_object *dt, if (dt_object_remote(dt)) return -ENOTSUPP; - return lod_sub_object_punch(env, dt_object_child(dt), start, end, th); + return lod_sub_punch(env, dt_object_child(dt), start, end, th); } static const struct dt_body_operations lod_body_lnk_ops = { diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index 81122e9..7103414 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -714,7 +714,7 @@ static struct dt_object *lod_qos_declare_object_on(const struct lu_env *env, dt = container_of(n, struct dt_object, do_lu); - rc = lod_sub_object_declare_create(env, dt, NULL, NULL, NULL, th); + rc = lod_sub_declare_create(env, dt, NULL, NULL, NULL, th); if (rc < 0) { CDEBUG(D_OTHER, "can't declare creation on #%u: %d\n", ost_idx, rc); @@ -2111,8 +2111,8 @@ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo, o = lod_comp->llc_stripe[i]; LASSERT(o); - rc = lod_sub_object_declare_create(env, o, attr, NULL, - NULL, th); + rc = lod_sub_declare_create(env, o, attr, NULL, + NULL, th); if (rc < 0) { CERROR("can't declare create: %d\n", rc); break; diff --git a/lustre/lod/lod_sub_object.c b/lustre/lod/lod_sub_object.c index b2e89c8..2b0d71e 100644 --- a/lustre/lod/lod_sub_object.c +++ b/lustre/lod/lod_sub_object.c @@ -76,7 +76,7 @@ struct thandle *lod_sub_get_thandle(const struct lu_env *env, tth = container_of(th, struct top_thandle, tt_super); /* local object must be mdt object, Note: during ost object - * creation, FID is not assigned until osp_object_create(), + * creation, FID is not assigned until osp_create(), * so if the FID of sub_obj is zero, it means OST object. */ if (!dt_object_remote(sub_obj) || fid_is_zero(lu_object_fid(&sub_obj->do_lu))) { @@ -126,12 +126,10 @@ struct thandle *lod_sub_get_thandle(const struct lu_env *env, * \retval 0 if the declaration succeeds * \retval negative errno if the declaration fails. */ -int lod_sub_object_declare_create(const struct lu_env *env, - struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th) +int lod_sub_declare_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, + struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -163,11 +161,9 @@ int lod_sub_object_declare_create(const struct lu_env *env, * \retval 0 if the creation succeeds * \retval negative errno if the creation fails. */ -int lod_sub_object_create(const struct lu_env *env, struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th) +int lod_sub_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -203,9 +199,8 @@ int lod_sub_object_create(const struct lu_env *env, struct dt_object *dt, * \retval 0 if the declaration succeeds. * \retval negative errno if the declaration fails. */ -int lod_sub_object_declare_ref_add(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th) +int lod_sub_declare_ref_add(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -237,8 +232,8 @@ int lod_sub_object_declare_ref_add(const struct lu_env *env, * \retval 0 if it succeeds. * \retval negative errno if it fails. */ -int lod_sub_object_ref_add(const struct lu_env *env, struct dt_object *dt, - struct thandle *th) +int lod_sub_ref_add(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -273,9 +268,8 @@ int lod_sub_object_ref_add(const struct lu_env *env, struct dt_object *dt, * \retval 0 if the declaration succeeds. * \retval negative errno if the declaration fails. */ -int lod_sub_object_declare_ref_del(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th) +int lod_sub_declare_ref_del(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -307,8 +301,8 @@ int lod_sub_object_declare_ref_del(const struct lu_env *env, * \retval 0 if it succeeds. * \retval negative errno if it fails. */ -int lod_sub_object_ref_del(const struct lu_env *env, struct dt_object *dt, - struct thandle *th) +int lod_sub_ref_del(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -343,9 +337,8 @@ int lod_sub_object_ref_del(const struct lu_env *env, struct dt_object *dt, * \retval 0 if the declaration succeeds. * \retval negative errno if the declaration fails. */ -int lod_sub_object_declare_destroy(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th) +int lod_sub_declare_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -357,8 +350,7 @@ int lod_sub_object_declare_destroy(const struct lu_env *env, RETURN(PTR_ERR(sub_th)); if (record_update) - update_record_size(env, object_destroy, th, - lu_object_fid(&dt->do_lu)); + update_record_size(env, destroy, th, lu_object_fid(&dt->do_lu)); rc = dt_declare_destroy(env, dt, sub_th); @@ -378,8 +370,8 @@ int lod_sub_object_declare_destroy(const struct lu_env *env, * \retval 0 if the destroy succeeds. * \retval negative errno if the destroy fails. */ -int lod_sub_object_destroy(const struct lu_env *env, struct dt_object *dt, - struct thandle *th) +int lod_sub_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -391,8 +383,7 @@ int lod_sub_object_destroy(const struct lu_env *env, struct dt_object *dt, RETURN(PTR_ERR(sub_th)); if (record_update) { - rc = update_record_pack(object_destroy, th, - lu_object_fid(&dt->do_lu)); + rc = update_record_pack(destroy, th, lu_object_fid(&dt->do_lu)); if (rc < 0) RETURN(rc); } @@ -416,11 +407,9 @@ int lod_sub_object_destroy(const struct lu_env *env, struct dt_object *dt, * \retval 0 if the declaration succeeds. * \retval negative errno if the declaration fails. */ -int lod_sub_object_declare_insert(const struct lu_env *env, - struct dt_object *dt, - const struct dt_rec *rec, - const struct dt_key *key, - struct thandle *th) +int lod_sub_declare_insert(const struct lu_env *env, struct dt_object *dt, + const struct dt_rec *rec, + const struct dt_key *key, struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -452,10 +441,9 @@ int lod_sub_object_declare_insert(const struct lu_env *env, * \retval 0 if the insertion succeeds. * \retval negative errno if the insertion fails. */ -int lod_sub_object_index_insert(const struct lu_env *env, struct dt_object *dt, - const struct dt_rec *rec, - const struct dt_key *key, struct thandle *th, - int ign) +int lod_sub_insert(const struct lu_env *env, struct dt_object *dt, + const struct dt_rec *rec, const struct dt_key *key, + struct thandle *th, int ign) { struct thandle *sub_th; int rc; @@ -488,10 +476,8 @@ int lod_sub_object_index_insert(const struct lu_env *env, struct dt_object *dt, * \retval 0 if the declaration succeeds. * \retval negative errno if the declaration fails. */ -int lod_sub_object_declare_delete(const struct lu_env *env, - struct dt_object *dt, - const struct dt_key *key, - struct thandle *th) +int lod_sub_declare_delete(const struct lu_env *env, struct dt_object *dt, + const struct dt_key *key, struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -521,8 +507,8 @@ int lod_sub_object_declare_delete(const struct lu_env *env, * \retval 0 if the deletion succeeds. * \retval negative errno if the deletion fails. */ -int lod_sub_object_delete(const struct lu_env *env, struct dt_object *dt, - const struct dt_key *name, struct thandle *th) +int lod_sub_delete(const struct lu_env *env, struct dt_object *dt, + const struct dt_key *name, struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -558,11 +544,9 @@ int lod_sub_object_delete(const struct lu_env *env, struct dt_object *dt, * \retval 0 if the declaration succeeds. * \retval negative errno if the declaration fails. */ -int lod_sub_object_declare_xattr_set(const struct lu_env *env, - struct dt_object *dt, - const struct lu_buf *buf, - const char *name, int fl, - struct thandle *th) +int lod_sub_declare_xattr_set(const struct lu_env *env, struct dt_object *dt, + const struct lu_buf *buf, const char *name, + int fl, struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -599,9 +583,9 @@ int lod_sub_object_declare_xattr_set(const struct lu_env *env, * \retval 0 if the xattr setting succeeds. * \retval negative errno if xattr setting fails. */ -int lod_sub_object_xattr_set(const struct lu_env *env, struct dt_object *dt, - const struct lu_buf *buf, const char *name, int fl, - struct thandle *th) +int lod_sub_xattr_set(const struct lu_env *env, struct dt_object *dt, + const struct lu_buf *buf, const char *name, int fl, + struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -638,10 +622,8 @@ int lod_sub_object_xattr_set(const struct lu_env *env, struct dt_object *dt, * \retval 0 if the declaration succeeds. * \retval negative errno if the declaration fails. */ -int lod_sub_object_declare_attr_set(const struct lu_env *env, - struct dt_object *dt, - const struct lu_attr *attr, - struct thandle *th) +int lod_sub_declare_attr_set(const struct lu_env *env, struct dt_object *dt, + const struct lu_attr *attr, struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -675,10 +657,8 @@ int lod_sub_object_declare_attr_set(const struct lu_env *env, * \retval 0 if attributes setting succeeds. * \retval negative errno if the attributes setting fails. */ -int lod_sub_object_attr_set(const struct lu_env *env, - struct dt_object *dt, - const struct lu_attr *attr, - struct thandle *th) +int lod_sub_attr_set(const struct lu_env *env, struct dt_object *dt, + const struct lu_attr *attr, struct thandle *th) { bool record_update; struct thandle *sub_th; @@ -714,10 +694,8 @@ int lod_sub_object_attr_set(const struct lu_env *env, * \retval 0 if the declaration succeeds. * \retval negative errno if the declaration fails. */ -int lod_sub_object_declare_xattr_del(const struct lu_env *env, - struct dt_object *dt, - const char *name, - struct thandle *th) +int lod_sub_declare_xattr_del(const struct lu_env *env, struct dt_object *dt, + const char *name, struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -752,10 +730,8 @@ int lod_sub_object_declare_xattr_del(const struct lu_env *env, * \retval 0 if the deletion succeeds. * \retval negative errno if the deletion fails. */ -int lod_sub_object_xattr_del(const struct lu_env *env, - struct dt_object *dt, - const char *name, - struct thandle *th) +int lod_sub_xattr_del(const struct lu_env *env, struct dt_object *dt, + const char *name, struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -792,10 +768,9 @@ int lod_sub_object_xattr_del(const struct lu_env *env, * \retval 0 if the insertion succeeds. * \retval negative errno if the insertion fails. */ -int lod_sub_object_declare_write(const struct lu_env *env, - struct dt_object *dt, - const struct lu_buf *buf, loff_t pos, - struct thandle *th) +int lod_sub_declare_write(const struct lu_env *env, struct dt_object *dt, + const struct lu_buf *buf, loff_t pos, + struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -832,9 +807,9 @@ int lod_sub_object_declare_write(const struct lu_env *env, * \retval the buffer size in bytes if it succeeds. * \retval negative errno if it fails. */ -ssize_t lod_sub_object_write(const struct lu_env *env, struct dt_object *dt, - const struct lu_buf *buf, loff_t *pos, - struct thandle *th, int rq) +ssize_t lod_sub_write(const struct lu_env *env, struct dt_object *dt, + const struct lu_buf *buf, loff_t *pos, + struct thandle *th, int rq) { struct thandle *sub_th; bool record_update; @@ -870,10 +845,8 @@ ssize_t lod_sub_object_write(const struct lu_env *env, struct dt_object *dt, * \retval 0 if the insertion succeeds. * \retval negative errno if the insertion fails. */ -int lod_sub_object_declare_punch(const struct lu_env *env, - struct dt_object *dt, - __u64 start, __u64 end, - struct thandle *th) +int lod_sub_declare_punch(const struct lu_env *env, struct dt_object *dt, + __u64 start, __u64 end, struct thandle *th) { struct thandle *sub_th; bool record_update; @@ -910,8 +883,8 @@ int lod_sub_object_declare_punch(const struct lu_env *env, * \retval the buffer size in bytes if it succeeds. * \retval negative errno if it fails. */ -int lod_sub_object_punch(const struct lu_env *env, struct dt_object *dt, - __u64 start, __u64 end, struct thandle *th) +int lod_sub_punch(const struct lu_env *env, struct dt_object *dt, + __u64 start, __u64 end, struct thandle *th) { struct thandle *sub_th; bool record_update; diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 2b4ab39..b0120ab 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -1989,7 +1989,7 @@ static int mdd_create_sanity_check(const struct lu_env *env, RETURN(rc); } -static int mdd_declare_object_create(const struct lu_env *env, +static int mdd_declare_create_object(const struct lu_env *env, struct mdd_device *mdd, struct mdd_object *p, struct mdd_object *c, struct lu_attr *attr, @@ -2002,10 +2002,10 @@ static int mdd_declare_object_create(const struct lu_env *env, const struct lu_buf *buf; int rc; - rc = mdd_declare_object_create_internal(env, p, c, attr, handle, spec, + rc = mdd_declare_create_object_internal(env, p, c, attr, handle, spec, hint); - if (rc) - GOTO(out, rc); + if (rc) + GOTO(out, rc); #ifdef CONFIG_FS_POSIX_ACL if (def_acl_buf->lb_len > 0 && S_ISDIR(attr->la_mode)) { @@ -2081,7 +2081,7 @@ static int mdd_declare_create(const struct lu_env *env, struct mdd_device *mdd, { int rc; - rc = mdd_declare_object_create(env, mdd, p, c, attr, handle, spec, + rc = mdd_declare_create_object(env, mdd, p, c, attr, handle, spec, def_acl_buf, acl_buf, hint); if (rc) GOTO(out, rc); @@ -2167,18 +2167,18 @@ static int mdd_acl_init(const struct lu_env *env, struct mdd_object *pobj, /** * Create a metadata object and initialize it, set acl, xattr. **/ -static int mdd_object_create(const struct lu_env *env, struct mdd_object *pobj, +static int mdd_create_object(const struct lu_env *env, struct mdd_object *pobj, struct mdd_object *son, struct lu_attr *attr, struct md_op_spec *spec, struct lu_buf *acl_buf, struct lu_buf *def_acl_buf, struct dt_allocation_hint *hint, struct thandle *handle) { - const struct lu_buf *buf; - int rc; + const struct lu_buf *buf; + int rc; mdd_write_lock(env, son, MOR_TGT_CHILD); - rc = mdd_object_create_internal(env, NULL, son, attr, handle, spec, + rc = mdd_create_object_internal(env, NULL, son, attr, handle, spec, hint); if (rc) GOTO(unlock, rc); @@ -2245,7 +2245,6 @@ static int mdd_object_create(const struct lu_env *env, struct mdd_object *pobj, struct dt_object *dt = mdd_object_child(son); const char *target_name = spec->u.sp_symname; int sym_len = strlen(target_name); - const struct lu_buf *buf; loff_t pos = 0; buf = mdd_buf_get_const(env, target_name, sym_len); @@ -2331,12 +2330,51 @@ stop: RETURN(rc); } -/* +/** * Create object and insert it into namespace. + * + * Two operations have to be performed: + * + * - an allocation of a new object (->do_create()), and + * - an insertion into a parent index (->dio_insert()). + * + * Due to locking, operation order is not important, when both are + * successful, *but* error handling cases are quite different: + * + * - if insertion is done first, and following object creation fails, + * insertion has to be rolled back, but this operation might fail + * also leaving us with dangling index entry. + * + * - if creation is done first, is has to be undone if insertion fails, + * leaving us with leaked space, which is not good but not fatal. + * + * It seems that creation-first is simplest solution, but it is sub-optimal + * in the frequent + * + * $ mkdir foo + * $ mkdir foo + * + * case, because second mkdir is bound to create object, only to + * destroy it immediately. + * + * To avoid this follow local file systems that do double lookup: + * + * 0. lookup -> -EEXIST (mdd_create_sanity_check()) + * 1. create (mdd_create_object_internal()) + * 2. insert (__mdd_index_insert(), lookup again) + * + * \param[in] pobj parent object + * \param[in] lname name of child being created + * \param[in,out] child child object being created + * \param[in] spec additional create parameters + * \param[in] ma attributes for new child object + * + * \retval 0 on success + * \retval negative errno on failure */ static int mdd_create(const struct lu_env *env, struct md_object *pobj, const struct lu_name *lname, struct md_object *child, - struct md_op_spec *spec, struct md_attr* ma) + struct md_op_spec *spec, struct md_attr *ma) { struct mdd_thread_info *info = mdd_env_info(env); struct lu_attr *la = &info->mti_la_for_fix; @@ -2355,42 +2393,6 @@ static int mdd_create(const struct lu_env *env, struct md_object *pobj, int rc2; ENTRY; - /* - * Two operations have to be performed: - * - * - an allocation of a new object (->do_create()), and - * - * - an insertion into a parent index (->dio_insert()). - * - * Due to locking, operation order is not important, when both are - * successful, *but* error handling cases are quite different: - * - * - if insertion is done first, and following object creation fails, - * insertion has to be rolled back, but this operation might fail - * also leaving us with dangling index entry. - * - * - if creation is done first, is has to be undone if insertion - * fails, leaving us with leaked space, which is neither good, nor - * fatal. - * - * It seems that creation-first is simplest solution, but it is - * sub-optimal in the frequent - * - * $ mkdir foo - * $ mkdir foo - * - * case, because second mkdir is bound to create object, only to - * destroy it immediately. - * - * To avoid this follow local file systems that do double lookup: - * - * 0. lookup -> -EEXIST (mdd_create_sanity_check()) - * - * 1. create (mdd_object_create_internal()) - * - * 2. insert (__mdd_index_insert(), lookup again) - */ - rc = mdd_la_get(env, mdd_pobj, pattr); if (rc != 0) RETURN(rc); @@ -2400,7 +2402,7 @@ static int mdd_create(const struct lu_env *env, struct md_object *pobj, if (rc) RETURN(rc); - if (OBD_FAIL_CHECK(OBD_FAIL_MDS_DQACQ_NET)) + if (OBD_FAIL_CHECK(OBD_FAIL_MDS_DQACQ_NET)) GOTO(out_free, rc = -EINPROGRESS); handle = mdd_trans_create(env, mdd); @@ -2434,14 +2436,14 @@ static int mdd_create(const struct lu_env *env, struct md_object *pobj, rc = mdd_declare_create(env, mdd, mdd_pobj, son, lname, attr, handle, spec, ldata, &def_acl_buf, &acl_buf, hint); - if (rc) - GOTO(out_stop, rc); + if (rc) + GOTO(out_stop, rc); - rc = mdd_trans_start(env, mdd, handle); - if (rc) - GOTO(out_stop, rc); + rc = mdd_trans_start(env, mdd, handle); + if (rc) + GOTO(out_stop, rc); - rc = mdd_object_create(env, mdd_pobj, son, attr, spec, &acl_buf, + rc = mdd_create_object(env, mdd_pobj, son, attr, spec, &acl_buf, &def_acl_buf, hint, handle); if (rc != 0) GOTO(out_stop, rc); @@ -3415,7 +3417,7 @@ static int mdd_declare_migrate_create(const struct lu_env *env, int rc; int mgr_easize; - rc = mdd_declare_object_create_internal(env, mdd_pobj, mdd_tobj, la, + rc = mdd_declare_create_object_internal(env, mdd_pobj, mdd_tobj, la, handle, spec, NULL); if (rc != 0) return rc; @@ -3565,7 +3567,7 @@ static int mdd_migrate_create(const struct lu_env *env, la->la_valid &= ~LA_NLINK; /* create the target object */ - rc = mdd_object_create(env, mdd_pobj, mdd_tobj, la, spec, NULL, NULL, + rc = mdd_create_object(env, mdd_pobj, mdd_tobj, la, spec, NULL, NULL, hint, handle); if (rc != 0) GOTO(stop_trans, rc); diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index e7e4eb7..2588436 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -177,7 +177,7 @@ int mdd_attr_set_internal(const struct lu_env *env, int mdd_update_time(const struct lu_env *env, struct mdd_object *obj, const struct lu_attr *oattr, struct lu_attr *attr, struct thandle *handle); -int mdd_object_create_internal(const struct lu_env *env, struct mdd_object *p, +int mdd_create_object_internal(const struct lu_env *env, struct mdd_object *p, struct mdd_object *c, struct lu_attr *attr, struct thandle *handle, const struct md_op_spec *spec, @@ -292,7 +292,7 @@ int mdd_changelog_ns_store(const struct lu_env *env, struct mdd_device *mdd, const struct lu_name *sname, struct thandle *handle); int mdd_invalidate(const struct lu_env *env, struct md_object *obj); -int mdd_declare_object_create_internal(const struct lu_env *env, +int mdd_declare_create_object_internal(const struct lu_env *env, struct mdd_object *p, struct mdd_object *c, struct lu_attr *attr, @@ -668,24 +668,20 @@ static inline int mdo_ref_del(const struct lu_env *env, struct mdd_object *obj, } static inline int -mdo_declare_create_obj(const struct lu_env *env, struct mdd_object *o, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *handle) +mdo_declare_create_object(const struct lu_env *env, struct mdd_object *obj, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *handle) { - struct dt_object *next = mdd_object_child(o); + struct dt_object *next = mdd_object_child(obj); return dt_declare_create(env, next, attr, hint, dof, handle); } static inline int -mdo_create_obj(const struct lu_env *env, struct mdd_object *o, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *handle) +mdo_create_object(const struct lu_env *env, struct mdd_object *obj, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *handle) { - struct dt_object *next = mdd_object_child(o); + struct dt_object *next = mdd_object_child(obj); return dt_create(env, next, attr, hint, dof, handle); } diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 6f8483c..cc32f59 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -338,7 +338,7 @@ int mdd_invalidate(const struct lu_env *env, struct md_object *obj) return mdo_invalidate(env, md2mdd_obj(obj)); } -int mdd_declare_object_create_internal(const struct lu_env *env, +int mdd_declare_create_object_internal(const struct lu_env *env, struct mdd_object *p, struct mdd_object *c, struct lu_attr *attr, @@ -346,15 +346,14 @@ int mdd_declare_object_create_internal(const struct lu_env *env, const struct md_op_spec *spec, struct dt_allocation_hint *hint) { - struct dt_object_format *dof = &mdd_env_info(env)->mti_dof; - const struct dt_index_features *feat = spec->sp_feat; - int rc; - ENTRY; + struct dt_object_format *dof = &mdd_env_info(env)->mti_dof; + const struct dt_index_features *feat = spec->sp_feat; + int rc; + ENTRY; if (feat != &dt_directory_features && feat != NULL) { - dof->dof_type = DFT_INDEX; + dof->dof_type = DFT_INDEX; dof->u.dof_idx.di_feat = feat; - } else { dof->dof_type = dt_mode_to_dft(attr->la_mode); if (dof->dof_type == DFT_REGULAR) { @@ -368,24 +367,24 @@ int mdd_declare_object_create_internal(const struct lu_env *env, } } - rc = mdo_declare_create_obj(env, c, attr, hint, dof, handle); + rc = mdo_declare_create_object(env, c, attr, hint, dof, handle); - RETURN(rc); + RETURN(rc); } -int mdd_object_create_internal(const struct lu_env *env, struct mdd_object *p, +int mdd_create_object_internal(const struct lu_env *env, struct mdd_object *p, struct mdd_object *c, struct lu_attr *attr, struct thandle *handle, const struct md_op_spec *spec, struct dt_allocation_hint *hint) { - struct dt_object_format *dof = &mdd_env_info(env)->mti_dof; - int rc; - ENTRY; + struct dt_object_format *dof = &mdd_env_info(env)->mti_dof; + int rc; + ENTRY; LASSERT(!mdd_object_exists(c)); - rc = mdo_create_obj(env, c, attr, hint, dof, handle); + rc = mdo_create_object(env, c, attr, hint, dof, handle); RETURN(rc); } @@ -394,15 +393,15 @@ int mdd_attr_set_internal(const struct lu_env *env, struct mdd_object *obj, const struct lu_attr *attr, struct thandle *handle, int needacl) { - int rc; - ENTRY; + int rc; + ENTRY; rc = mdo_attr_set(env, obj, attr, handle); #ifdef CONFIG_FS_POSIX_ACL - if (!rc && (attr->la_valid & LA_MODE) && needacl) - rc = mdd_acl_chmod(env, obj, attr->la_mode, handle); + if (!rc && (attr->la_valid & LA_MODE) && needacl) + rc = mdd_acl_chmod(env, obj, attr->la_mode, handle); #endif - RETURN(rc); + RETURN(rc); } int mdd_update_time(const struct lu_env *env, struct mdd_object *obj, diff --git a/lustre/mdd/mdd_orphans.c b/lustre/mdd/mdd_orphans.c index b8bb33b..e821f17 100644 --- a/lustre/mdd/mdd_orphans.c +++ b/lustre/mdd/mdd_orphans.c @@ -313,9 +313,8 @@ static int orph_index_delete(const struct lu_env *env, } -static int orphan_object_destroy(const struct lu_env *env, - struct mdd_object *obj, - struct dt_key *key) +static int orphan_destroy(const struct lu_env *env, struct mdd_object *obj, + struct dt_key *key) { struct thandle *th = NULL; struct mdd_device *mdd = mdo2mdd(&obj->mod_obj); @@ -374,25 +373,24 @@ stop: * \retval -ve error */ static int orph_key_test_and_del(const struct lu_env *env, - struct mdd_device *mdd, - struct lu_fid *lf, - struct dt_key *key) + struct mdd_device *mdd, struct lu_fid *lf, + struct dt_key *key) { - struct mdd_object *mdo; - int rc; + struct mdd_object *mdo; + int rc; - mdo = mdd_object_find(env, mdd, lf); + mdo = mdd_object_find(env, mdd, lf); - if (IS_ERR(mdo)) - return PTR_ERR(mdo); + if (IS_ERR(mdo)) + return PTR_ERR(mdo); - rc = -EBUSY; - if (mdo->mod_count == 0) { - CDEBUG(D_HA, "Found orphan "DFID", delete it\n", PFID(lf)); - rc = orphan_object_destroy(env, mdo, key); - if (rc) /* so replay-single.sh test_37 works */ - CERROR("%s: error unlinking orphan "DFID" from " - "PENDING: rc = %d\n", + rc = -EBUSY; + if (mdo->mod_count == 0) { + CDEBUG(D_HA, "Found orphan "DFID", delete it\n", PFID(lf)); + rc = orphan_destroy(env, mdo, key); + if (rc) /* so replay-single.sh test_37 works */ + CERROR("%s: error unlinking orphan "DFID" from " + "PENDING: rc = %d\n", mdd2obd_dev(mdd)->obd_name, PFID(lf), rc); } else { mdd_write_lock(env, mdo, MOR_TGT_CHILD); diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 63151d8..3eff74b 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -1443,30 +1443,24 @@ again: /* version of child will be changed */ tgt_vbr_obj_set(info->mti_env, mdt_obj2dt(child)); - /* Not found and with MDS_OPEN_CREAT: let's create it. */ - mdt_set_disposition(info, ldlm_rep, DISP_OPEN_CREATE); + /* Not found and with MDS_OPEN_CREAT: let's create it. */ + mdt_set_disposition(info, ldlm_rep, DISP_OPEN_CREATE); - /* Let lower layers know what is lock mode on directory. */ - info->mti_spec.sp_cr_mode = - mdt_dlm_mode2mdl_mode(lh->mlh_pdo_mode); + /* Let lower layers know what is lock mode on directory. */ + info->mti_spec.sp_cr_mode = + mdt_dlm_mode2mdl_mode(lh->mlh_pdo_mode); - /* - * Do not perform lookup sanity check. We know that name does - * not exist. - */ - info->mti_spec.sp_cr_lookup = 0; - info->mti_spec.sp_feat = &dt_directory_features; - - result = mdo_create(info->mti_env, - mdt_object_child(parent), - &rr->rr_name, - mdt_object_child(child), - &info->mti_spec, - &info->mti_attr); - if (result == -ERESTART) { - mdt_clear_disposition(info, ldlm_rep, DISP_OPEN_CREATE); - GOTO(out_child, result); - } else { + /* Don't do lookup sanity check. We know name doesn't exist. */ + info->mti_spec.sp_cr_lookup = 0; + info->mti_spec.sp_feat = &dt_directory_features; + + result = mdo_create(info->mti_env, mdt_object_child(parent), + &rr->rr_name, mdt_object_child(child), + &info->mti_spec, &info->mti_attr); + if (result == -ERESTART) { + mdt_clear_disposition(info, ldlm_rep, DISP_OPEN_CREATE); + GOTO(out_child, result); + } else { mdt_prep_ma_buf_from_rep(info, child, ma); /* XXX: we should call this once, see few lines below */ if (result == 0) diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 2c7297e..5184c0d 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -431,7 +431,7 @@ static int mdt_lock_slaves(struct mdt_thread_info *mti, struct mdt_object *obj, * 2 - child. Version of child by FID. Must be ENOENT. It is mostly sanity * check. */ -static int mdt_md_create(struct mdt_thread_info *info) +static int mdt_create(struct mdt_thread_info *info) { struct mdt_device *mdt = info->mti_mdt; struct mdt_object *parent; @@ -846,7 +846,7 @@ static int mdt_reint_create(struct mdt_thread_info *info, RETURN(err_serious(-EOPNOTSUPP)); } - rc = mdt_md_create(info); + rc = mdt_create(info); RETURN(rc); } diff --git a/lustre/ofd/ofd_fmd.c b/lustre/ofd/ofd_fmd.c index b0fe098..9c68078 100644 --- a/lustre/ofd/ofd_fmd.c +++ b/lustre/ofd/ofd_fmd.c @@ -264,7 +264,7 @@ struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, const struct lu_fid *fi * Drop FMD list reference so it will disappear when last reference is dropped * to zero. * - * This function is called from ofd_object_destroy() and may only affect + * This function is called from ofd_destroy() and may only affect * the one client that is doing the unlink and at worst we have an stale entry * referencing an object that should never be used again. * diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index c838029..bab0381 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -371,7 +371,7 @@ int ofd_attr_set(const struct lu_env *env, struct ofd_object *fo, int ofd_object_punch(const struct lu_env *env, struct ofd_object *fo, __u64 start, __u64 end, struct lu_attr *la, struct filter_fid *ff, struct obdo *oa); -int ofd_object_destroy(const struct lu_env *, struct ofd_object *, int); +int ofd_destroy(const struct lu_env *, struct ofd_object *, int); int ofd_attr_get(const struct lu_env *env, struct ofd_object *fo, struct lu_attr *la); int ofd_attr_handle_id(const struct lu_env *env, struct ofd_object *fo, diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index ebd74a8..1cc1e1d 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -889,7 +889,7 @@ out: * * Supplemental function to destroy object by FID, it is used by request * handler and by ofd_echo_destroy() below to find object by FID, lock it - * and call ofd_object_destroy() finally. + * and call ofd_destroy() finally. * * \param[in] env execution environment * \param[in] ofd OFD device @@ -929,7 +929,7 @@ int ofd_destroy_by_fid(const struct lu_env *env, struct ofd_device *ofd, LASSERT(fo != NULL); - rc = ofd_object_destroy(env, fo, orphan); + rc = ofd_destroy(env, fo, orphan); EXIT; ofd_object_put(env, fo); diff --git a/lustre/ofd/ofd_objects.c b/lustre/ofd/ofd_objects.c index 1799970..7f328ee 100644 --- a/lustre/ofd/ofd_objects.c +++ b/lustre/ofd/ofd_objects.c @@ -730,7 +730,7 @@ unlock: * \retval 0 if successful * \retval negative value on error */ -int ofd_object_destroy(const struct lu_env *env, struct ofd_object *fo, +int ofd_destroy(const struct lu_env *env, struct ofd_object *fo, int orphan) { struct ofd_device *ofd = ofd_obj2dev(fo); diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 262e6bf..e440762 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -113,11 +113,9 @@ static struct lu_kmem_descr ldiskfs_caches[] = { static const char dot[] = "."; static const char dotdot[] = ".."; -static const char remote_obj_dir[] = "REM_OBJ_DIR"; static const struct lu_object_operations osd_lu_obj_ops; static const struct dt_object_operations osd_obj_ops; -static const struct dt_object_operations osd_obj_ea_ops; static const struct dt_object_operations osd_obj_otable_it_ops; static const struct dt_index_operations osd_index_iam_ops; static const struct dt_index_operations osd_index_ea_ops; @@ -154,11 +152,7 @@ static int osd_object_invariant(const struct lu_object *l) /* * Concurrency: doesn't matter */ - -/* - * Concurrency: doesn't matter - */ -static int osd_write_locked(const struct lu_env *env, struct osd_object *o) +static int osd_is_write_locked(const struct lu_env *env, struct osd_object *o) { struct osd_thread_info *oti = osd_oti_get(env); return oti->oti_w_locks > 0 && o->oo_owner == env; @@ -341,7 +335,7 @@ static struct lu_object *osd_object_alloc(const struct lu_env *env, l = &mo->oo_dt.do_lu; dt_object_init(&mo->oo_dt, NULL, d); - mo->oo_dt.do_ops = &osd_obj_ea_ops; + mo->oo_dt.do_ops = &osd_obj_ops; l->lo_ops = &osd_lu_obj_ops; init_rwsem(&mo->oo_sem); init_rwsem(&mo->oo_ext_idx_sem); @@ -2131,12 +2125,12 @@ static int osd_sync(const struct lu_env *env, struct dt_device *d) { int rc; - CDEBUG(D_CACHE, "syncing OSD %s\n", LUSTRE_OSD_LDISKFS_NAME); + CDEBUG(D_CACHE, "%s: syncing OSD\n", osd_dt_dev(d)->od_svname); rc = ldiskfs_force_commit(osd_sb(osd_dt_dev(d))); - CDEBUG(D_CACHE, "synced OSD %s: rc = %d\n", - LUSTRE_OSD_LDISKFS_NAME, rc); + CDEBUG(D_CACHE, "%s: synced OSD: rc = %d\n", osd_dt_dev(d)->od_svname, + rc); return rc; } @@ -2159,7 +2153,7 @@ static int osd_commit_async(const struct lu_env *env, struct super_block *s = osd_sb(osd_dt_dev(d)); ENTRY; - CDEBUG(D_HA, "async commit OSD %s\n", LUSTRE_OSD_LDISKFS_NAME); + CDEBUG(D_HA, "%s: async commit OSD\n", osd_dt_dev(d)->od_svname); RETURN(s->s_op->sync_fs(s, 0)); } @@ -2279,73 +2273,70 @@ static const struct dt_device_operations osd_dt_ops = { .dt_commit_async = osd_commit_async, }; -static void osd_object_read_lock(const struct lu_env *env, - struct dt_object *dt, unsigned role) +static void osd_read_lock(const struct lu_env *env, struct dt_object *dt, + unsigned role) { - struct osd_object *obj = osd_dt_obj(dt); - struct osd_thread_info *oti = osd_oti_get(env); + struct osd_object *obj = osd_dt_obj(dt); + struct osd_thread_info *oti = osd_oti_get(env); - LINVRNT(osd_invariant(obj)); + LINVRNT(osd_invariant(obj)); - LASSERT(obj->oo_owner != env); + LASSERT(obj->oo_owner != env); down_read_nested(&obj->oo_sem, role); - LASSERT(obj->oo_owner == NULL); - oti->oti_r_locks++; + LASSERT(obj->oo_owner == NULL); + oti->oti_r_locks++; } -static void osd_object_write_lock(const struct lu_env *env, - struct dt_object *dt, unsigned role) +static void osd_write_lock(const struct lu_env *env, struct dt_object *dt, + unsigned role) { - struct osd_object *obj = osd_dt_obj(dt); - struct osd_thread_info *oti = osd_oti_get(env); + struct osd_object *obj = osd_dt_obj(dt); + struct osd_thread_info *oti = osd_oti_get(env); - LINVRNT(osd_invariant(obj)); + LINVRNT(osd_invariant(obj)); - LASSERT(obj->oo_owner != env); + LASSERT(obj->oo_owner != env); down_write_nested(&obj->oo_sem, role); - LASSERT(obj->oo_owner == NULL); - obj->oo_owner = env; - oti->oti_w_locks++; + LASSERT(obj->oo_owner == NULL); + obj->oo_owner = env; + oti->oti_w_locks++; } -static void osd_object_read_unlock(const struct lu_env *env, - struct dt_object *dt) +static void osd_read_unlock(const struct lu_env *env, struct dt_object *dt) { - struct osd_object *obj = osd_dt_obj(dt); - struct osd_thread_info *oti = osd_oti_get(env); + struct osd_object *obj = osd_dt_obj(dt); + struct osd_thread_info *oti = osd_oti_get(env); - LINVRNT(osd_invariant(obj)); + LINVRNT(osd_invariant(obj)); - LASSERT(oti->oti_r_locks > 0); - oti->oti_r_locks--; + LASSERT(oti->oti_r_locks > 0); + oti->oti_r_locks--; up_read(&obj->oo_sem); } -static void osd_object_write_unlock(const struct lu_env *env, - struct dt_object *dt) +static void osd_write_unlock(const struct lu_env *env, struct dt_object *dt) { - struct osd_object *obj = osd_dt_obj(dt); - struct osd_thread_info *oti = osd_oti_get(env); + struct osd_object *obj = osd_dt_obj(dt); + struct osd_thread_info *oti = osd_oti_get(env); - LINVRNT(osd_invariant(obj)); + LINVRNT(osd_invariant(obj)); - LASSERT(obj->oo_owner == env); - LASSERT(oti->oti_w_locks > 0); - oti->oti_w_locks--; - obj->oo_owner = NULL; + LASSERT(obj->oo_owner == env); + LASSERT(oti->oti_w_locks > 0); + oti->oti_w_locks--; + obj->oo_owner = NULL; up_write(&obj->oo_sem); } -static int osd_object_write_locked(const struct lu_env *env, - struct dt_object *dt) +static int osd_write_locked(const struct lu_env *env, struct dt_object *dt) { - struct osd_object *obj = osd_dt_obj(dt); + struct osd_object *obj = osd_dt_obj(dt); - LINVRNT(osd_invariant(obj)); + LINVRNT(osd_invariant(obj)); - return obj->oo_owner == env; + return obj->oo_owner == env; } static struct timespec *osd_inode_time(const struct lu_env *env, @@ -2998,15 +2989,13 @@ static void osd_attr_init(struct osd_thread_info *info, struct osd_object *obj, } /** - * Helper function for osd_object_create() + * Helper function for osd_create() * * \retval 0, on success */ -static int __osd_object_create(struct osd_thread_info *info, - struct osd_object *obj, struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th) +static int __osd_create(struct osd_thread_info *info, struct osd_object *obj, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th) { int result; __u32 umask; @@ -3041,7 +3030,7 @@ static int __osd_object_create(struct osd_thread_info *info, } /** - * Helper function for osd_object_create() + * Helper function for osd_create() * * \retval 0, on success */ @@ -3094,18 +3083,14 @@ int osd_fld_lookup(const struct lu_env *env, struct osd_device *osd, return fld_local_lookup(env, ss->ss_server_fld, seq, range); } -/* - * Concurrency: no external locking is necessary. - */ -static int osd_declare_object_create(const struct lu_env *env, - struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *handle) +static int osd_declare_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, + struct dt_allocation_hint *hint, + struct dt_object_format *dof, + struct thandle *handle) { - struct osd_thandle *oh; - int rc; + struct osd_thandle *oh; + int rc; ENTRY; LASSERT(handle != NULL); @@ -3141,51 +3126,13 @@ static int osd_declare_object_create(const struct lu_env *env, RETURN(rc); } -static int osd_object_create(const struct lu_env *env, struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, struct thandle *th) -{ - const struct lu_fid *fid = lu_object_fid(&dt->do_lu); - struct osd_object *obj = osd_dt_obj(dt); - struct osd_thread_info *info = osd_oti_get(env); - int result; - ENTRY; - - if (dt_object_exists(dt)) - return -EEXIST; - - LINVRNT(osd_invariant(obj)); - LASSERT(!dt_object_remote(dt)); - LASSERT(osd_write_locked(env, obj)); - LASSERT(th != NULL); - - if (unlikely(fid_is_acct(fid))) - /* Quota files can't be created from the kernel any more, - * 'tune2fs -O quota' will take care of creating them */ - RETURN(-EPERM); - - result = __osd_object_create(info, obj, attr, hint, dof, th); - if (result == 0) { - result = __osd_oi_insert(env, obj, fid, th); - if (obj->oo_dt.do_body_ops == &osd_body_ops_new) - obj->oo_dt.do_body_ops = &osd_body_ops; - } - LASSERT(ergo(result == 0, - dt_object_exists(dt) && !dt_object_remote(dt))); - - LASSERT(osd_invariant(obj)); - RETURN(result); -} - /** * Called to destroy on-disk representation of the object * * Concurrency: must be locked */ -static int osd_declare_object_destroy(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th) +static int osd_declare_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct osd_object *obj = osd_dt_obj(dt); struct inode *inode = obj->oo_inode; @@ -3226,22 +3173,21 @@ static int osd_declare_object_destroy(const struct lu_env *env, RETURN(rc); } -static int osd_object_destroy(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th) +static int osd_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { - const struct lu_fid *fid = lu_object_fid(&dt->do_lu); - struct osd_object *obj = osd_dt_obj(dt); - struct inode *inode = obj->oo_inode; - struct osd_device *osd = osd_obj2dev(obj); - struct osd_thandle *oh; - int result; - ENTRY; + const struct lu_fid *fid = lu_object_fid(&dt->do_lu); + struct osd_object *obj = osd_dt_obj(dt); + struct inode *inode = obj->oo_inode; + struct osd_device *osd = osd_obj2dev(obj); + struct osd_thandle *oh; + int result; + ENTRY; - oh = container_of0(th, struct osd_thandle, ot_super); - LASSERT(oh->ot_handle); - LASSERT(inode); - LASSERT(!lu_object_is_dying(dt->do_lu.lo_header)); + oh = container_of0(th, struct osd_thandle, ot_super); + LASSERT(oh->ot_handle); + LASSERT(inode); + LASSERT(!lu_object_is_dying(dt->do_lu.lo_header)); if (unlikely(fid_is_acct(fid))) RETURN(-EPERM); @@ -3589,18 +3535,16 @@ static int osd_process_scheduled_agent_removals(const struct lu_env *env, } /** - * OSD layer object create function for interoperability mode (b11826). - * This is mostly similar to osd_object_create(). Only difference being, fid is - * inserted into inode ea here. + * OSD layer object create function for OST objects (b=11826). + * + * The FID is inserted into inode xattr here. * * \retval 0, on success * \retval -ve, on error */ -static int osd_object_ea_create(const struct lu_env *env, struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th) +static int osd_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th) { const struct lu_fid *fid = lu_object_fid(&dt->do_lu); struct osd_object *obj = osd_dt_obj(dt); @@ -3612,9 +3556,9 @@ static int osd_object_ea_create(const struct lu_env *env, struct dt_object *dt, if (dt_object_exists(dt)) RETURN(-EEXIST); - LASSERT(osd_invariant(obj)); + LINVRNT(osd_invariant(obj)); LASSERT(!dt_object_remote(dt)); - LASSERT(osd_write_locked(env, obj)); + LASSERT(osd_is_write_locked(env, obj)); LASSERT(th != NULL); if (unlikely(fid_is_acct(fid))) @@ -3622,7 +3566,7 @@ static int osd_object_ea_create(const struct lu_env *env, struct dt_object *dt, * 'tune2fs -O quota' will take care of creating them */ RETURN(-EPERM); - result = __osd_object_create(info, obj, attr, hint, dof, th); + result = __osd_create(info, obj, attr, hint, dof, th); if (result == 0) { if (fid_is_idif(fid) && !osd_dev(dt->do_lu.lo_dev)->od_index_in_idif) { @@ -3659,21 +3603,20 @@ static int osd_object_ea_create(const struct lu_env *env, struct dt_object *dt, LASSERT(ergo(result == 0, dt_object_exists(dt) && !dt_object_remote(dt))); - LINVRNT(osd_invariant(obj)); - RETURN(result); + LINVRNT(osd_invariant(obj)); + RETURN(result); } -static int osd_declare_object_ref_add(const struct lu_env *env, - struct dt_object *dt, - struct thandle *handle) +static int osd_declare_ref_add(const struct lu_env *env, struct dt_object *dt, + struct thandle *handle) { - struct osd_thandle *oh; + struct osd_thandle *oh; - /* it's possible that object doesn't exist yet */ - LASSERT(handle != NULL); + /* it's possible that object doesn't exist yet */ + LASSERT(handle != NULL); - oh = container_of0(handle, struct osd_thandle, ot_super); - LASSERT(oh->ot_handle == NULL); + oh = container_of0(handle, struct osd_thandle, ot_super); + LASSERT(oh->ot_handle == NULL); osd_trans_declare_op(env, oh, OSD_OT_REF_ADD, osd_dto_credits_noquota[DTO_ATTR_SET_BASE]); @@ -3684,8 +3627,8 @@ static int osd_declare_object_ref_add(const struct lu_env *env, /* * Concurrency: @dt is write locked. */ -static int osd_object_ref_add(const struct lu_env *env, - struct dt_object *dt, struct thandle *th) +static int osd_ref_add(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct osd_object *obj = osd_dt_obj(dt); struct inode *inode = obj->oo_inode; @@ -3697,7 +3640,7 @@ static int osd_object_ref_add(const struct lu_env *env, LINVRNT(osd_invariant(obj)); LASSERT(!dt_object_remote(dt)); - LASSERT(osd_write_locked(env, obj)); + LASSERT(osd_is_write_locked(env, obj)); LASSERT(th != NULL); oh = container_of0(th, struct osd_thandle, ot_super); @@ -3737,9 +3680,8 @@ static int osd_object_ref_add(const struct lu_env *env, return rc; } -static int osd_declare_object_ref_del(const struct lu_env *env, - struct dt_object *dt, - struct thandle *handle) +static int osd_declare_ref_del(const struct lu_env *env, struct dt_object *dt, + struct thandle *handle) { struct osd_thandle *oh; @@ -3761,8 +3703,8 @@ static int osd_declare_object_ref_del(const struct lu_env *env, /* * Concurrency: @dt is write locked. */ -static int osd_object_ref_del(const struct lu_env *env, struct dt_object *dt, - struct thandle *th) +static int osd_ref_del(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct osd_object *obj = osd_dt_obj(dt); struct inode *inode = obj->oo_inode; @@ -3774,7 +3716,7 @@ static int osd_object_ref_del(const struct lu_env *env, struct dt_object *dt, LINVRNT(osd_invariant(obj)); LASSERT(!dt_object_remote(dt)); - LASSERT(osd_write_locked(env, obj)); + LASSERT(osd_is_write_locked(env, obj)); LASSERT(th != NULL); oh = container_of0(th, struct osd_thandle, ot_super); @@ -4397,65 +4339,32 @@ static int osd_otable_it_attr_get(const struct lu_env *env, } static const struct dt_object_operations osd_obj_ops = { - .do_read_lock = osd_object_read_lock, - .do_write_lock = osd_object_write_lock, - .do_read_unlock = osd_object_read_unlock, - .do_write_unlock = osd_object_write_unlock, - .do_write_locked = osd_object_write_locked, - .do_attr_get = osd_attr_get, - .do_declare_attr_set = osd_declare_attr_set, - .do_attr_set = osd_attr_set, - .do_ah_init = osd_ah_init, - .do_declare_create = osd_declare_object_create, - .do_create = osd_object_create, - .do_declare_destroy = osd_declare_object_destroy, - .do_destroy = osd_object_destroy, - .do_index_try = osd_index_try, - .do_declare_ref_add = osd_declare_object_ref_add, - .do_ref_add = osd_object_ref_add, - .do_declare_ref_del = osd_declare_object_ref_del, - .do_ref_del = osd_object_ref_del, - .do_xattr_get = osd_xattr_get, - .do_declare_xattr_set = osd_declare_xattr_set, - .do_xattr_set = osd_xattr_set, - .do_declare_xattr_del = osd_declare_xattr_del, - .do_xattr_del = osd_xattr_del, - .do_xattr_list = osd_xattr_list, - .do_object_sync = osd_object_sync, - .do_invalidate = osd_invalidate, -}; - -/** - * dt_object_operations for interoperability mode - * (i.e. to run 2.0 mds on 1.8 disk) (b11826) - */ -static const struct dt_object_operations osd_obj_ea_ops = { - .do_read_lock = osd_object_read_lock, - .do_write_lock = osd_object_write_lock, - .do_read_unlock = osd_object_read_unlock, - .do_write_unlock = osd_object_write_unlock, - .do_write_locked = osd_object_write_locked, - .do_attr_get = osd_attr_get, - .do_declare_attr_set = osd_declare_attr_set, - .do_attr_set = osd_attr_set, - .do_ah_init = osd_ah_init, - .do_declare_create = osd_declare_object_create, - .do_create = osd_object_ea_create, - .do_declare_destroy = osd_declare_object_destroy, - .do_destroy = osd_object_destroy, - .do_index_try = osd_index_try, - .do_declare_ref_add = osd_declare_object_ref_add, - .do_ref_add = osd_object_ref_add, - .do_declare_ref_del = osd_declare_object_ref_del, - .do_ref_del = osd_object_ref_del, - .do_xattr_get = osd_xattr_get, - .do_declare_xattr_set = osd_declare_xattr_set, - .do_xattr_set = osd_xattr_set, - .do_declare_xattr_del = osd_declare_xattr_del, - .do_xattr_del = osd_xattr_del, - .do_xattr_list = osd_xattr_list, - .do_object_sync = osd_object_sync, - .do_invalidate = osd_invalidate, + .do_read_lock = osd_read_lock, + .do_write_lock = osd_write_lock, + .do_read_unlock = osd_read_unlock, + .do_write_unlock = osd_write_unlock, + .do_write_locked = osd_write_locked, + .do_attr_get = osd_attr_get, + .do_declare_attr_set = osd_declare_attr_set, + .do_attr_set = osd_attr_set, + .do_ah_init = osd_ah_init, + .do_declare_create = osd_declare_create, + .do_create = osd_create, + .do_declare_destroy = osd_declare_destroy, + .do_destroy = osd_destroy, + .do_index_try = osd_index_try, + .do_declare_ref_add = osd_declare_ref_add, + .do_ref_add = osd_ref_add, + .do_declare_ref_del = osd_declare_ref_del, + .do_ref_del = osd_ref_del, + .do_xattr_get = osd_xattr_get, + .do_declare_xattr_set = osd_declare_xattr_set, + .do_xattr_set = osd_xattr_set, + .do_declare_xattr_del = osd_declare_xattr_del, + .do_xattr_del = osd_xattr_del, + .do_xattr_list = osd_xattr_list, + .do_object_sync = osd_object_sync, + .do_invalidate = osd_invalidate, }; static const struct dt_object_operations osd_obj_otable_it_ops = { diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index a96521f..8166023 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -114,19 +114,19 @@ struct osd_oi { extern const int osd_dto_credits_noquota[]; struct osd_object { - struct dt_object oo_dt; - /** - * Inode for file system object represented by this osd_object. This - * inode is pinned for the whole duration of lu_object life. - * - * Not modified concurrently (either setup early during object - * creation, or assigned by osd_object_create() under write lock). - */ - struct inode *oo_inode; - /** - * to protect index ops. - */ - struct htree_lock_head *oo_hl_head; + struct dt_object oo_dt; + /** + * Inode for file system object represented by this osd_object. This + * inode is pinned for the whole duration of lu_object life. + * + * Not modified concurrently (either setup early during object + * creation, or assigned by osd_create() under write lock). + */ + struct inode *oo_inode; + /** + * to protect index ops. + */ + struct htree_lock_head *oo_hl_head; struct rw_semaphore oo_ext_idx_sem; struct rw_semaphore oo_sem; struct osd_directory *oo_dir; diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index 38c7532..63f19c0 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -336,7 +336,7 @@ struct osd_object { * inode is pinned for the whole duration of lu_object life. * * Not modified concurrently (either setup early during object - * creation, or assigned by osd_object_create() under write lock). + * creation, or assigned by osd_create() under write lock). */ dnode_t *oo_dn; sa_handle_t *oo_sa_hdl; diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 4105630..2f1d2f2 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -447,7 +447,7 @@ osd_object_unlinked_add(struct osd_object *obj, struct osd_thandle *oh) LASSERT(obj->oo_destroy == OSD_DESTROY_ASYNC); /* the object is supposed to be exclusively locked by - * the caller (osd_object_destroy()), while the transaction + * the caller (osd_destroy()), while the transaction * (oh) is per-thread and not shared */ if (likely(list_empty(&obj->oo_unlinked_linkage))) { list_add(&obj->oo_unlinked_linkage, &oh->ot_unlinked_list); @@ -480,9 +480,8 @@ osd_object_set_destroy_type(struct osd_object *obj) up_write(&obj->oo_guard); } -static int osd_declare_object_destroy(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th) +static int osd_declare_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { const struct lu_fid *fid = lu_object_fid(&dt->do_lu); struct osd_object *obj = osd_dt_obj(dt); @@ -532,8 +531,8 @@ static int osd_declare_object_destroy(const struct lu_env *env, RETURN(0); } -static int osd_object_destroy(const struct lu_env *env, - struct dt_object *dt, struct thandle *th) +static int osd_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct osd_thread_info *info = osd_oti_get(env); char *buf = info->oti_str; @@ -649,8 +648,8 @@ static int osd_object_print(const struct lu_env *env, void *cookie, return (*p)(env, cookie, LUSTRE_OSD_ZFS_NAME"-object@%p", o); } -static void osd_object_read_lock(const struct lu_env *env, - struct dt_object *dt, unsigned role) +static void osd_read_lock(const struct lu_env *env, struct dt_object *dt, + unsigned role) { struct osd_object *obj = osd_dt_obj(dt); @@ -659,8 +658,8 @@ static void osd_object_read_lock(const struct lu_env *env, down_read_nested(&obj->oo_sem, role); } -static void osd_object_write_lock(const struct lu_env *env, - struct dt_object *dt, unsigned role) +static void osd_write_lock(const struct lu_env *env, struct dt_object *dt, + unsigned role) { struct osd_object *obj = osd_dt_obj(dt); @@ -669,8 +668,7 @@ static void osd_object_write_lock(const struct lu_env *env, down_write_nested(&obj->oo_sem, role); } -static void osd_object_read_unlock(const struct lu_env *env, - struct dt_object *dt) +static void osd_read_unlock(const struct lu_env *env, struct dt_object *dt) { struct osd_object *obj = osd_dt_obj(dt); @@ -678,17 +676,15 @@ static void osd_object_read_unlock(const struct lu_env *env, up_read(&obj->oo_sem); } -static void osd_object_write_unlock(const struct lu_env *env, - struct dt_object *dt) +static void osd_write_unlock(const struct lu_env *env, struct dt_object *dt) { - struct osd_object *obj = osd_dt_obj(dt); + struct osd_object *obj = osd_dt_obj(dt); - LASSERT(osd_invariant(obj)); + LASSERT(osd_invariant(obj)); up_write(&obj->oo_sem); } -static int osd_object_write_locked(const struct lu_env *env, - struct dt_object *dt) +static int osd_write_locked(const struct lu_env *env, struct dt_object *dt) { struct osd_object *obj = osd_dt_obj(dt); int rc = 1; @@ -1070,12 +1066,11 @@ static void osd_ah_init(const struct lu_env *env, struct dt_allocation_hint *ah, } } -static int osd_declare_object_create(const struct lu_env *env, - struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *handle) +static int osd_declare_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, + struct dt_allocation_hint *hint, + struct dt_object_format *dof, + struct thandle *handle) { const struct lu_fid *fid = lu_object_fid(&dt->do_lu); struct osd_object *obj = osd_dt_obj(dt); @@ -1432,11 +1427,9 @@ static osd_obj_type_f osd_create_type_f(enum dt_format_type type) /* * Concurrency: @dt is write locked. */ -static int osd_object_create(const struct lu_env *env, struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th) +static int osd_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th) { struct osd_thread_info *info = osd_oti_get(env); struct lustre_mdt_attrs *lma = &info->oti_mdt_attrs; @@ -1541,9 +1534,8 @@ out: RETURN(rc); } -static int osd_declare_object_ref_add(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th) +static int osd_declare_ref_add(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { return osd_declare_attr_set(env, dt, NULL, th); } @@ -1551,9 +1543,8 @@ static int osd_declare_object_ref_add(const struct lu_env *env, /* * Concurrency: @dt is write locked. */ -static int osd_object_ref_add(const struct lu_env *env, - struct dt_object *dt, - struct thandle *handle) +static int osd_ref_add(const struct lu_env *env, struct dt_object *dt, + struct thandle *handle) { struct osd_object *obj = osd_dt_obj(dt); struct osd_thandle *oh; @@ -1583,9 +1574,8 @@ out: RETURN(rc); } -static int osd_declare_object_ref_del(const struct lu_env *env, - struct dt_object *dt, - struct thandle *handle) +static int osd_declare_ref_del(const struct lu_env *env, struct dt_object *dt, + struct thandle *handle) { return osd_declare_attr_set(env, dt, NULL, handle); } @@ -1593,9 +1583,8 @@ static int osd_declare_object_ref_del(const struct lu_env *env, /* * Concurrency: @dt is write locked. */ -static int osd_object_ref_del(const struct lu_env *env, - struct dt_object *dt, - struct thandle *handle) +static int osd_ref_del(const struct lu_env *env, struct dt_object *dt, + struct thandle *handle) { struct osd_object *obj = osd_dt_obj(dt); struct osd_thandle *oh; @@ -1649,24 +1638,24 @@ static int osd_invalidate(const struct lu_env *env, struct dt_object *dt) } static struct dt_object_operations osd_obj_ops = { - .do_read_lock = osd_object_read_lock, - .do_write_lock = osd_object_write_lock, - .do_read_unlock = osd_object_read_unlock, - .do_write_unlock = osd_object_write_unlock, - .do_write_locked = osd_object_write_locked, + .do_read_lock = osd_read_lock, + .do_write_lock = osd_write_lock, + .do_read_unlock = osd_read_unlock, + .do_write_unlock = osd_write_unlock, + .do_write_locked = osd_write_locked, .do_attr_get = osd_attr_get, .do_declare_attr_set = osd_declare_attr_set, .do_attr_set = osd_attr_set, .do_ah_init = osd_ah_init, - .do_declare_create = osd_declare_object_create, - .do_create = osd_object_create, - .do_declare_destroy = osd_declare_object_destroy, - .do_destroy = osd_object_destroy, + .do_declare_create = osd_declare_create, + .do_create = osd_create, + .do_declare_destroy = osd_declare_destroy, + .do_destroy = osd_destroy, .do_index_try = osd_index_try, - .do_declare_ref_add = osd_declare_object_ref_add, - .do_ref_add = osd_object_ref_add, - .do_declare_ref_del = osd_declare_object_ref_del, - .do_ref_del = osd_object_ref_del, + .do_declare_ref_add = osd_declare_ref_add, + .do_ref_add = osd_ref_add, + .do_declare_ref_del = osd_declare_ref_del, + .do_ref_del = osd_ref_del, .do_xattr_get = osd_xattr_get, .do_declare_xattr_set = osd_declare_xattr_set, .do_xattr_set = osd_xattr_set, @@ -1695,6 +1684,6 @@ static int osd_otable_it_attr_get(const struct lu_env *env, } static struct dt_object_operations osd_obj_otable_it_ops = { - .do_attr_get = osd_otable_it_attr_get, - .do_index_try = osd_index_try, + .do_attr_get = osd_otable_it_attr_get, + .do_index_try = osd_index_try, }; diff --git a/lustre/osp/osp_internal.h b/lustre/osp/osp_internal.h index 6f05b14..2765810 100644 --- a/lustre/osp/osp_internal.h +++ b/lustre/osp/osp_internal.h @@ -790,15 +790,12 @@ int osp_it_key_rec(const struct lu_env *env, const struct dt_it *di, void *key_rec); int osp_it_next_page(const struct lu_env *env, struct dt_it *di); /* osp_md_object.c */ -int osp_md_declare_object_create(const struct lu_env *env, - struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th); -int osp_md_object_create(const struct lu_env *env, struct dt_object *dt, - struct lu_attr *attr, struct dt_allocation_hint *hint, - struct dt_object_format *dof, struct thandle *th); +int osp_md_declare_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th); +int osp_md_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th); int osp_md_declare_attr_set(const struct lu_env *env, struct dt_object *dt, const struct lu_attr *attr, struct thandle *th); int osp_md_attr_set(const struct lu_env *env, struct dt_object *dt, diff --git a/lustre/osp/osp_md_object.c b/lustre/osp/osp_md_object.c index ee60ffc..fb77b3b 100644 --- a/lustre/osp/osp_md_object.c +++ b/lustre/osp/osp_md_object.c @@ -77,11 +77,11 @@ * * \retval only return 0 for now */ -static int osp_object_create_interpreter(const struct lu_env *env, - struct object_update_reply *reply, - struct ptlrpc_request *req, - struct osp_object *obj, - void *data, int index, int rc) +static int osp_create_interpreter(const struct lu_env *env, + struct object_update_reply *reply, + struct ptlrpc_request *req, + struct osp_object *obj, + void *data, int index, int rc) { if (rc != 0 && rc != -EEXIST) { obj->opo_obj.do_lu.lo_header->loh_attr &= ~LOHA_EXISTS; @@ -113,12 +113,9 @@ static int osp_object_create_interpreter(const struct lu_env *env, * \retval 0 if preparation succeeds. * \retval negative errno if preparation fails. */ -int osp_md_declare_object_create(const struct lu_env *env, - struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th) +int osp_md_declare_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th) { return osp_trans_update_request_create(th); } @@ -156,9 +153,9 @@ update_buffer_get_update(struct object_update_request *request, * \retval 0 if packing creation succeeds. * \retval negative errno if packing creation fails. */ -int osp_md_object_create(const struct lu_env *env, struct dt_object *dt, - struct lu_attr *attr, struct dt_allocation_hint *hint, - struct dt_object_format *dof, struct thandle *th) +int osp_md_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th) { struct osp_update_request *update; struct osp_object *obj = dt2osp_obj(dt); @@ -174,7 +171,7 @@ int osp_md_object_create(const struct lu_env *env, struct dt_object *dt, GOTO(out, rc); rc = osp_insert_update_callback(env, update, dt2osp_obj(dt), NULL, - osp_object_create_interpreter); + osp_create_interpreter); if (rc < 0) GOTO(out, rc); @@ -358,7 +355,7 @@ int osp_md_attr_set(const struct lu_env *env, struct dt_object *dt, /** * Implementation of dt_object_operations::do_read_lock * - * osp_md_object_{read,write}_lock() will only lock the remote object in the + * osp_md_{read,write}_lock() will only lock the remote object in the * local cache, which uses the semaphore (opo_sem) inside the osp_object to * lock the object. Note: it will not lock the object in the whole cluster, * which relies on the LDLM lock. @@ -367,8 +364,8 @@ int osp_md_attr_set(const struct lu_env *env, struct dt_object *dt, * \param[in] dt object to be locked * \param[in] role lock role from MDD layer, see mdd_object_role(). */ -static void osp_md_object_read_lock(const struct lu_env *env, - struct dt_object *dt, unsigned role) +static void osp_md_read_lock(const struct lu_env *env, struct dt_object *dt, + unsigned role) { struct osp_object *obj = dt2osp_obj(dt); @@ -387,8 +384,8 @@ static void osp_md_object_read_lock(const struct lu_env *env, * \param[in] dt object to be locked * \param[in] role lock role from MDD layer, see mdd_object_role(). */ -static void osp_md_object_write_lock(const struct lu_env *env, - struct dt_object *dt, unsigned role) +static void osp_md_write_lock(const struct lu_env *env, struct dt_object *dt, + unsigned role) { struct osp_object *obj = dt2osp_obj(dt); @@ -406,8 +403,7 @@ static void osp_md_object_write_lock(const struct lu_env *env, * \param[in] env execution environment * \param[in] dt object to be unlocked */ -static void osp_md_object_read_unlock(const struct lu_env *env, - struct dt_object *dt) +static void osp_md_read_unlock(const struct lu_env *env, struct dt_object *dt) { struct osp_object *obj = dt2osp_obj(dt); @@ -422,8 +418,7 @@ static void osp_md_object_read_unlock(const struct lu_env *env, * \param[in] env execution environment * \param[in] dt object to be unlocked */ -static void osp_md_object_write_unlock(const struct lu_env *env, - struct dt_object *dt) +static void osp_md_write_unlock(const struct lu_env *env, struct dt_object *dt) { struct osp_object *obj = dt2osp_obj(dt); @@ -440,8 +435,7 @@ static void osp_md_object_write_unlock(const struct lu_env *env, * \param[in] env execution environment * \param[in] dt object to be tested */ -static int osp_md_object_write_locked(const struct lu_env *env, - struct dt_object *dt) +static int osp_md_write_locked(const struct lu_env *env, struct dt_object *dt) { struct osp_object *obj = dt2osp_obj(dt); @@ -935,8 +929,8 @@ static int osp_md_object_unlock(const struct lu_env *env, * \retval 0 for success * \retval negative error number on failure */ -int osp_md_declare_object_destroy(const struct lu_env *env, - struct dt_object *dt, struct thandle *th) +int osp_md_declare_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { return osp_trans_update_request_create(th); } @@ -956,8 +950,8 @@ int osp_md_declare_object_destroy(const struct lu_env *env, * \retval 0 for success * \retval negative error number on failure */ -int osp_md_object_destroy(const struct lu_env *env, struct dt_object *dt, - struct thandle *th) +int osp_md_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct osp_object *o = dt2osp_obj(dt); struct osp_device *osp = lu2osp_dev(dt->do_lu.lo_dev); @@ -971,7 +965,7 @@ int osp_md_object_destroy(const struct lu_env *env, struct dt_object *dt, update = thandle_to_osp_update_request(th); LASSERT(update != NULL); - rc = osp_update_rpc_pack(env, object_destroy, update, OUT_DESTROY, + rc = osp_update_rpc_pack(env, destroy, update, OUT_DESTROY, lu_object_fid(&dt->do_lu)); if (rc != 0) RETURN(rc); @@ -984,19 +978,19 @@ int osp_md_object_destroy(const struct lu_env *env, struct dt_object *dt, } struct dt_object_operations osp_md_obj_ops = { - .do_read_lock = osp_md_object_read_lock, - .do_write_lock = osp_md_object_write_lock, - .do_read_unlock = osp_md_object_read_unlock, - .do_write_unlock = osp_md_object_write_unlock, - .do_write_locked = osp_md_object_write_locked, - .do_declare_create = osp_md_declare_object_create, - .do_create = osp_md_object_create, + .do_read_lock = osp_md_read_lock, + .do_write_lock = osp_md_write_lock, + .do_read_unlock = osp_md_read_unlock, + .do_write_unlock = osp_md_write_unlock, + .do_write_locked = osp_md_write_locked, + .do_declare_create = osp_md_declare_create, + .do_create = osp_md_create, .do_declare_ref_add = osp_md_declare_ref_add, .do_ref_add = osp_md_ref_add, .do_declare_ref_del = osp_md_declare_ref_del, .do_ref_del = osp_md_ref_del, - .do_declare_destroy = osp_md_declare_object_destroy, - .do_destroy = osp_md_object_destroy, + .do_declare_destroy = osp_md_declare_destroy, + .do_destroy = osp_md_destroy, .do_ah_init = osp_md_ah_init, .do_attr_get = osp_attr_get, .do_declare_attr_set = osp_md_declare_attr_set, diff --git a/lustre/osp/osp_object.c b/lustre/osp/osp_object.c index 5b3d5a9..9ba9051 100644 --- a/lustre/osp/osp_object.c +++ b/lustre/osp/osp_object.c @@ -1284,7 +1284,7 @@ int osp_invalidate(const struct lu_env *env, struct dt_object *dt) * * If the transaction is a remote transaction and the FID for the OST-object * has been assigned already, then handle it as creating (remote) MDT object - * via osp_md_declare_object_create(). This function is usually used for LFSCK + * via osp_md_declare_create(). This function is usually used for LFSCK * to re-create the lost OST object. Otherwise, if it is not replay case, the * OSP will reserve pre-created object for the subsequent create operation; * if the MDT side cached pre-created objects are less than some threshold, @@ -1301,12 +1301,10 @@ int osp_invalidate(const struct lu_env *env, struct dt_object *dt) * \retval 0 for success * \retval negative error number on failure */ -static int osp_declare_object_create(const struct lu_env *env, - struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th) +static int osp_declare_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, + struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th) { struct osp_thread_info *osi = osp_env_info(env); struct osp_device *d = lu2osp_dev(dt->do_lu.lo_dev); @@ -1320,7 +1318,7 @@ static int osp_declare_object_create(const struct lu_env *env, if (is_only_remote_trans(th) && !fid_is_zero(fid)) { LASSERT(fid_is_sane(fid)); - rc = osp_md_declare_object_create(env, dt, attr, hint, dof, th); + rc = osp_md_declare_create(env, dt, attr, hint, dof, th); RETURN(rc); } @@ -1395,7 +1393,7 @@ static int osp_declare_object_create(const struct lu_env *env, * * If the transaction is a remote transaction and the FID for the OST-object * has been assigned already, then handle it as handling MDT object via the - * osp_md_object_create(). For other cases, the OSP will assign FID to the + * osp_md_create(). For other cases, the OSP will assign FID to the * object to be created, and update last_used Object ID (OID) file. * * \param[in] env pointer to the thread context @@ -1409,10 +1407,9 @@ static int osp_declare_object_create(const struct lu_env *env, * \retval 0 for success * \retval negative error number on failure */ -static int osp_object_create(const struct lu_env *env, struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, struct thandle *th) +static int osp_create(const struct lu_env *env, struct dt_object *dt, + struct lu_attr *attr, struct dt_allocation_hint *hint, + struct dt_object_format *dof, struct thandle *th) { struct osp_thread_info *osi = osp_env_info(env); struct osp_device *d = lu2osp_dev(dt->do_lu.lo_dev); @@ -1426,7 +1423,7 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt, !fid_is_zero(lu_object_fid(&dt->do_lu))) { LASSERT(fid_is_sane(lu_object_fid(&dt->do_lu))); - rc = osp_md_object_create(env, dt, attr, hint, dof, th); + rc = osp_md_create(env, dt, attr, hint, dof, th); if (rc == 0) o->opo_non_exist = 0; @@ -1526,8 +1523,8 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt, * \retval 0 for success * \retval negative error number on failure */ -int osp_declare_object_destroy(const struct lu_env *env, - struct dt_object *dt, struct thandle *th) +int osp_declare_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct osp_object *o = dt2osp_obj(dt); struct osp_device *osp = lu2osp_dev(dt->do_lu.lo_dev); @@ -1558,8 +1555,8 @@ int osp_declare_object_destroy(const struct lu_env *env, * \retval 0 for success * \retval negative error number on failure */ -static int osp_object_destroy(const struct lu_env *env, struct dt_object *dt, - struct thandle *th) +static int osp_destroy(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct osp_object *o = dt2osp_obj(dt); struct osp_device *osp = lu2osp_dev(dt->do_lu.lo_dev); @@ -2111,10 +2108,10 @@ static struct dt_object_operations osp_obj_ops = { .do_xattr_get = osp_xattr_get, .do_declare_xattr_set = osp_declare_xattr_set, .do_xattr_set = osp_xattr_set, - .do_declare_create = osp_declare_object_create, - .do_create = osp_object_create, - .do_declare_destroy = osp_declare_object_destroy, - .do_destroy = osp_object_destroy, + .do_declare_create = osp_declare_create, + .do_create = osp_create, + .do_declare_destroy = osp_declare_destroy, + .do_destroy = osp_destroy, .do_index_try = osp_index_try, }; diff --git a/lustre/osp/osp_precreate.c b/lustre/osp/osp_precreate.c index 1a8bfa5..e6f9478 100644 --- a/lustre/osp/osp_precreate.c +++ b/lustre/osp/osp_precreate.c @@ -52,7 +52,7 @@ * = import is disconnected = * * = import is inactive = - * in this case osp_declare_object_create() returns an error + * in this case osp_declare_create() returns an error * */ diff --git a/lustre/osp/osp_trans.c b/lustre/osp/osp_trans.c index 674078d..e5b8672 100644 --- a/lustre/osp/osp_trans.c +++ b/lustre/osp/osp_trans.c @@ -1208,7 +1208,7 @@ out: * Get local thandle for osp_thandle * * Get the local OSD thandle from the OSP thandle. Currently, there - * are a few OSP API (osp_object_create() and osp_sync_add()) needs + * are a few OSP API (osp_create() and osp_sync_add()) needs * to update the object on local OSD device. * * If the osp_thandle comes from normal stack (MDD->LOD->OSP), then diff --git a/lustre/target/out_lib.c b/lustre/target/out_lib.c index 55b47c6..c267ed2 100644 --- a/lustre/target/out_lib.c +++ b/lustre/target/out_lib.c @@ -330,14 +330,13 @@ int out_index_delete_pack(const struct lu_env *env, } EXPORT_SYMBOL(out_index_delete_pack); -int out_object_destroy_pack(const struct lu_env *env, - struct object_update *update, - size_t *max_update_size, const struct lu_fid *fid) +int out_destroy_pack(const struct lu_env *env, struct object_update *update, + size_t *max_update_size, const struct lu_fid *fid) { return out_update_pack(env, update, max_update_size, OUT_DESTROY, fid, 0, NULL, NULL, 0); } -EXPORT_SYMBOL(out_object_destroy_pack); +EXPORT_SYMBOL(out_destroy_pack); int out_write_pack(const struct lu_env *env, struct object_update *update, size_t *max_update_size, const struct lu_fid *fid, diff --git a/lustre/target/update_records.c b/lustre/target/update_records.c index 5510bf2..a64dc38 100644 --- a/lustre/target/update_records.c +++ b/lustre/target/update_records.c @@ -564,12 +564,12 @@ EXPORT_SYMBOL(update_records_ref_del_pack); * * \retval size of object destroy update. */ -size_t update_records_object_destroy_size(const struct lu_env *env, +size_t update_records_destroy_size(const struct lu_env *env, const struct lu_fid *fid) { return update_records_update_size(0, NULL); } -EXPORT_SYMBOL(update_records_object_destroy_size); +EXPORT_SYMBOL(update_records_destroy_size); /** * Pack object destroy update @@ -588,7 +588,7 @@ EXPORT_SYMBOL(update_records_object_destroy_size); * \retval 0 if packing succeeds. * \retval negative errno if packing fails. */ -int update_records_object_destroy_pack(const struct lu_env *env, +int update_records_destroy_pack(const struct lu_env *env, struct update_ops *ops, unsigned int *op_count, size_t *max_ops_size, @@ -601,7 +601,7 @@ int update_records_object_destroy_pack(const struct lu_env *env, max_ops_size, params, param_count, max_param_size, 0, NULL, NULL); } -EXPORT_SYMBOL(update_records_object_destroy_pack); +EXPORT_SYMBOL(update_records_destroy_pack); /** * Calculate index insert update size -- 1.8.3.1