From 32b4812a6afd1e71a3576835d445622d38cdafd1 Mon Sep 17 00:00:00 2001 From: wangdi <wangdi> Date: Tue, 8 Jun 2004 09:17:39 +0000 Subject: [PATCH] 1)do precreate record in obdfilter 2)fix bugs in fsfilt_commit in smfs, sometime inode will be null sometime --- lustre/include/linux/lustre_fsfilt.h | 38 ++++++++++++++++----- lustre/include/linux/lustre_smfs.h | 1 + lustre/lvfs/fsfilt_ext3.c | 3 +- lustre/lvfs/fsfilt_smfs.c | 33 ++++++++++++++++--- lustre/mds/handler.c | 2 +- lustre/mds/mds_fs.c | 7 ++-- lustre/mds/mds_lmv.c | 2 +- lustre/mds/mds_lov.c | 4 +-- lustre/mds/mds_open.c | 2 +- lustre/mds/mds_reint.c | 4 +-- lustre/mds/mds_unlink_open.c | 2 +- lustre/obdfilter/filter.c | 39 ++++++++++++++++------ lustre/smfs/cache_space.c | 2 +- lustre/smfs/journal.c | 8 ++--- lustre/smfs/kml.c | 6 ++++ lustre/smfs/ost_kml.c | 49 ++++++++++++++++------------ lustre/smfs/smfs_internal.h | 2 ++ 17 files changed, 143 insertions(+), 61 deletions(-) diff --git a/lustre/include/linux/lustre_fsfilt.h b/lustre/include/linux/lustre_fsfilt.h index 7360b24807..43c3123bdb 100644 --- a/lustre/include/linux/lustre_fsfilt.h +++ b/lustre/include/linux/lustre_fsfilt.h @@ -48,7 +48,8 @@ struct fsfilt_operations { void *(* fs_brw_start)(int objcount, struct fsfilt_objinfo *fso, int niocount, struct niobuf_local *nb, void *desc_private, int logs); - int (* fs_commit)(struct inode *inode, void *handle,int force_sync); + int (* fs_commit)(struct super_block *sb, struct inode *inode, + void *handle,int force_sync); int (* fs_commit_async)(struct inode *inode, void *handle, void **wait_handle); int (* fs_commit_wait)(struct inode *inode, void *handle); @@ -95,9 +96,11 @@ struct fsfilt_operations { int (* fs_get_reint_log_ctxt)(struct super_block *sb, struct llog_ctxt **ctxt); int (* fs_set_kml_flags)(struct inode *inode); + int (* fs_clear_kml_flags)(struct inode *inode); int (* fs_set_ost_flags)(struct super_block *sb); int (* fs_set_mds_flags)(struct super_block *sb); - + int (* fs_precreate_rec)(struct dentry *dentry, int *num, + struct obdo *oa); int (* fs_set_xattr)(struct inode *inode, void *handle, char *name, void *buffer, int buffer_size); int (* fs_get_xattr)(struct inode *inode, char *name, @@ -217,11 +220,11 @@ llog_fsfilt_start(struct llog_ctxt *ctxt, struct inode *inode, } static inline int -fsfilt_commit_ops(struct fsfilt_operations *ops, struct inode *inode, - void *handle, int force_sync) +fsfilt_commit_ops(struct fsfilt_operations *ops, struct super_block *sb, + struct inode *inode, void *handle, int force_sync) { unsigned long now = jiffies; - int rc = ops->fs_commit(inode, handle, force_sync); + int rc = ops->fs_commit(sb, inode, handle, force_sync); CDEBUG(D_HA, "committing handle %p\n", handle); if (time_after(jiffies, now + 15 * HZ)) @@ -231,17 +234,18 @@ fsfilt_commit_ops(struct fsfilt_operations *ops, struct inode *inode, } static inline int -fsfilt_commit(struct obd_device *obd, struct inode *inode, - void *handle, int force_sync) +fsfilt_commit(struct obd_device *obd, struct super_block *sb, + struct inode *inode, void *handle, int force_sync) { - return fsfilt_commit_ops(obd->obd_fsops, inode, handle, force_sync); + return fsfilt_commit_ops(obd->obd_fsops, sb, inode, handle, force_sync); } static inline int llog_fsfilt_commit(struct llog_ctxt *ctxt, struct inode *inode, void *handle, int force_sync) { - return fsfilt_commit_ops(ctxt->loc_fsops, inode, handle, force_sync); + return fsfilt_commit_ops(ctxt->loc_fsops, inode->i_sb, inode, handle, + force_sync); } static inline void * @@ -517,6 +521,22 @@ fsfilt_set_kml_flags(struct obd_device *obd, struct inode *inode) return 0; } +static inline int +fsfilt_clear_kml_flags(struct obd_device *obd, struct inode *inode) +{ + if (obd->obd_fsops->fs_clear_kml_flags) + return obd->obd_fsops->fs_clear_kml_flags(inode); + return 0; +} +static inline int +fsfilt_precreate_rec(struct obd_device *obd, struct dentry *dentry, + int *num, struct obdo *oa) +{ + if (obd->obd_fsops->fs_precreate_rec) + return obd->obd_fsops->fs_precreate_rec(dentry, num, oa); + return 0; +} + static inline int fsfilt_post_setup(struct obd_device *obd) { diff --git a/lustre/include/linux/lustre_smfs.h b/lustre/include/linux/lustre_smfs.h index 444622e524..ba335482b7 100644 --- a/lustre/include/linux/lustre_smfs.h +++ b/lustre/include/linux/lustre_smfs.h @@ -392,6 +392,7 @@ extern int smfs_write_extents(struct inode *dir, struct dentry *dentry, unsigned long from, unsigned long num); extern int smfs_rec_setattr(struct inode *dir, struct dentry *dentry, struct iattr *attr); +extern int smfs_rec_precreate(struct dentry *dentry, int *num, struct obdo *oa); extern int smfs_rec_md(struct inode *inode, void * lmm, int lmm_size); extern int smfs_rec_unpack(struct smfs_proc_args *args, char *record, char **pbuf, int *opcode); diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c index e78a153e69..1c44847120 100644 --- a/lustre/lvfs/fsfilt_ext3.c +++ b/lustre/lvfs/fsfilt_ext3.c @@ -310,7 +310,8 @@ static void *fsfilt_ext3_brw_start(int objcount, struct fsfilt_objinfo *fso, RETURN(handle); } -static int fsfilt_ext3_commit(struct inode *inode, void *h, int force_sync) +static int fsfilt_ext3_commit(struct super_block *sb, struct inode *inode, + void *h, int force_sync) { int rc; handle_t *handle = h; diff --git a/lustre/lvfs/fsfilt_smfs.c b/lustre/lvfs/fsfilt_smfs.c index 646c21c545..31b6b95063 100644 --- a/lustre/lvfs/fsfilt_smfs.c +++ b/lustre/lvfs/fsfilt_smfs.c @@ -96,13 +96,16 @@ exit: mds_open() behavior. It passes NULL inode to mds_finish_transno() sometimes. Probably we should have spare way to get cache fsfilt operations. */ -static int fsfilt_smfs_commit(struct inode *inode, void *h, int force_sync) +static int fsfilt_smfs_commit(struct super_block *sb, struct inode *inode, + void *h, int force_sync) { - struct fsfilt_operations *cache_fsfilt = I2FOPS(inode); + struct fsfilt_operations *cache_fsfilt = S2SMI(sb)->sm_cache_fsfilt; + struct super_block *csb = S2CSB(sb); struct inode *cache_inode = NULL; int rc = -EIO; - cache_inode = I2CI(inode); + if (inode) + cache_inode = I2CI(inode); if (cache_fsfilt == NULL) RETURN(rc); @@ -110,7 +113,7 @@ static int fsfilt_smfs_commit(struct inode *inode, void *h, int force_sync) if (!cache_fsfilt->fs_commit) RETURN(-ENOSYS); - rc = cache_fsfilt->fs_commit(cache_inode, h, force_sync); + rc = cache_fsfilt->fs_commit(csb, cache_inode, h, force_sync); RETURN(rc); } @@ -621,6 +624,14 @@ static int fsfilt_smfs_set_kml_flags(struct inode *inode) RETURN(rc); } +static int fsfilt_smfs_clear_kml_flags(struct inode *inode) +{ + int rc = 0; + if (SMFS_DO_REC(S2SMI(inode->i_sb))) + SMFS_CLEAN_INODE_REC(inode); + RETURN(rc); +} + static int fsfilt_smfs_set_ost_flags(struct super_block *sb) { int rc = 0; @@ -787,6 +798,7 @@ static int fsfilt_smfs_free_extents(struct super_block *sb, ino_t ino, OBD_FREE(pbuf, size * (sizeof(struct ldlm_extent))); return 0; } + static int fsfilt_smfs_write_extents(struct dentry *dentry, unsigned long from, unsigned long num) { @@ -798,6 +810,17 @@ static int fsfilt_smfs_write_extents(struct dentry *dentry, return rc; } +static int fsfilt_smfs_precreate_rec(struct dentry *dentry, int *count, + struct obdo *oa) +{ + int rc = 0; + + if (SMFS_DO_REC(S2SMI(dentry->d_inode->i_sb))) + rc = smfs_rec_precreate(dentry, count, oa); + + return rc; +} + static int fsfilt_smfs_get_ino_write_extents(struct super_block *sb, ino_t ino, char **pbuf, int *size) { @@ -901,8 +924,10 @@ static struct fsfilt_operations fsfilt_smfs_ops = { .fs_post_setup = fsfilt_smfs_post_setup, .fs_post_cleanup = fsfilt_smfs_post_cleanup, .fs_set_kml_flags = fsfilt_smfs_set_kml_flags, + .fs_clear_kml_flags = fsfilt_smfs_clear_kml_flags, .fs_set_ost_flags = fsfilt_smfs_set_ost_flags, .fs_set_mds_flags = fsfilt_smfs_set_mds_flags, + .fs_precreate_rec = fsfilt_smfs_precreate_rec, .fs_get_reint_log_ctxt = fsfilt_smfs_get_reint_log_ctxt, .fs_send_bio = fsfilt_smfs_send_bio, .fs_set_xattr = fsfilt_smfs_set_xattr, diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index d69ce24292..97ea846079 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1369,7 +1369,7 @@ repeat: if (IS_ERR(new)) { CERROR("%s: can't lookup new inode (%s) for mkdir: %d\n", obd->obd_name, fidname, (int) PTR_ERR(new)); - fsfilt_commit(obd, new->d_inode, handle, 0); + fsfilt_commit(obd, mds->mds_sb, new->d_inode, handle, 0); up(&parent_inode->i_sem); RETURN(PTR_ERR(new)); } else if (new->d_inode) { diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index db3a11b75e..7194c3bbe6 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -653,8 +653,8 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa, CERROR("error renaming new object "LPU64":%u: rc %d\n", oa->o_id, oa->o_generation, rc); - err = fsfilt_commit(exp->exp_obd, mds->mds_objects_dir->d_inode, - handle, 0); + err = fsfilt_commit(exp->exp_obd, mds->mds_sb, + mds->mds_objects_dir->d_inode, handle, 0); if (!err) { oa->o_gr = FILTER_GROUP_FIRST_MDS + mds->mds_num; oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGENER | OBD_MD_FLGROUP; @@ -714,7 +714,8 @@ int mds_obd_destroy(struct obd_export *exp, struct obdo *oa, CERROR("error destroying object "LPU64":%u: rc %d\n", oa->o_id, oa->o_generation, rc); - err = fsfilt_commit(obd, mds->mds_objects_dir->d_inode, handle, 0); + err = fsfilt_commit(obd, mds->mds_sb, mds->mds_objects_dir->d_inode, + handle, 0); if (err && !rc) rc = err; out_dput: diff --git a/lustre/mds/mds_lmv.c b/lustre/mds/mds_lmv.c index 54134df4ca..e1f09b8062 100644 --- a/lustre/mds/mds_lmv.c +++ b/lustre/mds/mds_lmv.c @@ -516,7 +516,7 @@ int mds_try_to_split_dir(struct obd_device *obd, LASSERT(!IS_ERR(handle)); rc = fsfilt_set_md(obd, dir, handle, *mea, mea_size); LASSERT(rc == 0); - fsfilt_commit(obd, dir, handle, 0); + fsfilt_commit(obd, mds->mds_sb, dir, handle, 0); LASSERT(rc == 0); up(&dir->i_sem); obdo_free(oa); diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index 82e1b05eb8..c9e0c2118d 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -439,7 +439,7 @@ int mds_iocontrol(unsigned int cmd, struct obd_export *exp, int len, handle = fsfilt_start(obd, inode, FSFILT_OP_MKNOD, NULL); LASSERT(handle); - rc = fsfilt_commit(obd, inode, handle, 1); + rc = fsfilt_commit(obd, obd->u.mds.mds_sb, inode, handle, 1); dev_set_rdonly(ll_sbdev(obd->u.mds.mds_sb), 2); RETURN(0); @@ -649,7 +649,7 @@ int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode, rc = fsfilt_set_md(obd, inode, handle, lmm, lmm_size); - err = fsfilt_commit(obd, inode, handle, 0); + err = fsfilt_commit(obd, obd->u.mds.mds_sb, inode, handle, 0); if (!rc) rc = err ? err : lmm_size; GOTO(conv_free, rc); diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index 3ff867ba24..2f3e7d0b7b 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -1321,7 +1321,7 @@ out: if (req != NULL && reply_body != NULL) { rc = mds_finish_transno(mds, pending_dir, handle, req, rc, 0); } else if (handle) { - int err = fsfilt_commit(obd, pending_dir, handle, 0); + int err = fsfilt_commit(obd, mds->mds_sb, pending_dir, handle, 0); if (err) { CERROR("error committing close: %d\n", err); if (!rc) diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index fe82cf2bf2..8c1269df87 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -174,7 +174,7 @@ int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle, CDEBUG(log_pri, "wrote objids: err = %d\n", err); commit: - err = fsfilt_commit(obd, inode, handle, 0); + err = fsfilt_commit(obd, mds->mds_sb, inode, handle, 0); if (err) { CERROR("error committing transaction: %d\n", err); if (!rc) @@ -1395,7 +1395,7 @@ int mds_create_local_dentry(struct mds_update_record *rec, } mark_inode_dirty(child->d_inode); } - fsfilt_commit(obd, fids_dir, handle, 0); + fsfilt_commit(obd, mds->mds_sb, fids_dir, handle, 0); rec->ur_fid1->id = fids_dir->i_ino; rec->ur_fid1->generation = fids_dir->i_generation; diff --git a/lustre/mds/mds_unlink_open.c b/lustre/mds/mds_unlink_open.c index 951c09f117..2c1092a278 100644 --- a/lustre/mds/mds_unlink_open.c +++ b/lustre/mds/mds_unlink_open.c @@ -228,7 +228,7 @@ static int mds_unlink_orphan(struct obd_device *obd, struct dentry *dchild, mds->mds_max_cookiesize) > 0) log_unlink = 1; } - err = fsfilt_commit(obd, pending_dir, handle, 0); + err = fsfilt_commit(obd, mds->mds_sb, pending_dir, handle, 0); if (err) { CERROR("error committing orphan unlink: %d\n", err); if (!rc) diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index e2a55dd985..644b735e19 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -207,7 +207,7 @@ static int filter_client_add(struct obd_device *obd, struct filter_obd *filter, fed->fed_fcd, sizeof(*fed->fed_fcd), &off, 1); - fsfilt_commit(obd, + fsfilt_commit(obd, filter->fo_sb, filter->fo_rcvd_filp->f_dentry->d_inode, handle, 1); } @@ -1867,7 +1867,7 @@ static int filter_setattr(struct obd_export *exp, struct obdo *oa, else rc = fsfilt_setattr(exp->exp_obd, dentry, handle, &iattr, 1); rc = filter_finish_transno(exp, oti, rc); - rc2 = fsfilt_commit(exp->exp_obd, dentry->d_inode, handle, 0); + rc2 = fsfilt_commit(exp->exp_obd, filter->fo_sb, dentry->d_inode, handle, 0); if (rc2) { CERROR("error on commit, err = %d\n", rc2); if (!rc) @@ -2043,7 +2043,16 @@ static int filter_should_precreate(struct obd_export *exp, struct obdo *oa, RETURN(diff); } } - +static int filter_precreate_rec(struct obd_device *obd, struct dentry *dentry, + int *number, struct obdo *oa) +{ + int rc = 0; + ENTRY; + + rc = fsfilt_precreate_rec(obd, dentry, number, oa); + + RETURN(rc); +} /* We rely on the fact that only one thread will be creating files in a given * group at a time, which is why we don't need an atomic filter_get_new_id. * Even if we had that atomic function, the following race would exist: @@ -2104,6 +2113,9 @@ static int filter_precreate(struct obd_device *obd, struct obdo *oa, GOTO(cleanup, rc = PTR_ERR(dparent)); cleanup_phase = 1; + /*only do precreate rec record. so clean kml flags here*/ + fsfilt_clear_kml_flags(obd, dparent->d_inode); + dchild = filter_fid2dentry(obd, dparent, group, next_id); if (IS_ERR(dchild)) GOTO(cleanup, rc = PTR_ERR(dchild)); @@ -2149,11 +2161,12 @@ static int filter_precreate(struct obd_device *obd, struct obdo *oa, CERROR("unable to write lastobjid " "but file created\n"); } - + fsfilt_set_kml_flags(obd, dparent->d_inode); + cleanup: switch(cleanup_phase) { case 3: - err = fsfilt_commit(obd, dparent->d_inode, handle, 0); + err = fsfilt_commit(obd, filter->fo_sb, dparent->d_inode, handle, 0); if (err) { CERROR("error on commit, err = %d\n", err); if (!rc) @@ -2172,8 +2185,10 @@ static int filter_precreate(struct obd_device *obd, struct obdo *oa, } *num = i; + rc = filter_precreate_rec(obd, dparent, num, oa); + up(&filter->fo_create_lock); - + CDEBUG(D_HA, "%s: server last_objid for group "LPU64": "LPU64"\n", obd->obd_name, group, filter->fo_last_objids[group]); @@ -2232,8 +2247,11 @@ static int filter_create(struct obd_export *exp, struct obdo *oa, obd = exp->exp_obd; push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - if ((oa->o_valid & OBD_MD_FLFLAGS) && - (oa->o_flags & OBD_FL_RECREATE_OBJS)) { + if (oa->o_valid & OBD_MD_REINT) { + int num = *((int*)oa->o_inline); + rc = filter_precreate(obd, oa, oa->o_gr, &num); + } else if ((oa->o_valid & OBD_MD_FLFLAGS) && + (oa->o_flags & OBD_FL_RECREATE_OBJS)) { if (oa->o_id > filter_last_id(&obd->u.filter, group)) { CERROR("recreate objid "LPU64" > last id "LPU64"\n", oa->o_id, filter_last_id(&obd->u.filter, group)); @@ -2356,7 +2374,8 @@ cleanup: fcc); } rc = filter_finish_transno(exp, oti, rc); - rc2 = fsfilt_commit(obd, dparent->d_inode, handle, 0); + rc2 = fsfilt_commit(obd, filter->fo_sb, dparent->d_inode, + handle, 0); if (rc2) { CERROR("error on commit, err = %d\n", rc2); if (!rc) @@ -2674,7 +2693,7 @@ int filter_iocontrol(unsigned int cmd, struct obd_export *exp, handle = fsfilt_start(obd, inode, FSFILT_OP_MKNOD, NULL); LASSERT(handle); - (void)fsfilt_commit(obd, inode, handle, 1); + (void)fsfilt_commit(obd, sb, inode, handle, 1); dev_set_rdonly(ll_sbdev(obd->u.filter.fo_sb), 2); RETURN(0); diff --git a/lustre/smfs/cache_space.c b/lustre/smfs/cache_space.c index 36bf95bec1..a5bd94bded 100644 --- a/lustre/smfs/cache_space.c +++ b/lustre/smfs/cache_space.c @@ -334,7 +334,7 @@ insert: if (op & CACHE_SPACE_COMMIT) { if (handle) { - err = fsops->fs_commit(inode, handle, 0); + err = fsops->fs_commit(inode->i_sb, inode, handle, 0); if (err) { CERROR("error committing transaction: %d\n", err); if (!rc) diff --git a/lustre/smfs/journal.c b/lustre/smfs/journal.c index 8a43df7f32..838440a625 100644 --- a/lustre/smfs/journal.c +++ b/lustre/smfs/journal.c @@ -75,7 +75,7 @@ void smfs_trans_commit(struct inode *inode, void *handle, int force_sync) CDEBUG(D_INFO, "trans commit %p\n", fsfilt->fs_commit); if (fsfilt->fs_commit) - fsfilt->fs_commit(inode, handle, force_sync); + fsfilt->fs_commit(inode->i_sb, inode, handle, force_sync); } /*smfs_path is gotten from intermezzo*/ @@ -159,10 +159,8 @@ static int smfs_pack_rec (char *buffer, struct dentry *dentry, return rc; } -static int smfs_post_rec_create(struct inode *dir, - struct dentry *dentry, - void *data1, - void *data2) +int smfs_post_rec_create(struct inode *dir, struct dentry *dentry, + void *data1, void *data2) { struct smfs_super_info *sinfo; char *buffer = NULL, *pbuf; diff --git a/lustre/smfs/kml.c b/lustre/smfs/kml.c index 78e8f56143..dd7b28de46 100644 --- a/lustre/smfs/kml.c +++ b/lustre/smfs/kml.c @@ -241,6 +241,12 @@ int smfs_rec_md(struct inode *inode, void * lmm, int lmm_size) } EXPORT_SYMBOL(smfs_rec_md); +int smfs_rec_precreate(struct dentry *dentry, int *num, struct obdo *oa) +{ + return smfs_post_rec_create(dentry->d_inode, dentry, num, oa); +} +EXPORT_SYMBOL(smfs_rec_precreate); + int smfs_process_rec(struct super_block *sb, int count, char *dir, int flags) { diff --git a/lustre/smfs/ost_kml.c b/lustre/smfs/ost_kml.c index 01d9ccd14c..3e8d81705f 100644 --- a/lustre/smfs/ost_kml.c +++ b/lustre/smfs/ost_kml.c @@ -80,27 +80,35 @@ static int ost_rec_create_pack(char *buffer, struct dentry *dentry, { struct obdo *oa = NULL; int rc = 0; - + PACK_KML_REC_INIT(buffer, OST_CREATE); oa = (struct obdo*)buffer; - oa->o_uid = 0; /* must have 0 uid / gid on OST */ - oa->o_gid = 0; - oa->o_valid = OBD_MD_FLID | OBD_MD_FLGENER | OBD_MD_FLTYPE | - OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID; - oa->o_size = 0; - obdo_from_inode(oa, dentry->d_inode, OBD_MD_FLTYPE|OBD_MD_FLATIME| - OBD_MD_FLMTIME| OBD_MD_FLCTIME); - rc = smfs_ost_get_id(&oa->o_id, (char*)dentry->d_name.name, - dentry->d_name.len); - if (rc) { - CERROR("Can not find id of node %lu\n", dentry->d_inode->i_ino); - GOTO(out, rc = -ENOMEM); - } - - rc = smfs_ost_get_group(dentry, oa); - if (rc) { - CERROR("Can not find group node %lu\n", dentry->d_inode->i_ino); - GOTO(out, rc = -ENOMEM); + if (data1 && data2) { + struct obdo *create_oa = (struct obdo *)data2; + int num = *((int *)data1); + + memcpy(oa, create_oa, sizeof(*oa)); + memcpy(oa->o_inline, &num, sizeof(int)); + oa->o_valid |= OBD_MD_REINT; + } else { + oa->o_uid = 0; /* must have 0 uid / gid on OST */ + oa->o_gid = 0; + oa->o_valid = OBD_MD_FLID | OBD_MD_FLGENER | OBD_MD_FLTYPE | + OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID; + oa->o_size = 0; + obdo_from_inode(oa, dentry->d_inode, OBD_MD_FLTYPE|OBD_MD_FLATIME| + OBD_MD_FLMTIME| OBD_MD_FLCTIME); + rc = smfs_ost_get_id(&oa->o_id, (char*)dentry->d_name.name, + dentry->d_name.len); + if (rc) { + CERROR("Can not find id of node %lu\n", dentry->d_inode->i_ino); + GOTO(out, rc = -ENOMEM); + } + rc = smfs_ost_get_group(dentry, oa); + if (rc) { + CERROR("Can not find group node %lu\n", dentry->d_inode->i_ino); + GOTO(out, rc = -ENOMEM); + } } rc = sizeof(*oa) + sizeof(int); out: @@ -133,11 +141,12 @@ static int ost_rec_setattr_pack(char *buffer, struct dentry *dentry, out: RETURN(rc); } + static int ost_rec_write_pack(char *buffer, struct dentry *dentry, struct inode *dir, void *data1, void *data2) { struct obdo *oa = NULL; - int rc = 0; + int rc = 0; PACK_KML_REC_INIT(buffer, OST_WRITE); oa = (struct obdo*)buffer; diff --git a/lustre/smfs/smfs_internal.h b/lustre/smfs/smfs_internal.h index 32e84ee796..7da1b7e74f 100644 --- a/lustre/smfs/smfs_internal.h +++ b/lustre/smfs/smfs_internal.h @@ -171,6 +171,8 @@ extern int smfs_post_rec_write(struct inode *dir, struct dentry *dentry, void *data1, void *data2); extern int smfs_post_rec_setattr(struct inode *dir, struct dentry *dentry, void *data1, void *data2); +extern int smfs_post_rec_create(struct inode *dir, struct dentry *dentry, + void *data1, void *data2); /*kml.c*/ extern int smfs_kml_init(struct super_block *sb); extern int smfs_do_rec(struct inode *inode); -- GitLab