[PATCH v2 06/10] Add filter_data_buffer_parallel
Zhou Wenjian
zhouwj-fnst at cn.fujitsu.com
Fri Jun 19 01:56:40 PDT 2015
From: Qiao Nuohan <qiaonuohan at cn.fujitsu.com>
filter_data_buffer_parallel is used to enable filtering buffer
parallely.
Signed-off-by: Qiao Nuohan <qiaonuohan at cn.fujitsu.com>
---
erase_info.c | 29 ++++++++++++++++++++++++++++-
erase_info.h | 2 ++
2 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/erase_info.c b/erase_info.c
index e0e0f71..0b253d7 100644
--- a/erase_info.c
+++ b/erase_info.c
@@ -2328,7 +2328,6 @@ extract_filter_info(unsigned long long start_paddr,
return TRUE;
}
-
/*
* External functions.
*/
@@ -2413,6 +2412,34 @@ filter_data_buffer(unsigned char *buf, unsigned long long paddr,
}
}
+/*
+ * Filter buffer if the physical address is in filter_info.
+ */
+void
+filter_data_buffer_parallel(unsigned char *buf, unsigned long long paddr,
+ size_t size, pthread_mutex_t *mutex)
+{
+ struct filter_info fl_info;
+ unsigned char *buf_ptr;
+ int found = FALSE;
+
+ while (TRUE) {
+ pthread_mutex_lock(mutex);
+ found = extract_filter_info(paddr, paddr + size, &fl_info);
+ pthread_mutex_unlock(mutex);
+
+ if (found) {
+ buf_ptr = buf + (fl_info.paddr - paddr);
+ if (fl_info.nullify)
+ memset(buf_ptr, 0, fl_info.size);
+ else
+ memset(buf_ptr, fl_info.erase_ch, fl_info.size);
+ } else {
+ break;
+ }
+ }
+}
+
unsigned long
get_size_eraseinfo(void)
{
diff --git a/erase_info.h b/erase_info.h
index 4d4957e..b363a40 100644
--- a/erase_info.h
+++ b/erase_info.h
@@ -60,6 +60,8 @@ extern unsigned long num_erase_info;
int gather_filter_info(void);
void clear_filter_info(void);
void filter_data_buffer(unsigned char *buf, unsigned long long paddr, size_t size);
+void filter_data_buffer_parallel(unsigned char *buf, unsigned long long paddr,
+ size_t size, pthread_mutex_t *mutex);
unsigned long get_size_eraseinfo(void);
int update_filter_info_raw(unsigned long long, int, int);
--
1.7.1
More information about the kexec
mailing list