From: yury Date: Tue, 1 Aug 2006 14:55:39 +0000 (+0000) Subject: - fixes in seq and fld after Mike's CODEINSP. X-Git-Tag: v1_8_0_110~486^2~1303 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=2d2b8b65ec47e4fb43b24d89338f5fd26e3525ae;p=fs%2Flustre-release.git - fixes in seq and fld after Mike's CODEINSP. --- diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index d96d89e..fd38b8e 100644 --- a/lustre/fid/fid_handler.c +++ b/lustre/fid/fid_handler.c @@ -84,6 +84,8 @@ seq_server_init_ctlr(struct lu_server_seq *seq, "sequence controller client %s\n", cli->seq_exp->exp_client_uuid.uuid); + /* asking client for new range, assign that range to ->seq_super and + * write seq state to backing store should be atomic. */ down(&seq->seq_sem); /* assign controller */ @@ -96,7 +98,7 @@ seq_server_init_ctlr(struct lu_server_seq *seq, if (rc) { CERROR("can't allocate super-sequence, " "rc %d\n", rc); - RETURN(rc); + GOTO(out_up, rc); } /* take super-seq from client seq mgr */ @@ -111,8 +113,11 @@ seq_server_init_ctlr(struct lu_server_seq *seq, "rc = %d\n", rc); } } + + EXIT; +out_up: up(&seq->seq_sem); - RETURN(rc); + return rc; } EXPORT_SYMBOL(seq_server_init_ctlr); @@ -129,7 +134,7 @@ seq_server_fini_ctlr(struct lu_server_seq *seq) } EXPORT_SYMBOL(seq_server_fini_ctlr); -/* on controller node, allocate new super sequence for regular sequnece +/* on controller node, allocate new super sequence for regular sequence * server. */ static int __seq_server_alloc_super(struct lu_server_seq *seq, @@ -157,10 +162,12 @@ __seq_server_alloc_super(struct lu_server_seq *seq, rc = 0; } - rc = seq_store_write(seq, ctx); - if (rc) { - CERROR("can't save state, rc = %d\n", - rc); + if (rc == 0) { + rc = seq_store_write(seq, ctx); + if (rc) { + CERROR("can't save state, rc = %d\n", + rc); + } } if (rc == 0) { @@ -248,35 +255,10 @@ seq_server_alloc_meta(struct lu_server_seq *seq, } static int -seq_server_handle(struct lu_server_seq *seq, - const struct lu_context *ctx, - struct lu_range *range, - __u32 opc) -{ - int rc; - ENTRY; - - switch (opc) { - case SEQ_ALLOC_SUPER: - rc = seq_server_alloc_super(seq, range, ctx); - break; - case SEQ_ALLOC_META: - rc = seq_server_alloc_meta(seq, range, ctx); - break; - default: - CERROR("wrong opc 0x%x\n", opc); - rc = -EINVAL; - break; - } - RETURN(rc); -} - -static int seq_req_handle0(const struct lu_context *ctx, struct ptlrpc_request *req) { int rep_buf_size[2] = { 0, }; - struct obd_device *obd; struct req_capsule pill; struct lu_site *site; struct lu_range *out; @@ -284,8 +266,7 @@ seq_req_handle0(const struct lu_context *ctx, __u32 *opc; ENTRY; - obd = req->rq_export->exp_obd; - site = obd->obd_lu_dev->ld_site; + site = req->rq_export->exp_obd->obd_lu_dev->ld_site; LASSERT(site != NULL); req_capsule_init(&pill, req, RCL_SERVER, @@ -302,20 +283,24 @@ seq_req_handle0(const struct lu_context *ctx, GOTO(out_pill, rc= -EPROTO); } - if (*opc == SEQ_ALLOC_META) { + switch (*opc) { + case SEQ_ALLOC_META: if (!site->ls_server_seq) { CERROR("sequence-server is not initialized\n"); GOTO(out_pill, rc == -EINVAL); } - rc = seq_server_handle(site->ls_server_seq, - ctx, out, *opc); - } else { + rc = seq_server_alloc_meta(site->ls_server_seq, out, ctx); + break; + case SEQ_ALLOC_SUPER: if (!site->ls_ctlr_seq) { CERROR("sequence-controller is not initialized\n"); GOTO(out_pill, rc == -EINVAL); } - rc = seq_server_handle(site->ls_ctlr_seq, - ctx, out, *opc); + rc = seq_server_alloc_super(site->ls_ctlr_seq, out, ctx); + break; + default: + CERROR("wrong opc 0x%x\n", *opc); + break; } } else { CERROR("cannot unpack client request\n"); @@ -346,7 +331,6 @@ seq_req_handle(struct ptlrpc_request *req) } else { CERROR("Unconnected request\n"); req->rq_status = -ENOTCONN; - GOTO(out, rc = -ENOTCONN); } } else { CERROR("Wrong opcode: %d\n", @@ -356,10 +340,8 @@ seq_req_handle(struct ptlrpc_request *req) RETURN(rc); } - EXIT; -out: target_send_reply(req, rc, fail); - return 0; + RETURN(0); } #ifdef LPROCFS @@ -392,11 +374,13 @@ seq_server_proc_init(struct lu_server_seq *seq) if (rc) { CERROR("can't init sequence manager " "proc, rc %d\n", rc); - GOTO(err_type, rc); + GOTO(err_entry, rc); } RETURN(0); +err_entry: + lprocfs_remove(seq->seq_proc_entry); err_type: lprocfs_remove(seq->seq_proc_dir); err: @@ -574,5 +558,5 @@ MODULE_AUTHOR("Cluster File Systems, Inc. "); MODULE_DESCRIPTION("Lustre FID Module"); MODULE_LICENSE("GPL"); -cfs_module(fid, "0.0.4", fid_mod_init, fid_mod_exit); +cfs_module(fid, "0.1.0", fid_mod_init, fid_mod_exit); #endif diff --git a/lustre/fid/fid_request.c b/lustre/fid/fid_request.c index 4706f93..050a1f2 100644 --- a/lustre/fid/fid_request.c +++ b/lustre/fid/fid_request.c @@ -47,7 +47,7 @@ #include #include "fid_internal.h" -/* client seq mgr interface */ +/* XXX: this should use new req-layout interface */ static int seq_client_rpc(struct lu_client_seq *seq, struct lu_range *range, @@ -180,12 +180,10 @@ __seq_client_alloc_seq(struct lu_client_seq *seq, seqno_t *seqnr) } *seqnr = seq->seq_range.lr_start; - seq->seq_range.lr_start += 1; + seq->seq_range.lr_start++; - if (rc == 0) { - CDEBUG(D_INFO, "SEQ-MGR(cli): allocated " - "sequence ["LPX64"]\n", *seqnr); - } + CDEBUG(D_INFO, "SEQ-MGR(cli): allocated " + "sequence ["LPX64"]\n", *seqnr); RETURN(rc); } @@ -235,7 +233,7 @@ seq_client_alloc_fid(struct lu_client_seq *seq, struct lu_fid *fid) * to setup FLD for it. */ rc = -ERESTART; } else { - seq->seq_fid.f_oid += 1; + seq->seq_fid.f_oid++; rc = 0; } @@ -274,11 +272,13 @@ seq_client_proc_init(struct lu_client_seq *seq) if (rc) { CERROR("can't init sequence manager " "proc, rc %d\n", rc); - GOTO(err, rc); + GOTO(err_dir, rc); } RETURN(0); +err_dir: + lprocfs_remove(seq->seq_proc_dir); err: seq->seq_proc_dir = NULL; return rc; diff --git a/lustre/fid/fid_store.c b/lustre/fid/fid_store.c index c2bfb82..6668a01 100644 --- a/lustre/fid/fid_store.c +++ b/lustre/fid/fid_store.c @@ -57,7 +57,7 @@ enum { SEQ_TXN_STORE_CREDITS = 20 }; -/* this function implies that caller takes about locking */ +/* this function implies that caller takes care about locking */ int seq_store_write(struct lu_server_seq *seq, const struct lu_context *ctx) diff --git a/lustre/fld/fld_cache.c b/lustre/fld/fld_cache.c index da1b56b..6bb2732 100644 --- a/lustre/fld/fld_cache.c +++ b/lustre/fld/fld_cache.c @@ -60,6 +60,9 @@ fld_cache_init(int size) int i; ENTRY; + /* check if size is power of two */ + LASSERT((size & -size) == size); + OBD_ALLOC_PTR(cache); if (cache == NULL) RETURN(ERR_PTR(-ENOMEM)); diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index e4b3d70..5454b43 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -261,11 +261,13 @@ fld_server_proc_init(struct lu_server_fld *fld) fld_server_proc_list, fld); if (rc) { CERROR("can't init FLD proc, rc %d\n", rc); - GOTO(err_type, rc); + GOTO(err_entry, rc); } RETURN(0); +err_entry: + lprocfs_remove(fld->fld_proc_entry); err_type: lprocfs_remove(fld->fld_proc_dir); err: @@ -375,5 +377,5 @@ MODULE_AUTHOR("Cluster File Systems, Inc. "); MODULE_DESCRIPTION("Lustre FLD"); MODULE_LICENSE("GPL"); -cfs_module(mdd, "0.0.4", fld_mod_init, fld_mod_exit); +cfs_module(mdd, "0.1.0", fld_mod_init, fld_mod_exit); #endif diff --git a/lustre/fld/fld_internal.h b/lustre/fld/fld_internal.h index 37dd080..9e5f2f2 100644 --- a/lustre/fld/fld_internal.h +++ b/lustre/fld/fld_internal.h @@ -4,6 +4,8 @@ * fld/fld_internal.h * * Copyright (C) 2006 Cluster File Systems, Inc. + * Author: Yury Umanets + * Tom WangDi * * This file is part of the Lustre file system, http://www.lustre.org * Lustre is a trademark of Cluster File Systems, Inc. diff --git a/lustre/fld/fld_request.c b/lustre/fld/fld_request.c index a6e0d75..e2fc9f2 100644 --- a/lustre/fld/fld_request.c +++ b/lustre/fld/fld_request.c @@ -1,7 +1,7 @@ /* -*- MODE: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * lustre/fld/fld_handler.c + * lustre/fld/fld_request.c * FLD (Fids Location Database) * * Copyright (C) 2006 Cluster File Systems, Inc. @@ -211,11 +211,13 @@ fld_client_proc_init(struct lu_client_fld *fld) if (rc) { CERROR("can't init FLD " "proc, rc %d\n", rc); - GOTO(err, rc); + GOTO(err_dir, rc); } RETURN(0); +err_dir: + lprocfs_remove(fld->fld_proc_dir); err: fld->fld_proc_dir = NULL; return rc; @@ -320,6 +322,7 @@ fld_client_fini(struct lu_client_fld *fld) } EXPORT_SYMBOL(fld_client_fini); +/* XXX: this should use new req-layout interface. */ static int fld_client_rpc(struct obd_export *exp, struct md_fld *mf, __u32 fld_op) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 5492160..3ef8e82 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -146,7 +146,7 @@ static inline void range_zero(struct lu_range *r) static inline int range_within(struct lu_range *r, __u64 s) { - return s >= r->lr_start && s <= r->lr_end; + return s >= r->lr_start && s < r->lr_end; } static inline void range_alloc(struct lu_range *r, @@ -160,9 +160,7 @@ static inline void range_alloc(struct lu_range *r, static inline int range_is_sane(struct lu_range *r) { - if (r->lr_end >= r->lr_start) - return 1; - return 0; + return (r->lr_end >= r->lr_start); } static inline int range_is_zero(struct lu_range *r)