Whamcloud - gitweb
LU-2240 fld: Move range lookup to fld.
[fs/lustre-release.git] / lustre / fid / lproc_fid.c
index 98e2317..fd66e19 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -35,6 +33,8 @@
  * 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
@@ -42,9 +42,6 @@
  * Author: Yury Umanets <umka@clusterfs.com>
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
 #define DEBUG_SUBSYSTEM S_FID
 
 #ifdef __KERNEL__
@@ -97,8 +94,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);
 }
 
@@ -115,7 +112,7 @@ seq_server_proc_write_space(struct file *file, const char *buffer,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lss_sem);
+       mutex_lock(&seq->lss_mutex);
        rc = seq_proc_write_common(file, buffer, count,
                                    data, &seq->lss_space);
        if (rc == 0) {
@@ -123,7 +120,7 @@ seq_server_proc_write_space(struct file *file, const char *buffer,
                        seq->lss_name, PRANGE(&seq->lss_space));
        }
 
-        cfs_up(&seq->lss_sem);
+       mutex_unlock(&seq->lss_mutex);
 
         RETURN(count);
 }
@@ -138,10 +135,10 @@ seq_server_proc_read_space(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lss_sem);
+       mutex_lock(&seq->lss_mutex);
        rc = seq_proc_read_common(page, start, off, count, eof,
                                   data, &seq->lss_space);
-        cfs_up(&seq->lss_sem);
+       mutex_unlock(&seq->lss_mutex);
 
        RETURN(rc);
 }
@@ -184,20 +181,20 @@ seq_server_proc_write_width(struct file *file, const char *buffer,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lss_sem);
-
-        rc = lprocfs_write_helper(buffer, count, &val);
-        if (rc)
-                RETURN(rc);
-
-        seq->lss_width = val;
+       mutex_lock(&seq->lss_mutex);
 
-       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_up(&seq->lss_sem);
+       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);
 }
@@ -212,9 +209,9 @@ seq_server_proc_read_width(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lss_sem);
+       mutex_lock(&seq->lss_mutex);
         rc = snprintf(page, count, LPU64"\n", seq->lss_width);
-        cfs_up(&seq->lss_sem);
+       mutex_unlock(&seq->lss_mutex);
 
        RETURN(rc);
 }
@@ -230,7 +227,7 @@ seq_client_proc_write_space(struct file *file, const char *buffer,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lcs_sem);
+       mutex_lock(&seq->lcs_mutex);
        rc = seq_proc_write_common(file, buffer, count,
                                    data, &seq->lcs_space);
 
@@ -239,7 +236,7 @@ seq_client_proc_write_space(struct file *file, const char *buffer,
                        seq->lcs_name, PRANGE(&seq->lcs_space));
        }
 
-        cfs_up(&seq->lcs_sem);
+       mutex_unlock(&seq->lcs_mutex);
 
         RETURN(count);
 }
@@ -254,10 +251,10 @@ seq_client_proc_read_space(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lcs_sem);
+       mutex_lock(&seq->lcs_mutex);
        rc = seq_proc_read_common(page, start, off, count, eof,
                                   data, &seq->lcs_space);
-        cfs_up(&seq->lcs_sem);
+       mutex_unlock(&seq->lcs_mutex);
 
        RETURN(rc);
 }
@@ -272,11 +269,11 @@ seq_client_proc_write_width(struct file *file, const char *buffer,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lcs_sem);
+       mutex_lock(&seq->lcs_mutex);
 
         rc = lprocfs_write_helper(buffer, count, &val);
         if (rc) {
-                cfs_up(&seq->lcs_sem);
+               mutex_unlock(&seq->lcs_mutex);
                 RETURN(rc);
         }
 
@@ -289,7 +286,7 @@ seq_client_proc_write_width(struct file *file, const char *buffer,
                 }
         }
 
-        cfs_up(&seq->lcs_sem);
+       mutex_unlock(&seq->lcs_mutex);
 
         RETURN(count);
 }
@@ -304,9 +301,9 @@ seq_client_proc_read_width(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lcs_sem);
+       mutex_lock(&seq->lcs_mutex);
         rc = snprintf(page, count, LPU64"\n", seq->lcs_width);
-        cfs_up(&seq->lcs_sem);
+       mutex_unlock(&seq->lcs_mutex);
 
        RETURN(rc);
 }
@@ -321,9 +318,9 @@ seq_client_proc_read_fid(char *page, char **start, off_t off,
 
         LASSERT(seq != NULL);
 
-        cfs_down(&seq->lcs_sem);
+       mutex_lock(&seq->lcs_mutex);
         rc = snprintf(page, count, DFID"\n", PFID(&seq->lcs_fid));
-        cfs_up(&seq->lcs_sem);
+       mutex_unlock(&seq->lcs_mutex);
 
        RETURN(rc);
 }