@@ -664,11 +664,12 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
oa->o_undirty = 0;
} else {
unsigned long nrpages;
+ unsigned long undirty;
nrpages = cli->cl_max_pages_per_rpc;
nrpages *= cli->cl_max_rpcs_in_flight + 1;
nrpages = max(nrpages, cli->cl_dirty_max_pages);
- oa->o_undirty = nrpages << PAGE_SHIFT;
+ undirty = nrpages << PAGE_SHIFT;
if (OCD_HAS_FLAG(&cli->cl_import->imp_connect_data,
GRANT_PARAM)) {
int nrextents;
@@ -679,8 +680,13 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
*/
nrextents = DIV_ROUND_UP(nrpages,
cli->cl_max_extent_pages);
- oa->o_undirty += nrextents * cli->cl_grant_extent_tax;
+ undirty += nrextents * cli->cl_grant_extent_tax;
}
+ /* Do not ask for more than OBD_MAX_GRANT - a margin for server
+ * to add extent tax, etc.
+ */
+ oa->o_undirty = min(undirty, OBD_MAX_GRANT -
+ (PTLRPC_MAX_BRW_PAGES << PAGE_SHIFT)*4UL);
}
oa->o_grant = cli->cl_avail_grant + cli->cl_reserved_grant;
oa->o_dropped = cli->cl_lost_grant;
@@ -1213,6 +1213,8 @@ struct hsm_state_set {
* it to sync quickly
*/
+#define OBD_MAX_GRANT 0x7fffffffUL /* Max grant allowed to one client: 2 GiB */
+
#define OBD_OBJECT_EOF LUSTRE_EOF
#define OST_MIN_PRECREATE 32