Re: [PATCH 2/3] scsi: add sd_unprep_fn to free discard page

Christoph Hellwig
2010-07-02T10:48:24Z

> sd_unprep() uses rq->buffer to free discard page allocated in
> sd_prepare_discard().

Eeek. Accessing it using the bio in both haves seems a lot cleaner than
abusing this. Especially as we don't really need a mapped page anyway
at least for WRITE SAME implementation.

> - return scsi_setup_blk_pc_cmnd(sdp, rq);
> + ret = scsi_setup_blk_pc_cmnd(sdp, rq);
> + rq->buffer = page_address(page);
> + return ret;

In addition I don't think this is quite correct. You still need to undo
the payload addition manually if scsi_setup_blk_pc_cmnd fails, as we
haven't marked the request as REQ_DONTPREP at that point - it's only
done by scsi_prep_return for the BLKPREP_OK case.