Re: [PATCH v1 2/2] zram: remove init_lock in zram_make_request

From: Minchan Kim
Date: Mon Feb 02 2015 - 00:18:19 EST


On Mon, Feb 02, 2015 at 02:09:12PM +0900, Sergey Senozhatsky wrote:
>
> the patch mosly looks good, except for one place:
>
> On (02/02/15 13:28), Minchan Kim wrote:
> > @@ -783,6 +812,8 @@ static ssize_t disksize_store(struct device *dev,
> > goto out_destroy_comp;
> > }
> >
> > + init_waitqueue_head(&zram->io_done);
> > + zram_meta_get(zram);
>
> it was
> + init_completion(&zram->io_done);
> + atomic_set(&zram->refcount, 1);
>
> I think we need to replace zram_meta_get(zram) with atomic_set(&zram->refcount, 1).
>
> ->refcount is 0 by default and atomic_inc_not_zero(&zram->refcount) will not
> increment it here, nor anywhere else.
>
>
> > zram->meta = meta;
> > zram->comp = comp;
> > zram->disksize = disksize;
> > @@ -838,8 +869,8 @@ static ssize_t reset_store(struct device *dev,
> > /* Make sure all pending I/O is finished */
> > fsync_bdev(bdev);
> > bdput(bdev);
> > -
>
> [..]
>
> > @@ -1041,6 +1075,7 @@ static int create_device(struct zram *zram, int device_id)
> > int ret = -ENOMEM;
> >
> > init_rwsem(&zram->init_lock);
> > + atomic_set(&zram->refcount, 0);
>
> sorry, I forgot that zram is kzalloc()-ated. so we can drop
>
> atomic_set(&zram->refcount, 0)
>

Everything are fixed. Ready to send a patch.
But before sending, hope we fix umount race issue first.

Thanks a lot, Sergey!

--
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/