[stgt] [PATCH] null backing store

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Sat Oct 4 08:01:20 CEST 2008


On Fri, 03 Oct 2008 13:20:50 +0300
Alexander Nezhinsky <nezhinsky at gmail.com> wrote:

> Implements a NULL I/O backing store, which shortcuts all scsi commands
> and returns a success status without actually performing them. 
> Useful for performance measurements, by eliminating or significantly 
> reducing I/O side bottleneck. 
> 
> Not based on bs_threads, commands are handled immediately from 
> the context they are submitted from. 
> 
> Comparison with the thread-based implementation shows the impact of 
> threading associated overhead on performance:
> Read,  thread: 69kIOPS, non-thread:72kIOPS
> Write, thread: 47kIOPS, non-thread:59kIOPS
> In both Read and Write tests, CPU util. dropped from ~30% to ~10%
> when switched to the non-thread based model.  
> 
> To add a device backed by this, "-E null" should be used with tgtadm,
> also a dummy device name (any string) should be supplied, 
> because bs_null does not use any real devices but the current 
> code won't admit a null-string device name. 
> 
> 
> Signed-off-by: Alexander Nezhinsky <nezhinsky at gmail.com>
> ---
> 
> diff --git a/usr/Makefile b/usr/Makefile
> index 82ddf07..3fb4bf4 100644
> --- a/usr/Makefile
> +++ b/usr/Makefile
> @@ -1,5 +1,7 @@
>  mandir = /usr/share/man
>  
> +TGTD_OBJS += bs_null.o
> +
>  ifneq ($(IBMVIO),)
>  CFLAGS += -DIBMVIO -DUSE_KERNEL
>  TGTD_OBJS += $(addprefix ibmvio/, ibmvio.o)
> diff --git a/usr/bs_null.c b/usr/bs_null.c
> new file mode 100644
> index 0000000..6de30d8
> --- /dev/null
> +++ b/usr/bs_null.c
> @@ -0,0 +1,91 @@
> +/*
> + * NULL I/O backing store routine
> + *
> + * Copyright (C) 2008 Alexander Nezhinsky <nezhinskyf at gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation, version 2 of the
> + * License.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA
> + */
> +
> +#include <errno.h>
> +#include <inttypes.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +#include "list.h"
> +#include "tgtd.h"
> +#include "scsi.h"
> +
> +#define NULL_BS_DEV_SIZE        (1ULL << 40)
> +
> +int bs_null_cmd_submit(struct scsi_cmd *cmd)
> +{
> +	int result = SAM_STAT_GOOD;
> +	uint16_t asc = 0;
> +	uint8_t key = 0;
> +	uint8_t scb_op = cmd->scb[0];
> +
> +	set_cmd_async(cmd);
> +
> +	if (scb_op == SYNCHRONIZE_CACHE || scb_op == SYNCHRONIZE_CACHE_16) {
> +		if (cmd->scb[1] & 0x2) {
> +			result = SAM_STAT_CHECK_CONDITION;
> +			key = ILLEGAL_REQUEST;
> +			asc = ASC_INVALID_FIELD_IN_CDB;
> +		}
> +	}

By default, the sbc code enables WCE. So if this code does the above,
it should disable WCE by default (an initiator sends SYNCHRONIZE_CACHE
and sees an error).

But this code is just for performance measurements. I think that it's
better to just remove the above code.
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list