// SPDX-License-Identifier: GPL-2.012#include "blk-cgroup.h"34/**5* blkcg_set_fc_appid - set the fc_app_id field associted to blkcg6* @app_id: application identifier7* @cgrp_id: cgroup id8* @app_id_len: size of application identifier9*/10int blkcg_set_fc_appid(char *app_id, u64 cgrp_id, size_t app_id_len)11{12struct cgroup *cgrp;13struct cgroup_subsys_state *css;14struct blkcg *blkcg;15int ret = 0;1617if (app_id_len > FC_APPID_LEN)18return -EINVAL;1920cgrp = cgroup_get_from_id(cgrp_id);21if (IS_ERR(cgrp))22return PTR_ERR(cgrp);23css = cgroup_get_e_css(cgrp, &io_cgrp_subsys);24if (!css) {25ret = -ENOENT;26goto out_cgrp_put;27}28blkcg = css_to_blkcg(css);29/*30* There is a slight race condition on setting the appid.31* Worst case an I/O may not find the right id.32* This is no different from the I/O we let pass while obtaining33* the vmid from the fabric.34* Adding the overhead of a lock is not necessary.35*/36strscpy(blkcg->fc_app_id, app_id, app_id_len);37css_put(css);38out_cgrp_put:39cgroup_put(cgrp);40return ret;41}42EXPORT_SYMBOL_GPL(blkcg_set_fc_appid);4344/**45* blkcg_get_fc_appid - get the fc app identifier associated with a bio46* @bio: target bio47*48* On success return the fc_app_id, on failure return NULL49*/50char *blkcg_get_fc_appid(struct bio *bio)51{52if (!bio->bi_blkg || bio->bi_blkg->blkcg->fc_app_id[0] == '\0')53return NULL;54return bio->bi_blkg->blkcg->fc_app_id;55}56EXPORT_SYMBOL_GPL(blkcg_get_fc_appid);575859