Whamcloud - gitweb
LU-2850 kernel: 3.8 upstream kills daemonize()
[fs/lustre-release.git] / lustre / fid / lproc_fid.c
index 27fd1f0..67cf63c 100644 (file)
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, Whamcloud, Inc.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  *
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
- *
  * lustre/fid/lproc_fid.c
  *
  * Lustre Sequence Manager
 
 #define DEBUG_SUBSYSTEM S_FID
 
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-# include <linux/module.h>
-#else /* __KERNEL__ */
-# include <liblustre.h>
-#endif
-
+#include <libcfs/libcfs.h>
+#include <linux/module.h>
 #include <obd.h>
 #include <obd_class.h>
-#include <dt_object.h>
-#include <md_object.h>
 #include <obd_support.h>
-#include <lustre_req_layout.h>
 #include <lustre_fid.h>
+#include <lprocfs_status.h>
 #include "fid_internal.h"
 
 #ifdef LPROCFS
@@ -99,6 +90,7 @@ seq_proc_read_common(char *page, char **start, off_t off,
        RETURN(rc);
 }
 
+#ifdef HAVE_SERVER_SUPPORT
 /*
  * Server side procfs stuff.
  */
@@ -112,7 +104,7 @@ seq_server_proc_write_space(struct file *file, const char *buffer,
 
         LASSERT(seq != NULL);
 
-        cfs_mutex_lock(&seq->lss_mutex);
+       mutex_lock(&seq->lss_mutex);
        rc = seq_proc_write_common(file, buffer, count,
                                    data, &seq->lss_space);
        if (rc == 0) {
@@ -120,7 +112,7 @@ seq_server_proc_write_space(struct file *file, const char *buffer,
                        seq->lss_name, PRANGE(&seq->lss_space));
        }
 
-        cfs_mutex_unlock(&seq->lss_mutex);
+       mutex_unlock(&seq->lss_mutex);
 
         RETURN(count);
 }
@@ -135,10 +127,10 @@ seq_server_proc_read_space(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_mutex_lock(&seq->lss_mutex);
+       mutex_lock(&seq->lss_mutex);
        rc = seq_proc_read_common(page, start, off, count, eof,
                                   data, &seq->lss_space);
-        cfs_mutex_unlock(&seq->lss_mutex);
+       mutex_unlock(&seq->lss_mutex);
 
        RETURN(rc);
 }
@@ -181,7 +173,7 @@ seq_server_proc_write_width(struct file *file, const char *buffer,
 
         LASSERT(seq != NULL);
 
-       cfs_mutex_lock(&seq->lss_mutex);
+       mutex_lock(&seq->lss_mutex);
 
        rc = lprocfs_write_helper(buffer, count, &val);
        if (rc != 0) {
@@ -194,7 +186,7 @@ seq_server_proc_write_width(struct file *file, const char *buffer,
        CDEBUG(D_INFO, "%s: Width: "LPU64"\n",
               seq->lss_name, seq->lss_width);
 out_unlock:
-       cfs_mutex_unlock(&seq->lss_mutex);
+       mutex_unlock(&seq->lss_mutex);
 
         RETURN(count);
 }
@@ -209,13 +201,24 @@ seq_server_proc_read_width(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_mutex_lock(&seq->lss_mutex);
+       mutex_lock(&seq->lss_mutex);
         rc = snprintf(page, count, LPU64"\n", seq->lss_width);
-        cfs_mutex_unlock(&seq->lss_mutex);
+       mutex_unlock(&seq->lss_mutex);
 
        RETURN(rc);
 }
 
+struct lprocfs_vars seq_server_proc_list[] = {
+       { "space",
+         seq_server_proc_read_space, seq_server_proc_write_space, NULL },
+       { "width",
+         seq_server_proc_read_width, seq_server_proc_write_width, NULL },
+       { "server",
+         seq_server_proc_read_server, NULL, NULL },
+       { NULL }
+};
+#endif /* HAVE_SERVER_SUPPORT */
+
 /* Client side procfs stuff */
 static int
 seq_client_proc_write_space(struct file *file, const char *buffer,
@@ -227,7 +230,7 @@ seq_client_proc_write_space(struct file *file, const char *buffer,
 
         LASSERT(seq != NULL);
 
-        cfs_mutex_lock(&seq->lcs_mutex);
+       mutex_lock(&seq->lcs_mutex);
        rc = seq_proc_write_common(file, buffer, count,
                                    data, &seq->lcs_space);
 
@@ -236,7 +239,7 @@ seq_client_proc_write_space(struct file *file, const char *buffer,
                        seq->lcs_name, PRANGE(&seq->lcs_space));
        }
 
-        cfs_mutex_unlock(&seq->lcs_mutex);
+       mutex_unlock(&seq->lcs_mutex);
 
         RETURN(count);
 }
@@ -251,10 +254,10 @@ seq_client_proc_read_space(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_mutex_lock(&seq->lcs_mutex);
+       mutex_lock(&seq->lcs_mutex);
        rc = seq_proc_read_common(page, start, off, count, eof,
                                   data, &seq->lcs_space);
-        cfs_mutex_unlock(&seq->lcs_mutex);
+       mutex_unlock(&seq->lcs_mutex);
 
        RETURN(rc);
 }
@@ -264,29 +267,35 @@ seq_client_proc_write_width(struct file *file, const char *buffer,
                             unsigned long count, void *data)
 {
         struct lu_client_seq *seq = (struct lu_client_seq *)data;
+       __u64  max;
        int rc, val;
        ENTRY;
 
         LASSERT(seq != NULL);
 
-        cfs_mutex_lock(&seq->lcs_mutex);
+       mutex_lock(&seq->lcs_mutex);
 
         rc = lprocfs_write_helper(buffer, count, &val);
         if (rc) {
-                cfs_mutex_unlock(&seq->lcs_mutex);
+               mutex_unlock(&seq->lcs_mutex);
                 RETURN(rc);
         }
 
-        if (val <= LUSTRE_SEQ_MAX_WIDTH && val > 0) {
-                seq->lcs_width = val;
+       if (seq->lcs_type == LUSTRE_SEQ_DATA)
+               max = LUSTRE_DATA_SEQ_MAX_WIDTH;
+       else
+               max = LUSTRE_METADATA_SEQ_MAX_WIDTH;
 
-                if (rc == 0) {
-                        CDEBUG(D_INFO, "%s: Sequence size: "LPU64"\n",
-                               seq->lcs_name, seq->lcs_width);
-                }
-        }
+       if (val <= max && val > 0) {
+               seq->lcs_width = val;
+
+               if (rc == 0) {
+                       CDEBUG(D_INFO, "%s: Sequence size: "LPU64"\n",
+                              seq->lcs_name, seq->lcs_width);
+               }
+       }
 
-        cfs_mutex_unlock(&seq->lcs_mutex);
+       mutex_unlock(&seq->lcs_mutex);
 
         RETURN(count);
 }
@@ -301,9 +310,9 @@ seq_client_proc_read_width(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_mutex_lock(&seq->lcs_mutex);
+       mutex_lock(&seq->lcs_mutex);
         rc = snprintf(page, count, LPU64"\n", seq->lcs_width);
-        cfs_mutex_unlock(&seq->lcs_mutex);
+       mutex_unlock(&seq->lcs_mutex);
 
        RETURN(rc);
 }
@@ -318,9 +327,9 @@ seq_client_proc_read_fid(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_mutex_lock(&seq->lcs_mutex);
+       mutex_lock(&seq->lcs_mutex);
         rc = snprintf(page, count, DFID"\n", PFID(&seq->lcs_fid));
-        cfs_mutex_unlock(&seq->lcs_mutex);
+       mutex_unlock(&seq->lcs_mutex);
 
        RETURN(rc);
 }
@@ -345,12 +354,6 @@ seq_client_proc_read_server(char *page, char **start, off_t off,
        RETURN(rc);
 }
 
-struct lprocfs_vars seq_server_proc_list[] = {
-       { "space",    seq_server_proc_read_space, seq_server_proc_write_space, NULL },
-       { "width",    seq_server_proc_read_width, seq_server_proc_write_width, NULL },
-       { "server",   seq_server_proc_read_server, NULL, NULL },
-       { NULL }};
-
 struct lprocfs_vars seq_client_proc_list[] = {
        { "space",    seq_client_proc_read_space, seq_client_proc_write_space, NULL },
        { "width",    seq_client_proc_read_width, seq_client_proc_write_width, NULL },