glusterfs

Форк
0
/
gf-io-legacy.c 
99 строк · 2.0 Кб
1
/*
2
  Copyright (c) 2021 Red Hat, Inc. <https://www.redhat.com>
3
  This file is part of GlusterFS.
4

5
  This file is licensed to you under your choice of the GNU Lesser
6
  General Public License, version 3 or any later version (LGPLv3 or
7
  later), or the GNU General Public License, version 2 (GPLv2), in all
8
  cases as published by the Free Software Foundation.
9
*/
10

11
#include <glusterfs/gf-io-legacy.h>
12

13
#include <glusterfs/globals.h>
14
#include <glusterfs/gf-event.h>
15
#include <glusterfs/timer.h>
16

17
static uint64_t gf_io_legacy_seq;
18

19
static int32_t
20
gf_io_legacy_setup(void)
21
{
22
    gf_io_legacy_seq = 0;
23

24
    return 0;
25
}
26

27
static void
28
gf_io_legacy_cleanup(void)
29
{
30
}
31

32
static int32_t
33
gf_io_legacy_wait(void)
34
{
35
    return gf_event_dispatch(global_ctx->event_pool);
36
}
37

38
static void
39
gf_io_legacy_flush(void)
40
{
41
}
42

43
static void
44
gf_io_legacy_cbk(uint64_t id, int32_t res)
45
{
46
    uint64_t seq;
47

48
    seq = uatomic_add_return(&gf_io_legacy_seq, 1) - 1;
49

50
    gf_io_cbk(NULL, seq, id, res);
51
}
52

53
static uint64_t
54
gf_io_legacy_cancel(uint64_t seq, uint64_t id, gf_io_op_t *op, uint32_t count)
55
{
56
    gf_timer_t *timer;
57

58
    timer = (gf_timer_t *)(uintptr_t)op->cancel.id;
59
    if (timer == NULL) {
60
        gf_io_legacy_cbk(id, -ENOENT);
61
    } else {
62
        op = timer->data;
63
        if (gf_timer_call_cancel(global_ctx, timer) < 0) {
64
            gf_io_legacy_cbk(id, -EALREADY);
65
        } else {
66
            gf_io_legacy_cbk(op->cancel.id, -ECANCELED);
67
            gf_io_legacy_cbk(id, 0);
68
        }
69
    }
70

71
    return 0;
72
}
73

74
static uint64_t
75
gf_io_legacy_callback(uint64_t seq, uint64_t id, gf_io_op_t *op, uint32_t count)
76
{
77
    gf_io_legacy_cbk(id, 0);
78

79
    return 0;
80
}
81

82
const gf_io_engine_t gf_io_engine_legacy = {
83
    .name = "legacy",
84
    .mode = GF_IO_MODE_LEGACY,
85

86
    .setup = gf_io_legacy_setup,
87
    .cleanup = gf_io_legacy_cleanup,
88
    .wait = gf_io_legacy_wait,
89

90
    .worker_setup = NULL,
91
    .worker_cleanup = NULL,
92
    .worker_stop = NULL,
93
    .worker = NULL,
94

95
    .flush = gf_io_legacy_flush,
96

97
    .cancel = gf_io_legacy_cancel,
98
    .callback = gf_io_legacy_callback
99
};
100

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.