aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>2014-04-07 18:38:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-07 19:36:02 -0400
commitd61f98c70e8b0d324e8e83be2ed546d6295e63f3 (patch)
treeef4c07ad1d867c0ad97d0478decd78ba209a9387 /drivers/block
parent6e76668e415adf799839f0ab205142ad7002d260 (diff)
zram: move comp allocation out of init_lock
While fixing lockdep spew of ->init_lock reported by Sasha Levin [1], Minchan Kim noted [2] that it's better to move compression backend allocation (using GPF_KERNEL) out of the ->init_lock lock, same way as with zram_meta_alloc(), in order to prevent the same lockdep spew. [1] https://lkml.org/lkml/2014/2/27/337 [2] https://lkml.org/lkml/2014/3/3/32 Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Reported-by: Minchan Kim <minchan@kernel.org> Acked-by: Minchan Kim <minchan@kernel.org> Cc: Sasha Levin <sasha.levin@oracle.com> Acked-by: Jerome Marchand <jmarchan@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/zram/zram_drv.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 15d46f2e158c..e4d536b485e6 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -580,9 +580,10 @@ static ssize_t disksize_store(struct device *dev,
580 struct device_attribute *attr, const char *buf, size_t len) 580 struct device_attribute *attr, const char *buf, size_t len)
581{ 581{
582 u64 disksize; 582 u64 disksize;
583 struct zcomp *comp;
583 struct zram_meta *meta; 584 struct zram_meta *meta;
584 struct zram *zram = dev_to_zram(dev); 585 struct zram *zram = dev_to_zram(dev);
585 int err; 586 int err = -EINVAL;
586 587
587 disksize = memparse(buf, NULL); 588 disksize = memparse(buf, NULL);
588 if (!disksize) 589 if (!disksize)
@@ -593,30 +594,32 @@ static ssize_t disksize_store(struct device *dev,
593 if (!meta) 594 if (!meta)
594 return -ENOMEM; 595 return -ENOMEM;
595 596
597 comp = zcomp_create(zram->compressor, zram->max_comp_streams);
598 if (!comp) {
599 pr_info("Cannot initialise %s compressing backend\n",
600 zram->compressor);
601 goto out_cleanup;
602 }
603
596 down_write(&zram->init_lock); 604 down_write(&zram->init_lock);
597 if (init_done(zram)) { 605 if (init_done(zram)) {
606 up_write(&zram->init_lock);
598 pr_info("Cannot change disksize for initialized device\n"); 607 pr_info("Cannot change disksize for initialized device\n");
599 err = -EBUSY; 608 err = -EBUSY;
600 goto out_free_meta; 609 goto out_cleanup;
601 }
602
603 zram->comp = zcomp_create(zram->compressor, zram->max_comp_streams);
604 if (!zram->comp) {
605 pr_info("Cannot initialise %s compressing backend\n",
606 zram->compressor);
607 err = -EINVAL;
608 goto out_free_meta;
609 } 610 }
610 611
611 zram->meta = meta; 612 zram->meta = meta;
613 zram->comp = comp;
612 zram->disksize = disksize; 614 zram->disksize = disksize;
613 set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); 615 set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
614 up_write(&zram->init_lock); 616 up_write(&zram->init_lock);
615 617
616 return len; 618 return len;
617 619
618out_free_meta: 620out_cleanup:
619 up_write(&zram->init_lock); 621 if (comp)
622 zcomp_destroy(comp);
620 zram_meta_free(meta); 623 zram_meta_free(meta);
621 return err; 624 return err;
622} 625}