}
static int cml_xattr_set(const struct lu_context *ctx, struct md_object *mo,
- const void *buf, int buflen, const char *name)
+ const void *buf, int buflen, const char *name, int fl)
{
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, fl);
+ RETURN(rc);
+}
+
+static int cml_xattr_del(const struct lu_context *ctx, struct md_object *mo,
+ const char *name)
+{
+ int rc;
+ ENTRY;
+ rc = mo_xattr_del(ctx, md_object_next(mo), name);
RETURN(rc);
}
.moo_xattr_get = cml_xattr_get,
.moo_xattr_list = cml_xattr_list,
.moo_xattr_set = cml_xattr_set,
+ .moo_xattr_del = cml_xattr_del,
.moo_object_create = cml_object_create,
.moo_ref_add = cml_ref_add,
.moo_ref_del = cml_ref_del,
}
static int cmr_xattr_set(const struct lu_context *ctx, struct md_object *mo,
- const void *buf, int buflen, const char *name)
+ const void *buf, int buflen, const char *name, int fl)
+{
+ RETURN(-EFAULT);
+}
+
+static int cmr_xattr_del(const struct lu_context *ctx, struct md_object *mo,
+ const char *name)
{
RETURN(-EFAULT);
}
.moo_attr_set = cmr_attr_set,
.moo_xattr_get = cmr_xattr_get,
.moo_xattr_set = cmr_xattr_set,
+ .moo_xattr_list = cmr_xattr_list,
+ .moo_xattr_del = cmr_xattr_del,
.moo_object_create = cmr_object_create,
.moo_ref_add = cmr_ref_add,
.moo_ref_del = cmr_ref_del,
/*
* Set value of an extended attribute.
*
+ * @fl - flags from enum lu_xattr_flags
+ *
* precondition: lu_object_exists(ctxt, &dt->do_lu);
*/
int (*do_xattr_set)(const struct lu_context *ctxt,
struct dt_object *dt,
const void *buf, int buf_len,
+ const char *name, int fl, struct thandle *handle);
+ /*
+ * Delete existing extended attribute.
+ *
+ * precondition: lu_object_exists(ctxt, &dt->do_lu);
+ */
+ int (*do_xattr_del)(const struct lu_context *ctxt,
+ struct dt_object *dt,
const char *name, struct thandle *handle);
/*
* Place list of existing extended attributes into @buf (which has
* precondition: lu_object_exists(ctxt, &dt->do_lu);
*/
int (*do_xattr_list)(const struct lu_context *ctxt,
- struct dt_object *dt,
- void *buf, int buf_len);
+ struct dt_object *dt, void *buf, int buf_len);
/*
* Create new object on this device.
*
__u64 rp_size; /* file size in total */
};
+enum lu_xattr_flags {
+ LU_XATTR_REPLACE = (1 << 0),
+ LU_XATTR_CREATE = (1 << 1)
+};
+
/*
* lu_context. Execution context for lu_object methods. Currently associated
* with thread.
#define MAX_MD_SIZE (sizeof(struct lov_mds_md) + 4 * sizeof(struct lov_ost_data))
#define XATTR_NAME_ACL_ACCESS "system.posix_acl_access"
-#define XATTR_NAME_LOV "lov"
+#define XATTR_NAME_LOV "trusted.lov"
#define OBD_MD_FLID (0x00000001ULL) /* object ID */
struct ptlrpc_request *req, struct lustre_handle *);
int md_lov_connect(struct obd_device *obd, struct md_lov_info *mli,
- char *lov_name, struct obd_uuid *uuid,
+ char *lov_name, struct obd_uuid *uuid,
struct md_lov_ops *mlo, const void *ctxt);
int md_lov_notity_pre(struct obd_device *obd, struct md_lov_info *mli,
struct obd_device *watched, enum obd_notify_event ev,
#define IOC_REQUEST_CLOSE _IOWR('f', 35, long)
#define IOC_REQUEST_MAX_NR 35
-#define MDS_LOV_MD_NAME "lov"
+#define MDS_LOV_MD_NAME "trusted.lov"
#define MDD_OBD_NAME "mdd_obd"
#define MDD_OBD_UUID "mdd_obd_uuid"
#define MDD_OBD_TYPE "mds"
int (*moo_xattr_set)(const struct lu_context *ctxt,
struct md_object *obj, const void *buf,
- int buf_len, const char *name);
+ int buf_len, const char *name, int fl);
+ int (*moo_xattr_del)(const struct lu_context *ctxt,
+ struct md_object *obj, const char *name);
+
/* part of cross-ref operation */
int (*moo_object_create)(const struct lu_context *,
struct md_object *, struct md_attr *);
const char *name)
{
LASSERT(m->mo_ops->moo_xattr_set);
- /*NULL buffer & zero length for set? or we need a new interface*/
- return m->mo_ops->moo_xattr_set(cx, m, NULL, 0, name);
+ return m->mo_ops->moo_xattr_del(cx, m, name);
}
static inline int mo_xattr_set(const struct lu_context *cx,
struct md_object *m, const void *buf,
- int buf_len, const char *name)
+ int buf_len, const char *name, int flags)
{
LASSERT(m->mo_ops->moo_xattr_set);
- return m->mo_ops->moo_xattr_set(cx, m, buf, buf_len, name);
+ return m->mo_ops->moo_xattr_set(cx, m, buf, buf_len, name, flags);
}
static inline int mo_xattr_list(const struct lu_context *cx,
Index: iam/fs/ext3/Makefile
===================================================================
--- iam.orig/fs/ext3/Makefile 2006-05-31 20:24:32.000000000 +0400
-+++ iam/fs/ext3/Makefile 2006-07-21 23:12:10.000000000 +0400
++++ iam/fs/ext3/Makefile 2006-07-25 16:59:51.000000000 +0400
@@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o
ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
Index: iam/include/linux/lustre_iam.h
===================================================================
--- iam.orig/include/linux/lustre_iam.h 2006-05-31 20:24:32.000000000 +0400
-+++ iam/include/linux/lustre_iam.h 2006-07-21 23:12:10.000000000 +0400
++++ iam/include/linux/lustre_iam.h 2006-07-25 16:59:51.000000000 +0400
@@ -1,9 +1,68 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
Index: iam/fs/ext3/Makefile
===================================================================
---- iam.orig/fs/ext3/Makefile 2006-07-21 23:12:10.000000000 +0400
-+++ iam/fs/ext3/Makefile 2006-07-21 23:12:10.000000000 +0400
+--- iam.orig/fs/ext3/Makefile 2006-07-25 16:59:51.000000000 +0400
++++ iam/fs/ext3/Makefile 2006-07-25 16:59:51.000000000 +0400
@@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o
ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
Index: iam/fs/ext3/dir.c
===================================================================
---- iam.orig/fs/ext3/dir.c 2006-07-21 23:12:10.000000000 +0400
-+++ iam/fs/ext3/dir.c 2006-07-21 23:12:10.000000000 +0400
+--- iam.orig/fs/ext3/dir.c 2006-07-25 16:59:51.000000000 +0400
++++ iam/fs/ext3/dir.c 2006-07-25 16:59:51.000000000 +0400
@@ -28,6 +28,7 @@
#include <linux/smp_lock.h>
#include <linux/slab.h>
(filp->f_version != inode->i_version)) {
Index: iam/fs/ext3/file.c
===================================================================
---- iam.orig/fs/ext3/file.c 2006-07-21 23:12:10.000000000 +0400
-+++ iam/fs/ext3/file.c 2006-07-21 23:12:10.000000000 +0400
+--- iam.orig/fs/ext3/file.c 2006-07-25 16:59:51.000000000 +0400
++++ iam/fs/ext3/file.c 2006-07-25 16:59:51.000000000 +0400
@@ -23,6 +23,7 @@
#include <linux/jbd.h>
#include <linux/ext3_fs.h>
Index: iam/fs/ext3/iam-uapi.c
===================================================================
--- iam.orig/fs/ext3/iam-uapi.c 2004-04-06 17:27:52.000000000 +0400
-+++ iam/fs/ext3/iam-uapi.c 2006-07-21 23:12:10.000000000 +0400
++++ iam/fs/ext3/iam-uapi.c 2006-07-25 16:59:51.000000000 +0400
@@ -0,0 +1,361 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+}
Index: iam/fs/ext3/ioctl.c
===================================================================
---- iam.orig/fs/ext3/ioctl.c 2006-07-21 23:12:10.000000000 +0400
-+++ iam/fs/ext3/ioctl.c 2006-07-21 23:12:10.000000000 +0400
+--- iam.orig/fs/ext3/ioctl.c 2006-07-25 16:59:51.000000000 +0400
++++ iam/fs/ext3/ioctl.c 2006-07-25 16:59:51.000000000 +0400
@@ -250,6 +250,6 @@ flags_err:
}
Index: iam/include/linux/lustre_iam.h
===================================================================
---- iam.orig/include/linux/lustre_iam.h 2006-07-21 23:12:10.000000000 +0400
-+++ iam/include/linux/lustre_iam.h 2006-07-21 23:12:10.000000000 +0400
+--- iam.orig/include/linux/lustre_iam.h 2006-07-25 16:59:51.000000000 +0400
++++ iam/include/linux/lustre_iam.h 2006-07-25 16:59:51.000000000 +0400
@@ -30,9 +30,6 @@
#ifndef __LINUX_LUSTRE_IAM_H__
#define __LINUX_LUSTRE_IAM_H__
icbd.icbd_parent = parent;
/* allocate new fid for child */
- if (it->it_op & IT_CREAT ||
+ if (it->it_op & IT_CREAT ||
(it->it_op & IT_OPEN && it->it_create_mode & O_CREAT)) {
struct lu_placement_hint hint = { .ph_pname = NULL,
.ph_cname = &dentry->d_name,
.ph_opc = LUSTRE_OPC_CREATE };
-
+
rc = ll_fid_md_alloc(ll_i2sbi(parent), &op_data.fid2, &hint);
if (rc) {
CERROR("can't allocate new fid, rc %d\n", rc);
struct lu_placement_hint hint = { .ph_pname = NULL,
.ph_cname = name,
.ph_opc = LUSTRE_OPC_SYMLINK };
-
+
struct ptlrpc_request *request = NULL;
struct ll_sb_info *sbi = ll_i2sbi(dir);
struct md_op_data op_data = { { 0 } };
err = md_create(sbi->ll_md_exp, &op_data, NULL, 0, mode,
current->fsuid, current->fsgid, current->cap_effective,
0, &request);
- if (err == 0)
- ll_update_times(request, 0, dir);
-
ll_update_times(request, 0, dir);
- if (dchild) {
+ if (!err && dchild) {
err = ll_prep_inode(&inode, request, 0,
dchild->d_sb);
if (err)
RETURN(-EBUSY);
}
}
-
+
ll_prepare_md_op_data(&op_data, dir, NULL, name->name,
name->len, S_IFDIR);
rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, &op_data, &request);
{
return ll_symlink_generic(dir, &dentry->d_name, oldname);
}
-static int ll_link(struct dentry *old_dentry, struct inode *dir,
+static int ll_link(struct dentry *old_dentry, struct inode *dir,
struct dentry *new_dentry)
{
return ll_link_generic(old_dentry->d_inode, dir, &new_dentry->d_name);
static int ll_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry)
{
- return ll_rename_generic(old_dir, &old_dentry->d_name, new_dir,
+ return ll_rename_generic(old_dir, &old_dentry->d_name, new_dir,
&new_dentry->d_name);
}
#endif
.setattr = ll_setattr,
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
.getattr_it = ll_getattr_it,
-#else
+#else
.revalidate_it = ll_inode_revalidate_it,
#endif
.permission = ll_inode_permission,
static int __mdd_xattr_set(const struct lu_context *ctxt,struct mdd_device *mdd,
struct mdd_object *obj, const void *buf,
- int buf_len, const char *name,struct thandle *handle)
+ int buf_len, const char *name, int fl,
+ struct thandle *handle)
{
struct dt_object *next;
LASSERT(lu_object_exists(ctxt, mdd2lu_obj(obj)));
next = mdd_object_child(obj);
- return next->do_ops->do_xattr_set(ctxt, next, buf, buf_len, name,
+ return next->do_ops->do_xattr_set(ctxt, next, buf, buf_len, name, fl,
handle);
}
int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
- const void *buf, int buf_len, const char *name)
+ const void *buf, int buf_len, const char *name, int fl)
{
struct mdd_device *mdd = mdo2mdd(obj);
struct thandle *handle;
RETURN(PTR_ERR(handle));
rc = __mdd_xattr_set(ctxt, mdd, md2mdd_obj(obj), buf, buf_len, name,
- handle);
+ fl, handle);
+
+ mdd_trans_stop(ctxt, mdd, handle);
+
+ RETURN(rc);
+}
+
+static int __mdd_xattr_del(const struct lu_context *ctxt,struct mdd_device *mdd,
+ struct mdd_object *obj,
+ const char *name, struct thandle *handle)
+{
+ struct dt_object *next;
+
+ LASSERT(lu_object_exists(ctxt, mdd2lu_obj(obj)));
+ next = mdd_object_child(obj);
+ return next->do_ops->do_xattr_del(ctxt, next, name, handle);
+}
+
+int mdd_xattr_del(const struct lu_context *ctxt, struct md_object *obj,
+ const char *name)
+{
+ struct mdd_device *mdd = mdo2mdd(obj);
+ struct thandle *handle;
+ int rc;
+ ENTRY;
+
+ mdd_txn_param_build(ctxt, &MDD_TXN_XATTR_SET);
+ handle = mdd_trans_start(ctxt, mdd);
+ if (IS_ERR(handle))
+ RETURN(PTR_ERR(handle));
+
+ rc = __mdd_xattr_del(ctxt, mdd, md2mdd_obj(obj), name, handle);
mdd_trans_stop(ctxt, mdd, handle);
.moo_xattr_get = mdd_xattr_get,
.moo_xattr_set = mdd_xattr_set,
.moo_xattr_list = mdd_xattr_list,
+ .moo_xattr_del = mdd_xattr_del,
.moo_object_create = mdd_object_create,
.moo_ref_add = mdd_ref_add,
.moo_ref_del = mdd_ref_del,
int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd);
int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
- const void *buf, int buf_len, const char *name);
+ const void *buf, int buf_len, const char *name, int fl);
int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj,
struct md_object *child, struct lov_mds_md *lmm,
int lmm_size);
#endif
RETURN(rc);
}
-static int mdd_lov_write_catlist(struct obd_device *obd, void *idarray, int size,
+static int mdd_lov_write_catlist(struct obd_device *obd, void *idarray, int size,
const void *ctxt)
{
int rc = 0;
struct md_lov_info *mli;
int rc;
ENTRY;
-
+
lustre_cfg_bufs_reset(&bufs, MDD_OBD_NAME);
lustre_cfg_bufs_set_string(&bufs, 1, MDD_OBD_TYPE);
lustre_cfg_bufs_set_string(&bufs, 2, MDD_OBD_UUID);
lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs);
if (!lcfg)
RETURN(-ENOMEM);
-
+
rc = class_attach(lcfg);
if (rc)
GOTO(lcfg_cleanup, rc);
-
+
obd = class_name2obd(MDD_OBD_NAME);
if (!obd) {
CERROR("can not find obd %s \n", MDD_OBD_NAME);
LBUG();
}
-
+
/*init mli, which will be used in following mds setup*/
mli = &obd->u.mds.mds_lov_info;
mli->md_lov_ops = &mdd_lov_ops;
-
+
obj_id = dt_store_open(ctxt, mdd->mdd_child, mdd_lov_objid_name,
&mli->md_lov_objid_fid);
if (IS_ERR(obj_id)){
struct lustre_cfg_bufs bufs;
struct md_lov_info *mli;
struct lustre_cfg *lcfg;
- struct obd_device *obd;
+ struct obd_device *obd;
int rc;
ENTRY;
-
+
obd = mdd->mdd_md_dev.md_lu_dev.ld_obd;
LASSERT(obd);
-
+
mli = &obd->u.mds.mds_lov_info;
dt_object_fini(mli->md_lov_objid_obj);
-
+
lustre_cfg_bufs_reset(&bufs, MDD_OBD_NAME);
lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs);
if (!lcfg)
rc = class_cleanup(obd, lcfg);
if (rc)
GOTO(lcfg_cleanup, rc);
-
+
rc = class_detach(obd, lcfg);
if (rc)
GOTO(lcfg_cleanup, rc);
next = mdd_object_child(md2mdd_obj(obj));
rc = next->do_ops->do_xattr_get(ctxt, next, md, *md_size,
MDS_LOV_MD_NAME);
- if (rc < 0) {
+ /*
+ * XXX: handling of -ENODATA, the right way is to have ->do_md_get()
+ * exported by dt layer.
+ */
+ if (rc == 0 || rc == -ENODATA) {
+ *md_size = 0;
+ rc = 0;
+ } else if (rc < 0) {
CERROR("Error %d reading eadata \n", rc);
} else if (rc > 0) {
lmm_size = rc;
/*FIXME convert lov EA necessary for this version?*/
*md_size = lmm_size;
rc = lmm_size;
- } else {
- *md_size = 0;
}
RETURN (rc);
rc = mdd_get_md(ctxt, pobj, &lmm, &size, 1);
if (rc > 0) {
rc = mdd_xattr_set(ctxt, child, lmm, size,
- MDS_LOV_MD_NAME);
+ /*
+ * Flags are 0: we don't care
+ * whether attribute exists
+ * already.
+ */
+ MDS_LOV_MD_NAME, 0);
if (rc)
CERROR("error on copy stripe info: rc = %d\n",
rc);
} else if (lmmp) {
LASSERT(lmm_size > 0);
rc = mdd_xattr_set(ctxt, child, lmmp, lmm_size,
- MDS_LOV_MD_NAME);
+ MDS_LOV_MD_NAME, 0);
if (rc)
CERROR("error on copy stripe info: rc = %d\n",
rc);
int *lmm_size)
{
struct obd_device *obd = mdd->mdd_md_dev.md_lu_dev.ld_obd;
- struct obd_export *lov_exp = obd->u.mds.mds_osc_exp;
+ struct obd_export *lov_exp = obd->u.mds.mds_osc_exp;
struct obdo *oa;
struct lov_stripe_md *lsm = NULL;
int rc = 0;
* also in mdt_md_create() and mdt_object_open()
*/
if (need_pack_reply) {
- rc = req_capsule_pack(&info->mti_pill);
+ rc = req_capsule_pack(pill);
if (rc)
RETURN(rc);
}
- repbody = req_capsule_server_get(&info->mti_pill,
- &RMF_MDT_BODY);
+ repbody = req_capsule_server_get(pill, &RMF_MDT_BODY);
repbody->fid1 = *mdt_object_fid(o);
repbody->valid |= OBD_MD_FLID;
RETURN(0);
/* now, to getattr*/
if (mdt_body_has_lov(la, reqbody)) {
if (length > 0) {
- rc = mo_xattr_get(info->mti_ctxt, next,
+ rc = mo_xattr_get(ctxt, next,
buffer, length, XATTR_NAME_LOV);
if (rc > 0) {
if (S_ISDIR(la->la_mode))
} else if (S_ISLNK(la->la_mode) &&
(reqbody->valid & OBD_MD_LINKNAME) != 0) {
/* FIXME How to readlink??
- rc = mo_xattr_get(info->mti_ctxt, next,
- buffer, length, "readlink");
+ rc = mo_xattr_get(ctxt, next, buffer, length, "readlink");
*/ rc = 10;
if (rc <= 0) {
CERROR("readlink failed: %d\n", rc);
#ifdef CONFIG_FS_POSIX_ACL
if ((req->rq_export->exp_connect_flags & OBD_CONNECT_ACL) &&
(reqbody->valid & OBD_MD_FLACL)) {
- buffer = req_capsule_server_get(&info->mti_pill,
- &RMF_EADATA);
- length = req_capsule_get_size(&info->mti_pill,
- &RMF_EADATA,
- RCL_SERVER);
+ buffer = req_capsule_server_get(pill, &RMF_EADATA);
+ length = req_capsule_get_size(pill, &RMF_EADATA, RCL_SERVER);
if (length > 0) {
- rc = mo_xattr_get(info->mti_ctxt, next, buffer,
+ rc = mo_xattr_get(ctxt, next, buffer,
length, XATTR_NAME_ACL_ACCESS);
if (rc < 0) {
CERROR("got acl size: %d\n", rc);
OBD_ALLOC(rdpg->rp_pages, rdpg->rp_npages * sizeof rdpg->rp_pages[0]);
if (rdpg->rp_pages == NULL)
GOTO(out, rc = -ENOMEM);
-
+
for (i = 0; i < rdpg->rp_npages; ++i) {
rdpg->rp_pages[i] = alloc_pages(GFP_KERNEL, 0);
if (rdpg->rp_pages[i] == NULL)
rc = mo_readpage(info->mti_ctxt, mdt_object_child(object), rdpg);
if (rc)
GOTO(free_rdpg, rc);
-
+
repbody->size = rdpg->rp_size;
repbody->valid = OBD_MD_FLSIZE;
/* send pages to client */
rc = mdt_sendpage(info, rdpg);
-
+
EXIT;
free_rdpg:
for (i = 0; i < rdpg->rp_npages; i++)
int mdt_update_last_transno(struct mdt_thread_info *info, int rc)
{
- struct mdt_device *mdt = info->mti_mdt;
- struct ptlrpc_request * req = mdt_info_req(info);
+ struct mdt_device *mdt = info->mti_mdt;
+ struct ptlrpc_request *req = mdt_info_req(info);
+ struct obd_export *exp = req->rq_export;
__u64 last_transno;
__u64 last_committed;
/*last_committed = (mdt->mdt_last_committed);*/
last_committed = last_transno;
#endif
- last_transno = info->mti_transno;
- CDEBUG(D_INFO, "last_transno = %llu, last_committed = %llu\n",
- last_transno, last_committed);
+ if (rc == 0) {
+ last_transno = info->mti_transno;
+ CDEBUG(D_INFO, "last_transno = %llu, last_committed = %llu\n",
+ last_transno, last_committed);
+ } else {
+ last_transno = 0;
+ CERROR("replay %s transno "LPU64" failed: rc %d\n",
+ libcfs_nid2str(exp->exp_connection->c_peer.nid),
+ last_transno, rc);
+ }
req->rq_repmsg->transno = req->rq_transno = last_transno;
req->rq_repmsg->last_xid = req->rq_xid;
req->rq_repmsg->last_committed = last_committed;
- req->rq_export->exp_obd->obd_last_committed = last_committed;
+ exp->exp_obd->obd_last_committed = last_committed;
return 0;
}
struct lu_attr *la = &info->mti_attr.ma_attr;
int rc = 0;
ENTRY;
-
+
body = req_capsule_server_get(&info->mti_pill,
&RMF_MDT_BODY);
mdt_pack_attr2body(body, la, mdt_object_fid(mo));
-
+
/* if last unlinked object reference so client should destroy ost
* objects*/
if (S_ISREG(la->la_mode) &&
la->la_nlink == 0 && mo->mot_header.loh_ref == 1) {
struct lov_mds_md *lmm;
-
+
/* reply should contains more data,
* * so we need to extend it */
req_capsule_extend(&info->mti_pill, fmt);
-
+
lmm = req_capsule_server_get(&info->mti_pill,
&RMF_MDT_MD);
-
-
+
+
/*TODO: lmm data & llog cookie
* rc = mo_xattr_get(info->mti_ctxt, mdt_object_child(o),
- * lmm, info->mti_mdt->mdt_max_mdsize,
- * XATTR_NAME_LOV);
+ * lmm, info->mti_mdt->mdt_max_mdsize,
+ * MDS_LOV_MD_NAME);
* if (rc >= 0) {
* if (S_ISDIR(info->mti_attr.la_mode))
* body->valid |= OBD_MD_FLDIREA;
if (req_capsule_field_present(pill, &RMF_EADATA)) {
rr->rr_eadata = req_capsule_client_get(pill, &RMF_EADATA);
- rr->rr_eadatalen = req_capsule_get_size(pill,
+ rr->rr_eadatalen = req_capsule_get_size(pill,
&RMF_EADATA,
RCL_CLIENT);
}
if (req_capsule_field_present(pill, &RMF_LOGCOOKIES)) {
- rr->rr_logcookies = req_capsule_client_get(pill,
+ rr->rr_logcookies = req_capsule_client_get(pill,
&RMF_LOGCOOKIES);
- rr->rr_logcookielen = req_capsule_get_size(pill,
+ rr->rr_logcookielen = req_capsule_get_size(pill,
&RMF_LOGCOOKIES,
RCL_CLIENT);
}
rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);
if (rr->rr_name) {
if (req_capsule_field_present(pill, &RMF_SYMTGT)) {
- rr->rr_tgt = req_capsule_client_get(pill,
+ rr->rr_tgt = req_capsule_client_get(pill,
&RMF_SYMTGT);
if (rr->rr_tgt == NULL)
result = -EFAULT;
rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);
if (rr->rr_name == NULL)
- result = -EFAULT;
+ result = -EFAULT;
} else
- result = -EFAULT;
+ result = -EFAULT;
RETURN(result);
}
{
}
-/* Create a new mdt_file_data struct, initialize it,
- * and insert it to global hash table */
+/* Create a new mdt_file_data struct, initialize it,
+ * and insert it to global hash table */
static struct mdt_file_data *mdt_mfd_new(void)
{
struct mdt_file_data *mfd;
}
static int mdt_mfd_open(struct mdt_thread_info *info,
- struct mdt_object *o,
+ struct mdt_object *o,
int flags, int created)
{
struct mdt_export_data *med;
if (rc == 0) {
ma->ma_valid |= MA_INODE;
if (S_ISREG(la->la_mode)) {
- rc = mo_xattr_get(info->mti_ctxt,
+ rc = mo_xattr_get(info->mti_ctxt,
mdt_object_child(o),
- ma->ma_lmm,
+ ma->ma_lmm,
ma->ma_lmm_size,
XATTR_NAME_LOV);
if (rc >= 0) {
/* FIXME:maybe this can be done earlier? */
if (S_ISDIR(la->la_mode)) {
if (flags & (MDS_OPEN_CREAT | FMODE_WRITE)) {
- /* we are trying to create or
+ /* we are trying to create or
* write an existing dir. */
rc = -EISDIR;
}
- } else if (flags & MDS_OPEN_DIRECTORY)
+ } else if (flags & MDS_OPEN_DIRECTORY)
rc = -ENOTDIR;
}
if (rc != 0)
spin_unlock(&med->med_open_lock);
repbody->handle.cookie = mfd->mfd_handle.h_cookie;
- } else
+ } else
rc = -ENOMEM;
RETURN(rc);
if (la->la_flags & MDS_OPEN_EXCL &&
la->la_flags & MDS_OPEN_CREAT)
rc = -EEXIST;
- else
+ else
rc = mdt_mfd_open(info, o, flags, 0);
} else {
rc = -ENOENT;
if (la->la_flags & MDS_OPEN_CREAT) {
- rc = mo_object_create(info->mti_ctxt,
+ rc = mo_object_create(info->mti_ctxt,
mdt_object_child(o),
&info->mti_attr);
if (rc == 0)
struct mdt_body *body;
int rc;
ENTRY;
-
+
rc = req_capsule_pack(&info->mti_pill);
if (rc == 0) {
body = req_capsule_client_get(&info->mti_pill, &RMF_MDT_BODY);
int created = 0;
struct mdt_reint_record *rr = &info->mti_rr;
ENTRY;
-
+
ma->ma_lmm = req_capsule_server_get(&info->mti_pill,
&RMF_MDT_MD);
ma->ma_lmm_size = req_capsule_get_size(&info->mti_pill,
lh->mlh_mode = LCK_PR;
else
lh->mlh_mode = LCK_PW;
- parent = mdt_object_find_lock(info, rr->rr_fid1, lh,
+ parent = mdt_object_find_lock(info, rr->rr_fid1, lh,
MDS_INODELOCK_UPDATE);
if (IS_ERR(parent))
GOTO(out, result = PTR_ERR(parent));
&info->mti_attr);
if (rc2 != 0)
CERROR("error in cleanup of open");
- }
+ }
out_child:
mdt_object_put(info->mti_ctxt, child);
out_parent:
class_handle_unhash(&mfd->mfd_handle);
list_del_init(&mfd->mfd_list);
spin_unlock(&med->med_open_lock);
-
+
rc = mdt_handle_last_unlink(info, mfd->mfd_object,
&RQF_MDS_CLOSE_LAST);
if (rr->rr_eadatalen > 0)
rc = mo_xattr_set(info->mti_ctxt, next,
rr->rr_eadata, rr->rr_eadatalen,
- XATTR_NAME_LOV);
+ XATTR_NAME_LOV, 0);
/* FIXME & TODO Please deal with logcookies here*/
GOTO(out_unlock, rc);
if (strlen(rr->rr_name) == 0) {
/* remote partial operation */
- rc = mo_ref_del(info->mti_ctxt, mdt_object_child(mp),
+ rc = mo_ref_del(info->mti_ctxt, mdt_object_child(mp),
&info->mti_attr);
GOTO(out_unlock_parent, rc);
}
/* cmm will take care if child is local or remote */
rc = mdo_unlink(info->mti_ctxt, mdt_object_child(mp),
mdt_object_child(mc), rr->rr_name, &info->mti_attr);
-
+
if (rc)
GOTO(out_unlock_child, rc);
-
+
rc = mdt_handle_last_unlink(info, mc, &RQF_MDS_REINT_UNLINK_LAST);
GOTO(out_unlock_child, rc);
#endif
#define DEBUG_SUBSYSTEM S_MDS
+/* prerequisite for linux/xattr.h */
+#include <linux/types.h>
+/* prerequisite for linux/xattr.h */
+#include <linux/fs.h>
+/* XATTR_{REPLACE,CREATE} */
+#include <linux/xattr.h>
+
#include "mdt_internal.h"
const char user_string[] = "user.";
const char trust_string[] = "trusted.";
struct mdt_lock_handle *lh;
- __u64 valid = info->mti_body->valid;
+ struct req_capsule *pill = &info->mti_pill;
+ struct mdt_object *obj = info->mti_object;
+ const struct mdt_body *body = info->mti_body;
+ const struct lu_context *ctx = info->mti_ctxt;
+ struct md_object *child = mdt_object_child(obj);
+ __u64 valid = body->valid;
char *xattr_name;
int xattr_len;
__u64 lockpart;
int rc;
ENTRY;
- CDEBUG(D_INODE, "setxattr "DFID3"\n",
- PFID3(&info->mti_body->fid1));
+ CDEBUG(D_INODE, "setxattr "DFID3"\n", PFID3(&body->fid1));
if (MDT_FAIL_CHECK(OBD_FAIL_MDS_SETXATTR))
RETURN(-ENOMEM);
/* various sanity check for xattr name */
- xattr_name = req_capsule_client_get(&info->mti_pill, &RMF_NAME);
+ xattr_name = req_capsule_client_get(pill, &RMF_NAME);
if (!xattr_name)
GOTO(out, rc = -EFAULT);
CDEBUG(D_INODE, "%s xattr %s\n",
- info->mti_body->valid & OBD_MD_FLXATTR ? "set" : "remove",
- xattr_name);
+ body->valid & OBD_MD_FLXATTR ? "set" : "remove", xattr_name);
if (strncmp(xattr_name, trust_string, sizeof(trust_string) - 1) == 0) {
if (strcmp(xattr_name + 8, XATTR_NAME_LOV) == 0)
lh = &info->mti_lh[MDT_LH_PARENT];
lh->mlh_mode = LCK_EX;
- rc = mdt_object_lock(info, info->mti_object, lh, lockpart);
+ rc = mdt_object_lock(info, obj, lh, lockpart);
if (rc != 0)
GOTO(out, rc);
if ((valid & OBD_MD_FLXATTR) == OBD_MD_FLXATTR) {
char * xattr;
- if (!req_capsule_field_present(&info->mti_pill, &RMF_EADATA)) {
+ if (!req_capsule_field_present(pill, &RMF_EADATA)) {
CERROR("no xattr data supplied\n");
GOTO(out_unlock, rc = -EFAULT);
}
- xattr_len = req_capsule_get_size(&info->mti_pill,
- &RMF_EADATA, RCL_CLIENT);
+ xattr_len = req_capsule_get_size(pill, &RMF_EADATA, RCL_CLIENT);
if (xattr_len) {
- xattr = req_capsule_client_get(&info->mti_pill,
- &RMF_EADATA);
+ int flags = 0;
+ xattr = req_capsule_client_get(pill, &RMF_EADATA);
+
+ if (body->flags & XATTR_REPLACE)
+ flags |= LU_XATTR_REPLACE;
- rc = mo_xattr_set(info->mti_ctxt,
- mdt_object_child(info->mti_object),
- xattr, xattr_len, xattr_name);
+ if (body->flags & XATTR_CREATE)
+ flags |= LU_XATTR_CREATE;
+
+ rc = mo_xattr_set(ctx, child, xattr,
+ xattr_len, xattr_name, flags);
}
} else if ((valid & OBD_MD_FLXATTRRM) == OBD_MD_FLXATTRRM) {
- rc = mo_xattr_del(info->mti_ctxt,
- mdt_object_child(info->mti_object),
- xattr_name);
+ rc = mo_xattr_del(ctx, child, xattr_name);
} else {
- CERROR("valid bits: "LPX64"\n", info->mti_body->valid);
+ CERROR("valid bits: "LPX64"\n", body->valid);
rc = -EINVAL;
}
EXIT;
out_unlock:
- mdt_object_unlock(info, info->mti_object, lh, rc);
+ mdt_object_unlock(info, obj, lh, rc);
out:
return rc;
}
/* LUSTRE_VERSION_CODE */
#include <lustre_ver.h>
+/* prerequisite for linux/xattr.h */
+#include <linux/types.h>
+/* prerequisite for linux/xattr.h */
+#include <linux/fs.h>
+/* XATTR_{REPLACE,CREATE} */
+#include <linux/xattr.h>
/*
* XXX temporary stuff: direct access to ldiskfs/jdb. Interface between osd
* and file system is not yet specified.
}
int osd_xattr_get(const struct lu_context *ctxt, struct dt_object *dt,
- void *buf, int buf_len, const char *name)
+ void *buf, int size, const char *name)
{
- return 0;
+ struct inode *inode = osd_dt_obj(dt)->oo_inode;
+ struct osd_thread_info *info = lu_context_key_get(ctxt, &osd_key);
+ struct dentry *dentry = &info->oti_dentry;
+
+ LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+ LASSERT(inode->i_op != NULL && inode->i_op->getxattr != NULL);
+ dentry->d_inode = inode;
+ return inode->i_op->getxattr(dentry, name, buf, size);
}
int osd_xattr_set(const struct lu_context *ctxt, struct dt_object *dt,
- const void *buf, int buf_len, const char *name,
+ const void *buf, int size, const char *name, int fl,
struct thandle *handle)
{
- return 0;
+ int fs_flags;
+
+ struct inode *inode = osd_dt_obj(dt)->oo_inode;
+ struct osd_thread_info *info = lu_context_key_get(ctxt, &osd_key);
+ struct dentry *dentry = &info->oti_dentry;
+
+ LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+ LASSERT(inode->i_op != NULL && inode->i_op->setxattr != NULL);
+ dentry->d_inode = inode;
+
+ fs_flags = 0;
+ if (fl & LU_XATTR_REPLACE)
+ fs_flags |= XATTR_REPLACE;
+
+ if (fl & LU_XATTR_CREATE)
+ fs_flags |= XATTR_CREATE;
+
+ return inode->i_op->setxattr(dentry, name, buf, size, fs_flags);
}
int osd_xattr_list(const struct lu_context *ctxt, struct dt_object *dt,
- void *buf, int buf_len)
+ void *buf, int size)
{
- return 0;
+ struct inode *inode = osd_dt_obj(dt)->oo_inode;
+ struct osd_thread_info *info = lu_context_key_get(ctxt, &osd_key);
+ struct dentry *dentry = &info->oti_dentry;
+
+ LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+ LASSERT(inode->i_op != NULL && inode->i_op->listxattr != NULL);
+ dentry->d_inode = inode;
+ return inode->i_op->listxattr(dentry, buf, size);
+}
+
+int osd_xattr_del(const struct lu_context *ctxt, struct dt_object *dt,
+ const char *name, struct thandle *handle)
+{
+ struct inode *inode = osd_dt_obj(dt)->oo_inode;
+ struct osd_thread_info *info = lu_context_key_get(ctxt, &osd_key);
+ struct dentry *dentry = &info->oti_dentry;
+
+ LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+ LASSERT(inode->i_op != NULL && inode->i_op->removexattr != NULL);
+ dentry->d_inode = inode;
+ return inode->i_op->removexattr(dentry, name);
}
+
int osd_readpage(const struct lu_context *ctxt,
struct dt_object *dt, struct lu_rdpg *rdpg)
{
#include <linux/jbd.h>
/* struct dx_hash_info */
#include <linux/ldiskfs_fs.h>
+/* struct dentry */
+#include <linux/dcache.h>
#include <linux/lustre_iam.h>
#include <dt_object.h>
#include "osd_oi.h"
struct inode;
-struct dentry;
struct dentry *osd_lookup(struct dentry *parent, const char *name);
struct dentry *osd_open(struct dentry *parent, const char *name, mode_t mode);
*/
struct qstr oti_str;
struct txn_param oti_txn;
+ /*
+ * XXX temporary: fake dentry used by xattr calls.
+ */
+ struct dentry oti_dentry;
};
#endif /* __KERNEL__ */