All of lore.kernel.org
 help / color / mirror / Atom feed
From: willy@linux.intel.com (Matthew Wilcox)
Subject: [PATCH v3 7/7] NVMe: End-to-end data protection
Date: Wed, 27 Mar 2013 18:51:31 -0400	[thread overview]
Message-ID: <20130327225131.GI4671@linux.intel.com> (raw)
In-Reply-To: <1363966604-5482-1-git-send-email-keith.busch@intel.com>

On Fri, Mar 22, 2013@09:36:44AM -0600, Keith Busch wrote:
> Registers a DIF capable nvme namespace with block integrity.

I'm assuming I can't apply this until Martin has applied 1-5?  But I
can apply 6 safely?

> @@ -692,6 +718,29 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
>  								GFP_ATOMIC);
>  	cmnd->rw.slba = cpu_to_le64(bio->bi_sector >> (ns->lba_shift - 9));
>  	cmnd->rw.length = cpu_to_le16((length >> ns->lba_shift) - 1);
> +
> +	if (ns->ms) {
> +		if (ns->pi_type) {
> +			control |= NVME_RW_PRINFO_PRCHK_GUARD;
> +			if (ns->pi_type != NVME_NS_DPS_PI_TYPE3) {
> +				control |= NVME_RW_PRINFO_PRCHK_REF;
> +				cmnd->rw.reftag = cpu_to_le32(
> +					(bio->bi_sector >> (ns->lba_shift - 9)) &
> +					0xffffffff);
> +			}
> +		}

Mmpf.  Sets off my "overly long lines" trigger.  The indentation is
deep, but I don't see a nice way to reduce it.  I notice we have the
'bio->bi_sector >> (ns->lba_shift - 9)' idiom in two places already in
the driver, and this adds a third.  There's also a place in the SCSI
emulation code that gets the shifting slightly wrong.  Probably harmless,
but clearly it's time to compute this in a macro.

How does this look?

+				u32 block = nvme_block_nr(ns, bio->bi_sector);
+				control |= NVME_RW_PRINFO_PRCHK_REF;
+				cmnd->rw.reftag = cpu_to_le32(block);

Along with the suitable:

static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector)
{
	return (sector >> (ns->lba_shift - 9));
}

in linux/nvme.h?

> +		if (bio_integrity(bio)) {
> +				iod->meta_dma =
> +					dma_map_single(nvmeq->q_dmadev,
> +						bio->bi_integrity->bip_buf,
> +						bio->bi_integrity->bip_size,
> +						dma_dir);
> +				cmnd->rw.metadata = cpu_to_le64(iod->meta_dma);

Indentation gone wild?  Should be:

+		if (bio_integrity(bio)) {
+			iod->meta_dma = dma_map_single(nvmeq->q_dmadev,
+						bio->bi_integrity->bip_buf,
+						bio->bi_integrity->bip_size,
+						dma_dir);
+			cmnd->rw.metadata = cpu_to_le64(iod->meta_dma);

Right?

  reply	other threads:[~2013-03-27 22:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-22 15:36 [PATCH v3 7/7] NVMe: End-to-end data protection Keith Busch
2013-03-27 22:51 ` Matthew Wilcox [this message]
2013-03-22 18:48   ` Keith Busch
2013-04-03 21:50     ` Busch, Keith

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=20130327225131.GI4671@linux.intel.com \
    --to=willy@linux.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.