blobfs: remove duplicated tailq operation statement.

The code can be merged into cache_free_buffers

Change-Id: I5da59ae5c5ea2b91d4aecd15a611ad6731bd4c56
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/372993
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Ziye Yang 2017-08-07 13:25:45 +08:00 committed by Daniel Verkamp
parent ddcc31d645
commit 95399c118e

View File

@ -1540,8 +1540,6 @@ alloc_cache_memory_buffer(struct spdk_file *context)
if (!file->open_for_writing && if (!file->open_for_writing &&
file->priority == SPDK_FILE_PRIORITY_LOW && file->priority == SPDK_FILE_PRIORITY_LOW &&
file != context) { file != context) {
TAILQ_REMOVE(&g_caches, file, cache_tailq);
TAILQ_INSERT_TAIL(&g_caches, file, cache_tailq);
break; break;
} }
} }
@ -1557,8 +1555,6 @@ alloc_cache_memory_buffer(struct spdk_file *context)
pthread_spin_lock(&g_caches_lock); pthread_spin_lock(&g_caches_lock);
TAILQ_FOREACH(file, &g_caches, cache_tailq) { TAILQ_FOREACH(file, &g_caches, cache_tailq) {
if (!file->open_for_writing && file != context) { if (!file->open_for_writing && file != context) {
TAILQ_REMOVE(&g_caches, file, cache_tailq);
TAILQ_INSERT_TAIL(&g_caches, file, cache_tailq);
break; break;
} }
} }
@ -1574,8 +1570,6 @@ alloc_cache_memory_buffer(struct spdk_file *context)
pthread_spin_lock(&g_caches_lock); pthread_spin_lock(&g_caches_lock);
TAILQ_FOREACH(file, &g_caches, cache_tailq) { TAILQ_FOREACH(file, &g_caches, cache_tailq) {
if (file != context) { if (file != context) {
TAILQ_REMOVE(&g_caches, file, cache_tailq);
TAILQ_INSERT_TAIL(&g_caches, file, cache_tailq);
break; break;
} }
} }
@ -2336,8 +2330,11 @@ cache_free_buffers(struct spdk_file *file)
return; return;
} }
spdk_tree_free_buffers(file->tree); spdk_tree_free_buffers(file->tree);
if (file->tree->present_mask == 0) {
TAILQ_REMOVE(&g_caches, file, cache_tailq); TAILQ_REMOVE(&g_caches, file, cache_tailq);
/* If not freed, put it in the end of the queue */
if (file->tree->present_mask != 0) {
TAILQ_INSERT_TAIL(&g_caches, file, cache_tailq);
} }
file->last = NULL; file->last = NULL;
pthread_spin_unlock(&g_caches_lock); pthread_spin_unlock(&g_caches_lock);