Skip to content

Commit

Permalink
In ltop, show >=2 rows in MDT window if displayed
Browse files Browse the repository at this point in the history
Make MDT window always show at least 2 MDTs if there is room to have an
MDT window at all.

Clean up window sizing logic to make it easier to reason about.

Fix a bug in logic to proportionately allocate rows to OST and MDT
windows.  MDT window detail window only had 1 row if the window was too
small to show all targets.
  • Loading branch information
ofaaland committed Sep 15, 2018
1 parent 6ec5155 commit f780089
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions utils/ltop.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,30 +305,30 @@ void
size_windows(int total_size, int mdts, int osts,
int *mdtlines, int *ostlines)
{
int headers = 2; /* max lines occupied by MDT and OST headers */
int extra = total_size - (TOPWIN_LINES + mdts + osts + headers);

if (total_size <= TOPWIN_LINES) {
if (total_size <= (TOPWIN_LINES+2)) {
*mdtlines = 0;
*ostlines = 0;
} else {
if (mdts < 2 || (total_size < (TOPWIN_LINES + headers + 2))) {
if (mdts < 2) {
// no need for per-mdt lines OR
// only big enough for topwin + small OST section
*mdtlines = 0;
*ostlines = total_size - TOPWIN_LINES;
} else {
/* big enough for both MDT and OST sections, and >1 MDT */
if (extra >= 0) {
/* enough room to display everything */
*mdtlines = mdts+1;
*ostlines = osts+1;
if (total_size <= (TOPWIN_LINES + 5)) {
// only big enough for topwin + small OST section
*mdtlines = 0;
} else {
/* OST and MDT section sizes proportional to target counts */
*mdtlines = mdts + 1 + ((float)extra*mdts) / ((float)mdts+osts);
*ostlines = total_size - (TOPWIN_LINES + *mdtlines);
int detail_size = total_size - TOPWIN_LINES;
/*
* OST and MDT section sizes proportional to target counts,
* except that we allow space for at least 2 MDTs since we know
* there is more than one MDT.
*/
*mdtlines = 2 + ((float)detail_size*mdts) / ((float)mdts+osts);
*mdtlines = (*mdtlines < 3 ? 3 : *mdtlines);
*mdtlines = (*mdtlines > (mdts+2) ? (mdts+2) : *mdtlines);
}
}
*ostlines = total_size - (TOPWIN_LINES + *mdtlines);
}
}

Expand Down

0 comments on commit f780089

Please sign in to comment.