queued_cmd ownership
I think we need to go to an alloc/free model for ata_queued_cmd, so that the creator can own the results after the queued_cmd is complete.
Jeff
Quoted 4 lines · Jeff Garzik
I think we need to go to an alloc/free model for
ata_queued_cmd, so that the creator can own the results after thequeued_cmdis complete.
I've no good idea for this issue; only the following quick fix.
Changes:
- Add "void *complete_data" to ata_queued_cmd as private parameter for the complete function.
- Let the internal complete function (ata_qc_complete_noop() and ata_identify_complete()) copy out the err_mask from the HSM thread to the caller thread, via qc->complete_data, before the qc is completed.
- add check for the err_mask result in the functions using internal commands:
ex. - ata_dev_identify()
- ata_dev_set_xfermode()
- ata_dev_init_params()
- ata_dev_reread_id()
- Add a new "ata_identify_complete()" complete function for ata_dev_identify() such that if an error is found, the "ata_identify_complete()" returns non-zero and qc will not be fully completed.
The caller thread can reuse the qc and do additional processing on the qc. (modeled after the qc reuse case as in the recent atapi error handling patch) The caller thread has to call __ata_qc_complete() explicitly for such not-fully-completed qc.
- In ata_qc_complete(): notify the thread waiting on the "qc->waiting" completion when the callback indicates not to fully complete the command (non-zero).
This is to make the waiting works for ata_identify_complete() under the not-fully-completed qc case.
Patch against the libata-dev upstream-fixes branch (c6e6e666cbfe40f0d7fb1a293ff6332973acac37).
For your review and comment, thanks.
Albert
===========
include/linux/libata.h +1 -0
@@ -280,6 +280,7 @@ struct ata_queued_cmd {struct scatterlist *__sg;ata_qc_cb_t complete_fn; +void *complete_data;struct completion *waiting;
drivers/scsi/libata-core.c +76 -16
209 lines not on this page · raw message