static void llu_fsop_gone(struct filesys *fs)
{
struct llu_sb_info *sbi = (struct llu_sb_info *) fs->fs_private;
- struct obd_device *obd = class_exp2obd(sbi->ll_mdc_exp);
+ struct obd_device *obd = class_exp2obd(sbi->ll_md_exp);
int next = 0;
ENTRY;
list_del(&sbi->ll_conn_chain);
- obd_disconnect(sbi->ll_osc_exp);
- obd_disconnect(sbi->ll_mdc_exp);
+ obd_disconnect(sbi->ll_dt_exp);
+ obd_disconnect(sbi->ll_md_exp);
while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL)
class_manual_cleanup(obd);
static struct inode_ops llu_inode_ops;
-void llu_update_inode(struct inode *inode, struct mds_body *body,
+void llu_update_inode(struct inode *inode, struct mdt_body *body,
struct lov_stripe_md *lsm)
{
struct llu_inode_info *lli = llu_i2info(inode);
}
}
- if (body->valid & OBD_MD_FLID)
- st->st_ino = body->ino;
+ if (body->valid & OBD_MD_FLMTIME &&
+ body->mtime > LTIME_S(st->st_mtime))
+ LTIME_S(st->st_mtime) = body->mtime;
if (body->valid & OBD_MD_FLATIME &&
body->atime > LTIME_S(st->st_atime))
LTIME_S(st->st_atime) = body->atime;
-
+
/* mtime is always updated with ctime, but can be set in past.
As write and utime(2) may happen within 1 second, and utime's
- mtime has a priority over write's one, so take mtime from mds
+ mtime has a priority over write's one, so take mtime from mds
for the same ctimes. */
if (body->valid & OBD_MD_FLCTIME &&
body->ctime >= LTIME_S(st->st_ctime)) {
st->st_blocks = body->blocks;
if (body->valid & OBD_MD_FLFLAGS)
lli->lli_st_flags = body->flags;
- if (body->valid & OBD_MD_FLGENER)
- lli->lli_st_generation = body->generation;
-
- /* fillin fid */
- if (body->valid & OBD_MD_FLID)
- lli->lli_fid.id = body->ino;
- if (body->valid & OBD_MD_FLGENER)
- lli->lli_fid.generation = body->generation;
- if (body->valid & OBD_MD_FLTYPE)
- lli->lli_fid.f_type = body->mode & S_IFMT;
}
void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid)
st->st_gid = src->o_gid;
if (valid & OBD_MD_FLFLAGS)
lli->lli_st_flags = src->o_flags;
- if (valid & OBD_MD_FLGENER)
- lli->lli_st_generation = src->o_generation;
}
#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
/*
* really does the getattr on the inode and updates its fields
*/
-int llu_inode_getattr(struct inode *inode, struct lov_stripe_md *lsm)
+int llu_inode_getattr(struct inode *inode, struct obdo *obdo)
{
struct llu_inode_info *lli = llu_i2info(inode);
- struct obd_export *exp = llu_i2obdexp(inode);
struct ptlrpc_request_set *set;
+ struct lov_stripe_md *lsm = lli->lli_smd;
struct obd_info oinfo = { { { 0 } } };
- struct obdo oa = { 0 };
- obd_flag refresh_valid;
int rc;
ENTRY;
LASSERT(lsm);
- LASSERT(lli);
oinfo.oi_md = lsm;
- oinfo.oi_oa = &oa;
- oa.o_id = lsm->lsm_object_id;
- oa.o_mode = S_IFREG;
- oa.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLSIZE |
- OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ | OBD_MD_FLMTIME |
- OBD_MD_FLCTIME;
+ oinfo.oi_oa = obdo;
+ oinfo.oi_oa->o_id = lsm->lsm_object_id;
+ oinfo.oi_oa->o_gr = lsm->lsm_object_gr;
+ oinfo.oi_oa->o_mode = S_IFREG;
+ oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE |
+ OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
+ OBD_MD_FLBLKSZ | OBD_MD_FLMTIME |
+ OBD_MD_FLCTIME;
set = ptlrpc_prep_set();
if (set == NULL) {
CERROR ("ENOMEM allocing request set\n");
rc = -ENOMEM;
} else {
- rc = obd_getattr_async(exp, &oinfo, set);
+ rc = obd_getattr_async(llu_i2obdexp(inode), &oinfo, set);
if (rc == 0)
rc = ptlrpc_set_wait(set);
ptlrpc_set_destroy(set);
if (rc)
RETURN(rc);
- refresh_valid = OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ | OBD_MD_FLMTIME |
- OBD_MD_FLCTIME | OBD_MD_FLSIZE;
-
- obdo_refresh_inode(inode, &oa, refresh_valid);
+ oinfo.oi_oa->o_valid = OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ |
+ OBD_MD_FLMTIME | OBD_MD_FLCTIME |
+ OBD_MD_FLSIZE;
+ obdo_refresh_inode(inode, oinfo.oi_oa, oinfo.oi_oa->o_valid);
+ CDEBUG(D_INODE, "objid "LPX64" size %Lu, blocks %Lu, "
+ "blksize %Lu\n", lli->lli_smd->lsm_object_id,
+ (long long unsigned)llu_i2stat(inode)->st_size,
+ (long long unsigned)llu_i2stat(inode)->st_blocks,
+ (long long unsigned)llu_i2stat(inode)->st_blksize);
RETURN(0);
}
static struct inode* llu_new_inode(struct filesys *fs,
- struct ll_fid *fid)
+ struct lu_fid *fid)
{
struct inode *inode;
struct llu_inode_info *lli;
struct intnl_stat st = {
.st_dev = 0,
+#if 0
#ifndef AUTOMOUNT_FILE_NAME
.st_mode = fid->f_type & S_IFMT,
#else
.st_mode = fid->f_type /* all of the bits! */
#endif
+#endif
+ /* FIXME: fix this later */
+ .st_mode = 0,
+
.st_uid = geteuid(),
.st_gid = getegid(),
};
LASSERT(inode);
- obddev = sbi->ll_mdc_exp->exp_obd;
- res_id.name[0] = llu_i2stat(inode)->st_ino;
- res_id.name[1] = lli->lli_st_generation;
+ obddev = sbi->ll_md_exp->exp_obd;
+ res_id.name[0] = fid_seq(&lli->lli_fid);
+ res_id.name[1] = fid_oid(&lli->lli_fid);
+ res_id.name[2] = fid_ver(&lli->lli_fid);
CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id.name[0]);
struct lustre_md md;
struct ptlrpc_request *req = NULL;
struct llu_sb_info *sbi = llu_i2sbi(inode);
- struct ll_fid fid;
unsigned long valid = OBD_MD_FLGETATTR;
int rc, ealen = 0;
/* Why don't we update all valid MDS fields here, if we're
* doing an RPC anyways? -phil */
if (S_ISREG(llu_i2stat(inode)->st_mode)) {
- ealen = obd_size_diskmd(sbi->ll_osc_exp, NULL);
+ ealen = obd_size_diskmd(sbi->ll_dt_exp, NULL);
valid |= OBD_MD_FLEASIZE;
}
- ll_inode2fid(&fid, inode);
- rc = mdc_getattr(sbi->ll_mdc_exp, &fid, valid, ealen, &req);
+ rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode),
+ NULL, valid, ealen, &req);
if (rc) {
CERROR("failure %d inode %llu\n", rc,
(long long)llu_i2stat(inode)->st_ino);
RETURN(-abs(rc));
}
- rc = mdc_req2lustre_md(req, REPLY_REC_OFF, sbi->ll_osc_exp,&md);
+ rc = md_get_lustre_md(sbi->ll_md_exp, req, REPLY_REC_OFF,
+ sbi->ll_dt_exp, sbi->ll_md_exp, &md);
/* XXX Too paranoid? */
if (((md.body->valid ^ valid) & OBD_MD_FLEASIZE) &&
llu_update_inode(inode, md.body, md.lsm);
if (md.lsm != NULL && llu_i2info(inode)->lli_smd != md.lsm)
- obd_free_memmd(sbi->ll_osc_exp, &md.lsm);
-
- if (md.body->valid & OBD_MD_FLSIZE)
- set_bit(LLI_F_HAVE_MDS_SIZE_LOCK,
- &llu_i2info(inode)->lli_flags);
+ obd_free_memmd(sbi->ll_dt_exp, &md.lsm);
+ if (md.body->valid & OBD_MD_FLSIZE &&
+ sbi->ll_lco.lco_flags & OBD_CONNECT_SOM)
+ llu_i2info(inode)->lli_flags |= LLIF_MDS_SIZE_LOCK;
ptlrpc_req_finished(req);
}
void llu_clear_inode(struct inode *inode)
{
- struct ll_fid fid;
struct llu_inode_info *lli = llu_i2info(inode);
struct llu_sb_info *sbi = llu_i2sbi(inode);
ENTRY;
(long long)llu_i2stat(inode)->st_ino, lli->lli_st_generation,
inode);
- ll_inode2fid(&fid, inode);
- clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(lli->lli_flags));
- mdc_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode);
+ lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK;
+ md_change_cbdata(sbi->ll_md_exp, ll_inode2fid(inode),
+ null_if_equal, inode);
if (lli->lli_smd)
- obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd,
+ obd_change_cbdata(sbi->ll_dt_exp, lli->lli_smd,
null_if_equal, inode);
if (lli->lli_smd) {
- obd_free_memmd(sbi->ll_osc_exp, &lli->lli_smd);
+ obd_free_memmd(sbi->ll_dt_exp, &lli->lli_smd);
lli->lli_smd = NULL;
}
return error;
}
+int llu_md_setattr(struct inode *inode, struct md_op_data *op_data)
+{
+ struct lustre_md md;
+ struct llu_sb_info *sbi = llu_i2sbi(inode);
+ struct ptlrpc_request *request = NULL;
+ int rc;
+ ENTRY;
+
+ llu_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY);
+ rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, NULL, 0, &request);
+
+ if (rc) {
+ ptlrpc_req_finished(request);
+ if (rc != -EPERM && rc != -EACCES)
+ CERROR("md_setattr fails: rc = %d\n", rc);
+ RETURN(rc);
+ }
+
+ rc = md_get_lustre_md(sbi->ll_md_exp, request, REPLY_REC_OFF,
+ sbi->ll_dt_exp, sbi->ll_md_exp, &md);
+ if (rc) {
+ ptlrpc_req_finished(request);
+ RETURN(rc);
+ }
+
+ /* We call inode_setattr to adjust timestamps.
+ * If there is at least some data in file, we cleared ATTR_SIZE
+ * above to avoid invoking vmtruncate, otherwise it is important
+ * to call vmtruncate in inode_setattr to update inode->i_size
+ * (bug 6196) */
+ inode_setattr(inode, &op_data->op_attr);
+ llu_update_inode(inode, md.body, md.lsm);
+ ptlrpc_req_finished(request);
+
+ RETURN(rc);
+}
+
+/* Close IO epoch and send Size-on-MDS attribute update. */
+static int llu_setattr_done_writing(struct inode *inode,
+ struct md_op_data *op_data)
+{
+ struct llu_inode_info *lli = llu_i2info(inode);
+ struct intnl_stat *st = llu_i2stat(inode);
+ int rc = 0;
+ ENTRY;
+
+ LASSERT(op_data != NULL);
+ if (!S_ISREG(st->st_mode))
+ RETURN(0);
+
+ /* XXX: pass och here for the recovery purpose. */
+ CDEBUG(D_INODE, "Epoch "LPU64" closed on "DFID" for truncate\n",
+ op_data->op_ioepoch, PFID(&lli->lli_fid));
+
+ op_data->op_flags = MF_EPOCH_CLOSE | MF_SOM_CHANGE;
+ rc = md_done_writing(llu_i2sbi(inode)->ll_md_exp, op_data, NULL);
+ if (rc == -EAGAIN) {
+ /* MDS has instructed us to obtain Size-on-MDS attribute
+ * from OSTs and send setattr to back to MDS. */
+ rc = llu_sizeonmds_update(inode, &op_data->op_handle,
+ op_data->op_ioepoch);
+ } else if (rc) {
+ CERROR("inode %llu mdc truncate failed: rc = %d\n",
+ st->st_ino, rc);
+ }
+ RETURN(rc);
+}
+
/* If this inode has objects allocated to it (lsm != NULL), then the OST
* object(s) determine the file size and mtime. Otherwise, the MDS will
* keep these values until such a time that objects are allocated for it.
struct lov_stripe_md *lsm = llu_i2info(inode)->lli_smd;
struct llu_sb_info *sbi = llu_i2sbi(inode);
struct intnl_stat *st = llu_i2stat(inode);
- struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data;
int ia_valid = attr->ia_valid;
+ struct md_op_data op_data = { { 0 } };
int rc = 0;
ENTRY;
attr->ia_valid |= ATTR_MTIME_SET;
}
if ((attr->ia_valid & ATTR_CTIME) && !(attr->ia_valid & ATTR_MTIME)) {
- /* To avoid stale mtime on mds, obtain it from ost and send
+ /* To avoid stale mtime on mds, obtain it from ost and send
to mds. */
rc = llu_glimpse_size(inode);
- if (rc)
+ if (rc)
RETURN(rc);
-
+
attr->ia_valid |= ATTR_MTIME_SET | ATTR_MTIME;
attr->ia_mtime = inode->i_stbuf.st_mtime;
}
CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
LTIME_S(CURRENT_TIME));
+
+ /* NB: ATTR_SIZE will only be set after this point if the size
+ * resides on the MDS, ie, this file has no objects. */
if (lsm)
attr->ia_valid &= ~ATTR_SIZE;
/* If only OST attributes being set on objects, don't do MDS RPC.
* In that case, we need to check permissions and update the local
* inode ourselves so we can call obdo_from_inode() always. */
- if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
- struct lustre_md md;
- llu_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
-
- rc = mdc_setattr(sbi->ll_mdc_exp, &op_data,
- attr, NULL, 0, NULL, 0, &request);
+ if (ia_valid & (lsm ? ~(ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
+ memcpy(&op_data.op_attr, attr, sizeof(*attr));
- if (rc) {
- ptlrpc_req_finished(request);
- if (rc != -EPERM && rc != -EACCES)
- CERROR("mdc_setattr fails: rc = %d\n", rc);
- RETURN(rc);
- }
-
- rc = mdc_req2lustre_md(request, REPLY_REC_OFF, sbi->ll_osc_exp,
- &md);
- if (rc) {
- ptlrpc_req_finished(request);
+ /* Open epoch for truncate. */
+ if (ia_valid & ATTR_SIZE)
+ op_data.op_flags = MF_EPOCH_OPEN;
+ rc = llu_md_setattr(inode, &op_data);
+ if (rc)
RETURN(rc);
- }
-
- /* We call inode_setattr to adjust timestamps.
- * If there is at least some data in file, we cleared ATTR_SIZE
- * above to avoid invoking vmtruncate, otherwise it is important
- * to call vmtruncate in inode_setattr to update inode->i_size
- * (bug 6196) */
- inode_setattr(inode, attr);
- llu_update_inode(inode, md.body, md.lsm);
- ptlrpc_req_finished(request);
if (!lsm || !S_ISREG(st->st_mode)) {
CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
- RETURN(0);
+ if (op_data.op_ioepoch)
+ rc = llu_setattr_done_writing(inode, &op_data);
+ RETURN(rc);
}
} else {
/* The OST doesn't check permissions, but the alternative is
}
}
+
/* Won't invoke llu_vmtruncate(), as we already cleared
* ATTR_SIZE */
inode_setattr(inode, attr);
obd_flag obd_flags;
/* check that there are no matching locks */
- LASSERT(obd_match(sbi->ll_osc_exp, lsm, LDLM_EXTENT, &policy,
+ LASSERT(obd_match(sbi->ll_dt_exp, lsm, LDLM_EXTENT, &policy,
LCK_PW, &flags, inode, &match_lockh) <= 0);
/* XXX when we fix the AST intents to pass the discard-range
if (!rc)
rc = err;
}
+
+ if (op_data.op_ioepoch)
+ rc = llu_setattr_done_writing(inode, &op_data);
} else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
struct obd_info oinfo = { { { 0 } } };
struct obdo oa;
oinfo.oi_oa = &oa;
oinfo.oi_md = lsm;
- rc = obd_setattr_rqset(sbi->ll_osc_exp, &oinfo, NULL);
+ rc = obd_setattr_rqset(sbi->ll_dt_exp, &oinfo, NULL);
if (rc)
CERROR("obd_setattr_async fails: rc=%d\n", rc);
}
int len = qstr->len;
struct ptlrpc_request *request = NULL;
struct llu_sb_info *sbi = llu_i2sbi(dir);
- struct mdc_op_data op_data;
+ struct md_op_data op_data;
int err = -EMLINK;
ENTRY;
if (llu_i2stat(dir)->st_nlink >= EXT2_LINK_MAX)
RETURN(err);
- llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0);
- err = mdc_create(sbi->ll_mdc_exp, &op_data,
- tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO,
- current->fsuid, current->fsgid, current->cap_effective,
- 0, &request);
+ llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0,
+ LUSTRE_OPC_SYMLINK);
+
+ err = md_create(sbi->ll_md_exp, &op_data,
+ tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO,
+ current->fsuid, current->fsgid, current->cap_effective,
+ 0, &request);
ptlrpc_req_finished(request);
liblustre_wait_event(0);
RETURN(err);
{
struct llu_inode_info *lli = llu_i2info(inode);
struct llu_sb_info *sbi = llu_i2sbi(inode);
- struct ll_fid fid;
- struct mds_body *body;
+ struct mdt_body *body;
struct intnl_stat *st = llu_i2stat(inode);
int rc, symlen = st->st_size + 1;
ENTRY;
RETURN(0);
}
- ll_inode2fid(&fid, inode);
- rc = mdc_getattr(sbi->ll_mdc_exp, &fid,
- OBD_MD_LINKNAME, symlen, request);
+ rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), NULL,
+ OBD_MD_LINKNAME, symlen, request);
if (rc) {
CERROR("inode %llu: rc = %d\n", (long long)st->st_ino, rc);
RETURN(rc);
struct ptlrpc_request *request = NULL;
struct inode *dir = pno->p_parent->p_base->pb_ino;
struct llu_sb_info *sbi = llu_i2sbi(dir);
- struct mdc_op_data op_data;
+ struct md_op_data op_data;
int err = -EMLINK;
ENTRY;
case S_IFBLK:
case S_IFIFO:
case S_IFSOCK:
- llu_prepare_mdc_op_data(&op_data, dir, NULL,
- pno->p_base->pb_name.name,
- pno->p_base->pb_name.len,
- 0);
- err = mdc_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode,
- current->fsuid, current->fsgid,
- current->cap_effective, dev, &request);
+ llu_prep_md_op_data(&op_data, dir, NULL,
+ pno->p_base->pb_name.name,
+ pno->p_base->pb_name.len, 0,
+ LUSTRE_OPC_MKNOD);
+
+ err = md_create(sbi->ll_md_exp, &op_data, NULL, 0, mode,
+ current->fsuid, current->fsgid,
+ current->cap_effective, dev, &request);
ptlrpc_req_finished(request);
break;
case S_IFDIR:
const char *name = new->p_base->pb_name.name;
int namelen = new->p_base->pb_name.len;
struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data;
+ struct md_op_data op_data;
int rc;
ENTRY;
LASSERT(dir);
liblustre_wait_event(0);
- llu_prepare_mdc_op_data(&op_data, src, dir, name, namelen, 0);
- rc = mdc_link(llu_i2sbi(src)->ll_mdc_exp, &op_data, &request);
+ llu_prep_md_op_data(&op_data, src, dir, name, namelen, 0,
+ LUSTRE_OPC_ANY);
+ rc = md_link(llu_i2sbi(src)->ll_md_exp, &op_data, &request);
ptlrpc_req_finished(request);
liblustre_wait_event(0);
int len = qstr->len;
struct inode *target = pno->p_base->pb_ino;
struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data;
+ struct md_op_data op_data;
int rc;
ENTRY;
LASSERT(target);
liblustre_wait_event(0);
- llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0);
- rc = mdc_unlink(llu_i2sbi(dir)->ll_mdc_exp, &op_data, &request);
+ llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0,
+ LUSTRE_OPC_ANY);
+ rc = md_unlink(llu_i2sbi(dir)->ll_md_exp, &op_data, &request);
if (!rc)
rc = llu_objects_destroy(request, dir);
ptlrpc_req_finished(request);
const char *newname = new->p_base->pb_name.name;
int newnamelen = new->p_base->pb_name.len;
struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data;
+ struct md_op_data op_data;
int rc;
ENTRY;
LASSERT(tgt);
liblustre_wait_event(0);
- llu_prepare_mdc_op_data(&op_data, src, tgt, NULL, 0, 0);
- rc = mdc_rename(llu_i2sbi(src)->ll_mdc_exp, &op_data,
- oldname, oldnamelen, newname, newnamelen,
- &request);
+ llu_prep_md_op_data(&op_data, src, tgt, NULL, 0, 0,
+ LUSTRE_OPC_ANY);
+ rc = md_rename(llu_i2sbi(src)->ll_md_exp, &op_data,
+ oldname, oldnamelen, newname, newnamelen,
+ &request);
if (!rc) {
rc = llu_objects_destroy(request, src);
}
int rc;
ENTRY;
- rc = obd_statfs(class_exp2obd(sbi->ll_mdc_exp), osfs, max_age);
+ rc = obd_statfs(class_exp2obd(sbi->ll_md_exp), osfs, max_age);
if (rc) {
- CERROR("mdc_statfs fails: rc = %d\n", rc);
+ CERROR("md_statfs fails: rc = %d\n", rc);
RETURN(rc);
}
CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
- rc = obd_statfs_rqset(class_exp2obd(sbi->ll_osc_exp),
- &obd_osfs, max_age);
+ rc = obd_statfs_rqset(class_exp2obd(sbi->ll_dt_exp),
+ &obd_statfs, max_age);
if (rc) {
CERROR("obd_statfs fails: rc = %d\n", rc);
RETURN(rc);
int len = qstr->len;
struct ptlrpc_request *request = NULL;
struct intnl_stat *st = llu_i2stat(dir);
- struct mdc_op_data op_data;
+ struct md_op_data op_data;
int err = -EMLINK;
ENTRY;
if (st->st_nlink >= EXT2_LINK_MAX)
RETURN(err);
- llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0);
- err = mdc_create(llu_i2sbi(dir)->ll_mdc_exp, &op_data, NULL, 0, mode | S_IFDIR,
- current->fsuid, current->fsgid, current->cap_effective,
- 0, &request);
+ llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0,
+ LUSTRE_OPC_MKDIR);
+
+ err = md_create(llu_i2sbi(dir)->ll_md_exp, &op_data, NULL, 0,
+ mode | S_IFDIR, current->fsuid, current->fsgid,
+ current->cap_effective, 0, &request);
ptlrpc_req_finished(request);
liblustre_wait_event(0);
RETURN(err);
const char *name = qstr->name;
int len = qstr->len;
struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data;
+ struct md_op_data op_data;
int rc;
ENTRY;
(long long)llu_i2stat(dir)->st_ino,
llu_i2info(dir)->lli_st_generation, dir);
- llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, S_IFDIR);
- rc = mdc_unlink(llu_i2sbi(dir)->ll_mdc_exp, &op_data, &request);
+ llu_prep_md_op_data(&op_data, dir, NULL, name, len, S_IFDIR,
+ LUSTRE_OPC_ANY);
+ rc = md_unlink(llu_i2sbi(dir)->ll_md_exp, &op_data, &request);
ptlrpc_req_finished(request);
liblustre_wait_event(0);
struct llu_inode_info *lli = llu_i2info(ino);
struct intnl_stat *st = llu_i2stat(ino);
struct ldlm_res_id res_id =
- { .name = {st->st_ino,
- lli->lli_st_generation, LDLM_FLOCK} };
+ { .name = {fid_seq(&lli->lli_fid),
+ fid_oid(&lli->lli_fid),
+ fid_ver(&lli->lli_fid),
+ LDLM_FLOCK} };
struct lustre_handle lockh = {0};
ldlm_policy_data_t flock;
ldlm_mode_t mode = 0;
int rc;
CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu file_lock=%p\n",
- (unsigned long long) st->st_ino, file_lock);
+ (unsigned long long)st->st_ino, file_lock);
flock.l_flock.pid = file_lock->fl_pid;
flock.l_flock.start = file_lock->fl_start;
}
CDEBUG(D_DLMTRACE, "inode=%llu, pid=%u, flags=%#x, mode=%u, "
- "start="LPU64", end="LPU64"\n",
- (unsigned long long) st->st_ino, flock.l_flock.pid,
- flags, mode, flock.l_flock.start, flock.l_flock.end);
+ "start="LPU64", end="LPU64"\n", (unsigned long long)st->st_ino,
+ flock.l_flock.pid, flags, mode, flock.l_flock.start,
+ flock.l_flock.end);
- rc = ldlm_cli_enqueue(llu_i2mdcexp(ino), NULL, res_id,
- LDLM_FLOCK, &flock, mode, &flags, NULL,
- ldlm_flock_completion_ast, NULL,
+ rc = ldlm_cli_enqueue(llu_i2mdcexp(ino), NULL, &res_id,
+ LDLM_FLOCK, &flock, mode, &flags, NULL,
+ ldlm_flock_completion_ast, NULL,
file_lock, NULL, 0, NULL, &lockh, 0);
RETURN(rc);
}
flags = va_arg(ap, long);
flags &= FCNTL_FLMASK;
if (flags & FCNTL_FLMASK_INVALID) {
- CERROR("liblustre don't support O_NONBLOCK, O_ASYNC, "
- "and O_DIRECT on file descriptor\n");
+ LCONSOLE_ERROR_MSG(0x010, "liblustre does not support "
+ "the O_NONBLOCK or O_ASYNC flags. "
+ "Please fix your application.\n");
*rtn = -EINVAL;
err = EINVAL;
break;
static int llu_lov_dir_setstripe(struct inode *ino, unsigned long arg)
{
- struct llu_sb_info *sbi = llu_i2sbi(ino);
+ struct llu_sb_info *sbi = llu_i2sbi(ino);
struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data;
- struct iattr attr = { 0 };
+ struct md_op_data op_data;
struct lov_user_md lum, *lump = (struct lov_user_md *)arg;
int rc = 0;
- llu_prepare_mdc_op_data(&op_data, ino, NULL, NULL, 0, 0);
+ llu_prep_md_op_data(&op_data, ino, NULL, NULL, 0, 0,
+ LUSTRE_OPC_ANY);
LASSERT(sizeof(lum) == sizeof(*lump));
LASSERT(sizeof(lum.lmm_objects[0]) ==
lustre_swab_lov_user_md(&lum);
/* swabbing is done in lov_setstripe() on server side */
- rc = mdc_setattr(sbi->ll_mdc_exp, &op_data,
- &attr, &lum, sizeof(lum), NULL, 0, &request);
+ rc = md_setattr(sbi->ll_md_exp, &op_data, &lum,
+ sizeof(lum), NULL, 0, &request);
if (rc) {
ptlrpc_req_finished(request);
if (rc != -EPERM && rc != -EACCES)
- CERROR("mdc_setattr fails: rc = %d\n", rc);
+ CERROR("md_setattr fails: rc = %d\n", rc);
return rc;
}
ptlrpc_req_finished(request);
static int llu_lov_setstripe_ea_info(struct inode *ino, int flags,
struct lov_user_md *lum, int lum_size)
{
- struct llu_sb_info *sbi = llu_i2sbi(ino);
- struct obd_export *exp = llu_i2obdexp(ino);
+ struct llu_sb_info *sbi = llu_i2sbi(ino);
struct llu_inode_info *lli = llu_i2info(ino);
struct llu_inode_info *lli2 = NULL;
struct lov_stripe_md *lsm;
struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags};
struct ptlrpc_request *req = NULL;
struct lustre_md md;
- struct mdc_op_data data;
+ struct md_op_data data;
struct lustre_handle lockh;
int rc = 0;
ENTRY;
lsm = lli->lli_smd;
if (lsm) {
- CDEBUG(D_IOCTL, "stripe already exists for ino "LPU64"\n",
- lli->lli_fid.id);
+ CDEBUG(D_IOCTL, "stripe already exists for ino "DFID"\n",
+ PFID(&lli->lli_fid));
return -EEXIST;
}
OBD_ALLOC(lli2, sizeof(struct llu_inode_info));
if (!lli2)
return -ENOMEM;
-
+
memcpy(lli2, lli, sizeof(struct llu_inode_info));
lli2->lli_open_count = 0;
lli2->lli_it = NULL;
lli2->lli_symlink_name = NULL;
ino->i_private = lli2;
- llu_prepare_mdc_op_data(&data, NULL, ino, NULL, 0, O_RDWR);
+ llu_prep_md_op_data(&data, NULL, ino, NULL, 0, O_RDWR,
+ LUSTRE_OPC_ANY);
- rc = mdc_enqueue(sbi->ll_mdc_exp, LDLM_IBITS, &oit, LCK_CR, &data,
- &lockh, lum, lum_size, ldlm_completion_ast,
- llu_mdc_blocking_ast, NULL, LDLM_FL_INTENT_ONLY);
+ rc = md_enqueue(sbi->ll_md_exp, LDLM_IBITS, &oit, LCK_CR, &data,
+ &lockh, lum, lum_size, ldlm_completion_ast,
+ llu_md_blocking_ast, NULL, LDLM_FL_INTENT_ONLY);
if (rc)
GOTO(out, rc);
-
+
req = oit.d.lustre.it_data;
rc = it_open_error(DISP_IT_EXECD, &oit);
if (rc) {
req->rq_replay = 0;
GOTO(out, rc);
}
-
+
rc = it_open_error(DISP_OPEN_OPEN, &oit);
if (rc) {
req->rq_replay = 0;
GOTO(out, rc);
}
-
- rc = mdc_req2lustre_md(req, DLM_REPLY_REC_OFF, exp, &md);
+
+ rc = md_get_lustre_md(sbi->ll_md_exp, req,
+ DLM_REPLY_REC_OFF, sbi->ll_dt_exp, sbi->ll_md_exp, &md);
if (rc)
GOTO(out, rc);
-
+
llu_update_inode(ino, md.body, md.lsm);
lli->lli_smd = lli2->lli_smd;
lli2->lli_smd = NULL;
llu_local_open(lli2, &oit);
-
+
/* release intent */
if (lustre_handle_is_used(&lockh))
ldlm_lock_decref(&lockh, LCK_CR);
ptlrpc_req_finished(req);
req = NULL;
-
+
rc = llu_file_release(ino);
out:
ino->i_private = lli;
return llu_lov_file_setstripe(ino, arg);
if (S_ISDIR(st->st_mode))
return llu_lov_dir_setstripe(ino, arg);
-
- return -EINVAL;
+
+ return -EINVAL;
}
static int llu_lov_getstripe(struct inode *ino, unsigned long arg)
struct inode *llu_iget(struct filesys *fs, struct lustre_md *md)
{
struct inode *inode;
- struct ll_fid fid;
+ struct lu_fid fid;
struct file_identifier fileid = {&fid, sizeof(fid)};
- if ((md->body->valid &
- (OBD_MD_FLGENER | OBD_MD_FLID | OBD_MD_FLTYPE)) !=
- (OBD_MD_FLGENER | OBD_MD_FLID | OBD_MD_FLTYPE)) {
+ if ((md->body->valid & (OBD_MD_FLID | OBD_MD_FLTYPE)) !=
+ (OBD_MD_FLID | OBD_MD_FLTYPE)) {
CERROR("bad md body valid mask "LPX64"\n", md->body->valid);
LBUG();
return ERR_PTR(-EPERM);
}
/* try to find existing inode */
- fid.id = md->body->ino;
- fid.generation = md->body->generation;
- fid.f_type = md->body->mode & S_IFMT;
+ fid = md->body->fid1;
inode = _sysio_i_find(fs, &fileid);
if (inode) {
- struct llu_inode_info *lli = llu_i2info(inode);
-
- if (inode->i_zombie ||
- lli->lli_st_generation != md->body->generation) {
+ if (inode->i_zombie/* ||
+ lli->lli_st_generation != md->body->generation*/) {
I_RELE(inode);
}
else {
return inode;
}
-extern struct list_head lustre_profile_list;
+static int
+llu_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp)
+{
+ struct lov_stripe_md lsm = { .lsm_magic = LOV_MAGIC };
+ __u32 valsize = sizeof(struct lov_desc);
+ int rc, easize, def_easize, cookiesize;
+ struct lov_desc desc;
+ __u32 stripes;
+ ENTRY;
+
+ rc = obd_get_info(dt_exp, strlen(KEY_LOVDESC) + 1, KEY_LOVDESC,
+ &valsize, &desc);
+ if (rc)
+ RETURN(rc);
+
+ stripes = min(desc.ld_tgt_count, (__u32)LOV_MAX_STRIPE_COUNT);
+ lsm.lsm_stripe_count = stripes;
+ easize = obd_size_diskmd(dt_exp, &lsm);
+
+ lsm.lsm_stripe_count = desc.ld_default_stripe_count;
+ def_easize = obd_size_diskmd(dt_exp, &lsm);
+
+ cookiesize = stripes * sizeof(struct llog_cookie);
+
+ CDEBUG(D_HA, "updating max_mdsize/max_cookiesize: %d/%d\n",
+ easize, cookiesize);
+
+ rc = md_init_ea_size(md_exp, easize, def_easize, cookiesize);
+ RETURN(rc);
+}
static int
llu_fsswop_mount(const char *source,
struct inode *root;
struct pnode_base *rootpb;
struct obd_device *obd;
- struct ll_fid rootfid;
+ struct lu_fid rootfid;
struct llu_sb_info *sbi;
struct obd_statfs osfs;
static struct qstr noname = { NULL, 0, 0 };
struct ptlrpc_request *request = NULL;
- struct lustre_handle mdc_conn = {0, };
- struct lustre_handle osc_conn = {0, };
+ struct lustre_handle md_conn = {0, };
+ struct lustre_handle dt_conn = {0, };
struct lustre_md md;
class_uuid_t uuid;
struct config_llog_instance cfg = {0, };
CERROR("No profile found: %s\n", zconf_profile);
GOTO(out_free, err = -EINVAL);
}
- OBD_ALLOC(osc, strlen(lprof->lp_osc) + strlen(ll_instance) + 2);
- sprintf(osc, "%s-%s", lprof->lp_osc, ll_instance);
+ OBD_ALLOC(osc, strlen(lprof->lp_dt) + strlen(ll_instance) + 2);
+ sprintf(osc, "%s-%s", lprof->lp_dt, ll_instance);
- OBD_ALLOC(mdc, strlen(lprof->lp_mdc) + strlen(ll_instance) + 2);
- sprintf(mdc, "%s-%s", lprof->lp_mdc, ll_instance);
+ OBD_ALLOC(mdc, strlen(lprof->lp_md) + strlen(ll_instance) + 2);
+ sprintf(mdc, "%s-%s", lprof->lp_md, ll_instance);
if (!osc) {
CERROR("no osc\n");
ocd.ocd_version = LUSTRE_VERSION_CODE;
/* setup mdc */
- err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, &ocd);
+ err = obd_connect(NULL, &md_conn, obd, &sbi->ll_sb_uuid, &ocd);
if (err) {
CERROR("cannot connect to %s: rc = %d\n", mdc, err);
GOTO(out_free, err);
}
- sbi->ll_mdc_exp = class_conn2export(&mdc_conn);
+ sbi->ll_md_exp = class_conn2export(&md_conn);
err = obd_statfs(obd, &osfs, 100000000);
if (err)
- GOTO(out_mdc, err);
+ GOTO(out_md, err);
/*
* FIXME fill fs stat data into sbi here!!! FIXME
obd = class_name2obd(osc);
if (!obd) {
CERROR("OSC %s: not setup or attached\n", osc);
- GOTO(out_mdc, err = -EINVAL);
+ GOTO(out_md, err = -EINVAL);
}
obd_set_info_async(obd->obd_self_export, strlen("async"), "async",
sizeof(async), &async, NULL);
ocd.ocd_connect_flags = OBD_CONNECT_SRVLOCK | OBD_CONNECT_REQPORTAL |
OBD_CONNECT_VERSION | OBD_CONNECT_TRUNCLOCK;
ocd.ocd_version = LUSTRE_VERSION_CODE;
- err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, &ocd);
+ err = obd_connect(NULL, &dt_conn, obd, &sbi->ll_sb_uuid, &ocd);
if (err) {
CERROR("cannot connect to %s: rc = %d\n", osc, err);
- GOTO(out_mdc, err);
+ GOTO(out_md, err);
}
- sbi->ll_osc_exp = class_conn2export(&osc_conn);
+ sbi->ll_dt_exp = class_conn2export(&dt_conn);
sbi->ll_lco.lco_flags = ocd.ocd_connect_flags;
- mdc_init_ea_size(sbi->ll_mdc_exp, sbi->ll_osc_exp);
+ llu_init_ea_size(sbi->ll_md_exp, sbi->ll_dt_exp);
- err = mdc_getstatus(sbi->ll_mdc_exp, &rootfid);
+ err = md_getstatus(sbi->ll_md_exp, &rootfid, NULL);
if (err) {
CERROR("cannot mds_connect: rc = %d\n", err);
- GOTO(out_osc, err);
+ GOTO(out_dt, err);
}
- CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id);
- sbi->ll_rootino = rootfid.id;
+ CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&rootfid));
+ sbi->ll_root_fid = rootfid;
/* fetch attr of root inode */
- err = mdc_getattr(sbi->ll_mdc_exp, &rootfid,
- OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS, 0, &request);
+ err = md_getattr(sbi->ll_md_exp, &rootfid, NULL,
+ OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS, 0, &request);
if (err) {
- CERROR("mdc_getattr failed for root: rc = %d\n", err);
- GOTO(out_osc, err);
+ CERROR("md_getattr failed for root: rc = %d\n", err);
+ GOTO(out_dt, err);
}
- err = mdc_req2lustre_md(request, REPLY_REC_OFF, sbi->ll_osc_exp, &md);
+ err = md_get_lustre_md(sbi->ll_md_exp, request, REPLY_REC_OFF,
+ sbi->ll_dt_exp, sbi->ll_md_exp, &md);
if (err) {
CERROR("failed to understand root inode md: rc = %d\n",err);
GOTO(out_request, err);
}
- LASSERT(sbi->ll_rootino != 0);
+ LASSERT(fid_is_sane(&sbi->ll_root_fid));
root = llu_iget(fs, &md);
if (!root || IS_ERR(root)) {
_sysio_i_gone(root);
out_request:
ptlrpc_req_finished(request);
-out_osc:
- obd_disconnect(sbi->ll_osc_exp);
-out_mdc:
- obd_disconnect(sbi->ll_mdc_exp);
+out_dt:
+ obd_disconnect(sbi->ll_dt_exp);
+out_md:
+ obd_disconnect(sbi->ll_md_exp);
out_free:
if (osc)
OBD_FREE(osc, strlen(osc) + 1);
if (mdc)
OBD_FREE(mdc, strlen(mdc) + 1);
OBD_FREE(sbi, sizeof(*sbi));
-
liblustre_wait_idle();
return err;
}