zram: delay pending free request in read path
[firefly-linux-kernel-4.4.55.git] / drivers / block / zram / zram_drv.c
index 134d605836ca089a9190ed1f54bb41b50a1ee27e..d87c7e98fb1117ee37a987df505f59eca80c2f00 100644 (file)
@@ -2,6 +2,7 @@
  * Compressed RAM block device
  *
  * Copyright (C) 2008, 2009, 2010  Nitin Gupta
+ *               2012, 2013 Minchan Kim
  *
  * This code is released using a dual license strategy: BSD/GPL
  * You can choose the licence that better fits your requirements.
@@ -534,7 +535,6 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
 
        if (rw == READ) {
                down_read(&zram->lock);
-               handle_pending_slot_free(zram);
                ret = zram_bvec_read(zram, bvec, index, offset, bio);
                up_read(&zram->lock);
        } else {
@@ -552,14 +552,14 @@ static void zram_reset_device(struct zram *zram, bool reset_capacity)
        size_t index;
        struct zram_meta *meta;
 
-       flush_work(&zram->free_work);
-
        down_write(&zram->init_lock);
        if (!zram->init_done) {
                up_write(&zram->init_lock);
                return;
        }
 
+       flush_work(&zram->free_work);
+
        meta = zram->meta;
        zram->init_done = 0;