public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <keith.busch@linux.intel.com>
To: Max Gurtovoy <maxg@mellanox.com>
Cc: keith.busch@intel.com, linux-nvme@lists.infradead.org,
	sagi@grimberg.me, hch@lst.de, martin.petersen@oracle.com,
	linux-block@vger.kernel.org, axboe@kernel.dk,
	vladimirk@mellanox.com
Subject: Re: [PATCH 2/3] block: move dif_prepare/dif_complete functions to block layer
Date: Tue, 24 Jul 2018 14:33:23 -0600	[thread overview]
Message-ID: <20180724203323.GA13926@localhost.localdomain> (raw)
In-Reply-To: <1532439222-5668-2-git-send-email-maxg@mellanox.com>

On Tue, Jul 24, 2018 at 04:33:41PM +0300, Max Gurtovoy wrote:
> +void t10_pi_prepare(struct request *rq, u8 protection_type)
> +{
> +	const int tuple_sz = rq->q->integrity.tuple_size;
> +	u32 ref_tag = t10_pi_ref_tag(rq);
> +	struct bio *bio;
> +
> +	if (protection_type == T10_PI_TYPE3_PROTECTION)
> +		return;
> +
> +	__rq_for_each_bio(bio, rq) {
> +		struct bio_integrity_payload *bip = bio_integrity(bio);
> +		u32 virt = bip_get_seed(bip) & 0xffffffff;
> +		struct bio_vec iv;
> +		struct bvec_iter iter;
> +
> +		/* Already remapped? */
> +		if (bip->bip_flags & BIP_MAPPED_INTEGRITY)
> +			break;
> +
> +		bip_for_each_vec(iv, bip, iter) {
> +			struct t10_pi_tuple *pi = kmap_atomic(iv.bv_page) +
> +						iv.bv_offset;
> +			unsigned int j;
> +
> +			for (j = 0; j < iv.bv_len; j += tuple_sz) {
> +				if (be32_to_cpu(pi->ref_tag) == virt)
> +					pi->ref_tag = cpu_to_be32(ref_tag);
> +				virt++;
> +				ref_tag++;
> +				pi += tuple_sz;
> +			}
> +
> +			kunmap_atomic(pi);
> +		}

Since you're incrementing 'pi', you end up unmapping an address that
you didn't map. It does appears harmless in current kunmap_atomic()
implementation, though.

You are also incrementing 'pi' by too many bytes since it is of type
struct t10_pi_tuple. The nvme driver used void* to make the pointer
arithmentic easier.

  parent reply	other threads:[~2018-07-24 20:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-24 13:33 [PATCH 1/3] block: move ref_tag calculation func to the block layer Max Gurtovoy
2018-07-24 13:33 ` [PATCH 2/3] block: move dif_prepare/dif_complete functions to " Max Gurtovoy
2018-07-24 13:55   ` Christoph Hellwig
2018-07-24 14:33     ` Max Gurtovoy
2018-07-24 17:41       ` Christoph Hellwig
2018-07-24 20:33   ` Keith Busch [this message]
2018-07-24 22:32     ` Max Gurtovoy
2018-07-24 13:33 ` [PATCH 3/3] nvme: use blk API to remap ref tags for IOs with metadata Max Gurtovoy
2018-07-24 13:56   ` Christoph Hellwig
2018-07-24 13:52 ` [PATCH 1/3] block: move ref_tag calculation func to the block layer Christoph Hellwig

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=20180724203323.GA13926@localhost.localdomain \
    --to=keith.busch@linux.intel.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=keith.busch@intel.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martin.petersen@oracle.com \
    --cc=maxg@mellanox.com \
    --cc=sagi@grimberg.me \
    --cc=vladimirk@mellanox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox