All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bart.vanassche@sandisk.com>
To: Douglas Gilbert <dgilbert@interlog.com>, linux-scsi@vger.kernel.org
Cc: martin.petersen@oracle.com, tomas.winkler@intel.com,
	emilne@redhat.com, bart.vanassche@sandisk.com
Subject: Re: [PATCH v3 3/6] scsi_debug: add multiple queue support
Date: Mon, 9 May 2016 09:12:28 -0700	[thread overview]
Message-ID: <5730B6EC.90001@sandisk.com> (raw)
In-Reply-To: <1462509629-24282-4-git-send-email-dgilbert@interlog.com>

On 05/05/2016 09:40 PM, Douglas Gilbert wrote:
>   static bool stop_queued_cmnd(struct scsi_cmnd *cmnd)
>   {
>   	unsigned long iflags;
> -	int k, qmax, r_qmax;
> +	int j, k, qmax, r_qmax;
> +	struct sdebug_queue *sqp;
>   	struct sdebug_queued_cmd *sqcp;
>   	struct sdebug_dev_info *devip;
>   	struct sdebug_defer *sd_dp;
>
> -	[ ... ]
> +	for (j = 0, sqp = sdebug_q_arr; j < submit_queues; ++j, ++sqp) {
> +		spin_lock_irqsave(&sqp->qc_lock, iflags);
> +		qmax = sdebug_max_queue;
> +		r_qmax = atomic_read(&retired_max_queue);
> +		if (r_qmax > qmax)
> +			qmax = r_qmax;
> +		for (k = 0; k < qmax; ++k) {
> +			if (test_bit(k, sqp->in_use_bm)) {
> +				sqcp = &sqp->qc_arr[k];
> +				if (cmnd != sqcp->a_cmnd)
> +					continue;
> +				/* found */
> +				[ ... ]

It is not clear to me why a for-loop is used in this function to look up 
the sqp pointer instead of calling get_queue() or using sqa_idx?

>   static const char * scsi_debug_info(struct Scsi_Host * shp)
>   {
> -	sprintf(sdebug_info,
> -		"scsi_debug, version %s [%s], dev_size_mb=%d, opts=0x%x",
> -		SDEBUG_VERSION, sdebug_version_date, sdebug_dev_size_mb,
> -		sdebug_opts);
> +	int k;
> +
> +	k = scnprintf(sdebug_info, sizeof(sdebug_info),
> +		      "%s: version %s [%s], dev_size_mb=%d, opts=0x%x\n",
> +		      my_name, SDEBUG_VERSION, sdebug_version_date,
> +		      sdebug_dev_size_mb, sdebug_opts);
> +	if (k >= (sizeof(sdebug_info) - 1))
> +		return sdebug_info;
> +	scnprintf(sdebug_info + k, sizeof(sdebug_info) - k,
> +		  "%s: submit_queues=%d, statistics=%d\n", my_name,
> +		  submit_queues, (int)sdebug_statistics);
>   	return sdebug_info;
>   }

 From the comment above the definition of scnprintf(): "The return value 
is the number of characters written into @buf not including the trailing 
'\0'". Maybe you need snprintf() instead of scnprintf()?

Bart.

  reply	other threads:[~2016-05-09 16:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-06  4:40 [PATCH v3 0/6] scsi_debug: multiple queue support and cleanup Douglas Gilbert
2016-05-06  4:40 ` [PATCH v3 1/6] scsi_debug: use pdt constants Douglas Gilbert
2016-05-06  4:40 ` [PATCH v3 2/6] scsi_debug: rework resp_report_luns Douglas Gilbert
2016-05-06  4:40 ` [PATCH v3 3/6] scsi_debug: add multiple queue support Douglas Gilbert
2016-05-09 16:12   ` Bart Van Assche [this message]
2016-05-09 22:30     ` Douglas Gilbert
2016-05-09 22:36       ` Bart Van Assche
2016-05-06  4:40 ` [PATCH v3 4/6] scsi_debug: vpd and mode page work Douglas Gilbert
2016-05-06  4:40 ` [PATCH v3 5/6] scsi_debug: uuid for lu name Douglas Gilbert
2016-05-31 12:57   ` Andy Shevchenko
2016-05-06  4:40 ` [PATCH v3 6/6] scsi_debug: use locally assigned naa Douglas Gilbert
2016-05-11  1:27 ` [PATCH v3 0/6] scsi_debug: multiple queue support and cleanup Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5730B6EC.90001@sandisk.com \
    --to=bart.vanassche@sandisk.com \
    --cc=dgilbert@interlog.com \
    --cc=emilne@redhat.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=tomas.winkler@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.