Skip to content

Commit ad3ebde

Browse files
set metadata priority to maximum and use macros for min and max priorities
1 parent cd367e3 commit ad3ebde

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

include/spdk/priority_class.h

+2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ class mask PRIORITY_CLASS_MASK to get the priority class as an integer
88
#define PRIORITY_CLASS_BITS_POS (64 - NBITS_PRIORITY_CLASS)
99
#define PRIORITY_CLASS_MASK (0xFFFFFFFFFFFFFFFF << PRIORITY_CLASS_BITS_POS)
1010
#define MASK_OUT_PRIORITY_CLASS (~PRIORITY_CLASS_MASK)
11+
#define MIN_PRIORITY_CLASS 0
12+
#define MAX_PRIORITY_CLASS ((1 << NBITS_PRIORITY_CLASS) - 1)
1113

1214
#endif

lib/blob/blobstore.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3915,6 +3915,8 @@ bs_alloc(struct spdk_bs_dev *dev, struct spdk_bs_opts *opts, struct spdk_blob_st
39153915
bs->md_thread = spdk_get_thread();
39163916
assert(bs->md_thread != NULL);
39173917

3918+
bs->priority_class = MAX_PRIORITY_CLASS; // max priority for metadata I/O
3919+
39183920
/*
39193921
* Do not use bs_lba_to_cluster() here since blockcnt may not be an
39203922
* even multiple of the cluster size.
@@ -10300,8 +10302,6 @@ void
1030010302
spdk_blob_set_priority_class(struct spdk_blob* blob, int priority_class)
1030110303
{
1030210304
blob->priority_class = priority_class;
10303-
int old_bs_priority_class = blob->bs->priority_class;
10304-
blob->bs->priority_class = spdk_max(old_bs_priority_class, blob->priority_class);
1030510305
}
1030610306

1030710307
SPDK_LOG_REGISTER_COMPONENT(blob)

module/bdev/lvol/vbdev_lvol_rpc.c

+4-8
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,8 @@ rpc_bdev_lvol_create(struct spdk_jsonrpc_request *request,
369369
clear_method = LVOL_CLEAR_WITH_DEFAULT;
370370
}
371371

372-
const int min_priority_class = 0;
373-
const int max_priority_class = (1 << NBITS_PRIORITY_CLASS) - 1;
374-
if (!(req.lvol_priority_class >= min_priority_class && req.lvol_priority_class <= max_priority_class)) {
375-
SPDK_ERRLOG("lvol priority class is not within the allowed range of [%d, %d]", min_priority_class, max_priority_class);
372+
if (!(req.lvol_priority_class >= MIN_PRIORITY_CLASS && req.lvol_priority_class <= MAX_PRIORITY_CLASS)) {
373+
SPDK_ERRLOG("lvol priority class is not within the allowed range of [%d, %d]", MIN_PRIORITY_CLASS, MAX_PRIORITY_CLASS);
376374
spdk_jsonrpc_send_error_response(request, -EINVAL, spdk_strerror(EINVAL));
377375
goto cleanup;
378376
}
@@ -1712,10 +1710,8 @@ void rpc_bdev_lvol_set_priority_class(struct spdk_jsonrpc_request *request,
17121710
goto cleanup;
17131711
}
17141712

1715-
const int min_priority_class = 0;
1716-
const int max_priority_class = (1 << NBITS_PRIORITY_CLASS) - 1;
1717-
if (!(req.lvol_priority_class >= min_priority_class && req.lvol_priority_class <= max_priority_class)) {
1718-
SPDK_ERRLOG("lvol priority class is not within the allowed range of [%d, %d]", min_priority_class, max_priority_class);
1713+
if (!(req.lvol_priority_class >= MIN_PRIORITY_CLASS && req.lvol_priority_class <= MAX_PRIORITY_CLASS)) {
1714+
SPDK_ERRLOG("lvol priority class is not within the allowed range of [%d, %d]", MIN_PRIORITY_CLASS, MAX_PRIORITY_CLASS);
17191715
spdk_jsonrpc_send_error_response(request, -EINVAL, spdk_strerror(EINVAL));
17201716
goto cleanup;
17211717
}

0 commit comments

Comments
 (0)