Commit f96aa905 authored by Mikhail Pershin's avatar Mikhail Pershin Committed by Oleg Drokin
Browse files

LU-13763 osc: don't allow negative grants

Add check in the osc_init_grant() to prevent possible
underflow of cl_avail_grant and report error if it happens

Lustre-change: https://review.whamcloud.com/#/c/39827
Lustre-commit: e05ccafd

Signed-off-by: default avatarMikhail Pershin <mpershin@whamcloud.com>
Change-Id: Idcd25ed427c23735e1cdc70359bace43b5b9d886
Reviewed-on: https://review.whamcloud.com/39380

Tested-by: default avatarjenkins <devops@whamcloud.com>
Reviewed-by: default avatarOleg Drokin <green@whamcloud.com>
parent ab95f0c3
......@@ -964,12 +964,19 @@ void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd)
spin_lock(&cli->cl_loi_list_lock);
cli->cl_avail_grant = ocd->ocd_grant;
if (cli->cl_import->imp_state != LUSTRE_IMP_EVICTED) {
cli->cl_avail_grant -= cli->cl_reserved_grant;
unsigned long consumed = cli->cl_reserved_grant;
if (OCD_HAS_FLAG(ocd, GRANT_PARAM))
cli->cl_avail_grant -= cli->cl_dirty_grant;
consumed += cli->cl_dirty_grant;
else
cli->cl_avail_grant -=
cli->cl_dirty_pages << PAGE_SHIFT;
consumed += cli->cl_dirty_pages << PAGE_SHIFT;
if (cli->cl_avail_grant < consumed) {
CERROR("%s: granted %ld but already consumed %ld\n",
cli_name(cli), cli->cl_avail_grant, consumed);
cli->cl_avail_grant = 0;
} else {
cli->cl_avail_grant -= consumed;
}
}
if (OCD_HAS_FLAG(ocd, GRANT_PARAM)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment