1 // SPDX-License-Identifier: GPL-2.0
3 #include "blk-cgroup.h"
6 * blkcg_set_fc_appid - set the fc_app_id field associted to blkcg
7 * @app_id: application identifier
9 * @app_id_len: size of application identifier
11 int blkcg_set_fc_appid(char *app_id
, u64 cgrp_id
, size_t app_id_len
)
14 struct cgroup_subsys_state
*css
;
18 if (app_id_len
> FC_APPID_LEN
)
21 cgrp
= cgroup_get_from_id(cgrp_id
);
24 css
= cgroup_get_e_css(cgrp
, &io_cgrp_subsys
);
29 blkcg
= css_to_blkcg(css
);
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.
37 strscpy(blkcg
->fc_app_id
, app_id
, app_id_len
);
43 EXPORT_SYMBOL_GPL(blkcg_set_fc_appid
);
46 * blkcg_get_fc_appid - get the fc app identifier associated with a bio
49 * On success return the fc_app_id, on failure return NULL
51 char *blkcg_get_fc_appid(struct bio
*bio
)
53 if (!bio
->bi_blkg
|| bio
->bi_blkg
->blkcg
->fc_app_id
[0] == '\0')
55 return bio
->bi_blkg
->blkcg
->fc_app_id
;
57 EXPORT_SYMBOL_GPL(blkcg_get_fc_appid
);