From: Andreas Dilger Date: Thu, 14 Jan 2021 16:01:21 +0000 (-0700) Subject: LU-14283 osc: avoid crash if ocd reset X-Git-Tag: 2.14.0-RC1~8 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=1ec58a2e6ef98bacbb806f1b141ef38cdefe2226;p=fs%2Flustre-release.git LU-14283 osc: avoid crash if ocd reset Avoid divide-by-zero if OSC obd_connect_data is not fully initialized. cl_ocd_grant_param is only set after cl_max_extent_pages is OK to use. Signed-off-by: Andreas Dilger Change-Id: Ibcee30b46e24ca3d4c2b571b27f3c0bb43f4bf71 Reviewed-on: https://review.whamcloud.com/41225 Tested-by: jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Wang Shilong Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/obd.h b/lustre/include/obd.h index ddc37d1..3adc7db 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -215,6 +215,9 @@ struct client_obd { */ __u32 cl_dom_min_inline_repsize; + unsigned int cl_checksum:1, /* 0 = disabled, 1 = enabled */ + cl_checksum_dump:1, /* same */ + cl_ocd_grant_param:1; enum lustre_sec_part cl_sp_me; enum lustre_sec_part cl_sp_to; struct sptlrpc_flavor cl_flvr_mgc; /* fixed flavor of mgc->mgs */ @@ -342,9 +345,6 @@ struct client_obd { struct list_head cl_flight_waiters; __u32 cl_rpcs_in_flight; - /* checksumming for data sent over the network */ - unsigned int cl_checksum:1, /* 0 = disabled, 1 = enabled */ - cl_checksum_dump:1; /* same */ /* supported checksum types that are worked out at connect time */ __u32 cl_supp_cksum_types; /* checksum algorithm to be used */ diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 4ec83b6..6dbfcee 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -699,7 +699,7 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, oa->o_valid |= bits; spin_lock(&cli->cl_loi_list_lock); - if (OCD_HAS_FLAG(&cli->cl_import->imp_connect_data, GRANT_PARAM)) + if (cli->cl_ocd_grant_param) oa->o_dirty = cli->cl_dirty_grant; else oa->o_dirty = cli->cl_dirty_pages << PAGE_SHIFT; @@ -730,13 +730,12 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, nrpages *= cli->cl_max_rpcs_in_flight + 1; nrpages = max(nrpages, cli->cl_dirty_max_pages); undirty = nrpages << PAGE_SHIFT; - if (OCD_HAS_FLAG(&cli->cl_import->imp_connect_data, - GRANT_PARAM)) { + if (cli->cl_ocd_grant_param) { int nrextents; /* take extent tax into account when asking for more * grant space */ - nrextents = (nrpages + cli->cl_max_extent_pages - 1) / + nrextents = (nrpages + cli->cl_max_extent_pages - 1) / cli->cl_max_extent_pages; undirty += nrextents * cli->cl_grant_extent_tax; } @@ -1062,10 +1061,10 @@ void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd) ~chunk_mask) & chunk_mask; /* determine maximum extent size, in #pages */ size = (u64)ocd->ocd_grant_max_blks << ocd->ocd_grant_blkbits; - cli->cl_max_extent_pages = size >> PAGE_SHIFT; - if (cli->cl_max_extent_pages == 0) - cli->cl_max_extent_pages = 1; + cli->cl_max_extent_pages = (size >> PAGE_SHIFT) ?: 1; + cli->cl_ocd_grant_param = 1; } else { + cli->cl_ocd_grant_param = 0; cli->cl_grant_extent_tax = 0; cli->cl_chunkbits = PAGE_SHIFT; cli->cl_max_extent_pages = DT_MAX_BRW_PAGES;