No need to have these helpers inline. Also remove the stubs and just use an IS_ENABLED for the get side (the set side already is only built conditionlly).
Unified · Split
| @@ -16,6 +16,7 @@ obj-$(CONFIG_BLK_DEV_BSG_COMMON) += bsg.o · 15 unmodified lines | ||
| 16 | 16 | obj-$(CONFIG_BLK_DEV_BSGLIB) += bsg-lib.o |
| 17 | 17 | obj-$(CONFIG_BLK_CGROUP) += blk-cgroup.o |
| 18 | 18 | obj-$(CONFIG_BLK_CGROUP_RWSTAT) += blk-cgroup-rwstat.o |
| 19 | +obj-$(CONFIG_BLK_CGROUP_FC_APPID) += blk-cgroup-fc-appid.o | |
| 19 | 20 | obj-$(CONFIG_BLK_DEV_THROTTLING) += blk-throttle.o |
| 20 | 21 | obj-$(CONFIG_BLK_CGROUP_IOPRIO) += blk-ioprio.o |
| 21 | 22 | obj-$(CONFIG_BLK_CGROUP_IOLATENCY) += blk-iolatency.o |
| @@ -0,0 +1,57 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | + | |
| 3 | +#include "blk-cgroup.h" | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * blkcg_set_fc_appid - set the fc_app_id field associted to blkcg | |
| 7 | + * @app_id: application identifier | |
| 8 | + * @cgrp_id: cgroup id | |
| 9 | + * @app_id_len: size of application identifier | |
| 10 | + */ | |
| 11 | +int blkcg_set_fc_appid(char *app_id, u64 cgrp_id, size_t app_id_len) | |
| 12 | +{ | |
| 13 | + struct cgroup *cgrp; | |
| 14 | + struct cgroup_subsys_state *css; | |
| 15 | + struct blkcg *blkcg; | |
| 16 | + int ret = 0; | |
| 17 | + | |
| 18 | + if (app_id_len > FC_APPID_LEN) | |
| 19 | + return -EINVAL; | |
| 20 | + | |
| 21 | + cgrp = cgroup_get_from_id(cgrp_id); | |
| 22 | + if (!cgrp) | |
| 23 | + return -ENOENT; | |
| 24 | + css = cgroup_get_e_css(cgrp, &io_cgrp_subsys); | |
| 25 | + if (!css) { | |
| 26 | + ret = -ENOENT; | |
| 27 | + goto out_cgrp_put; | |
| 28 | + } | |
| 29 | + blkcg = css_to_blkcg(css); | |
| 30 | + /* | |
| 31 | + * There is a slight race condition on setting the appid. | |
| 32 | + * Worst case an I/O may not find the right id. | |
| 33 | + * This is no different from the I/O we let pass while obtaining | |
| 34 | + * the vmid from the fabric. | |
| 35 | + * Adding the overhead of a lock is not necessary. | |
| 36 | + */ | |
| 37 | + strlcpy(blkcg->fc_app_id, app_id, app_id_len); | |
| 38 | + css_put(css); | |
| 39 | +out_cgrp_put: | |
| 40 | + cgroup_put(cgrp); | |
| 41 | + return ret; | |
| 42 | +} | |
| 43 | +EXPORT_SYMBOL_GPL(blkcg_set_fc_appid); | |
| 44 | + | |
| 45 | +/** | |
| 46 | + * blkcg_get_fc_appid - get the fc app identifier associated with a bio | |
| 47 | + * @bio: target bio | |
| 48 | + * | |
| 49 | + * On success return the fc_app_id, on failure return NULL | |
| 50 | + */ | |
| 51 | +char *blkcg_get_fc_appid(struct bio *bio) | |
| 52 | +{ | |
| 53 | + if (!bio->bi_blkg || bio->bi_blkg->blkcg->fc_app_id[0] == '\0') | |
| 54 | + return NULL; | |
| 55 | + return bio->bi_blkg->blkcg->fc_app_id; | |
| 56 | +} | |
| 57 | +EXPORT_SYMBOL_GPL(blkcg_get_fc_appid); | |
| @@ -5528,7 +5528,9 @@ static char *lpfc_is_command_vm_io(struct scsi_cmnd *cmd) · 5527 unmodified lines | ||
| 5528 | 5528 | { |
| 5529 | 5529 | struct bio *bio = scsi_cmd_to_rq(cmd)->bio; |
| 5530 | 5530 | |
| 5531 | − return bio ? blkcg_get_fc_appid(bio) : NULL; | |
| 5531 | + if (!IS_ENABLED(CONFIG_BLK_CGROUP_FC_APPID) || !bio) | |
| 5532 | + return NULL; | |
| 5533 | + return blkcg_get_fc_appid(bio); | |
| 5532 | 5534 | } |
| 5533 | 5535 | |
| 5534 | 5536 | /** |
| @@ -218,61 +218,7 @@ static inline struct blkcg *bio_blkcg(struct bio *bio) { return NULL; } · 217 unmodified lines | ||
| 218 | 218 | |
| 219 | 219 | #endif /* CONFIG_BLK_CGROUP */ |
| 220 | 220 | |
| 221 | −#ifdef CONFIG_BLK_CGROUP_FC_APPID | |
| 222 | −/* | |
| 223 | − * Sets the fc_app_id field associted to blkcg | |
| 224 | − * @app_id: application identifier | |
| 225 | − * @cgrp_id: cgroup id | |
| 226 | − * @app_id_len: size of application identifier | |
| 227 | − */ | |
| 228 | −static inline int blkcg_set_fc_appid(char *app_id, u64 cgrp_id, size_t app_id_len) | |
| 229 | −{ | |
| 230 | − struct cgroup *cgrp; | |
| 231 | − struct cgroup_subsys_state *css; | |
| 232 | − struct blkcg *blkcg; | |
| 233 | − int ret = 0; | |
| 234 | − | |
| 235 | − if (app_id_len > FC_APPID_LEN) | |
| 236 | − return -EINVAL; | |
| 237 | − | |
| 238 | − cgrp = cgroup_get_from_id(cgrp_id); | |
| 239 | − if (!cgrp) | |
| 240 | − return -ENOENT; | |
| 241 | − css = cgroup_get_e_css(cgrp, &io_cgrp_subsys); | |
| 242 | − if (!css) { | |
| 243 | − ret = -ENOENT; | |
| 244 | − goto out_cgrp_put; | |
| 245 | − } | |
| 246 | − blkcg = css_to_blkcg(css); | |
| 247 | − /* | |
| 248 | − * There is a slight race condition on setting the appid. | |
| 249 | − * Worst case an I/O may not find the right id. | |
| 250 | − * This is no different from the I/O we let pass while obtaining | |
| 251 | − * the vmid from the fabric. | |
| 252 | − * Adding the overhead of a lock is not necessary. | |
| 253 | − */ | |
| 254 | − strlcpy(blkcg->fc_app_id, app_id, app_id_len); | |
| 255 | − css_put(css); | |
| 256 | −out_cgrp_put: | |
| 257 | − cgroup_put(cgrp); | |
| 258 | − return ret; | |
| 259 | −} | |
| 221 | +int blkcg_set_fc_appid(char *app_id, u64 cgrp_id, size_t app_id_len); | |
| 222 | +char *blkcg_get_fc_appid(struct bio *bio); | |
| 260 | 223 | |
| 261 | −/** | |
| 262 | − * blkcg_get_fc_appid - get the fc app identifier associated with a bio | |
| 263 | − * @bio: target bio | |
| 264 | − * | |
| 265 | − * On success return the fc_app_id, on failure return NULL | |
| 266 | − */ | |
| 267 | −static inline char *blkcg_get_fc_appid(struct bio *bio) | |
| 268 | −{ | |
| 269 | − if (bio && bio->bi_blkg && | |
| 270 | − (bio->bi_blkg->blkcg->fc_app_id[0] != '\0')) | |
| 271 | − return bio->bi_blkg->blkcg->fc_app_id; | |
| 272 | − return NULL; | |
| 273 | −} | |
| 274 | −#else | |
| 275 | −static inline int blkcg_set_fc_appid(char *buf, u64 id, size_t len) { return -EINVAL; } | |
| 276 | −static inline char *blkcg_get_fc_appid(struct bio *bio) { return NULL; } | |
| 277 | −#endif /*CONFIG_BLK_CGROUP_FC_APPID*/ | |
| 278 | 224 | #endif /* _BLK_CGROUP_H */ |