From: Vitaly Fertman Date: Tue, 22 Dec 2009 01:28:50 +0000 (+0300) Subject: b=19964 SOM cleanups, part2 X-Git-Tag: 1.10.0.33~6 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=573f9f768040290ace270fe2bfbad32a1474b65f b=19964 SOM cleanups, part2 SOM cleanups, comments and some bugfixes i=zam i=vs --- diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index dfc2c1f..ef7c346 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -1027,7 +1027,7 @@ struct lov_mds_md_v3 { /* LOV EA mds/wire data (little-endian) */ #define OBD_MD_FLCOOKIE (0x00800000ULL) /* log cancellation cookie */ #define OBD_MD_FLGROUP (0x01000000ULL) /* group */ #define OBD_MD_FLFID (0x02000000ULL) /* ->ost write inline fid */ -#define OBD_MD_FLEPOCH (0x04000000ULL) /* ->ost write easize is epoch */ +#define OBD_MD_FLEPOCH (0x04000000ULL) /* ->ost write with ioepoch */ /* ->mds if epoch opens or closes */ #define OBD_MD_FLGRANT (0x08000000ULL) /* ost preallocation space grant */ #define OBD_MD_FLDIREA (0x10000000ULL) /* dir's extended attribute data */ @@ -1530,8 +1530,11 @@ extern void lustre_swab_mdt_rec_setattr (struct mdt_rec_setattr *sa); #define FMODE_WRITE 00000002 #endif +/* IO Epoch is opened on a closed file. */ #define FMODE_EPOCH 01000000 -#define FMODE_EPOCHLCK 02000000 +/* IO Epoch is opened on a file truncate. */ +#define FMODE_TRUNC 02000000 +/* Size-on-MDS Attribute Update is pending. */ #define FMODE_SOM 04000000 #define FMODE_CLOSED 0 diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c index bad86ece..a24c1b0 100644 --- a/lustre/liblustre/file.c +++ b/lustre/liblustre/file.c @@ -157,6 +157,11 @@ void obdo_refresh_inode(struct inode *dst, st->st_blocks = src->o_blocks; } +/** + * 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 llu_ioepoch_open(struct llu_inode_info *lli, __u64 ioepoch) { if (ioepoch && lli->lli_ioepoch != ioepoch) { @@ -335,12 +340,11 @@ int llu_objects_destroy(struct ptlrpc_request *req, struct inode *dir) return rc; } -int llu_sizeonmds_update(struct inode *inode, struct lustre_handle *fh, - __u64 ioepoch) +/** Cliens updates SOM attributes on MDS: obd_getattr and md_setattr. */ +int llu_som_update(struct inode *inode, struct md_op_data *op_data) { struct llu_inode_info *lli = llu_i2info(inode); struct llu_sb_info *sbi = llu_i2sbi(inode); - struct md_op_data op_data = {{ 0 }}; struct obdo oa = { 0 }; int rc; ENTRY; @@ -348,29 +352,32 @@ int llu_sizeonmds_update(struct inode *inode, struct lustre_handle *fh, LASSERT(!(lli->lli_flags & LLIF_MDS_SIZE_LOCK)); LASSERT(sbi->ll_lco.lco_flags & OBD_CONNECT_SOM); + op_data->op_flags = MF_SOM_CHANGE; + /* If inode is already in another epoch, skip getattr from OSTs. */ - if (lli->lli_ioepoch == ioepoch) { - rc = llu_inode_getattr(inode, &oa); - if (rc == -ENOENT) { + if (lli->lli_ioepoch == op_data->op_ioepoch) { + rc = llu_inode_getattr(inode, &oa, op_data->op_ioepoch); + if (rc) { oa.o_valid = 0; - CDEBUG(D_INODE, "objid "LPX64" is already destroyed\n", - lli->lli_smd->lsm_object_id); - } else if (rc) { - CERROR("inode_getattr failed (%d): unable to send a " - "Size-on-MDS attribute update for inode " - "%llu/%lu\n", rc, - (long long)llu_i2stat(inode)->st_ino, - lli->lli_st_generation); - RETURN(rc); + if (rc == -ENOENT) + CDEBUG(D_INODE, "objid "LPX64" is destroyed\n", + lli->lli_smd->lsm_object_id); + else + CERROR("inode_getattr failed (%d): unable to " + "send a Size-on-MDS attribute update " + "for inode %llu/%lu\n", rc, + (long long)llu_i2stat(inode)->st_ino, + lli->lli_st_generation); + } else { + CDEBUG(D_INODE, "Size-on-MDS update on "DFID"\n", + PFID(&lli->lli_fid)); } - md_from_obdo(&op_data, &oa, oa.o_valid); + /* Install attributes into op_data. */ + md_from_obdo(op_data, &oa, oa.o_valid); } - memcpy(&op_data.op_handle, fh, sizeof(*fh)); - op_data.op_ioepoch = ioepoch; - op_data.op_flags |= MF_SOM_CHANGE; - rc = llu_md_setattr(inode, &op_data, NULL); + rc = llu_md_setattr(inode, op_data, NULL); RETURN(rc); } @@ -394,6 +401,7 @@ void llu_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, EXIT; } +/** Pack SOM attributes info @opdata for CLOSE, DONE_WRITING rpc. */ void llu_done_writing_attr(struct inode *inode, struct md_op_data *op_data) { struct llu_inode_info *lli = llu_i2info(inode); @@ -411,6 +419,32 @@ void llu_done_writing_attr(struct inode *inode, struct md_op_data *op_data) EXIT; } +static void llu_prepare_close(struct inode *inode, struct md_op_data *op_data, + struct ll_file_data *fd) +{ + struct obd_client_handle *och = &fd->fd_mds_och; + + op_data->op_attr.ia_valid = ATTR_MODE | ATTR_ATIME_SET | + ATTR_MTIME_SET | ATTR_CTIME_SET; + + if (fd->fd_flags & FMODE_WRITE) { + struct llu_sb_info *sbi = llu_i2sbi(inode); + if (!(sbi->ll_lco.lco_flags & OBD_CONNECT_SOM) || + !S_ISREG(llu_i2stat(inode)->st_mode)) { + op_data->op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS; + } else { + /* Inode cannot be dirty. Close the epoch. */ + op_data->op_flags |= MF_EPOCH_CLOSE; + /* XXX: Send SOM attributes only if they are really + * changed. */ + llu_done_writing_attr(inode, op_data); + } + } + llu_pack_inode2opdata(inode, op_data, &och->och_fh); + llu_prep_md_op_data(op_data, inode, NULL, NULL, + 0, 0, LUSTRE_OPC_ANY); +} + int llu_md_close(struct obd_export *md_exp, struct inode *inode) { struct llu_inode_info *lli = llu_i2info(inode); @@ -426,31 +460,13 @@ int llu_md_close(struct obd_export *md_exp, struct inode *inode) if (fd->fd_flags & LL_FILE_GROUP_LOCKED) llu_put_grouplock(inode, fd->fd_grouplock.cg_gid); - op_data.op_attr.ia_valid = ATTR_MODE | ATTR_ATIME_SET | - ATTR_MTIME_SET | ATTR_CTIME_SET; - - if (lli->lli_open_flags & FMODE_WRITE) { - struct llu_sb_info *sbi = llu_i2sbi(inode); - if (!(sbi->ll_lco.lco_flags & OBD_CONNECT_SOM) || - !S_ISREG(llu_i2stat(inode)->st_mode)) { - op_data.op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS; - } else { - /* Inode cannot be dirty. Close the epoch. */ - op_data.op_flags |= MF_EPOCH_CLOSE; - /* XXX: Send SOM attributes only if they are really - * changed. */ - llu_done_writing_attr(inode, &op_data); - } - } - llu_pack_inode2opdata(inode, &op_data, &och->och_fh); - + llu_prepare_close(inode, &op_data, fd); rc = md_close(md_exp, &op_data, och->och_mod, &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. */ LASSERT(lli->lli_open_flags & FMODE_WRITE); - rc = llu_sizeonmds_update(inode, &och->och_fh, - op_data.op_ioepoch); + rc = llu_som_update(inode, &op_data); if (rc) { CERROR("inode %llu mdc Size-on-MDS update failed: " "rc = %d\n", (long long)st->st_ino, rc); diff --git a/lustre/liblustre/llite_lib.h b/lustre/liblustre/llite_lib.h index afe017c..b5e0468 100644 --- a/lustre/liblustre/llite_lib.h +++ b/lustre/liblustre/llite_lib.h @@ -230,7 +230,7 @@ void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid); void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid); int ll_it_open_error(int phase, struct lookup_intent *it); struct inode *llu_iget(struct filesys *fs, struct lustre_md *md); -int llu_inode_getattr(struct inode *inode, struct obdo *obdo); +int llu_inode_getattr(struct inode *inode, struct obdo *obdo, __u64 ioepoch); int llu_md_setattr(struct inode *inode, struct md_op_data *op_data, struct md_open_data **mod); int llu_setattr_raw(struct inode *inode, struct iattr *attr); @@ -251,8 +251,7 @@ int llu_md_close(struct obd_export *md_exp, struct inode *inode); void llu_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, struct lustre_handle *fh); int llu_file_release(struct inode *inode); -int llu_sizeonmds_update(struct inode *inode, struct lustre_handle *fh, - __u64 ioepoch); +int llu_som_update(struct inode *inode, struct md_op_data *op_data); int llu_iop_close(struct inode *inode); _SYSIO_OFF_T llu_iop_pos(struct inode *ino, _SYSIO_OFF_T off); int llu_vmtruncate(struct inode * inode, loff_t offset, obd_flag obd_flags); diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 7824522..b1d16ab 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -343,7 +343,7 @@ void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid) /* * really does the getattr on the inode and updates its fields */ -int llu_inode_getattr(struct inode *inode, struct obdo *obdo) +int llu_inode_getattr(struct inode *inode, struct obdo *obdo, __u64 ioepoch) { struct llu_inode_info *lli = llu_i2info(inode); struct ptlrpc_request_set *set; @@ -359,10 +359,12 @@ int llu_inode_getattr(struct inode *inode, struct obdo *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_ioepoch = ioepoch; 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 | OBD_MD_FLGROUP; + OBD_MD_FLCTIME | OBD_MD_FLGROUP | + OBD_MD_FLATIME | OBD_MD_FLEPOCH; set = ptlrpc_prep_set(); if (set == NULL) { @@ -712,8 +714,7 @@ static int llu_setattr_done_writing(struct inode *inode, 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); + rc = llu_som_update(inode, op_data); } else if (rc) { CERROR("inode %llu mdc truncate failed: rc = %d\n", (unsigned long long)st->st_ino, rc); diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 0c0ee79..c98ff0a 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -82,6 +82,10 @@ void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, 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) { @@ -100,6 +104,8 @@ static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data, 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; } @@ -137,8 +143,7 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, 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, &op_data->op_handle, - 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); @@ -398,6 +403,11 @@ out: 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) { @@ -677,7 +687,8 @@ out_openerr: /* 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) { struct ptlrpc_request_set *set; struct obd_info oinfo = { { { 0 } } }; @@ -692,11 +703,12 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, 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; set = ptlrpc_prep_set(); @@ -716,15 +728,16 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, 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 for @ioepoch on the inode and updates its fields. */ +int ll_inode_getattr(struct inode *inode, struct obdo *obdo, __u64 ioepoch) { 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); capa_put(capa); if (rc == 0) { obdo_refresh_inode(inode, obdo, obdo->o_valid); @@ -766,7 +779,7 @@ int ll_glimpse_ioctl(struct ll_sb_info *sbi, struct lov_stripe_md *lsm, 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); if (rc == 0) { st->st_size = obdo.o_size; st->st_blocks = obdo.o_blocks; diff --git a/lustre/llite/llite_close.c b/lustre/llite/llite_close.c index f2f36c2..803f478 100644 --- a/lustre/llite/llite_close.c +++ b/lustre/llite/llite_close.c @@ -122,6 +122,7 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags) EXIT; } +/** Pack SOM attributes info @opdata for CLOSE, DONE_WRITING rpc. */ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data) { struct ll_inode_info *lli = ll_i2info(inode); @@ -142,10 +143,9 @@ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data) EXIT; } -/** Closes epoch and sends Size-on-MDS attribute update if possible. Call - * this under ll_inode_info::lli_lock spinlock. */ +/** Closes ioepoch and packs Size-on-MDS attribute if needed into @op_data. */ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, - struct obd_client_handle **och, unsigned long flags) + struct obd_client_handle **och, unsigned long flags) { struct ll_inode_info *lli = ll_i2info(inode); struct ccc_object *club = cl2ccc(ll_i2info(inode)->lli_clob); @@ -214,11 +214,14 @@ out: return; } -int ll_sizeonmds_update(struct inode *inode, struct lustre_handle *fh, - __u64 ioepoch) +/** + * Cliens updates SOM attributes on MDS (including llog cookies): + * obd_getattr with no lock and md_setattr. + */ +int ll_som_update(struct inode *inode, struct md_op_data *op_data) { struct ll_inode_info *lli = ll_i2info(inode); - struct md_op_data *op_data; + struct ptlrpc_request *request = NULL; struct obdo *oa; int rc; ENTRY; @@ -229,46 +232,61 @@ int ll_sizeonmds_update(struct inode *inode, struct lustre_handle *fh, lli->lli_flags); OBDO_ALLOC(oa); - OBD_ALLOC_PTR(op_data); - if (!oa || !op_data) { + if (!oa) { CERROR("can't allocate memory for Size-on-MDS update.\n"); RETURN(-ENOMEM); } + + op_data->op_flags = MF_SOM_CHANGE; + /* If inode is already in another epoch, skip getattr from OSTs. */ - if (lli->lli_ioepoch == ioepoch) { - rc = ll_inode_getattr(inode, oa); - if (rc == -ENOENT) { + if (lli->lli_ioepoch == op_data->op_ioepoch) { + rc = ll_inode_getattr(inode, oa, op_data->op_ioepoch); + if (rc) { oa->o_valid = 0; - CDEBUG(D_INODE, "objid "LPX64" is already destroyed\n", - lli->lli_smd->lsm_object_id); - } else if (rc) { - CERROR("inode_getattr failed (%d): unable to send a " - "Size-on-MDS attribute update for inode " - "%lu/%u\n", rc, inode->i_ino, - inode->i_generation); - GOTO(out, rc); + if (rc == -ENOENT) + CDEBUG(D_INODE, "objid "LPX64" is destroyed\n", + lli->lli_smd->lsm_object_id); + else + CERROR("inode_getattr failed (%d): unable to " + "send a Size-on-MDS attribute update " + "for inode %lu/%u\n", rc, inode->i_ino, + inode->i_generation); + } else { + CDEBUG(D_INODE, "Size-on-MDS update on "DFID"\n", + PFID(&lli->lli_fid)); } - CDEBUG(D_INODE, "Size-on-MDS update on "DFID"\n", - PFID(&lli->lli_fid)); + /* Install attributes into op_data. */ md_from_obdo(op_data, oa, oa->o_valid); } - memcpy(&op_data->op_handle, fh, sizeof(*fh)); - op_data->op_ioepoch = ioepoch; - op_data->op_flags |= MF_SOM_CHANGE; + rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, + NULL, 0, NULL, 0, &request, NULL); + ptlrpc_req_finished(request); - rc = ll_md_setattr(inode, op_data, NULL); - EXIT; -out: - if (oa) - OBDO_FREE(oa); - if (op_data) - ll_finish_md_op_data(op_data); - return rc; + OBDO_FREE(oa); + RETURN(rc); } -/** Sends a DONE_WRITING rpc, packs Size-on-MDS attributes into it, if - * possible */ +/** + * Closes the ioepoch and packs all the attributes into @op_data for + * DONE_WRITING rpc. + */ +static void ll_prepare_done_writing(struct inode *inode, + struct md_op_data *op_data, + struct obd_client_handle **och) +{ + ll_ioepoch_close(inode, op_data, och, LLIF_DONE_WRITING); + /* If there is no @och, we do not do D_W yet. */ + if (*och == NULL) + return; + + 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); +} + +/** Send a DONE_WRITING rpc. */ static void ll_done_writing(struct inode *inode) { struct obd_client_handle *och = NULL; @@ -285,19 +303,16 @@ static void ll_done_writing(struct inode *inode) return; } - ll_ioepoch_close(inode, op_data, &och, LLIF_DONE_WRITING); + ll_prepare_done_writing(inode, op_data, &och); /* If there is no @och, we do not do D_W yet. */ if (och == NULL) GOTO(out, 0); - ll_pack_inode2opdata(inode, op_data, &och->och_fh); - rc = md_done_writing(ll_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 = ll_sizeonmds_update(inode, &op_data->op_handle, - op_data->op_ioepoch); + rc = ll_som_update(inode, op_data); } else if (rc) { CERROR("inode %lu mdc done_writing failed: rc = %d\n", inode->i_ino, rc); diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 6e19b0e..e571a4d 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -623,9 +623,8 @@ int ll_md_real_close(struct inode *inode, int flags); void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, struct obd_client_handle **och, unsigned long flags); void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data); -int ll_sizeonmds_update(struct inode *inode, struct lustre_handle *fh, - __u64 ioepoch); -int ll_inode_getattr(struct inode *inode, struct obdo *obdo); +int ll_som_update(struct inode *inode, struct md_op_data *op_data); +int ll_inode_getattr(struct inode *inode, struct obdo *obdo, __u64 ioepoch); int ll_md_setattr(struct inode *inode, struct md_op_data *op_data, struct md_open_data **mod); void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 6338762..ed63c2b 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1215,8 +1215,7 @@ static int ll_setattr_done_writing(struct inode *inode, if (rc == -EAGAIN) { /* MDS has instructed us to obtain Size-on-MDS attribute * from OSTs and send setattr to back to MDS. */ - rc = ll_sizeonmds_update(inode, &op_data->op_handle, - op_data->op_ioepoch); + rc = ll_som_update(inode, op_data); } else if (rc) { CERROR("inode %lu mdc truncate failed: rc = %d\n", inode->i_ino, rc); diff --git a/lustre/lov/lov_merge.c b/lustre/lov/lov_merge.c index 6a1bfc7..091e435 100644 --- a/lustre/lov/lov_merge.c +++ b/lustre/lov/lov_merge.c @@ -210,6 +210,6 @@ void lov_merge_attrs(struct obdo *tgt, struct obdo *src, obd_flag valid, tgt->o_id = lsm->lsm_object_id; if (valid & OBD_MD_FLSIZE) tgt->o_size = lov_stripe_size(lsm,src->o_size,stripeno); - *set = 1; } + *set += 1; } diff --git a/lustre/lov/lov_request.c b/lustre/lov/lov_request.c index b84551a..c34f3fc 100644 --- a/lustre/lov/lov_request.c +++ b/lustre/lov/lov_request.c @@ -788,6 +788,14 @@ static int common_attr_done(struct lov_request_set *set) CERROR("No stripes had valid attrs\n"); rc = -EIO; } + if ((set->set_oi->oi_oa->o_valid & OBD_MD_FLEPOCH) && + (set->set_oi->oi_md->lsm_stripe_count != attrset)) { + /* When we take attributes of some epoch, we require all the + * ost to be active. */ + CERROR("Not all the stripes had valid attrs\n"); + GOTO(out, rc = -EIO); + } + tmp_oa->o_id = set->set_oi->oi_oa->o_id; memcpy(set->set_oi->oi_oa, tmp_oa, sizeof(*set->set_oi->oi_oa)); out: @@ -1009,6 +1017,9 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, if (!lov->lov_tgts[loi->loi_ost_idx] || !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) { CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx); + if (oinfo->oi_oa->o_valid & OBD_MD_FLEPOCH) + /* SOM requires all the OSTs to be active. */ + GOTO(out_set, rc = -EIO); continue; } diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index e47e9c9..417af35 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -377,7 +377,7 @@ void mdt_pack_size2body(struct mdt_thread_info *info, struct mdt_object *o) /* Check if Size-on-MDS is enabled. */ if ((mdt_conn_flags(info) & OBD_CONNECT_SOM) && - S_ISREG(attr->la_mode) && mdt_sizeonmds_enabled(o)) { + S_ISREG(attr->la_mode) && mdt_object_is_som_enabled(o)) { b->valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS); b->size = attr->la_size; b->blocks = attr->la_blocks; diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 8a7fa19..bc14e74 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -575,8 +575,8 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_file_data *mdt_handle2mfd(struct mdt_thread_info *, const struct lustre_handle *); int mdt_ioepoch_open(struct mdt_thread_info *info, struct mdt_object *o); -void mdt_sizeonmds_enable(struct mdt_thread_info *info, struct mdt_object *mo); -int mdt_sizeonmds_enabled(struct mdt_object *mo); +void mdt_object_som_enable(struct mdt_thread_info *info, struct mdt_object *mo); +int mdt_object_is_som_enabled(struct mdt_object *mo); int mdt_write_get(struct mdt_device *mdt, struct mdt_object *o); int mdt_write_read(struct mdt_device *mdt, struct mdt_object *o); struct mdt_file_data *mdt_mfd_new(void); diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 6edad7a..19ca96e 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -128,14 +128,14 @@ static int mdt_ioepoch_opened(struct mdt_object *mo) return mo->mot_ioepoch_count; } -int mdt_sizeonmds_enabled(struct mdt_object *mo) +int mdt_object_is_som_enabled(struct mdt_object *mo) { return !mo->mot_ioepoch; } /* Re-enable Size-on-MDS. */ -void mdt_sizeonmds_enable(struct mdt_thread_info *info, - struct mdt_object *mo) +void mdt_object_som_enable(struct mdt_thread_info *info, + struct mdt_object *mo) { spin_lock(&info->mti_mdt->mdt_ioepoch_lock); if (info->mti_ioepoch->ioepoch == mo->mot_ioepoch) { @@ -213,7 +213,7 @@ static int mdt_sizeonmds_update(struct mdt_thread_info *info, LA_ATIME | LA_MTIME | LA_CTIME; RETURN(mdt_attr_set(info, o, 0)); } else - mdt_sizeonmds_enable(info, o); + mdt_object_som_enable(info, o); RETURN(0); } @@ -1220,7 +1220,7 @@ out: } #define MFD_CLOSED(mode) (((mode) & ~(FMODE_EPOCH | FMODE_SOM | \ - FMODE_EPOCHLCK)) == FMODE_CLOSED) + FMODE_TRUNC)) == FMODE_CLOSED) static int mdt_mfd_closed(struct mdt_file_data *mfd) { @@ -1238,7 +1238,7 @@ int mdt_mfd_close(struct mdt_thread_info *info, struct mdt_file_data *mfd) mode = mfd->mfd_mode; - if ((mode & FMODE_WRITE) || (mode & FMODE_EPOCHLCK)) { + if ((mode & FMODE_WRITE) || (mode & FMODE_TRUNC)) { mdt_write_put(info->mti_mdt, o); ret = mdt_ioepoch_close(info, o); } else if (mode & MDS_FMODE_EXEC) { @@ -1423,7 +1423,7 @@ int mdt_done_writing(struct mdt_thread_info *info) } LASSERT(mfd->mfd_mode == FMODE_EPOCH || - mfd->mfd_mode == FMODE_EPOCHLCK); + mfd->mfd_mode == FMODE_TRUNC); class_handle_unhash(&mfd->mfd_handle); list_del_init(&mfd->mfd_list); spin_unlock(&med->med_open_lock); diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 30d08ec..2e62360 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -343,7 +343,7 @@ int mdt_attr_set(struct mdt_thread_info *info, struct mdt_object *mo, int flags) ". Count %d\n", mo->mot_ioepoch, PFID(mdt_object_fid(mo)), ma->ma_attr.la_size, mo->mot_ioepoch_count); - mdt_sizeonmds_enable(info, mo); + mdt_object_som_enable(info, mo); } EXIT; @@ -400,7 +400,7 @@ static int mdt_reint_setattr(struct mdt_thread_info *info, repbody->ioepoch = mo->mot_ioepoch; mdt_object_get(info->mti_env, mo); - mdt_mfd_set_mode(mfd, FMODE_EPOCHLCK); + mdt_mfd_set_mode(mfd, FMODE_TRUNC); mfd->mfd_object = mo; mfd->mfd_xid = req->rq_xid; diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index eaa65e3..c871388 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -2029,10 +2029,8 @@ void dump_obdo(struct obdo *oa) if (valid & OBD_MD_FLGENER) CDEBUG(D_RPCTRACE, "obdo: o_generation = %u\n", oa->o_generation); - if (valid & OBD_MD_FLEASIZE) - CDEBUG(D_RPCTRACE, "obdo: o_easize = %u\n", oa->o_easize); else if (valid & OBD_MD_FLEPOCH) - CDEBUG(D_RPCTRACE, "obdo: o_epoc (o_easize) = %u\n", oa->o_easize); + CDEBUG(D_RPCTRACE, "obdo: o_ioepoch = "LPD64"\n", oa->o_ioepoch); if (valid & OBD_MD_FLID) CDEBUG(D_RPCTRACE, "obdo: o_stripe_idx = %u\n", oa->o_stripe_idx); if (valid & OBD_MD_FLHANDLE)