All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Damien Le Moal <Damien.LeMoal@wdc.com>
Cc: "dm-devel@redhat.com" <dm-devel@redhat.com>,
	John Pittman <jpittman@redhat.com>
Subject: Re: [PATCH 2/3] dm zoned: metadata: use refcount_t for dm zoned reference counters
Date: Tue, 16 Oct 2018 14:33:55 -0400	[thread overview]
Message-ID: <20181016183355.GA27563@redhat.com> (raw)
In-Reply-To: <BN3PR0401MB1640A8B0BA57BD0FCBE691DCE7370@BN3PR0401MB1640.namprd04.prod.outlook.com>

On Thu, Aug 23 2018 at  6:12pm -0400,
Damien Le Moal <Damien.LeMoal@wdc.com> wrote:

> John,
> 
> On 2018/08/23 10:37, John Pittman wrote:
> > The API surrounding refcount_t should be used in place of atomic_t
> > when variables are being used as reference counters.  This API can
> > prevent issues such as counter overflows and use-after-free
> > conditions.  Within the dm zoned metadata stack, the atomic_t API
> > is used for mblk->ref and zone->refcount.  Change these to use
> > refcount_t, avoiding the issues mentioned.
> > 
> > Signed-off-by: John Pittman <jpittman@redhat.com>
> > ---
> >  drivers/md/dm-zoned-metadata.c | 25 +++++++++++++------------
> >  drivers/md/dm-zoned.h          |  2 +-
> >  2 files changed, 14 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
> > index 969954915566..92e635749414 100644
> > --- a/drivers/md/dm-zoned-metadata.c
> > +++ b/drivers/md/dm-zoned-metadata.c
> > @@ -99,7 +99,7 @@ struct dmz_mblock {
> >  	struct rb_node		node;
> >  	struct list_head	link;
> >  	sector_t		no;
> > -	atomic_t		ref;
> > +	refcount_t		ref;
> 
> While reviewing your patch, I realized that this ref is always manipulated under
> the zmd->mblk_lock spinlock. So there is no need for it to be an atomic or a
> refcount. An unsigned int would do as well and be faster. My fault.
> 
> I will send a patch to go on top of yours to fix that.

Hi Damien,

Given what you've said I'm not seeing the point in the intermediate
refcount_t conversion. 

I'd rather you just send a patch that switches atomic_t to int.

Thanks,
Mike

  parent reply	other threads:[~2018-10-16 18:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-23 17:35 [PATCH 0/3] dm: replace atomic_t reference counters with refcount_t John Pittman
2018-08-23 17:35 ` [PATCH 1/3] dm thin: use refcount_t for thin_c reference counting John Pittman
2018-08-23 17:35 ` [PATCH 2/3] dm zoned: metadata: use refcount_t for dm zoned reference counters John Pittman
2018-08-23 22:12   ` Damien Le Moal
2018-08-23 22:54     ` John Pittman
2018-10-16 18:33     ` Mike Snitzer [this message]
2018-10-17  2:59       ` Damien Le Moal
2018-08-23 17:35 ` [PATCH 3/3] dm zoned: target: " John Pittman
2018-08-23 22:12   ` Damien Le Moal

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=20181016183355.GA27563@redhat.com \
    --to=snitzer@redhat.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=dm-devel@redhat.com \
    --cc=jpittman@redhat.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.