Fix a case where a request frame can be composed that requires 2 or more
SGList elements, but there's only enough space in the request frame for either 1 element or a chain frame pointer. Previously, the code would hit the wrong case, add the SGList element, but then fail to add the chain frame due to lack of space. Re-arrange the code to catch this case earlier and handle it. Sponsored by: Netflix
This commit is contained in:
parent
99e7a4ad9e
commit
4b07a5606c
@ -2609,6 +2609,17 @@ mps_push_sge(struct mps_command *cm, void *sgep, size_t len, int segsleft)
|
||||
if (cm->cm_sglsize < MPS_SGC_SIZE)
|
||||
panic("MPS: Need SGE Error Code\n");
|
||||
|
||||
if (segsleft >= 1 && cm->cm_sglsize < len + MPS_SGC_SIZE) {
|
||||
/*
|
||||
* 1 or more segment, enough room for only a chain.
|
||||
* Hope the previous element wasn't a Simple entry
|
||||
* that needed to be marked with
|
||||
* MPI2_SGE_FLAGS_LAST_ELEMENT. Case (4).
|
||||
*/
|
||||
if ((error = mps_add_chain(cm)) != 0)
|
||||
return (error);
|
||||
}
|
||||
|
||||
if (segsleft >= 2 &&
|
||||
cm->cm_sglsize < len + MPS_SGC_SIZE + MPS_SGE64_SIZE) {
|
||||
/*
|
||||
@ -2633,17 +2644,6 @@ mps_push_sge(struct mps_command *cm, void *sgep, size_t len, int segsleft)
|
||||
return (mps_add_chain(cm));
|
||||
}
|
||||
|
||||
if (segsleft >= 1 && cm->cm_sglsize < len + MPS_SGC_SIZE) {
|
||||
/*
|
||||
* 1 or more segment, enough room for only a chain.
|
||||
* Hope the previous element wasn't a Simple entry
|
||||
* that needed to be marked with
|
||||
* MPI2_SGE_FLAGS_LAST_ELEMENT. Case (4).
|
||||
*/
|
||||
if ((error = mps_add_chain(cm)) != 0)
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifdef INVARIANTS
|
||||
/* Case 1: 1 more segment, enough room for it. */
|
||||
if (segsleft == 1 && cm->cm_sglsize < len)
|
||||
|
Loading…
Reference in New Issue
Block a user