Whamcloud - gitweb
b=16461
[fs/lustre-release.git] / lustre / fid / fid_handler.c
index 45e1ebb..774aacc 100644 (file)
@@ -1,29 +1,43 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  lustre/fid/fid_handler.c
- *  Lustre Sequence Manager
+ * GPL HEADER START
  *
- *  Copyright (c) 2006 Cluster File Systems, Inc.
- *   Author: Yury Umanets <umka@clusterfs.com>
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   This file is part of the Lustre file system, http://www.lustre.org
- *   Lustre is a trademark of Cluster File Systems, Inc.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
  *
- *   You may have signed or agreed to another license before downloading
- *   this software.  If so, you are bound by the terms and conditions
- *   of that agreement, and the following does not apply to you.  See the
- *   LICENSE file included with this distribution for more information.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
  *
- *   If you did not agree to a different license, then this copy of Lustre
- *   is open source software; you can redistribute it and/or modify it
- *   under the terms of version 2 of the GNU General Public License as
- *   published by the Free Software Foundation.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
- *   In either case, Lustre is distributed in the hope that it will be
- *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   license text for more details.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/fid/fid_handler.c
+ *
+ * Lustre Sequence Manager
+ *
+ * Author: Yury Umanets <umka@clusterfs.com>
  */
 
 #ifndef EXPORT_SYMTAB
@@ -288,25 +302,27 @@ static int seq_server_handle(struct lu_site *site,
                              struct lu_range *out)
 {
         int rc;
+        struct md_site *mite;
         ENTRY;
 
+        mite = lu_site2md(site);
         switch (opc) {
         case SEQ_ALLOC_META:
-                if (!site->ls_server_seq) {
+                if (!mite->ms_server_seq) {
                         CERROR("Sequence server is not "
                                "initialized\n");
                         RETURN(-EINVAL);
                 }
-                rc = seq_server_alloc_meta(site->ls_server_seq,
+                rc = seq_server_alloc_meta(mite->ms_server_seq,
                                            in, out, env);
                 break;
         case SEQ_ALLOC_SUPER:
-                if (!site->ls_control_seq) {
+                if (!mite->ms_control_seq) {
                         CERROR("Sequence controller is not "
                                "initialized\n");
                         RETURN(-EINVAL);
                 }
-                rc = seq_server_alloc_super(site->ls_control_seq,
+                rc = seq_server_alloc_super(mite->ms_control_seq,
                                             in, out, env);
                 break;
         default:
@@ -330,20 +346,18 @@ static int seq_req_handle(struct ptlrpc_request *req,
         site = req->rq_export->exp_obd->obd_lu_dev->ld_site;
         LASSERT(site != NULL);
                        
-        rc = req_capsule_pack(&info->sti_pill);
+        rc = req_capsule_server_pack(info->sti_pill);
         if (rc)
                 RETURN(err_serious(rc));
 
-        opc = req_capsule_client_get(&info->sti_pill,
-                                     &RMF_SEQ_OPC);
+        opc = req_capsule_client_get(info->sti_pill, &RMF_SEQ_OPC);
         if (opc != NULL) {
-                out = req_capsule_server_get(&info->sti_pill,
-                                             &RMF_SEQ_RANGE);
+                out = req_capsule_server_get(info->sti_pill, &RMF_SEQ_RANGE);
                 if (out == NULL)
                         RETURN(err_serious(-EPROTO));
 
                 if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
-                        in = req_capsule_client_get(&info->sti_pill,
+                        in = req_capsule_client_get(info->sti_pill,
                                                     &RMF_SEQ_RANGE);
 
                         LASSERT(!range_is_zero(in) && range_is_sane(in));
@@ -356,33 +370,24 @@ static int seq_req_handle(struct ptlrpc_request *req,
         RETURN(rc);
 }
 
+/* context key constructor/destructor: seq_key_init, seq_key_fini */
 LU_KEY_INIT_FINI(seq, struct seq_thread_info);
 
-struct lu_context_key seq_thread_key = {
-        .lct_tags = LCT_MD_THREAD,
-        .lct_init = seq_key_init,
-        .lct_fini = seq_key_fini
-};
+/* context key: seq_thread_key */
+LU_CONTEXT_KEY_DEFINE(seq, LCT_MD_THREAD);
 
 static void seq_thread_info_init(struct ptlrpc_request *req,
                                  struct seq_thread_info *info)
 {
-        int i;
-
-        /* Mark rep buffer as req-layout stuff expects */
-        for (i = 0; i < ARRAY_SIZE(info->sti_rep_buf_size); i++)
-                info->sti_rep_buf_size[i] = -1;
-
+        info->sti_pill = &req->rq_pill;
         /* Init request capsule */
-        req_capsule_init(&info->sti_pill, req, RCL_SERVER,
-                         info->sti_rep_buf_size);
-
-        req_capsule_set(&info->sti_pill, &RQF_SEQ_QUERY);
+        req_capsule_init(info->sti_pill, req, RCL_SERVER);
+        req_capsule_set(info->sti_pill, &RQF_SEQ_QUERY);
 }
 
 static void seq_thread_info_fini(struct seq_thread_info *info)
 {
-        req_capsule_fini(&info->sti_pill);
+        req_capsule_fini(info->sti_pill);
 }
 
 static int seq_handle(struct ptlrpc_request *req)
@@ -409,7 +414,7 @@ static int seq_handle(struct ptlrpc_request *req)
  */
 int seq_query(struct com_thread_info *info)
 {
-        return seq_handle(info->cti_pill.rc_req);
+        return seq_handle(info->cti_pill->rc_req);
 }
 EXPORT_SYMBOL(seq_query);
 
@@ -480,7 +485,7 @@ int seq_server_init(struct lu_server_seq *seq,
 
         seq->lss_cli = NULL;
         seq->lss_type = type;
-        range_zero(&seq->lss_space);
+        range_init(&seq->lss_space);
         sema_init(&seq->lss_sem, 1);
 
         seq->lss_width = is_srv ?
@@ -573,7 +578,7 @@ static void __exit fid_mod_exit(void)
         }
 }
 
-MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
+MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre FID Module");
 MODULE_LICENSE("GPL");