Re: [PATCHv3 4/4] nvme: use return value from blk_execute_rq()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +/*
> + * Return values:
> + * 0:  success
> + * >0: nvme controller's cqe status response
> + * <0: kernel error in lieu of controller response
> + */

For better reading flow I'd reformat this as:

/*
 * Return value:
 *   0:	success
 * > 0:	nvme controller's cqe status response
 * < 0: kernel error in lieu of controller response
 */

> +static int nvme_passthrough_status(struct request *rq, blk_status_t status)
> +{
> +	if (nvme_req(rq)->flags & NVME_REQ_CANCELLED)
> +		return -EINTR;
> +	else if (nvme_req(rq)->status)
> +		return nvme_req(rq)->status;
> +	return blk_status_to_errno(status);
> +}

I find this a little odd disconnected from the actual execure call.
What about a helper like this instead:

static int nvme_execute_rq(struct gendisk *disk, struct request *rq,
		bool at_head)
{
	blk_status_t status;

	status = blk_execute_rq(disk, req, at_head);
	if (nvme_req(rq)->flags & NVME_REQ_CANCELLED)
		return -EINTR;
	if (nvme_req(rq)->status)
		return nvme_req(rq)->status;
	return blk_status_to_errno(status);
}

> -	nvme_execute_passthru_rq(rq);
> +	status = nvme_execute_passthru_rq(rq);
>  
> -	status = nvme_req(rq)->status;
>  	if (status == NVME_SC_SUCCESS &&
>  	    req->cmd->common.opcode == nvme_admin_identify) {
>  		switch (req->cmd->identify.cns) {
> @@ -168,7 +167,8 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w)
>  			nvmet_passthru_override_id_ns(req);
>  			break;
>  		}
> -	}
> +	} else if (status < 0)
> +		status = NVME_SC_INTERNAL;

Don't we need a better translation here?



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux