Whamcloud - gitweb
LU-9859 libcfs: move tracefile locking from linux-tracefile.c 08/37408/4
authorNeilBrown <neilb@suse.com>
Tue, 4 Feb 2020 02:28:36 +0000 (21:28 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 14 Feb 2020 05:51:09 +0000 (05:51 +0000)
 to tracefile.c

There is no value in keeping it separate.

Linux-commit: 49209c598d93289ca077575615e98f242b1d8156

Test-Parameters: trivial

Change-Id: I24ee7545a40fd6d2ac15018f089d51142736fa27
Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-on: https://review.whamcloud.com/37408
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/linux-tracefile.c
libcfs/libcfs/tracefile.c
libcfs/libcfs/tracefile.h

index 0cc9c39..5e39fc9 100644 (file)
@@ -48,8 +48,6 @@ static unsigned int pages_factor[CFS_TCD_TYPE_MAX] = {
 
 char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX];
 
 
 char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX];
 
-static DECLARE_RWSEM(cfs_tracefile_sem);
-
 int cfs_tracefile_init_arch(void)
 {
        int i;
 int cfs_tracefile_init_arch(void)
 {
        int i;
@@ -110,26 +108,6 @@ void cfs_tracefile_fini_arch(void)
        }
 }
 
        }
 }
 
-void cfs_tracefile_read_lock(void)
-{
-       down_read(&cfs_tracefile_sem);
-}
-
-void cfs_tracefile_read_unlock(void)
-{
-       up_read(&cfs_tracefile_sem);
-}
-
-void cfs_tracefile_write_lock(void)
-{
-       down_write(&cfs_tracefile_sem);
-}
-
-void cfs_tracefile_write_unlock(void)
-{
-       up_write(&cfs_tracefile_sem);
-}
-
 enum cfs_trace_buf_type cfs_trace_buf_idx_get(void)
 {
        if (in_irq())
 enum cfs_trace_buf_type cfs_trace_buf_idx_get(void)
 {
        if (in_irq())
index 555a5bb..7513f92 100644 (file)
@@ -58,6 +58,7 @@ static DEFINE_MUTEX(cfs_trace_thread_mutex);
 static int thread_running = 0;
 
 static atomic_t cfs_tage_allocated = ATOMIC_INIT(0);
 static int thread_running = 0;
 
 static atomic_t cfs_tage_allocated = ATOMIC_INIT(0);
+static DECLARE_RWSEM(cfs_tracefile_sem);
 
 static void put_pages_on_tcd_daemon_list(struct page_collection *pc,
                                        struct cfs_trace_cpu_data *tcd);
 
 static void put_pages_on_tcd_daemon_list(struct page_collection *pc,
                                        struct cfs_trace_cpu_data *tcd);
@@ -642,7 +643,7 @@ int cfs_tracefile_dump_all_pages(char *filename)
        char                    *buf;
        int rc;
 
        char                    *buf;
        int rc;
 
-       cfs_tracefile_write_lock();
+       down_write(&cfs_tracefile_sem);
 
        filp = filp_open(filename, O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, 0600);
        if (IS_ERR(filp)) {
 
        filp = filp_open(filename, O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, 0600);
        if (IS_ERR(filp)) {
@@ -686,7 +687,7 @@ int cfs_tracefile_dump_all_pages(char *filename)
 close:
        filp_close(filp, NULL);
 out:
 close:
        filp_close(filp, NULL);
 out:
-       cfs_tracefile_write_unlock();
+       up_write(&cfs_tracefile_sem);
        return rc;
 }
 
        return rc;
 }
 
@@ -799,12 +800,12 @@ int cfs_trace_daemon_command(char *str)
 {
         int       rc = 0;
 
 {
         int       rc = 0;
 
-        cfs_tracefile_write_lock();
+       down_write(&cfs_tracefile_sem);
 
         if (strcmp(str, "stop") == 0) {
 
         if (strcmp(str, "stop") == 0) {
-                cfs_tracefile_write_unlock();
+               up_write(&cfs_tracefile_sem);
                 cfs_trace_stop_thread();
                 cfs_trace_stop_thread();
-                cfs_tracefile_write_lock();
+               down_write(&cfs_tracefile_sem);
                 memset(cfs_tracefile, 0, sizeof(cfs_tracefile));
 
        } else if (strncmp(str, "size=", 5) == 0) {
                 memset(cfs_tracefile, 0, sizeof(cfs_tracefile));
 
        } else if (strncmp(str, "size=", 5) == 0) {
@@ -830,7 +831,7 @@ int cfs_trace_daemon_command(char *str)
                cfs_trace_start_thread();
         }
 
                cfs_trace_start_thread();
         }
 
-        cfs_tracefile_write_unlock();
+       up_write(&cfs_tracefile_sem);
         return rc;
 }
 
         return rc;
 }
 
@@ -875,12 +876,12 @@ int cfs_trace_set_debug_mb(int mb)
        mb /= num_possible_cpus();
        pages = mb << (20 - PAGE_SHIFT);
 
        mb /= num_possible_cpus();
        pages = mb << (20 - PAGE_SHIFT);
 
-       cfs_tracefile_write_lock();
+       down_write(&cfs_tracefile_sem);
 
        cfs_tcd_for_each(tcd, i, j)
                tcd->tcd_max_pages = (pages * tcd->tcd_pages_factor) / 100;
 
 
        cfs_tcd_for_each(tcd, i, j)
                tcd->tcd_max_pages = (pages * tcd->tcd_pages_factor) / 100;
 
-       cfs_tracefile_write_unlock();
+       up_write(&cfs_tracefile_sem);
 
        return 0;
 }
 
        return 0;
 }
@@ -892,12 +893,12 @@ int cfs_trace_get_debug_mb(void)
         struct cfs_trace_cpu_data *tcd;
         int total_pages = 0;
 
         struct cfs_trace_cpu_data *tcd;
         int total_pages = 0;
 
-        cfs_tracefile_read_lock();
+       down_read(&cfs_tracefile_sem);
 
         cfs_tcd_for_each(tcd, i, j)
                 total_pages += tcd->tcd_max_pages;
 
 
         cfs_tcd_for_each(tcd, i, j)
                 total_pages += tcd->tcd_max_pages;
 
-        cfs_tracefile_read_unlock();
+       up_read(&cfs_tracefile_sem);
 
        return (total_pages >> (20 - PAGE_SHIFT)) + 1;
 }
 
        return (total_pages >> (20 - PAGE_SHIFT)) + 1;
 }
@@ -927,7 +928,7 @@ static int tracefiled(void *arg)
                         goto end_loop;
 
                 filp = NULL;
                         goto end_loop;
 
                 filp = NULL;
-                cfs_tracefile_read_lock();
+               down_read(&cfs_tracefile_sem);
                 if (cfs_tracefile[0] != 0) {
                        filp = filp_open(cfs_tracefile,
                                         O_CREAT | O_RDWR | O_LARGEFILE,
                 if (cfs_tracefile[0] != 0) {
                        filp = filp_open(cfs_tracefile,
                                         O_CREAT | O_RDWR | O_LARGEFILE,
@@ -939,7 +940,7 @@ static int tracefiled(void *arg)
                                        cfs_tracefile, rc);
                        }
                }
                                        cfs_tracefile, rc);
                        }
                }
-                cfs_tracefile_read_unlock();
+               up_read(&cfs_tracefile_sem);
                 if (filp == NULL) {
                         put_pages_on_daemon_list(&pc);
                        __LASSERT(list_empty(&pc.pc_pages));
                 if (filp == NULL) {
                         put_pages_on_daemon_list(&pc);
                        __LASSERT(list_empty(&pc.pc_pages));
index 9497e88..7638bc0 100644 (file)
@@ -58,11 +58,6 @@ extern void libcfs_run_debug_log_upcall(char *file);
 int  cfs_tracefile_init_arch(void);
 void cfs_tracefile_fini_arch(void);
 
 int  cfs_tracefile_init_arch(void);
 void cfs_tracefile_fini_arch(void);
 
-void cfs_tracefile_read_lock(void);
-void cfs_tracefile_read_unlock(void);
-void cfs_tracefile_write_lock(void);
-void cfs_tracefile_write_unlock(void);
-
 int cfs_tracefile_dump_all_pages(char *filename);
 void cfs_trace_debug_print(void);
 void cfs_trace_flush_pages(void);
 int cfs_tracefile_dump_all_pages(char *filename);
 void cfs_trace_debug_print(void);
 void cfs_trace_flush_pages(void);