From: NeilBrown Date: Tue, 4 Feb 2020 02:28:36 +0000 (-0500) Subject: LU-9859 libcfs: move tracefile locking from linux-tracefile.c X-Git-Tag: 2.13.53~230 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=649a76711efd1dc3d30d7069fac1afcb141b8239 LU-9859 libcfs: move tracefile locking from linux-tracefile.c to tracefile.c There is no value in keeping it separate. Linux-commit: 49209c598d93289ca077575615e98f242b1d8156 Test-Parameters: trivial Change-Id: I24ee7545a40fd6d2ac15018f089d51142736fa27 Signed-off-by: NeilBrown Reviewed-on: https://review.whamcloud.com/37408 Tested-by: jenkins Reviewed-by: Neil Brown Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- diff --git a/libcfs/libcfs/linux-tracefile.c b/libcfs/libcfs/linux-tracefile.c index 0cc9c39..5e39fc9 100644 --- a/libcfs/libcfs/linux-tracefile.c +++ b/libcfs/libcfs/linux-tracefile.c @@ -48,8 +48,6 @@ static unsigned int pages_factor[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; @@ -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()) diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index 555a5bb..7513f92 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -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 DECLARE_RWSEM(cfs_tracefile_sem); 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; - 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)) { @@ -686,7 +687,7 @@ int cfs_tracefile_dump_all_pages(char *filename) close: filp_close(filp, NULL); out: - cfs_tracefile_write_unlock(); + up_write(&cfs_tracefile_sem); return rc; } @@ -799,12 +800,12 @@ int cfs_trace_daemon_command(char *str) { int rc = 0; - cfs_tracefile_write_lock(); + down_write(&cfs_tracefile_sem); if (strcmp(str, "stop") == 0) { - cfs_tracefile_write_unlock(); + up_write(&cfs_tracefile_sem); 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) { @@ -830,7 +831,7 @@ int cfs_trace_daemon_command(char *str) cfs_trace_start_thread(); } - cfs_tracefile_write_unlock(); + up_write(&cfs_tracefile_sem); return rc; } @@ -875,12 +876,12 @@ int cfs_trace_set_debug_mb(int mb) 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_tracefile_write_unlock(); + up_write(&cfs_tracefile_sem); return 0; } @@ -892,12 +893,12 @@ int cfs_trace_get_debug_mb(void) 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_tracefile_read_unlock(); + up_read(&cfs_tracefile_sem); return (total_pages >> (20 - PAGE_SHIFT)) + 1; } @@ -927,7 +928,7 @@ static int tracefiled(void *arg) 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, @@ -939,7 +940,7 @@ static int tracefiled(void *arg) 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)); diff --git a/libcfs/libcfs/tracefile.h b/libcfs/libcfs/tracefile.h index 9497e88..7638bc0 100644 --- a/libcfs/libcfs/tracefile.h +++ b/libcfs/libcfs/tracefile.h @@ -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); -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);