|
25 | 25 | #include <linux/genhd.h> |
26 | 26 | #include <linux/highmem.h> |
27 | 27 | #include <linux/slab.h> |
| 28 | +#include <linux/backing-dev.h> |
28 | 29 | #include <linux/string.h> |
29 | 30 | #include <linux/vmalloc.h> |
30 | 31 | #include <linux/err.h> |
@@ -112,6 +113,14 @@ static inline bool is_partial_io(struct bio_vec *bvec) |
112 | 113 | return bvec->bv_len != PAGE_SIZE; |
113 | 114 | } |
114 | 115 |
|
| 116 | +static void zram_revalidate_disk(struct zram *zram) |
| 117 | +{ |
| 118 | + revalidate_disk(zram->disk); |
| 119 | + /* revalidate_disk reset the BDI_CAP_STABLE_WRITES so set again */ |
| 120 | + zram->disk->queue->backing_dev_info.capabilities |= |
| 121 | + BDI_CAP_STABLE_WRITES; |
| 122 | +} |
| 123 | + |
115 | 124 | /* |
116 | 125 | * Check if request is within bounds and aligned on zram logical blocks. |
117 | 126 | */ |
@@ -1095,7 +1104,7 @@ static ssize_t disksize_store(struct device *dev, |
1095 | 1104 | zram->comp = comp; |
1096 | 1105 | zram->disksize = disksize; |
1097 | 1106 | set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); |
1098 | | - revalidate_disk(zram->disk); |
| 1107 | + zram_revalidate_disk(zram); |
1099 | 1108 | up_write(&zram->init_lock); |
1100 | 1109 |
|
1101 | 1110 | return len; |
@@ -1143,7 +1152,7 @@ static ssize_t reset_store(struct device *dev, |
1143 | 1152 | /* Make sure all the pending I/O are finished */ |
1144 | 1153 | fsync_bdev(bdev); |
1145 | 1154 | zram_reset_device(zram); |
1146 | | - revalidate_disk(zram->disk); |
| 1155 | + zram_revalidate_disk(zram); |
1147 | 1156 | bdput(bdev); |
1148 | 1157 |
|
1149 | 1158 | mutex_lock(&bdev->bd_mutex); |
|
0 commit comments