Whamcloud - gitweb
LU-12635 build: Support for gcc -Wimplicit-fallthrough
[fs/lustre-release.git] / lustre / fid / fid_handler.c
index 9f378a5..34d0157 100644 (file)
  *
  * 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
- *
- * 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.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2015, Intel Corporation.
+ * Copyright (c) 2011, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -52,8 +48,6 @@
 #include <lustre_fid.h>
 #include "fid_internal.h"
 
-static void seq_server_proc_fini(struct lu_server_seq *seq);
-
 /* Assigns client to sequence controller node. */
 int seq_server_set_cli(const struct lu_env *env, struct lu_server_seq *seq,
                       struct lu_client_seq *cli)
@@ -329,8 +323,17 @@ static int __seq_server_alloc_meta(struct lu_server_seq *seq,
 
        rc = seq_server_check_and_alloc_super(env, seq);
        if (rc < 0) {
-               CERROR("%s: Allocated super-sequence failed: rc = %d\n",
-                       seq->lss_name, rc);
+               if (rc == -EINPROGRESS) {
+                       static int printed;
+
+                       if (printed++ % 8 == 0)
+                               LCONSOLE_INFO("%s: Waiting to contact MDT0000 "
+                                             "to allocate super-sequence\n",
+                                             seq->lss_name);
+               } else {
+                       CERROR("%s: Allocated super-sequence failed: rc = %d\n",
+                              seq->lss_name, rc);
+               }
                RETURN(rc);
        }
 
@@ -368,6 +371,7 @@ static int seq_server_handle(struct lu_site *site,
 {
        int rc;
        struct seq_server_site *ss_site;
+       struct dt_device *dev;
        ENTRY;
 
        ss_site = lu_site2seq(site);
@@ -379,6 +383,11 @@ static int seq_server_handle(struct lu_site *site,
                               "initialized\n");
                        RETURN(-EINVAL);
                }
+
+               dev = lu2dt_dev(ss_site->ss_server_seq->lss_obj->do_lu.lo_dev);
+               if (dev->dd_rdonly)
+                       RETURN(-EROFS);
+
                rc = seq_server_alloc_meta(ss_site->ss_server_seq, out, env);
                break;
        case SEQ_ALLOC_SUPER:
@@ -387,6 +396,11 @@ static int seq_server_handle(struct lu_site *site,
                               "initialized\n");
                        RETURN(-EINVAL);
                }
+
+               dev = lu2dt_dev(ss_site->ss_control_seq->lss_obj->do_lu.lo_dev);
+               if (dev->dd_rdonly)
+                       RETURN(-EROFS);
+
                rc = seq_server_alloc_super(ss_site->ss_control_seq, out, env);
                break;
        default:
@@ -432,7 +446,7 @@ static int seq_handler(struct tgt_session_info *tsi)
 }
 
 struct tgt_handler seq_handlers[] = {
-TGT_SEQ_HDL(HABEO_REFERO,      SEQ_QUERY,      seq_handler),
+TGT_SEQ_HDL(HAS_REPLY, SEQ_QUERY,      seq_handler),
 };
 EXPORT_SYMBOL(seq_handlers);
 
@@ -442,35 +456,43 @@ LU_KEY_INIT_FINI(seq, struct seq_thread_info);
 /* context key: seq_thread_key */
 LU_CONTEXT_KEY_DEFINE(seq, LCT_MD_THREAD | LCT_DT_THREAD);
 
-extern const struct file_operations seq_fld_proc_seq_fops;
+extern const struct file_operations seq_fld_debugfs_seq_fops;
 
-static int seq_server_proc_init(struct lu_server_seq *seq)
+static void seq_server_debugfs_fini(struct lu_server_seq *seq)
+{
+       if (!IS_ERR_OR_NULL(seq->lss_debugfs_entry))
+               ldebugfs_remove(&seq->lss_debugfs_entry);
+}
+
+static int seq_server_debugfs_init(struct lu_server_seq *seq)
 {
-#ifdef CONFIG_PROC_FS
        int rc;
        ENTRY;
 
-       seq->lss_proc_dir = lprocfs_register(seq->lss_name,
-                                            seq_type_proc_dir,
-                                            NULL, NULL);
-       if (IS_ERR(seq->lss_proc_dir)) {
-               rc = PTR_ERR(seq->lss_proc_dir);
+       seq->lss_debugfs_entry = ldebugfs_register(seq->lss_name,
+                                                  seq_debugfs_dir,
+                                                  NULL, NULL);
+       if (IS_ERR_OR_NULL(seq->lss_debugfs_entry)) {
+               rc = seq->lss_debugfs_entry ? PTR_ERR(seq->lss_debugfs_entry)
+                                           : -ENOMEM;
+               seq->lss_debugfs_entry = NULL;
                RETURN(rc);
        }
 
-       rc = lprocfs_add_vars(seq->lss_proc_dir, seq_server_proc_list, seq);
+       rc = ldebugfs_add_vars(seq->lss_debugfs_entry,
+                              seq_server_debugfs_list, seq);
        if (rc) {
-               CERROR("%s: Can't init sequence manager "
-                      "proc, rc %d\n", seq->lss_name, rc);
+               CERROR("%s: Can't init sequence manager debugfs, rc %d\n",
+                      seq->lss_name, rc);
                GOTO(out_cleanup, rc);
        }
 
        if (seq->lss_type == LUSTRE_SEQ_CONTROLLER) {
-               rc = lprocfs_seq_create(seq->lss_proc_dir, "fldb", 0644,
-                                       &seq_fld_proc_seq_fops, seq);
+               rc = ldebugfs_seq_create(seq->lss_debugfs_entry, "fldb", 0644,
+                                        &seq_fld_debugfs_seq_fops, seq);
                if (rc) {
-                       CERROR("%s: Can't create fldb for sequence manager "
-                              "proc: rc = %d\n", seq->lss_name, rc);
+                       CERROR("%s: Can't create fldb for sequence manager debugfs: rc = %d\n",
+                              seq->lss_name, rc);
                        GOTO(out_cleanup, rc);
                }
        }
@@ -478,24 +500,8 @@ static int seq_server_proc_init(struct lu_server_seq *seq)
        RETURN(0);
 
 out_cleanup:
-       seq_server_proc_fini(seq);
+       seq_server_debugfs_fini(seq);
        return rc;
-#else /* !CONFIG_PROC_FS */
-       return 0;
-#endif /* CONFIG_PROC_FS */
-}
-
-static void seq_server_proc_fini(struct lu_server_seq *seq)
-{
-#ifdef CONFIG_PROC_FS
-        ENTRY;
-        if (seq->lss_proc_dir != NULL) {
-                if (!IS_ERR(seq->lss_proc_dir))
-                        lprocfs_remove(&seq->lss_proc_dir);
-                seq->lss_proc_dir = NULL;
-        }
-        EXIT;
-#endif /* CONFIG_PROC_FS */
 }
 
 int seq_server_init(const struct lu_env *env,
@@ -576,7 +582,7 @@ int seq_server_init(const struct lu_env *env,
                        lu_seq_range_is_sane(&seq->lss_space));
        }
 
-        rc  = seq_server_proc_init(seq);
+       rc  = seq_server_debugfs_init(seq);
         if (rc)
                 GOTO(out, rc);
 
@@ -593,7 +599,7 @@ void seq_server_fini(struct lu_server_seq *seq,
 {
         ENTRY;
 
-        seq_server_proc_fini(seq);
+       seq_server_debugfs_fini(seq);
         seq_store_fini(seq, env);
 
         EXIT;