op_data->op_attr_blocks = inode->i_blocks;
((struct ll_iattr *)&op_data->op_attr)->ia_attr_flags = inode->i_flags;
op_data->op_ioepoch = ll_i2info(inode)->lli_ioepoch;
- memcpy(&op_data->op_handle, fh, sizeof(op_data->op_handle));
+ if (fh)
+ op_data->op_handle = *fh;
op_data->op_capa1 = ll_mdscapa_get(inode);
}
+/**
+ * Closes the IO epoch and packs all the attributes into @op_data for
+ * the CLOSE rpc.
+ */
static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data,
struct obd_client_handle *och)
{
if (!(och->och_flags & FMODE_WRITE))
goto out;
- if (!(exp_connect_som(ll_i2mdexp(inode))) || !S_ISREG(inode->i_mode))
+ if (!exp_connect_som(ll_i2mdexp(inode)) || !S_ISREG(inode->i_mode))
op_data->op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS;
else
- ll_epoch_close(inode, op_data, &och, 0);
+ ll_ioepoch_close(inode, op_data, &och, 0);
out:
ll_pack_inode2opdata(inode, op_data, &och->och_fh);
+ ll_prep_md_op_data(op_data, inode, NULL, NULL,
+ 0, 0, LUSTRE_OPC_ANY, NULL);
EXIT;
}
LASSERT(epoch_close);
/* MDS has instructed us to obtain Size-on-MDS attribute from
* OSTs and send setattr to back to MDS. */
- rc = ll_sizeonmds_update(inode, &och->och_fh,
- op_data->op_ioepoch);
+ rc = ll_som_update(inode, op_data);
if (rc) {
CERROR("inode %lu mdc Size-on-MDS update failed: "
"rc = %d\n", inode->i_ino, rc);
EXIT;
out:
- if ((exp->exp_connect_flags & OBD_CONNECT_SOM) && !epoch_close &&
+ if (exp_connect_som(exp) && !epoch_close &&
S_ISREG(inode->i_mode) && (och->och_flags & FMODE_WRITE)) {
ll_queue_done_writing(inode, LLIF_DONE_WRITING);
} else {
RETURN(rc);
}
+/**
+ * Assign an obtained @ioepoch to client's inode. No lock is needed, MDS does
+ * not believe attributes if a few ioepoch holders exist. Attributes for
+ * previous ioepoch if new one is opened are also skipped by MDS.
+ */
void ll_ioepoch_open(struct ll_inode_info *lli, __u64 ioepoch)
{
if (ioepoch && lli->lli_ioepoch != ioepoch) {
/* Fills the obdo with the attributes for the lsm */
static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp,
- struct obd_capa *capa, struct obdo *obdo)
+ struct obd_capa *capa, struct obdo *obdo,
+ __u64 ioepoch, int sync)
{
struct ptlrpc_request_set *set;
struct obd_info oinfo = { { { 0 } } };
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_ioepoch = ioepoch;
oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE |
OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
OBD_MD_FLBLKSZ | OBD_MD_FLATIME |
OBD_MD_FLMTIME | OBD_MD_FLCTIME |
- OBD_MD_FLGROUP;
+ OBD_MD_FLGROUP | OBD_MD_FLEPOCH;
oinfo.oi_capa = capa;
+ if (sync) {
+ oinfo.oi_oa->o_valid |= OBD_MD_FLFLAGS;
+ oinfo.oi_oa->o_flags |= OBD_FL_SRVLOCK;
+ }
set = ptlrpc_prep_set();
if (set == NULL) {
RETURN(rc);
}
-/* Fills the obdo with the attributes for the inode defined by lsm */
-int ll_inode_getattr(struct inode *inode, struct obdo *obdo)
+/**
+ * Performs the getattr on the inode and updates its fields.
+ * If @sync != 0, perform the getattr under the server-side lock.
+ */
+int ll_inode_getattr(struct inode *inode, struct obdo *obdo,
+ __u64 ioepoch, int sync)
{
struct ll_inode_info *lli = ll_i2info(inode);
struct obd_capa *capa = ll_mdscapa_get(inode);
int rc;
ENTRY;
- rc = ll_lsm_getattr(lli->lli_smd, ll_i2dtexp(inode), capa, obdo);
+ rc = ll_lsm_getattr(lli->lli_smd, ll_i2dtexp(inode),
+ capa, obdo, ioepoch, sync);
capa_put(capa);
if (rc == 0) {
obdo_refresh_inode(inode, obdo, obdo->o_valid);
struct obdo obdo = { 0 };
int rc;
- rc = ll_lsm_getattr(lsm, sbi->ll_dt_exp, NULL, &obdo);
+ rc = ll_lsm_getattr(lsm, sbi->ll_dt_exp, NULL, &obdo, 0, 0);
if (rc == 0) {
st->st_size = obdo.o_size;
st->st_blocks = obdo.o_blocks;
memset(io, 0, sizeof *io);
io->u.ci_rw.crw_nonblock = file->f_flags & O_NONBLOCK;
if (write)
- io->u.ci_wr.wr_append = file->f_flags & O_APPEND;
+ io->u.ci_wr.wr_append = !!(file->f_flags & O_APPEND);
io->ci_obj = ll_i2info(inode)->lli_clob;
io->ci_lockreq = CILR_MAYBE;
if (ll_file_nolock(file)) {