Skip to content

Commit b5510ef

Browse files
author
Rafal Stefanowski
committed
Fix formatting
Change-Id: Ib43ab22b3fa457e624deae912b3c587bdf6b0648 Signed-off-by: Rafal Stefanowski <rafal.stefanowski@huawei.com>
1 parent 8033268 commit b5510ef

File tree

18 files changed

+812
-775
lines changed

18 files changed

+812
-775
lines changed

lib/env_ocf/ocf_env_refcnt.c

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
#include "ocf_env_refcnt.h"
88

9-
int env_refcnt_init(struct env_refcnt *rc, const char *name, size_t name_len)
9+
int
10+
env_refcnt_init(struct env_refcnt *rc, const char *name, size_t name_len)
1011
{
1112
env_atomic_set(&rc->counter, 0);
1213
env_atomic_set(&rc->freeze, 0);
@@ -16,43 +17,50 @@ int env_refcnt_init(struct env_refcnt *rc, const char *name, size_t name_len)
1617
return 0;
1718
}
1819

19-
void env_refcnt_deinit(struct env_refcnt *rc)
20+
void
21+
env_refcnt_deinit(struct env_refcnt *rc)
2022
{
2123

2224
}
2325

24-
void env_refcnt_dec(struct env_refcnt *rc)
26+
void
27+
env_refcnt_dec(struct env_refcnt *rc)
2528
{
2629
int val = env_atomic_dec_return(&rc->counter);
2730
ENV_BUG_ON(val < 0);
2831

29-
if (!val && env_atomic_cmpxchg(&rc->callback, 1, 0))
32+
if (!val && env_atomic_cmpxchg(&rc->callback, 1, 0)) {
3033
rc->cb(rc->priv);
34+
}
3135
}
3236

33-
bool env_refcnt_inc(struct env_refcnt *rc)
37+
bool
38+
env_refcnt_inc(struct env_refcnt *rc)
3439
{
3540
int val;
3641

3742
if (!env_atomic_read(&rc->freeze)) {
3843
val = env_atomic_inc_return(&rc->counter);
39-
if (!env_atomic_read(&rc->freeze))
44+
if (!env_atomic_read(&rc->freeze)) {
4045
return !!val;
41-
else
46+
} else {
4247
env_refcnt_dec(rc);
48+
}
4349
}
4450

4551
return 0;
4652
}
4753

4854

49-
void env_refcnt_freeze(struct env_refcnt *rc)
55+
void
56+
env_refcnt_freeze(struct env_refcnt *rc)
5057
{
5158
env_atomic_inc(&rc->freeze);
5259
}
5360

54-
void env_refcnt_register_zero_cb(struct env_refcnt *rc, env_refcnt_cb_t cb,
55-
void *priv)
61+
void
62+
env_refcnt_register_zero_cb(struct env_refcnt *rc, env_refcnt_cb_t cb,
63+
void *priv)
5664
{
5765
ENV_BUG_ON(!env_atomic_read(&rc->freeze));
5866
ENV_BUG_ON(env_atomic_read(&rc->callback));
@@ -64,18 +72,21 @@ void env_refcnt_register_zero_cb(struct env_refcnt *rc, env_refcnt_cb_t cb,
6472
env_refcnt_dec(rc);
6573
}
6674

67-
void env_refcnt_unfreeze(struct env_refcnt *rc)
75+
void
76+
env_refcnt_unfreeze(struct env_refcnt *rc)
6877
{
6978
int val = env_atomic_dec_return(&rc->freeze);
7079
ENV_BUG_ON(val < 0);
7180
}
7281

73-
bool env_refcnt_frozen(struct env_refcnt *rc)
82+
bool
83+
env_refcnt_frozen(struct env_refcnt *rc)
7484
{
7585
return !!env_atomic_read(&rc->freeze);
7686
}
7787

78-
bool env_refcnt_zeroed(struct env_refcnt *rc)
88+
bool
89+
env_refcnt_zeroed(struct env_refcnt *rc)
7990
{
8091
return (env_atomic_read(&rc->counter) == 0);
8192
}

lib/env_ocf/ocf_env_refcnt.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
typedef void (*env_refcnt_cb_t)(void *priv);
1313

14-
struct env_refcnt
15-
{
14+
struct env_refcnt {
1615
env_atomic counter __attribute__((aligned(64)));
1716
env_atomic freeze;
1817
env_atomic callback;
@@ -35,7 +34,7 @@ void env_refcnt_dec(struct env_refcnt *rc);
3534
/* Disallow incrementing of underlying counter - attempts to increment counter
3635
* will be failing until env_refcnt_unfreeze is calleed.
3736
* It's ok to call freeze multiple times, in which case counter is frozen
38-
* until all freeze calls are offset by a corresponding unfreeze.*/
37+
* until all freeze calls are offset by a corresponding unfreeze. */
3938
void env_refcnt_freeze(struct env_refcnt *rc);
4039

4140
/* Cancel the effect of single env_refcnt_freeze call */
@@ -49,6 +48,6 @@ bool env_refcnt_zeroed(struct env_refcnt *rc);
4948
* Must be called after counter is frozen.
5049
* Cannot be called until previously regsitered callback had fired. */
5150
void env_refcnt_register_zero_cb(struct env_refcnt *rc, env_refcnt_cb_t cb,
52-
void *priv);
51+
void *priv);
5352

54-
#endif // __OCF_ENV_REFCNT_H__
53+
#endif /* __OCF_ENV_REFCNT_H__ */

module/bdev/ocf/ctx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ vbdev_ocf_ctx_cleaner_stop(ocf_cleaner_t c)
363363
}
364364

365365
/* TODO?: this one should only set next_run to "now" and poller
366-
* registration should be move to _init with saved thread */
366+
* registration should be move to _init with saved thread */
367367
static void
368368
vbdev_ocf_ctx_cleaner_kick(ocf_cleaner_t cleaner)
369369
{

module/bdev/ocf/vbdev_ocf.c

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ _module_fini_cache_visitor(ocf_cache_t cache, void *cb_arg)
340340
SPDK_DEBUGLOG(vbdev_ocf, "OCF cache '%s': module stop visit\n", ocf_cache_get_name(cache));
341341

342342
if (!ocf_cache_get_core_count(cache) ||
343-
ocf_cache_get_core_count(cache) == ocf_cache_get_core_inactive_count(cache)) {
343+
ocf_cache_get_core_count(cache) == ocf_cache_get_core_inactive_count(cache)) {
344344
/* If there are no cores or all of them are detached,
345345
* then cache stop can be triggered already. */
346346
ocf_mngt_cache_lock(cache, _cache_stop_lock_cb, NULL);
@@ -975,7 +975,7 @@ vbdev_ocf_submit_io(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io, ui
975975

976976
/* OCF core should be added before vbdev register and removed after vbdev unregister. */
977977
assert(core);
978-
978+
979979
io = ocf_volume_new_io(ocf_core_get_front_volume(core), ch_ctx->queue,
980980
offset, len, dir, 0, flags);
981981
if (!io) {
@@ -1158,7 +1158,7 @@ _cache_start_rpc_attach_cb(ocf_cache_t cache, void *cb_arg, int error)
11581158
ocf_mngt_cache_unlock(cache);
11591159
vbdev_ocf_core_add_from_waitlist(cache);
11601160
}
1161-
1161+
11621162
mngt_ctx->rpc_cb_fn(ocf_cache_get_name(cache), mngt_ctx->rpc_cb_arg, error);
11631163
free(mngt_ctx);
11641164
}
@@ -1279,7 +1279,7 @@ vbdev_ocf_cache_stop(const char *cache_name, vbdev_ocf_rpc_mngt_cb rpc_cb_fn, vo
12791279
mngt_ctx->cache = cache;
12801280

12811281
if (!ocf_cache_get_core_count(cache) ||
1282-
ocf_cache_get_core_count(cache) == ocf_cache_get_core_inactive_count(cache)) {
1282+
ocf_cache_get_core_count(cache) == ocf_cache_get_core_inactive_count(cache)) {
12831283
/* If there are no cores or all of them are detached,
12841284
* then cache stop can be triggered already. */
12851285
ocf_mngt_cache_lock(cache, _cache_stop_lock_cb, mngt_ctx);
@@ -1966,8 +1966,9 @@ _promotion_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
19661966
}
19671967

19681968
if (mngt_ctx->u.promotion.nhit_insertion_threshold >= 0) {
1969-
if ((rc = ocf_mngt_cache_promotion_set_param(cache, ocf_promotion_nhit, ocf_nhit_insertion_threshold,
1970-
mngt_ctx->u.promotion.nhit_insertion_threshold))) {
1969+
if ((rc = ocf_mngt_cache_promotion_set_param(cache, ocf_promotion_nhit,
1970+
ocf_nhit_insertion_threshold,
1971+
mngt_ctx->u.promotion.nhit_insertion_threshold))) {
19711972
SPDK_ERRLOG("OCF cache '%s': failed to set promotion nhit_insertion_threshold param (OCF error: %d)\n",
19721973
ocf_cache_get_name(cache), rc);
19731974
goto err_param;
@@ -1976,7 +1977,7 @@ _promotion_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
19761977

19771978
if (mngt_ctx->u.promotion.nhit_trigger_threshold >= 0) {
19781979
if ((rc = ocf_mngt_cache_promotion_set_param(cache, ocf_promotion_nhit, ocf_nhit_trigger_threshold,
1979-
mngt_ctx->u.promotion.nhit_trigger_threshold))) {
1980+
mngt_ctx->u.promotion.nhit_trigger_threshold))) {
19801981
SPDK_ERRLOG("OCF cache '%s': failed to set promotion nhit_trigger_threshold param (OCF error: %d)\n",
19811982
ocf_cache_get_name(cache), rc);
19821983
goto err_param;
@@ -2073,7 +2074,7 @@ _cleaning_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
20732074

20742075
if (mngt_ctx->u.cleaning.acp_wake_up_time >= 0) {
20752076
if ((rc = ocf_mngt_cache_cleaning_set_param(cache, ocf_cleaning_acp, ocf_acp_wake_up_time,
2076-
mngt_ctx->u.cleaning.acp_wake_up_time))) {
2077+
mngt_ctx->u.cleaning.acp_wake_up_time))) {
20772078
SPDK_ERRLOG("OCF cache '%s': failed to set cleaning acp_wake_up_time param (OCF error: %d)\n",
20782079
ocf_cache_get_name(cache), rc);
20792080
goto err_param;
@@ -2082,7 +2083,7 @@ _cleaning_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
20822083

20832084
if (mngt_ctx->u.cleaning.acp_flush_max_buffers >= 0) {
20842085
if ((rc = ocf_mngt_cache_cleaning_set_param(cache, ocf_cleaning_acp, ocf_acp_flush_max_buffers,
2085-
mngt_ctx->u.cleaning.acp_flush_max_buffers))) {
2086+
mngt_ctx->u.cleaning.acp_flush_max_buffers))) {
20862087
SPDK_ERRLOG("OCF cache '%s': failed to set cleaning acp_flush_max_buffers param (OCF error: %d)\n",
20872088
ocf_cache_get_name(cache), rc);
20882089
goto err_param;
@@ -2091,7 +2092,7 @@ _cleaning_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
20912092

20922093
if (mngt_ctx->u.cleaning.alru_wake_up_time >= 0) {
20932094
if ((rc = ocf_mngt_cache_cleaning_set_param(cache, ocf_cleaning_alru, ocf_alru_wake_up_time,
2094-
mngt_ctx->u.cleaning.alru_wake_up_time))) {
2095+
mngt_ctx->u.cleaning.alru_wake_up_time))) {
20952096
SPDK_ERRLOG("OCF cache '%s': failed to set cleaning alru_wake_up_time param (OCF error: %d)\n",
20962097
ocf_cache_get_name(cache), rc);
20972098
goto err_param;
@@ -2100,7 +2101,7 @@ _cleaning_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
21002101

21012102
if (mngt_ctx->u.cleaning.alru_flush_max_buffers >= 0) {
21022103
if ((rc = ocf_mngt_cache_cleaning_set_param(cache, ocf_cleaning_alru, ocf_alru_flush_max_buffers,
2103-
mngt_ctx->u.cleaning.alru_flush_max_buffers))) {
2104+
mngt_ctx->u.cleaning.alru_flush_max_buffers))) {
21042105
SPDK_ERRLOG("OCF cache '%s': failed to set cleaning alru_flush_max_buffers param (OCF error: %d)\n",
21052106
ocf_cache_get_name(cache), rc);
21062107
goto err_param;
@@ -2109,7 +2110,7 @@ _cleaning_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
21092110

21102111
if (mngt_ctx->u.cleaning.alru_staleness_time >= 0) {
21112112
if ((rc = ocf_mngt_cache_cleaning_set_param(cache, ocf_cleaning_alru, ocf_alru_stale_buffer_time,
2112-
mngt_ctx->u.cleaning.alru_staleness_time))) {
2113+
mngt_ctx->u.cleaning.alru_staleness_time))) {
21132114
SPDK_ERRLOG("OCF cache '%s': failed to set cleaning alru_staleness_time param (OCF error: %d)\n",
21142115
ocf_cache_get_name(cache), rc);
21152116
goto err_param;
@@ -2118,7 +2119,7 @@ _cleaning_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
21182119

21192120
if (mngt_ctx->u.cleaning.alru_activity_threshold >= 0) {
21202121
if ((rc = ocf_mngt_cache_cleaning_set_param(cache, ocf_cleaning_alru, ocf_alru_activity_threshold,
2121-
mngt_ctx->u.cleaning.alru_activity_threshold))) {
2122+
mngt_ctx->u.cleaning.alru_activity_threshold))) {
21222123
SPDK_ERRLOG("OCF cache '%s': failed to set cleaning alru_activity_threshold param (OCF error: %d)\n",
21232124
ocf_cache_get_name(cache), rc);
21242125
goto err_param;
@@ -2127,7 +2128,7 @@ _cleaning_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
21272128

21282129
if (mngt_ctx->u.cleaning.alru_max_dirty_ratio >= 0) {
21292130
if ((rc = ocf_mngt_cache_cleaning_set_param(cache, ocf_cleaning_alru, ocf_alru_max_dirty_ratio,
2130-
mngt_ctx->u.cleaning.alru_max_dirty_ratio))) {
2131+
mngt_ctx->u.cleaning.alru_max_dirty_ratio))) {
21312132
SPDK_ERRLOG("OCF cache '%s': failed to set cleaning alru_max_dirty_ratio param (OCF error: %d)\n",
21322133
ocf_cache_get_name(cache), rc);
21332134
goto err_param;
@@ -2238,15 +2239,17 @@ _seqcutoff_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
22382239
}
22392240

22402241
if (mngt_ctx->u.seqcutoff.promotion_count >= 0) {
2241-
if ((rc = ocf_mngt_core_set_seq_cutoff_promotion_count(core, mngt_ctx->u.seqcutoff.promotion_count))) {
2242+
if ((rc = ocf_mngt_core_set_seq_cutoff_promotion_count(core,
2243+
mngt_ctx->u.seqcutoff.promotion_count))) {
22422244
SPDK_ERRLOG("OCF core '%s': failed to set sequential cut-off promotion_count (OCF error: %d)\n",
22432245
ocf_core_get_name(core), rc);
22442246
goto err_param;
22452247
}
22462248
}
22472249

22482250
if (mngt_ctx->u.seqcutoff.promote_on_threshold >= 0) {
2249-
if ((rc = ocf_mngt_core_set_seq_cutoff_promote_on_threshold(core, mngt_ctx->u.seqcutoff.promote_on_threshold))) {
2251+
if ((rc = ocf_mngt_core_set_seq_cutoff_promote_on_threshold(core,
2252+
mngt_ctx->u.seqcutoff.promote_on_threshold))) {
22502253
SPDK_ERRLOG("OCF core '%s': failed to set sequential cut-off promote_on_threshold (OCF error: %d)\n",
22512254
ocf_core_get_name(core), rc);
22522255
goto err_param;
@@ -2268,23 +2271,26 @@ _seqcutoff_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
22682271
}
22692272

22702273
if (mngt_ctx->u.seqcutoff.threshold >= 0) {
2271-
if ((rc = ocf_mngt_core_set_seq_cutoff_threshold_all(cache, mngt_ctx->u.seqcutoff.threshold * KiB))) {
2274+
if ((rc = ocf_mngt_core_set_seq_cutoff_threshold_all(cache,
2275+
mngt_ctx->u.seqcutoff.threshold * KiB))) {
22722276
SPDK_ERRLOG("OCF cache '%s': failed to set sequential cut-off threshold (OCF error: %d)\n",
22732277
ocf_cache_get_name(cache), rc);
22742278
goto err_param;
22752279
}
22762280
}
22772281

22782282
if (mngt_ctx->u.seqcutoff.promotion_count >= 0) {
2279-
if ((rc = ocf_mngt_core_set_seq_cutoff_promotion_count_all(cache, mngt_ctx->u.seqcutoff.promotion_count))) {
2283+
if ((rc = ocf_mngt_core_set_seq_cutoff_promotion_count_all(cache,
2284+
mngt_ctx->u.seqcutoff.promotion_count))) {
22802285
SPDK_ERRLOG("OCF cache '%s': failed to set sequential cut-off promotion_count (OCF error: %d)\n",
22812286
ocf_cache_get_name(cache), rc);
22822287
goto err_param;
22832288
}
22842289
}
22852290

22862291
if (mngt_ctx->u.seqcutoff.promote_on_threshold >= 0) {
2287-
if ((rc = ocf_mngt_core_set_seq_cutoff_promote_on_threshold_all(cache, mngt_ctx->u.seqcutoff.promote_on_threshold))) {
2292+
if ((rc = ocf_mngt_core_set_seq_cutoff_promote_on_threshold_all(cache,
2293+
mngt_ctx->u.seqcutoff.promote_on_threshold))) {
22882294
SPDK_ERRLOG("OCF cache '%s': failed to set sequential cut-off promote_on_threshold (OCF error: %d)\n",
22892295
ocf_cache_get_name(cache), rc);
22902296
goto err_param;
@@ -2311,8 +2317,8 @@ _seqcutoff_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
23112317
/* RPC entry point. */
23122318
void
23132319
vbdev_ocf_set_seqcutoff(const char *bdev_name, const char *policy, int32_t threshold,
2314-
int32_t promotion_count, int32_t promote_on_threshold,
2315-
vbdev_ocf_rpc_mngt_cb rpc_cb_fn, void *rpc_cb_arg)
2320+
int32_t promotion_count, int32_t promote_on_threshold,
2321+
vbdev_ocf_rpc_mngt_cb rpc_cb_fn, void *rpc_cb_arg)
23162322
{
23172323
struct vbdev_ocf_mngt_ctx *mngt_ctx;
23182324
int rc;
@@ -2629,13 +2635,13 @@ dump_promotion_info(struct spdk_json_write_ctx *w, ocf_cache_t cache)
26292635

26302636
if (promotion_policy == ocf_promotion_nhit) {
26312637
if ((rc = ocf_mngt_cache_promotion_get_param(cache, ocf_promotion_nhit,
2632-
ocf_nhit_insertion_threshold, &param_val))) {
2638+
ocf_nhit_insertion_threshold, &param_val))) {
26332639
return rc;
26342640
}
26352641
spdk_json_write_named_uint32(w, "insertion_threshold", param_val);
26362642

26372643
if ((rc = ocf_mngt_cache_promotion_get_param(cache, ocf_promotion_nhit,
2638-
ocf_nhit_trigger_threshold, &param_val))) {
2644+
ocf_nhit_trigger_threshold, &param_val))) {
26392645
return rc;
26402646
}
26412647
spdk_json_write_named_uint32(w, "trigger_threshold", param_val);
@@ -2663,44 +2669,44 @@ dump_cleaning_info(struct spdk_json_write_ctx *w, ocf_cache_t cache)
26632669

26642670
if (cleaning_policy == ocf_cleaning_acp) {
26652671
if ((rc = ocf_mngt_cache_cleaning_get_param(cache, ocf_cleaning_acp,
2666-
ocf_acp_wake_up_time, &param_val))) {
2672+
ocf_acp_wake_up_time, &param_val))) {
26672673
return rc;
26682674
}
26692675
spdk_json_write_named_uint32(w, "wake_up_time", param_val);
26702676

26712677
if ((rc = ocf_mngt_cache_cleaning_get_param(cache, ocf_cleaning_acp,
2672-
ocf_acp_flush_max_buffers, &param_val))) {
2678+
ocf_acp_flush_max_buffers, &param_val))) {
26732679
return rc;
26742680
}
26752681
spdk_json_write_named_uint32(w, "flush_max_buffers", param_val);
26762682

26772683
} else if (cleaning_policy == ocf_cleaning_alru) {
26782684
if ((rc = ocf_mngt_cache_cleaning_get_param(cache, ocf_cleaning_alru,
2679-
ocf_alru_wake_up_time, &param_val))) {
2685+
ocf_alru_wake_up_time, &param_val))) {
26802686
return rc;
26812687
}
26822688
spdk_json_write_named_uint32(w, "wake_up_time", param_val);
26832689

26842690
if ((rc = ocf_mngt_cache_cleaning_get_param(cache, ocf_cleaning_alru,
2685-
ocf_alru_flush_max_buffers, &param_val))) {
2691+
ocf_alru_flush_max_buffers, &param_val))) {
26862692
return rc;
26872693
}
26882694
spdk_json_write_named_uint32(w, "flush_max_buffers", param_val);
26892695

26902696
if ((rc = ocf_mngt_cache_cleaning_get_param(cache, ocf_cleaning_alru,
2691-
ocf_alru_stale_buffer_time, &param_val))) {
2697+
ocf_alru_stale_buffer_time, &param_val))) {
26922698
return rc;
26932699
}
26942700
spdk_json_write_named_uint32(w, "staleness_time", param_val);
26952701

26962702
if ((rc = ocf_mngt_cache_cleaning_get_param(cache, ocf_cleaning_alru,
2697-
ocf_alru_activity_threshold, &param_val))) {
2703+
ocf_alru_activity_threshold, &param_val))) {
26982704
return rc;
26992705
}
27002706
spdk_json_write_named_uint32(w, "activity_threshold", param_val);
27012707

27022708
if ((rc = ocf_mngt_cache_cleaning_get_param(cache, ocf_cleaning_alru,
2703-
ocf_alru_max_dirty_ratio, &param_val))) {
2709+
ocf_alru_max_dirty_ratio, &param_val))) {
27042710
return rc;
27052711
}
27062712
spdk_json_write_named_uint32(w, "max_dirty_ratio", param_val);
@@ -2885,7 +2891,8 @@ _get_bdevs_cache_visitor(ocf_cache_t cache, void *cb_arg)
28852891

28862892
/* RPC entry point. */
28872893
void
2888-
vbdev_ocf_get_bdevs(const char *bdev_name, vbdev_ocf_rpc_dump_cb rpc_cb_fn, void *rpc_cb_arg1, void *rpc_cb_arg2)
2894+
vbdev_ocf_get_bdevs(const char *bdev_name, vbdev_ocf_rpc_dump_cb rpc_cb_fn, void *rpc_cb_arg1,
2895+
void *rpc_cb_arg2)
28892896
{
28902897
struct spdk_json_write_ctx *w = rpc_cb_arg1;
28912898
struct vbdev_ocf_core *core_ctx;

0 commit comments

Comments
 (0)