Scott, do you mean to make it larger than the calculated value? If larger, there is a danger that the I/O will fail because the number of chains in the I/O could exceed the MaxChainDepth of the controller. But, the calculated value is also based on the smallest SG element allowed for every SG element (PAGE_SIZE), so the max I/O can actually be much larger than the calculated max I/O. Maybe a warning message could be printed if the user's max I/O size is larger than the calculated size. Would that work?
Smaller than the calculated value is what I meant. It's a convenient backstop against unexpected code, disk, and controller bugs. Just a simple cpi->maxio = min(sc->user_max_io, cpi->maxio);
I could default the user value to 0, which would force the driver to use the calculated value. If not 0, then use the user value. Otherwise, we don't really know what to default the value to and we're back to using a guess. Sound OK?
Actually I would set the default user value to 0xffffffff, and then do a min() calculation with that and the calculated value. That way you never go above the calculated value, but you can go lower (maybe clip the lower value to something sensible, not allow absurdly low values like '1').
Rewrote a little to use a new sysctl variable (max_io_pages). This is the max number of pages that a user wants to use per I/O. The driver will use the lesser of this new value and the calculated value from IOCFacts. The default for max_io_pages is -1, meaning the driver will use IOCFacts.