blobfs: cache_insert_buffer() - check count before allocating buffer
This avoids corner case where a buffer gets allocated on the 100th try. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: If65053d539d458d9a53c8850bbb4cbe4ee84f604
This commit is contained in:
parent
7079a18f21
commit
38f91be52b
@ -1496,18 +1496,20 @@ cache_insert_buffer(struct spdk_file *file, uint64_t offset)
|
||||
buf->buf = alloc_cache_memory_buffer(file);
|
||||
if (buf->buf == NULL) {
|
||||
while (buf->buf == NULL) {
|
||||
count++;
|
||||
buf->buf = alloc_cache_memory_buffer(file);
|
||||
/*
|
||||
* TODO: __free_oldest_cache() should eventually free some buffers.
|
||||
* Should have a more sophisticated check here, instead of just
|
||||
* bailing if 100 tries does not result in getting a free buffer.
|
||||
* TODO: alloc_cache_memory_buffer() should eventually free
|
||||
* some buffers. Need a more sophisticated check here, instead
|
||||
* of just bailing if 100 tries does not result in getting a
|
||||
* free buffer. This will involve using the sync channel's
|
||||
* semaphore to block until a buffer becomes available.
|
||||
*/
|
||||
if (count == 100) {
|
||||
if (count++ == 100) {
|
||||
SPDK_ERRLOG("could not allocate cache buffer\n");
|
||||
assert(false);
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
buf->buf = alloc_cache_memory_buffer(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user