X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fliblustre%2Ffile.c;h=d5921243b87958891c7f6d9d2284f621f3c906bb;hb=cfaf31a01d1e3023611130ec1f8ece073f0092b9;hp=78b9202fae8d4badb97f9dfdfe3608d6c88b1669;hpb=9d4b898b1c1c7c318fda5f0c345ed726c774c06a;p=fs%2Flustre-release.git diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c index 78b9202..d592124 100644 --- a/lustre/liblustre/file.c +++ b/lustre/liblustre/file.c @@ -31,12 +31,16 @@ #include #include +#ifdef HAVE_XTIO_H #include +#endif #include #include #include #include +#ifdef HAVE_FILE_H #include +#endif #undef LIST_HEAD @@ -59,15 +63,71 @@ void llu_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1, data->mod_time = CURRENT_TIME; } +static void llu_inode2mdc_data(struct mdc_op_data *op_data, + struct inode *inode, + obd_valid valid) +{ + struct llu_inode_info *lli = llu_i2info(inode); + obd_valid newvalid = 0; + + LASSERT(op_data != NULL); + LASSERT(inode != NULL); + + /* put object id there all the time. */ + if (valid & OBD_MD_FLID) { + ll_inode2id(&op_data->id1, inode); + newvalid |= OBD_MD_FLID; + } + + if (valid & OBD_MD_FLSIZE) { + op_data->size = lli->lli_st_size; + newvalid |= OBD_MD_MEA; + } + if (valid & OBD_MD_FLBLOCKS) { + op_data->blocks = lli->lli_st_blocks; + newvalid |= OBD_MD_FLBLOCKS; + } + if (valid & OBD_MD_FLFLAGS) { + op_data->flags = lli->lli_st_flags; + newvalid |= OBD_MD_FLFLAGS; + } + if (valid & OBD_MD_FLATIME) { + op_data->atime = LTIME_S(lli->lli_st_atime); + newvalid |= OBD_MD_FLATIME; + } + if (valid & OBD_MD_FLMTIME) { + op_data->mtime = LTIME_S(lli->lli_st_mtime); + newvalid |= OBD_MD_FLMTIME; + } + if (valid & OBD_MD_FLCTIME) { + op_data->ctime = LTIME_S(lli->lli_st_ctime); + newvalid |= OBD_MD_FLCTIME; + } + + if (valid & OBD_MD_FLTYPE) { + op_data->mode = (op_data->mode & S_IALLUGO) | + (lli->lli_st_mode & S_IFMT); + newvalid |= OBD_MD_FLTYPE; + } + + if (valid & OBD_MD_FLMODE) { + op_data->mode = (op_data->mode & S_IFMT) | + (lli->lli_st_mode & S_IALLUGO); + newvalid |= OBD_MD_FLMODE; + } + + op_data->valid |= newvalid; +} + void obdo_refresh_inode(struct inode *dst, struct obdo *src, - obd_flag valid) + obd_valid valid) { struct llu_inode_info *lli = llu_i2info(dst); valid &= src->o_valid; if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME)) - CDEBUG(D_INODE, "valid %x, cur time %lu/%lu, new %lu/%lu\n", + CDEBUG(D_INODE, "valid "LPX64", cur time %lu/%lu, new %lu/%lu\n", src->o_valid, LTIME_S(lli->lli_st_mtime), LTIME_S(lli->lli_st_ctime), (long)src->o_mtime, (long)src->o_ctime); @@ -90,7 +150,7 @@ void obdo_refresh_inode(struct inode *dst, static int llu_local_open(struct llu_inode_info *lli, struct lookup_intent *it) { - struct ptlrpc_request *req = it->d.lustre.it_data; + struct ptlrpc_request *req = LUSTRE_IT(it)->it_data; struct ll_file_data *fd; struct mds_body *body; ENTRY; @@ -107,14 +167,14 @@ static int llu_local_open(struct llu_inode_info *lli, struct lookup_intent *it) OBD_ALLOC(fd, sizeof(*fd)); /* We can't handle this well without reorganizing ll_file_open and - * ll_mdc_close, so don't even try right now. */ + * ll_md_close(), so don't even try right now. */ LASSERT(fd != NULL); memcpy(&fd->fd_mds_och.och_fh, &body->handle, sizeof(body->handle)); fd->fd_mds_och.och_magic = OBD_CLIENT_HANDLE_MAGIC; lli->lli_file_data = fd; - mdc_set_open_replay_data(NULL, &fd->fd_mds_och, it->d.lustre.it_data); + mdc_set_open_replay_data(NULL, &fd->fd_mds_och, LUSTRE_IT(it)->it_data); RETURN(0); } @@ -139,9 +199,8 @@ int llu_iop_open(struct pnode *pnode, int flags, mode_t mode) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", lli->lli_st_ino); LL_GET_INTENT(inode, it); - if (!it->d.lustre.it_disposition) { + if (!LUSTRE_IT(it)->it_disposition) LBUG(); - } rc = it_open_error(DISP_OPEN_OPEN, it); if (rc) @@ -168,7 +227,7 @@ int llu_iop_open(struct pnode *pnode, int flags, mode_t mode) lli->lli_open_flags = flags & ~(O_CREAT | O_EXCL | O_TRUNC); out_release: - request = it->d.lustre.it_data; + request = LUSTRE_IT(it)->it_data; ptlrpc_req_finished(request); it->it_op_release(it); @@ -225,7 +284,7 @@ int llu_objects_destroy(struct ptlrpc_request *request, struct inode *dir) GOTO(out, rc = -EPROTO); } - rc = obd_unpackmd(llu_i2obdexp(dir), &lsm, eadata, body->eadatasize); + rc = obd_unpackmd(llu_i2dtexp(dir), &lsm, eadata, body->eadatasize); if (rc < 0) { CERROR("obd_unpackmd: %d\n", rc); GOTO(out, rc); @@ -252,13 +311,13 @@ int llu_objects_destroy(struct ptlrpc_request *request, struct inode *dir) } } - rc = obd_destroy(llu_i2obdexp(dir), oa, lsm, &oti); + rc = obd_destroy(llu_i2dtexp(dir), oa, lsm, &oti); obdo_free(oa); if (rc) CERROR("obd destroy objid 0x"LPX64" error %d\n", lsm->lsm_object_id, rc); out_free_memmd: - obd_free_memmd(llu_i2obdexp(dir), &lsm); + obd_free_memmd(llu_i2dtexp(dir), &lsm); out: return rc; } @@ -269,7 +328,7 @@ int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode) struct ll_file_data *fd = lli->lli_file_data; struct ptlrpc_request *req = NULL; struct obd_client_handle *och = &fd->fd_mds_och; - struct obdo obdo; + struct mdc_op_data op_data; int rc, valid; ENTRY; @@ -281,20 +340,21 @@ int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode) &fd->fd_cwlockh); } - obdo.o_id = lli->lli_st_ino; - obdo.o_valid = OBD_MD_FLID; + memset(&op_data, 0, sizeof(op_data)); + id_ino(&op_data.id1) = lli->lli_st_ino; + op_data.valid = OBD_MD_FLID; valid = OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLSIZE |OBD_MD_FLBLOCKS | OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME; if (test_bit(LLI_F_HAVE_OST_SIZE_LOCK, &lli->lli_flags)) valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; - obdo_from_inode(&obdo, inode, valid); + llu_inode2mdc_data(&op_data, inode, valid); if (0 /* ll_is_inode_dirty(inode) */) { - obdo.o_flags = MDS_BFLAG_UNCOMMITTED_WRITES; - obdo.o_valid |= OBD_MD_FLFLAGS; + op_data.flags = MDS_BFLAG_UNCOMMITTED_WRITES; + op_data.valid |= OBD_MD_FLFLAGS; } - rc = mdc_close(mdc_exp, &obdo, och, &req); + rc = mdc_close(mdc_exp, &op_data, och, &req); if (rc == EAGAIN) { /* We are the last writer, so the MDS has instructed us to get * the file size and any write cookies, then close again. */ @@ -340,7 +400,7 @@ int llu_file_release(struct inode *inode) if (!fd) /* no process opened the file after an mcreate */ RETURN(0); - rc2 = llu_mdc_close(sbi->ll_lmv_exp, inode); + rc2 = llu_mdc_close(sbi->ll_md_exp, inode); if (rc2 && !rc) rc = rc2; @@ -405,8 +465,9 @@ static void llu_truncate(struct inode *inode) oa.o_id, lli->lli_st_size); /* truncate == punch from new size to absolute end of file */ - err = obd_punch(llu_i2obdexp(inode), &oa, lsm, lli->lli_st_size, - OBD_OBJECT_EOF, NULL); + /* XXX: capa is NULL here, is it correct? */ + err = obd_punch(llu_i2dtexp(inode), &oa, lsm, lli->lli_st_size, + OBD_OBJECT_EOF, NULL, NULL); if (err) CERROR("obd_truncate fails (%d) ino %lu\n", err, lli->lli_st_ino); else