[lustre-devel] [PATCH 144/622] lustre: osc: re-check target versus available grant
James Simmons
jsimmons at infradead.org
Thu Feb 27 13:10:12 PST 2020
From: Alex Zhuravlev <bzzz at whamcloud.com>
- under the spinlock, otherwise it's possible that available
grant has changed since target calculation and bytes to
shrink go negative.
- tgt_grant_alloc() should avoid negative grants
WC-bug-id: https://jira.whamcloud.com/browse/LU-11288
Lustre-commit: fcbd8c981239 ("LU-11288 osc: re-check target versus available grant")
Signed-off-by: Alex Zhuravlev <bzzz at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/33226
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Bobi Jam <bobijam at hotmail.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
fs/lustre/osc/osc_request.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/lustre/osc/osc_request.c b/fs/lustre/osc/osc_request.c
index 4524a98..18b99a9 100644
--- a/fs/lustre/osc/osc_request.c
+++ b/fs/lustre/osc/osc_request.c
@@ -811,6 +811,12 @@ int osc_shrink_grant_to_target(struct client_obd *cli, u64 target_bytes)
osc_announce_cached(cli, &body->oa, 0);
spin_lock(&cli->cl_loi_list_lock);
+ if (target_bytes >= cli->cl_avail_grant) {
+ /* available grant has changed since target calculation */
+ spin_unlock(&cli->cl_loi_list_lock);
+ rc = 0;
+ goto out_free;
+ }
body->oa.o_grant = cli->cl_avail_grant - target_bytes;
cli->cl_avail_grant = target_bytes;
spin_unlock(&cli->cl_loi_list_lock);
@@ -826,6 +832,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, u64 target_bytes)
sizeof(*body), body, NULL);
if (rc != 0)
__osc_update_grant(cli, body->oa.o_grant);
+out_free:
kfree(body);
return rc;
}
--
1.8.3.1
More information about the lustre-devel
mailing list