blobfs: allocate flush request before appending to cache buffer
After the write data has been appended to cache buffer, the allocation of flush request can return error, so we move this allocation before appending to the cache buffer. Change-Id: Ia8baae8f3d88596561633bd8a5c4f83e554c72d7 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450981 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
dd90ff7a21
commit
3732429c00
@ -2195,6 +2195,12 @@ spdk_file_write(struct spdk_file *file, struct spdk_fs_thread_ctx *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
args = calloc(1, sizeof(*args));
|
||||
if (args == NULL) {
|
||||
pthread_spin_unlock(&file->lock);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
last = file->last;
|
||||
rem_length = length;
|
||||
cur_payload = payload;
|
||||
@ -2217,6 +2223,7 @@ spdk_file_write(struct spdk_file *file, struct spdk_fs_thread_ctx *ctx,
|
||||
last = cache_append_buffer(file);
|
||||
if (last == NULL) {
|
||||
BLOBFS_TRACE(file, "nomem\n");
|
||||
__free_args(args);
|
||||
pthread_spin_unlock(&file->lock);
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -2226,14 +2233,10 @@ spdk_file_write(struct spdk_file *file, struct spdk_fs_thread_ctx *ctx,
|
||||
pthread_spin_unlock(&file->lock);
|
||||
|
||||
if (cache_buffers_filled == 0) {
|
||||
__free_args(args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
args = calloc(1, sizeof(*args));
|
||||
if (args == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
args->file = file;
|
||||
file->fs->send_request(__file_flush, args);
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user