diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index dbeef66a3..edeeacfd9 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -1929,7 +1929,23 @@ __file_flush(void *_args) * progress we will flush more data after that is completed. */ __free_args(args); + if (next == NULL) { + /* + * For cases where a file's cache was evicted, and then the + * file was later appended, we will write the data directly + * to disk and bypass cache. So just update length_flushed + * here to reflect that all data was already written to disk. + */ + file->length_flushed = file->append_pos; + } pthread_spin_unlock(&file->lock); + if (next == NULL) { + /* + * There is no data to flush, but we still need to check for any + * outstanding sync requests to make sure metadata gets updated. + */ + __check_sync_reqs(file); + } return; } @@ -2307,7 +2323,7 @@ _file_sync(struct spdk_file *file, struct spdk_fs_channel *channel, BLOBFS_TRACE(file, "offset=%jx\n", file->append_pos); pthread_spin_lock(&file->lock); - if (file->append_pos <= file->length_flushed || file->last == NULL) { + if (file->append_pos <= file->length_flushed) { BLOBFS_TRACE(file, "done - no data to flush\n"); pthread_spin_unlock(&file->lock); cb_fn(cb_arg, 0);