From: yury Date: Sat, 29 Jul 2006 08:56:16 +0000 (+0000) Subject: - using dt_body_ops in server sequence manager to store seq mgr state and read it... X-Git-Tag: v1_8_0_110~486^2~1319 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=6442718a67aa4279149f6917c47ca2b6cf5e407f;p=fs%2Flustre-release.git - using dt_body_ops in server sequence manager to store seq mgr state and read it from store in startup time. --- diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index 8482cb3..d96d89e 100644 --- a/lustre/fid/fid_handler.c +++ b/lustre/fid/fid_handler.c @@ -537,8 +537,6 @@ seq_server_fini(struct lu_server_seq *seq, seq->seq_dev = NULL; } - CDEBUG(D_INFO|D_WARNING, "Server Sequence " - "Manager\n"); EXIT; } EXPORT_SYMBOL(seq_server_fini); diff --git a/lustre/fid/fid_store.c b/lustre/fid/fid_store.c index ad40838..c2bfb82 100644 --- a/lustre/fid/fid_store.c +++ b/lustre/fid/fid_store.c @@ -48,22 +48,78 @@ #include "fid_internal.h" #ifdef __KERNEL__ +struct seq_store_capsule { + struct lu_range ssc_space; + struct lu_range ssc_super; +}; + +enum { + SEQ_TXN_STORE_CREDITS = 20 +}; + +/* this function implies that caller takes about locking */ int seq_store_write(struct lu_server_seq *seq, const struct lu_context *ctx) { - int rc = 0; + struct dt_object *dt_obj = seq->seq_obj; + struct dt_device *dt_dev = seq->seq_dev; + struct seq_store_capsule capsule; + loff_t pos = 0; + struct txn_param txn; + struct thandle *th; + int rc; ENTRY; + /* stub here, will fix it later */ + txn.tp_credits = SEQ_TXN_STORE_CREDITS; + + th = dt_dev->dd_ops->dt_trans_start(ctx, dt_dev, &txn); + if (!IS_ERR(th)) { + rc = dt_obj->do_body_ops->dbo_write(ctx, dt_obj, + (char *)&capsule, + sizeof(capsule), + &pos, th); + if (rc == sizeof(capsule)) { + rc = 0; + } else if (rc >= 0) { + rc = -EIO; + } + + dt_dev->dd_ops->dt_trans_stop(ctx, th); + } else { + rc = PTR_ERR(th); + } + RETURN(rc); } +/* this function implies that caller takes care about locking or locking is not + * needed (init time). */ int seq_store_read(struct lu_server_seq *seq, const struct lu_context *ctx) { - int rc = -ENODATA; + struct dt_object *dt_obj = seq->seq_obj; + struct seq_store_capsule capsule; + loff_t pos = 0; + int rc; ENTRY; + + rc = dt_obj->do_body_ops->dbo_read(ctx, dt_obj, + (char *)&capsule, + sizeof(capsule), &pos); + if (rc == sizeof(capsule)) { + seq->seq_space = capsule.ssc_space; + seq->seq_super = capsule.ssc_super; + rc = 0; + } else if (rc == 0) { + rc = -ENODATA; + } else if (rc >= 0) { + CERROR("read only %d bytes of %d\n", + rc, sizeof(capsule)); + rc = -EIO; + } RETURN(rc); } diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index 106a867..e4b3d70 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -367,7 +367,6 @@ fld_server_fini(struct lu_server_fld *fld, fld_index_fini(fld, ctx); fld->fld_dt = NULL; } - CDEBUG(D_INFO|D_WARNING, "Server FLD\n"); EXIT; } EXPORT_SYMBOL(fld_server_fini); diff --git a/lustre/fld/fld_index.c b/lustre/fld/fld_index.c index de2023e..4378781 100644 --- a/lustre/fld/fld_index.c +++ b/lustre/fld/fld_index.c @@ -66,7 +66,7 @@ static const struct dt_index_features fld_index_features = { */ enum { FLD_TXN_INDEX_INSERT_CREDITS = 20, - FLD_TXN_INDEX_DELETE_CREDITS = 20 + FLD_TXN_INDEX_DELETE_CREDITS = 20, }; struct fld_thread_info { @@ -140,7 +140,7 @@ int fld_index_create(struct lu_server_fld *fld, int rc; ENTRY; - /*stub here, will fix it later*/ + /* stub here, will fix it later */ txn.tp_credits = FLD_TXN_INDEX_INSERT_CREDITS; th = dt->dd_ops->dt_trans_start(ctx, dt, &txn);