Whamcloud - gitweb
LU-812 compat: clean up mutex lock to use kernel mutex primitive
[fs/lustre-release.git] / lustre / fid / lproc_fid.c
index 70b5c9c..07a4a0c 100644 (file)
@@ -28,6 +28,8 @@
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -77,7 +79,8 @@ seq_proc_write_common(struct file *file, const char *buffer,
 
        LASSERT(range != NULL);
 
-        rc = sscanf(buffer, "[%Lx - %Lx]\n",(long long unsigned *)&tmp.lsr_start,
+        rc = sscanf(buffer, "[%llx - %llx]\n",
+                    (long long unsigned *)&tmp.lsr_start,
                     (long long unsigned *)&tmp.lsr_end);
        if (rc != 2 || !range_is_sane(&tmp) || range_is_zero(&tmp))
                RETURN(-EINVAL);
@@ -112,7 +115,7 @@ seq_server_proc_write_space(struct file *file, const char *buffer,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lss_sem);
+        cfs_mutex_lock(&seq->lss_mutex);
        rc = seq_proc_write_common(file, buffer, count,
                                    data, &seq->lss_space);
        if (rc == 0) {
@@ -120,7 +123,7 @@ seq_server_proc_write_space(struct file *file, const char *buffer,
                        seq->lss_name, PRANGE(&seq->lss_space));
        }
 
-        cfs_up(&seq->lss_sem);
+        cfs_mutex_unlock(&seq->lss_mutex);
 
         RETURN(count);
 }
@@ -135,10 +138,10 @@ seq_server_proc_read_space(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lss_sem);
+        cfs_mutex_lock(&seq->lss_mutex);
        rc = seq_proc_read_common(page, start, off, count, eof,
                                   data, &seq->lss_space);
-        cfs_up(&seq->lss_sem);
+        cfs_mutex_unlock(&seq->lss_mutex);
 
        RETURN(rc);
 }
@@ -181,7 +184,7 @@ seq_server_proc_write_width(struct file *file, const char *buffer,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lss_sem);
+        cfs_mutex_lock(&seq->lss_mutex);
 
         rc = lprocfs_write_helper(buffer, count, &val);
         if (rc)
@@ -194,7 +197,7 @@ seq_server_proc_write_width(struct file *file, const char *buffer,
                        seq->lss_name, seq->lss_width);
        }
 
-        cfs_up(&seq->lss_sem);
+        cfs_mutex_unlock(&seq->lss_mutex);
 
         RETURN(count);
 }
@@ -209,9 +212,9 @@ seq_server_proc_read_width(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lss_sem);
+        cfs_mutex_lock(&seq->lss_mutex);
         rc = snprintf(page, count, LPU64"\n", seq->lss_width);
-        cfs_up(&seq->lss_sem);
+        cfs_mutex_unlock(&seq->lss_mutex);
 
        RETURN(rc);
 }
@@ -227,7 +230,7 @@ seq_client_proc_write_space(struct file *file, const char *buffer,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lcs_sem);
+        cfs_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_up(&seq->lcs_sem);
+        cfs_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_down(&seq->lcs_sem);
+        cfs_mutex_lock(&seq->lcs_mutex);
        rc = seq_proc_read_common(page, start, off, count, eof,
                                   data, &seq->lcs_space);
-        cfs_up(&seq->lcs_sem);
+        cfs_mutex_unlock(&seq->lcs_mutex);
 
        RETURN(rc);
 }
@@ -269,11 +272,13 @@ seq_client_proc_write_width(struct file *file, const char *buffer,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lcs_sem);
+        cfs_mutex_lock(&seq->lcs_mutex);
 
         rc = lprocfs_write_helper(buffer, count, &val);
-        if (rc)
+        if (rc) {
+                cfs_mutex_unlock(&seq->lcs_mutex);
                 RETURN(rc);
+        }
 
         if (val <= LUSTRE_SEQ_MAX_WIDTH && val > 0) {
                 seq->lcs_width = val;
@@ -284,7 +289,7 @@ seq_client_proc_write_width(struct file *file, const char *buffer,
                 }
         }
 
-        cfs_up(&seq->lcs_sem);
+        cfs_mutex_unlock(&seq->lcs_mutex);
 
         RETURN(count);
 }
@@ -299,9 +304,9 @@ seq_client_proc_read_width(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lcs_sem);
+        cfs_mutex_lock(&seq->lcs_mutex);
         rc = snprintf(page, count, LPU64"\n", seq->lcs_width);
-        cfs_up(&seq->lcs_sem);
+        cfs_mutex_unlock(&seq->lcs_mutex);
 
        RETURN(rc);
 }
@@ -316,9 +321,9 @@ seq_client_proc_read_fid(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lcs_sem);
+        cfs_mutex_lock(&seq->lcs_mutex);
         rc = snprintf(page, count, DFID"\n", PFID(&seq->lcs_fid));
-        cfs_up(&seq->lcs_sem);
+        cfs_mutex_unlock(&seq->lcs_mutex);
 
        RETURN(rc);
 }