Whamcloud - gitweb
LU-1866 lfsck: enhance otable-based iteration
[fs/lustre-release.git] / lustre / fid / lproc_fid.c
index 83e701d..3670ee4 100644 (file)
@@ -27,7 +27,7 @@
  * 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, 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -92,8 +92,8 @@ seq_proc_read_common(char *page, char **start, off_t off,
        ENTRY;
 
         *eof = 1;
-        rc = snprintf(page, count, "["LPX64" - "LPX64"]:%x:%x\n",
-                      PRANGE(range));
+       rc = snprintf(page, count, "["LPX64" - "LPX64"]:%x:%s\n",
+                       PRANGE(range));
        RETURN(rc);
 }
 
@@ -110,7 +110,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) {
@@ -118,7 +118,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);
 }
@@ -133,10 +133,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);
 }
@@ -179,20 +179,20 @@ 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)
-                RETURN(rc);
-
-        seq->lss_width = val;
-
-       if (rc == 0) {
-               CDEBUG(D_INFO, "%s: Width: "LPU64"\n",
-                       seq->lss_name, seq->lss_width);
+       rc = lprocfs_write_helper(buffer, count, &val);
+       if (rc != 0) {
+               CERROR("%s: invalid width.\n", seq->lss_name);
+               GOTO(out_unlock, rc);
        }
 
-        cfs_mutex_unlock(&seq->lss_mutex);
+       seq->lss_width = val;
+
+       CDEBUG(D_INFO, "%s: Width: "LPU64"\n",
+              seq->lss_name, seq->lss_width);
+out_unlock:
+       mutex_unlock(&seq->lss_mutex);
 
         RETURN(count);
 }
@@ -207,9 +207,9 @@ 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);
 }
@@ -225,7 +225,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);
 
@@ -234,7 +234,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);
 }
@@ -249,10 +249,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);
 }
@@ -262,29 +262,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);
 }
@@ -299,9 +305,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);
 }
@@ -316,9 +322,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);
 }