{
struct zram *zram = queue->queuedata;
- if (unlikely(!zram->init_done) && zram_init_device(zram))
- goto error;
-
down_read(&zram->init_lock);
if (unlikely(!zram->init_done))
- goto error_unlock;
+ goto error;
if (!valid_io_request(zram, bio)) {
zram_stat64_inc(zram, &zram->stats.invalid_io);
- goto error_unlock;
+ goto error;
}
__zram_make_request(zram, bio, bio_data_dir(bio));
return;
-error_unlock:
- up_read(&zram->init_lock);
error:
+ up_read(&zram->init_lock);
bio_io_error(bio);
}
up_write(&zram->init_lock);
}
+/* zram->init_lock should be held */
int zram_init_device(struct zram *zram)
{
int ret;
size_t num_pages;
- down_write(&zram->init_lock);
-
- if (zram->init_done) {
- up_write(&zram->init_lock);
- return 0;
- }
-
if (zram->disksize > 2 * (totalram_pages << PAGE_SHIFT)) {
pr_info(
"There is little point creating a zram of greater than "
}
zram->init_done = 1;
- up_write(&zram->init_lock);
pr_debug("Initialization done!\n");
return 0;
zram->disksize = 0;
fail:
__zram_reset_device(zram);
- up_write(&zram->init_lock);
pr_err("Initialization failed: err=%d\n", ret);
return ret;
}