mmc: block: do not query the sd card if a fault is injected

When the fault injection framework introduces an error to the data
block, the current code queries the SD card to find the number of
blocks actually programmed. This value would be as requested by the
generic block layer. So the entire request would be completed.

Say, request 0 is pulled from queue and submitted. When this is being
processed, request 1 is pulled from queue and prepared. Request 0
though is successful, fault-injection framework injects an error
and modifies the bytes_xferred variable to a random value less than
requested transfer. Request 1 is not processed and during the handling
of error, the SD card is queried for the actual bytes programmed. This
would be the correct value. Thus blk_end_request would complete
this request and the control would return to fetch request 2. In this
process, request 1 is not processed at all and the application waits
indefinitely for request 1 to be processed. No further requests are
issued to the queue.

This patch identifies, if the fault injection-framework has inserted an
error to this request and doesn't query the card and uses
bytes_xferred to complete the request.

Change-Id: I496802e244745bc7550402027a594d967cf7b756
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This commit is contained in:
Asutosh Das 2012-07-27 18:10:19 +05:30 committed by Subhash Jadavani
parent 883e57df75
commit fd7c52accf
3 changed files with 10 additions and 5 deletions

View file

@ -1487,6 +1487,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
brq->stop.arg = 0;
brq->data.blocks = blk_rq_sectors(req);
brq->data.fault_injected = false;
/*
* The block layer doesn't support all sector count
* restrictions, so we need to be prepared for too big
@ -1807,6 +1808,7 @@ static void mmc_blk_packed_hdr_wrq_prep(struct mmc_queue_req *mqrq,
brq->data.blksz = 512;
brq->data.blocks = packed->blocks + hdr_blocks;
brq->data.flags |= MMC_DATA_WRITE;
brq->data.fault_injected = false;
brq->stop.opcode = MMC_STOP_TRANSMISSION;
brq->stop.arg = 0;
@ -1840,11 +1842,12 @@ static int mmc_blk_cmd_err(struct mmc_blk_data *md, struct mmc_card *card,
*/
if (mmc_card_sd(card)) {
u32 blocks;
blocks = mmc_sd_num_wr_blocks(card);
if (blocks != (u32)-1) {
ret = blk_end_request(req, 0, blocks << 9);
}
if (!brq->data.fault_injected) {
blocks = mmc_sd_num_wr_blocks(card);
if (blocks != (u32)-1)
ret = blk_end_request(req, 0, blocks << 9);
} else
ret = blk_end_request(req, 0, brq->data.bytes_xfered);
} else {
if (!mmc_packed_cmd(mq_rq->cmd_type))
ret = blk_end_request(req, 0, brq->data.bytes_xfered);

View file

@ -112,6 +112,7 @@ static void mmc_should_fail_request(struct mmc_host *host,
data->error = data_errors[prandom_u32() % ARRAY_SIZE(data_errors)];
data->bytes_xfered = (prandom_u32() % (data->bytes_xfered >> 9)) << 9;
data->fault_injected = true;
}
#else /* CONFIG_FAIL_MMC_REQUEST */

View file

@ -93,6 +93,7 @@ struct mmc_data {
int sg_count; /* mapped sg entries */
struct scatterlist *sg; /* I/O scatter list */
s32 host_cookie; /* host private data */
bool fault_injected; /* fault injected */
};
struct mmc_host;