From bb9fda315609f26a514ec2c63820adbfaafa1ba2 Mon Sep 17 00:00:00 2001 From: tappro Date: Fri, 12 May 2006 09:24:54 +0000 Subject: [PATCH] alloc new fid using range of sequences --- lustre/fid/fid_seq.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lustre/fid/fid_seq.c b/lustre/fid/fid_seq.c index 4e319f5..6e1e59f 100644 --- a/lustre/fid/fid_seq.c +++ b/lustre/fid/fid_seq.c @@ -71,8 +71,9 @@ int seq_mgr_read(struct lu_context *ctx, struct lu_seq_mgr *mgr) } EXPORT_SYMBOL(seq_mgr_read); -/* manager functinality stuff */ -int seq_mgr_alloc(struct lu_context *ctx, struct lu_seq_mgr *mgr, __u64 *seq) +/* manager functionality stuff */ +int seq_mgr_alloc(struct lu_context *ctx, struct lu_seq_mgr *mgr, + __u64 *seq) { int rc = 0; ENTRY; @@ -81,11 +82,15 @@ int seq_mgr_alloc(struct lu_context *ctx, struct lu_seq_mgr *mgr, __u64 *seq) LASSERT(seq != NULL); down(&mgr->m_seq_sem); - mgr->m_seq += 1; - *seq = mgr->m_seq; - - rc = seq_mgr_write(ctx, mgr); + if (mgr->m_seq > mgr->m_seq_last) { + /* new range of seqs should be got from master */ + rc = -EOPNOTSUPP; + } else { + *seq = mgr->m_seq; + mgr->m_seq++; + rc = seq_mgr_write(ctx, mgr); + } up(&mgr->m_seq_sem); RETURN(rc); } @@ -99,8 +104,10 @@ int seq_mgr_setup(struct lu_context *ctx, struct lu_seq_mgr *mgr) int rc = 0; ENTRY; + /* set seq range */ + mgr->m_seq_last = mgr->m_seq + LUSTRE_SEQ_RANGE; /* allocate next seq after root one */ - mgr->m_seq = LUSTRE_ROOT_FID_SEQ + 1; + mgr->m_seq += LUSTRE_ROOT_FID_SEQ + 1; rc = seq_mgr_read(ctx, mgr); if (rc == -ENODATA) { @@ -132,4 +139,4 @@ MODULE_AUTHOR("Cluster File Systems, Inc. "); MODULE_DESCRIPTION("Lustre FID Module"); MODULE_LICENSE("GPL"); -cfs_module(fid, "0.0.1", fid_mod_init, fid_mod_exit); +cfs_module(fid, "0.0.2", fid_mod_init, fid_mod_exit); -- 1.8.3.1