From: nikita Date: Mon, 24 Jul 2006 19:25:57 +0000 (+0000) Subject: add ->{do,moo}_xattr_list() method to list existing extended attributes X-Git-Tag: v1_8_0_110~486^2~1343 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=b4347618b6e6ce908e7bb49f7d81a3d5818d0bcc;p=fs%2Flustre-release.git add ->{do,moo}_xattr_list() method to list existing extended attributes --- diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 7f7fa55..1ffeb0a 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -243,8 +243,16 @@ static int cml_xattr_get(const struct lu_context *ctx, struct md_object *mo, { int rc; ENTRY; - rc = mo_xattr_get(ctx, md_object_next(mo), - buf, buflen, name); + rc = mo_xattr_get(ctx, md_object_next(mo), buf, buflen, name); + RETURN(rc); +} + +static int cml_xattr_list(const struct lu_context *ctx, struct md_object *mo, + void *buf, int buflen) +{ + int rc; + ENTRY; + rc = mo_xattr_list(ctx, md_object_next(mo), buf, buflen); RETURN(rc); } @@ -253,8 +261,7 @@ static int cml_xattr_set(const struct lu_context *ctx, struct md_object *mo, { int rc; ENTRY; - rc = mo_xattr_set(ctx, md_object_next(mo), - buf, buflen, name); + rc = mo_xattr_set(ctx, md_object_next(mo), buf, buflen, name); RETURN(rc); } @@ -304,6 +311,7 @@ static struct md_object_operations cml_mo_ops = { .moo_attr_get = cml_attr_get, .moo_attr_set = cml_attr_set, .moo_xattr_get = cml_xattr_get, + .moo_xattr_list = cml_xattr_list, .moo_xattr_set = cml_xattr_set, .moo_object_create = cml_object_create, .moo_ref_add = cml_ref_add, @@ -528,6 +536,12 @@ static int cmr_xattr_get(const struct lu_context *ctx, struct md_object *mo, RETURN(-EFAULT); } +static int cmr_xattr_list(const struct lu_context *ctx, struct md_object *mo, + void *buf, int buflen) +{ + RETURN(-EFAULT); +} + static int cmr_xattr_set(const struct lu_context *ctx, struct md_object *mo, const void *buf, int buflen, const char *name) { diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index 98d3589..28a3cc2 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -182,6 +182,15 @@ struct dt_object_operations { const void *buf, int buf_len, const char *name, struct thandle *handle); /* + * Place list of existing extended attributes into @buf (which has + * length len). + * + * precondition: lu_object_exists(ctxt, &dt->do_lu); + */ + int (*do_xattr_list)(const struct lu_context *ctxt, + struct dt_object *dt, + const void *buf, int buf_len); + /* * Create new object on this device. * * precondition: !lu_object_exists(ctxt, &dt->do_lu); diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index 3cd8bc3..1fbed82 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -72,6 +72,10 @@ struct md_object_operations { struct md_object *obj, void *buf, int buf_len, const char *name); + int (*moo_xattr_list)(const struct lu_context *ctxt, + struct md_object *obj, + void *buf, int buf_len); + int (*moo_xattr_set)(const struct lu_context *ctxt, struct md_object *obj, const void *buf, int buf_len, const char *name); @@ -83,7 +87,7 @@ struct md_object_operations { struct md_attr *); int (*moo_open)(const struct lu_context *, struct md_object *); int (*moo_close)(const struct lu_context *, struct md_object *); - + int (*moo_readpage)(const struct lu_context *, struct md_object *, struct lu_rdpg *); }; @@ -215,7 +219,7 @@ static inline int mo_xattr_del(const struct lu_context *cx, } static inline int mo_xattr_set(const struct lu_context *cx, - struct md_object *m, const void *buf, + struct md_object *m, const void *buf, int buf_len, const char *name) { LASSERT(m->mo_ops->moo_xattr_set); @@ -227,8 +231,7 @@ static inline int mo_xattr_list(const struct lu_context *cx, void *buf, int buf_len) { LASSERT(m->mo_ops->moo_xattr_get); - /*NULL name for get? or we need a new interface*/ - return m->mo_ops->moo_xattr_get(cx, m, buf, buf_len, NULL); + return m->mo_ops->moo_xattr_list(cx, m, buf, buf_len); } static inline int mo_open(const struct lu_context *cx, struct md_object *m) @@ -279,7 +282,7 @@ static inline int mdo_lookup(const struct lu_context *cx, struct md_object *p, } static inline int mdo_create(const struct lu_context *cx, struct md_object *p, - const char *child_name, struct md_object *c, + const char *child_name, struct md_object *c, const char *target_name, struct md_attr *at) { LASSERT(c->mo_dir_ops->mdo_create); diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index f2e49bf..5f01e84 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -160,6 +160,23 @@ static int mdd_xattr_get(const struct lu_context *ctxt, struct md_object *obj, RETURN(rc); } +static int mdd_xattr_list(const struct lu_context *ctxt, struct md_object *obj, + void *buf, int buf_len) +{ + struct mdd_object *mdd_obj = md2mdd_obj(obj); + struct dt_object *next; + int rc; + + ENTRY; + + LASSERT(lu_object_exists(ctxt, &obj->mo_lu)); + + next = mdd_object_child(mdd_obj); + rc = next->do_ops->do_xattr_list(ctxt, next, buf, buf_len); + + RETURN(rc); +} + enum mdd_txn_op { MDD_TXN_OBJECT_DESTROY_OP, MDD_TXN_OBJECT_CREATE_OP, @@ -1192,7 +1209,8 @@ static struct md_object_operations mdd_obj_ops = { .moo_attr_set = mdd_attr_set, .moo_xattr_get = mdd_xattr_get, .moo_xattr_set = mdd_xattr_set, - .moo_object_create = mdd_object_create, + .moo_xattr_list = mdd_xattr_list, + .moo_object_create = mdd_object_create, .moo_ref_add = mdd_ref_add, .moo_ref_del = mdd_ref_del, .moo_open = mdd_open, diff --git a/lustre/mdt/mdt_xattr.c b/lustre/mdt/mdt_xattr.c index 69b96ff..572076c 100644 --- a/lustre/mdt/mdt_xattr.c +++ b/lustre/mdt/mdt_xattr.c @@ -106,7 +106,7 @@ int mdt_getxattr(struct mdt_thread_info *info) CDEBUG(D_INODE, "getxattr "DFID3"\n", PFID3(&info->mti_body->fid1)); - if (MDT_FAIL_CHECK(OBD_FAIL_MDS_GETXATTR_PACK)) + if (MDT_FAIL_CHECK(OBD_FAIL_MDS_GETXATTR_PACK)) RETURN(-ENOMEM); next = mdt_object_child(info->mti_object); @@ -127,7 +127,7 @@ int mdt_getxattr(struct mdt_thread_info *info) CDEBUG(D_INODE, "getxattr %s\n", xattr_name); rc = mo_xattr_get(info->mti_ctxt, next, - buf, buflen, xattr_name); + buf, buflen, xattr_name); if (rc < 0 && rc != -ENODATA && rc != -EOPNOTSUPP && rc != -ERANGE) @@ -167,7 +167,7 @@ int mdt_setxattr(struct mdt_thread_info *info) CDEBUG(D_INODE, "setxattr "DFID3"\n", PFID3(&info->mti_body->fid1)); - if (MDT_FAIL_CHECK(OBD_FAIL_MDS_SETXATTR)) + if (MDT_FAIL_CHECK(OBD_FAIL_MDS_SETXATTR)) RETURN(-ENOMEM); /* various sanity check for xattr name */ diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index ae5404b..d89a3f9 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -820,6 +820,12 @@ int osd_xattr_set(const struct lu_context *ctxt, struct dt_object *dt, return 0; } +int osd_xattr_list(const struct lu_context *ctxt, struct dt_object *dt, + const void *buf, int buf_len, struct thandle *handle) +{ + return 0; +} + int osd_readpage(const struct lu_context *ctxt, struct dt_object *dt, struct lu_rdpg *rdpg) { @@ -828,7 +834,7 @@ int osd_readpage(const struct lu_context *ctxt, LASSERT(osd_invariant(obj)); LASSERT(rdpg->rp_pages != NULL); - + /* check input params */ if ((rdpg->rp_offset & (obj->oo_inode->i_blksize - 1)) != 0) { CERROR("offset "LPU64" not on a block boundary of %lu\n", @@ -853,17 +859,18 @@ int osd_readpage(const struct lu_context *ctxt, } static struct dt_object_operations osd_obj_ops = { - .do_lock = osd_object_lock, - .do_unlock = osd_object_unlock, - .do_attr_get = osd_attr_get, - .do_attr_set = osd_attr_set, - .do_create = osd_object_create, - .do_index_try = osd_index_try, - .do_ref_add = osd_object_ref_add, - .do_ref_del = osd_object_ref_del, - .do_xattr_get = osd_xattr_get, - .do_xattr_set = osd_xattr_set, - .do_readpage = osd_readpage + .do_lock = osd_object_lock, + .do_unlock = osd_object_unlock, + .do_attr_get = osd_attr_get, + .do_attr_set = osd_attr_set, + .do_create = osd_object_create, + .do_index_try = osd_index_try, + .do_ref_add = osd_object_ref_add, + .do_ref_del = osd_object_ref_del, + .do_xattr_get = osd_xattr_get, + .do_xattr_set = osd_xattr_set, + .do_xattr_list = osd_xattr_list, + .do_readpage = osd_readpage }; static struct dt_body_operations osd_body_ops = {