blobfs: change readahead to take spdk_fs_request as input parameter
Change-Id: I00639a711a4f1637d24d58afb087e9d667d34c95 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450719 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> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
125797e07e
commit
824cda201d
@ -2245,9 +2245,10 @@ spdk_file_write(struct spdk_file *file, struct spdk_fs_thread_ctx *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
__readahead_done(void *arg, int bserrno)
|
__readahead_done(void *ctx, int bserrno)
|
||||||
{
|
{
|
||||||
struct spdk_fs_cb_args *args = arg;
|
struct spdk_fs_request *req = ctx;
|
||||||
|
struct spdk_fs_cb_args *args = &req->args;
|
||||||
struct cache_buffer *cache_buffer = args->op.readahead.cache_buffer;
|
struct cache_buffer *cache_buffer = args->op.readahead.cache_buffer;
|
||||||
struct spdk_file *file = args->file;
|
struct spdk_file *file = args->file;
|
||||||
|
|
||||||
@ -2259,13 +2260,14 @@ __readahead_done(void *arg, int bserrno)
|
|||||||
cache_buffer->in_progress = false;
|
cache_buffer->in_progress = false;
|
||||||
pthread_spin_unlock(&file->lock);
|
pthread_spin_unlock(&file->lock);
|
||||||
|
|
||||||
__free_args(args);
|
free_fs_request(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
__readahead(void *_args)
|
__readahead(void *ctx)
|
||||||
{
|
{
|
||||||
struct spdk_fs_cb_args *args = _args;
|
struct spdk_fs_request *req = ctx;
|
||||||
|
struct spdk_fs_cb_args *args = &req->args;
|
||||||
struct spdk_file *file = args->file;
|
struct spdk_file *file = args->file;
|
||||||
uint64_t offset, length, start_lba, num_lba;
|
uint64_t offset, length, start_lba, num_lba;
|
||||||
uint32_t lba_size;
|
uint32_t lba_size;
|
||||||
@ -2280,7 +2282,7 @@ __readahead(void *_args)
|
|||||||
offset, length, start_lba, num_lba);
|
offset, length, start_lba, num_lba);
|
||||||
spdk_blob_io_read(file->blob, file->fs->sync_target.sync_fs_channel->bs_channel,
|
spdk_blob_io_read(file->blob, file->fs->sync_target.sync_fs_channel->bs_channel,
|
||||||
args->op.readahead.cache_buffer->buf,
|
args->op.readahead.cache_buffer->buf,
|
||||||
start_lba, num_lba, __readahead_done, args);
|
start_lba, num_lba, __readahead_done, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t
|
static uint64_t
|
||||||
@ -2290,8 +2292,10 @@ __next_cache_buffer_offset(uint64_t offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_readahead(struct spdk_file *file, uint64_t offset)
|
check_readahead(struct spdk_file *file, uint64_t offset,
|
||||||
|
struct spdk_fs_channel *channel)
|
||||||
{
|
{
|
||||||
|
struct spdk_fs_request *req;
|
||||||
struct spdk_fs_cb_args *args;
|
struct spdk_fs_cb_args *args;
|
||||||
|
|
||||||
offset = __next_cache_buffer_offset(offset);
|
offset = __next_cache_buffer_offset(offset);
|
||||||
@ -2299,10 +2303,11 @@ check_readahead(struct spdk_file *file, uint64_t offset)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
args = calloc(1, sizeof(*args));
|
req = alloc_fs_request(channel);
|
||||||
if (args == NULL) {
|
if (req == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
args = &req->args;
|
||||||
|
|
||||||
BLOBFS_TRACE(file, "offset=%jx\n", offset);
|
BLOBFS_TRACE(file, "offset=%jx\n", offset);
|
||||||
|
|
||||||
@ -2311,7 +2316,7 @@ check_readahead(struct spdk_file *file, uint64_t offset)
|
|||||||
args->op.readahead.cache_buffer = cache_insert_buffer(file, offset);
|
args->op.readahead.cache_buffer = cache_insert_buffer(file, offset);
|
||||||
if (!args->op.readahead.cache_buffer) {
|
if (!args->op.readahead.cache_buffer) {
|
||||||
BLOBFS_TRACE(file, "Cannot allocate buf for offset=%jx\n", offset);
|
BLOBFS_TRACE(file, "Cannot allocate buf for offset=%jx\n", offset);
|
||||||
free(args);
|
free_fs_request(req);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2321,7 +2326,7 @@ check_readahead(struct spdk_file *file, uint64_t offset)
|
|||||||
} else {
|
} else {
|
||||||
args->op.readahead.length = CACHE_BUFFER_SIZE;
|
args->op.readahead.length = CACHE_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
file->fs->send_request(__readahead, args);
|
file->fs->send_request(__readahead, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -2386,8 +2391,8 @@ spdk_file_read(struct spdk_file *file, struct spdk_fs_thread_ctx *ctx,
|
|||||||
file->seq_byte_count += length;
|
file->seq_byte_count += length;
|
||||||
file->next_seq_offset = offset + length;
|
file->next_seq_offset = offset + length;
|
||||||
if (file->seq_byte_count >= CACHE_READAHEAD_THRESHOLD) {
|
if (file->seq_byte_count >= CACHE_READAHEAD_THRESHOLD) {
|
||||||
check_readahead(file, offset);
|
check_readahead(file, offset, channel);
|
||||||
check_readahead(file, offset + CACHE_BUFFER_SIZE);
|
check_readahead(file, offset + CACHE_BUFFER_SIZE, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
final_length = 0;
|
final_length = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user