All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: Sagi Grimberg <sagig@dev.mellanox.co.il>
Cc: "Nicholas A. Bellinger" <nab@daterainc.com>,
	target-devel <target-devel@vger.kernel.org>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Sagi Grimberg <sagig@mellanox.com>,
	Or Gerlitz <ogerlitz@mellanox.com>,
	Quinn Tran <quinn.tran@qlogic.com>,
	Giridhar Malavali <giridhar.malavali@qlogic.com>
Subject: Re: [PATCH 6/9] target/sbc: Add sbc_dif_write_insert software emulation
Date: Mon, 07 Apr 2014 01:07:35 -0700	[thread overview]
Message-ID: <1396858055.19888.5.camel@haakon3.risingtidesystems.com> (raw)
In-Reply-To: <5342558A.9070205@dev.mellanox.co.il>

On Mon, 2014-04-07 at 10:36 +0300, Sagi Grimberg wrote:
> On 4/3/2014 12:35 PM, Nicholas A. Bellinger wrote:
> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> >
> > This patch adds WRITE_INSERT emulation within target-core
> > using TYPE1 / TYPE3 PI modes.
> >
> > This is useful in order for existing legacy fabrics that do not
> > support protection offloads to interact with backend devices that
> > currently have T10 PI enabled.
> >
> > Cc: Martin K. Petersen <martin.petersen@oracle.com>
> > Cc: Sagi Grimberg <sagig@mellanox.com>
> > Cc: Or Gerlitz <ogerlitz@mellanox.com>
> > Cc: Quinn Tran <quinn.tran@qlogic.com>
> > Cc: Giridhar Malavali <giridhar.malavali@qlogic.com>
> > Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> > ---
> >   drivers/target/target_core_sbc.c     |   44 ++++++++++++++++++++++++++++++++++
> >   include/target/target_core_backend.h |    1 +
> >   2 files changed, 45 insertions(+)
> >
> > diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
> > index f2d73dd..97b207d 100644
> > --- a/drivers/target/target_core_sbc.c
> > +++ b/drivers/target/target_core_sbc.c
> > @@ -1096,6 +1096,50 @@ err:
> >   }
> >   EXPORT_SYMBOL(sbc_execute_unmap);
> >   
> > +void
> > +sbc_dif_write_insert(struct se_cmd *cmd)
> 
> Better to call it sbc_dif_generate()

Changed to sbc_dif_generate().

> 
> > +{
> > +	struct se_device *dev = cmd->se_dev;
> > +	struct se_dif_v1_tuple *sdt;
> > +	struct scatterlist *dsg, *psg = cmd->t_prot_sg;
> > +	sector_t sector = cmd->t_task_lba;
> > +	void *daddr, *paddr;
> > +	int i, j, offset = 0;
> > +
> > +	for_each_sg(cmd->t_data_sg, dsg, cmd->t_data_nents, i) {
> > +		daddr = kmap_atomic(sg_page(dsg)) + dsg->offset;
> > +		paddr = kmap_atomic(sg_page(psg)) + psg->offset;
> > +
> > +		for (j = 0; j < dsg->length; j += dev->dev_attrib.block_size) {
> > +
> > +			if (offset >= psg->length) {
> > +				kunmap_atomic(paddr);
> > +				psg = sg_next(psg);
> > +				paddr = kmap_atomic(sg_page(psg)) + psg->offset;
> > +				offset = 0;
> > +			}
> > +
> > +			sdt = paddr + offset;
> > +			sdt->guard_tag = cpu_to_be16(crc_t10dif(daddr + j,
> > +						dev->dev_attrib.block_size));
> > +			if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT)
> > +				sdt->ref_tag = cpu_to_be32(sector & 0xffffffff);
> > +			sdt->app_tag = 0;
> > +
> > +			pr_debug("DIF WRITE INSERT sector: %llu guard_tag: 0x%04x"
> > +				 " app_tag: 0x%04x ref_tag: %u\n",
> > +				 (unsigned long long)sector, sdt->guard_tag,
> > +				 sdt->app_tag, be32_to_cpu(sdt->ref_tag));
> > +
> > +			sector++;
> > +			offset += sizeof(struct se_dif_v1_tuple);
> > +		}
> > +
> > +		kunmap_atomic(paddr);
> > +		kunmap_atomic(daddr);
> > +	}
> > +}
> 
> Seems like a substantial code duplication here, can't you reuse the code 
> from verify?
> Maybe use this function also from verify (call generate() and then do 
> compare to t_prot_sg).

Yeah, there are a few differences between the two cases, and I stopped
short of merging them together for the moment.

Should be a pretty straight-forward post -rc1 change to make this into
common code.

--nab

  reply	other threads:[~2014-04-07  8:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-03  9:35 [PATCH 0/9] target: Allow fabric to expose PI + add WRITE_INSERT/READ_STRIP Nicholas A. Bellinger
2014-04-03  9:35 ` [PATCH 1/9] target/iblock: Fix double bioset_integrity_free bug Nicholas A. Bellinger
2014-04-07  7:19   ` Sagi Grimberg
2014-04-03  9:35 ` [PATCH 2/9] target: Pass in transport supported PI at session initialization Nicholas A. Bellinger
2014-04-07  7:28   ` Sagi Grimberg
2014-04-07  8:01     ` Nicholas A. Bellinger
2014-04-03  9:35 ` [PATCH 3/9] target/spc: Only expose PI inquiry bits when supported by fabric Nicholas A. Bellinger
2014-04-07  7:30   ` Sagi Grimberg
2014-04-03  9:35 ` [PATCH 4/9] target/spc: Only expose PI mode page " Nicholas A. Bellinger
2014-04-07  7:31   ` Sagi Grimberg
2014-04-03  9:35 ` [PATCH 5/9] target/sbc: Only expose PI read_cap16 " Nicholas A. Bellinger
2014-04-07  7:32   ` Sagi Grimberg
2014-04-03  9:35 ` [PATCH 6/9] target/sbc: Add sbc_dif_write_insert software emulation Nicholas A. Bellinger
2014-04-07  7:36   ` Sagi Grimberg
2014-04-07  8:07     ` Nicholas A. Bellinger [this message]
2014-04-03  9:35 ` [PATCH 7/9] target: Enable WRITE_INSERT emulation in target_execute_cmd Nicholas A. Bellinger
2014-04-07  7:39   ` Sagi Grimberg
2014-04-07  8:11     ` Nicholas A. Bellinger
2014-04-07  8:13       ` sagi grimberg
2014-04-03  9:35 ` [PATCH 8/9] target/sbc: Add sbc_dif_read_strip software emulation Nicholas A. Bellinger
2014-04-07  7:44   ` Sagi Grimberg
2014-04-03  9:35 ` [PATCH 9/9] target: Enable READ_STRIP emulation in target_complete_ok_work Nicholas A. Bellinger
2014-04-07  7:49   ` Sagi Grimberg
2014-04-07  8:15     ` Nicholas A. Bellinger

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=1396858055.19888.5.camel@haakon3.risingtidesystems.com \
    --to=nab@linux-iscsi.org \
    --cc=giridhar.malavali@qlogic.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nab@daterainc.com \
    --cc=ogerlitz@mellanox.com \
    --cc=quinn.tran@qlogic.com \
    --cc=sagig@dev.mellanox.co.il \
    --cc=sagig@mellanox.com \
    --cc=target-devel@vger.kernel.org \
    /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.