Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 1 | /* |
| 2 | * Functions related to generic helpers functions |
| 3 | */ |
| 4 | #include <linux/kernel.h> |
| 5 | #include <linux/module.h> |
| 6 | #include <linux/bio.h> |
| 7 | #include <linux/blkdev.h> |
| 8 | #include <linux/scatterlist.h> |
| 9 | |
| 10 | #include "blk.h" |
| 11 | |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 12 | struct bio_batch { |
| 13 | atomic_t done; |
Christoph Hellwig | 4246a0b | 2015-07-20 15:29:37 +0200 | [diff] [blame] | 14 | int error; |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 15 | struct completion *wait; |
| 16 | }; |
| 17 | |
Christoph Hellwig | 4246a0b | 2015-07-20 15:29:37 +0200 | [diff] [blame] | 18 | static void bio_batch_end_io(struct bio *bio) |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 19 | { |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 20 | struct bio_batch *bb = bio->bi_private; |
| 21 | |
Christoph Hellwig | 4246a0b | 2015-07-20 15:29:37 +0200 | [diff] [blame] | 22 | if (bio->bi_error && bio->bi_error != -EOPNOTSUPP) |
| 23 | bb->error = bio->bi_error; |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 24 | if (atomic_dec_and_test(&bb->done)) |
| 25 | complete(bb->wait); |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 26 | bio_put(bio); |
| 27 | } |
| 28 | |
Ming Lin | b49a087 | 2015-05-22 00:46:56 -0700 | [diff] [blame^] | 29 | /* |
| 30 | * Ensure that max discard sectors doesn't overflow bi_size and hopefully |
| 31 | * it is of the proper granularity as long as the granularity is a power |
| 32 | * of two. |
| 33 | */ |
| 34 | #define MAX_BIO_SECTORS ((1U << 31) >> 9) |
| 35 | |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 36 | /** |
| 37 | * blkdev_issue_discard - queue a discard |
| 38 | * @bdev: blockdev to issue discard for |
| 39 | * @sector: start sector |
| 40 | * @nr_sects: number of sectors to discard |
| 41 | * @gfp_mask: memory allocation flags (for bio_alloc) |
| 42 | * @flags: BLKDEV_IFL_* flags to control behaviour |
| 43 | * |
| 44 | * Description: |
| 45 | * Issue a discard request for the sectors in question. |
| 46 | */ |
| 47 | int blkdev_issue_discard(struct block_device *bdev, sector_t sector, |
| 48 | sector_t nr_sects, gfp_t gfp_mask, unsigned long flags) |
| 49 | { |
| 50 | DECLARE_COMPLETION_ONSTACK(wait); |
| 51 | struct request_queue *q = bdev_get_queue(bdev); |
Christoph Hellwig | 8c55536 | 2010-08-18 05:29:22 -0400 | [diff] [blame] | 52 | int type = REQ_WRITE | REQ_DISCARD; |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 53 | struct bio_batch bb; |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 54 | struct bio *bio; |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 55 | int ret = 0; |
Shaohua Li | 0cfbcaf | 2012-12-14 11:15:51 +0800 | [diff] [blame] | 56 | struct blk_plug plug; |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 57 | |
| 58 | if (!q) |
| 59 | return -ENXIO; |
| 60 | |
| 61 | if (!blk_queue_discard(q)) |
| 62 | return -EOPNOTSUPP; |
| 63 | |
Christoph Hellwig | dd3932e | 2010-09-16 20:51:46 +0200 | [diff] [blame] | 64 | if (flags & BLKDEV_DISCARD_SECURE) { |
Adrian Hunter | 8d57a98 | 2010-08-11 14:17:49 -0700 | [diff] [blame] | 65 | if (!blk_queue_secdiscard(q)) |
| 66 | return -EOPNOTSUPP; |
Christoph Hellwig | 8c55536 | 2010-08-18 05:29:22 -0400 | [diff] [blame] | 67 | type |= REQ_SECURE; |
Adrian Hunter | 8d57a98 | 2010-08-11 14:17:49 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 70 | atomic_set(&bb.done, 1); |
Christoph Hellwig | 4246a0b | 2015-07-20 15:29:37 +0200 | [diff] [blame] | 71 | bb.error = 0; |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 72 | bb.wait = &wait; |
| 73 | |
Shaohua Li | 0cfbcaf | 2012-12-14 11:15:51 +0800 | [diff] [blame] | 74 | blk_start_plug(&plug); |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 75 | while (nr_sects) { |
Paolo Bonzini | c6e6663 | 2012-08-02 09:48:50 +0200 | [diff] [blame] | 76 | unsigned int req_sects; |
Ming Lin | b49a087 | 2015-05-22 00:46:56 -0700 | [diff] [blame^] | 77 | sector_t end_sect; |
Paolo Bonzini | c6e6663 | 2012-08-02 09:48:50 +0200 | [diff] [blame] | 78 | |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 79 | bio = bio_alloc(gfp_mask, 1); |
Christoph Hellwig | 66ac028 | 2010-06-18 16:59:42 +0200 | [diff] [blame] | 80 | if (!bio) { |
| 81 | ret = -ENOMEM; |
| 82 | break; |
| 83 | } |
| 84 | |
Ming Lin | b49a087 | 2015-05-22 00:46:56 -0700 | [diff] [blame^] | 85 | req_sects = min_t(sector_t, nr_sects, MAX_BIO_SECTORS); |
Paolo Bonzini | c6e6663 | 2012-08-02 09:48:50 +0200 | [diff] [blame] | 86 | end_sect = sector + req_sects; |
Paolo Bonzini | c6e6663 | 2012-08-02 09:48:50 +0200 | [diff] [blame] | 87 | |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 88 | bio->bi_iter.bi_sector = sector; |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 89 | bio->bi_end_io = bio_batch_end_io; |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 90 | bio->bi_bdev = bdev; |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 91 | bio->bi_private = &bb; |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 92 | |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 93 | bio->bi_iter.bi_size = req_sects << 9; |
Paolo Bonzini | c6e6663 | 2012-08-02 09:48:50 +0200 | [diff] [blame] | 94 | nr_sects -= req_sects; |
| 95 | sector = end_sect; |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 96 | |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 97 | atomic_inc(&bb.done); |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 98 | submit_bio(type, bio); |
Jens Axboe | c8123f8 | 2014-02-12 09:34:01 -0700 | [diff] [blame] | 99 | |
| 100 | /* |
| 101 | * We can loop for a long time in here, if someone does |
| 102 | * full device discards (like mkfs). Be nice and allow |
| 103 | * us to schedule out to avoid softlocking if preempt |
| 104 | * is disabled. |
| 105 | */ |
| 106 | cond_resched(); |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 107 | } |
Shaohua Li | 0cfbcaf | 2012-12-14 11:15:51 +0800 | [diff] [blame] | 108 | blk_finish_plug(&plug); |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 109 | |
Lukas Czerner | 5dba308 | 2011-05-06 19:26:27 -0600 | [diff] [blame] | 110 | /* Wait for bios in-flight */ |
| 111 | if (!atomic_dec_and_test(&bb.done)) |
Vladimir Davydov | 5577022 | 2013-02-14 18:19:59 +0400 | [diff] [blame] | 112 | wait_for_completion_io(&wait); |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 113 | |
Christoph Hellwig | 4246a0b | 2015-07-20 15:29:37 +0200 | [diff] [blame] | 114 | if (bb.error) |
| 115 | return bb.error; |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 116 | return ret; |
Dmitry Monakhov | f31e7e4 | 2010-04-28 17:55:08 +0400 | [diff] [blame] | 117 | } |
| 118 | EXPORT_SYMBOL(blkdev_issue_discard); |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 119 | |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 120 | /** |
Martin K. Petersen | 4363ac7 | 2012-09-18 12:19:27 -0400 | [diff] [blame] | 121 | * blkdev_issue_write_same - queue a write same operation |
| 122 | * @bdev: target blockdev |
| 123 | * @sector: start sector |
| 124 | * @nr_sects: number of sectors to write |
| 125 | * @gfp_mask: memory allocation flags (for bio_alloc) |
| 126 | * @page: page containing data to write |
| 127 | * |
| 128 | * Description: |
| 129 | * Issue a write same request for the sectors in question. |
| 130 | */ |
| 131 | int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, |
| 132 | sector_t nr_sects, gfp_t gfp_mask, |
| 133 | struct page *page) |
| 134 | { |
| 135 | DECLARE_COMPLETION_ONSTACK(wait); |
| 136 | struct request_queue *q = bdev_get_queue(bdev); |
| 137 | unsigned int max_write_same_sectors; |
| 138 | struct bio_batch bb; |
| 139 | struct bio *bio; |
| 140 | int ret = 0; |
| 141 | |
| 142 | if (!q) |
| 143 | return -ENXIO; |
| 144 | |
Ming Lin | b49a087 | 2015-05-22 00:46:56 -0700 | [diff] [blame^] | 145 | /* Ensure that max_write_same_sectors doesn't overflow bi_size */ |
| 146 | max_write_same_sectors = UINT_MAX >> 9; |
Martin K. Petersen | 4363ac7 | 2012-09-18 12:19:27 -0400 | [diff] [blame] | 147 | |
| 148 | atomic_set(&bb.done, 1); |
Christoph Hellwig | 4246a0b | 2015-07-20 15:29:37 +0200 | [diff] [blame] | 149 | bb.error = 0; |
Martin K. Petersen | 4363ac7 | 2012-09-18 12:19:27 -0400 | [diff] [blame] | 150 | bb.wait = &wait; |
| 151 | |
| 152 | while (nr_sects) { |
| 153 | bio = bio_alloc(gfp_mask, 1); |
| 154 | if (!bio) { |
| 155 | ret = -ENOMEM; |
| 156 | break; |
| 157 | } |
| 158 | |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 159 | bio->bi_iter.bi_sector = sector; |
Martin K. Petersen | 4363ac7 | 2012-09-18 12:19:27 -0400 | [diff] [blame] | 160 | bio->bi_end_io = bio_batch_end_io; |
| 161 | bio->bi_bdev = bdev; |
| 162 | bio->bi_private = &bb; |
| 163 | bio->bi_vcnt = 1; |
| 164 | bio->bi_io_vec->bv_page = page; |
| 165 | bio->bi_io_vec->bv_offset = 0; |
| 166 | bio->bi_io_vec->bv_len = bdev_logical_block_size(bdev); |
| 167 | |
| 168 | if (nr_sects > max_write_same_sectors) { |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 169 | bio->bi_iter.bi_size = max_write_same_sectors << 9; |
Martin K. Petersen | 4363ac7 | 2012-09-18 12:19:27 -0400 | [diff] [blame] | 170 | nr_sects -= max_write_same_sectors; |
| 171 | sector += max_write_same_sectors; |
| 172 | } else { |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 173 | bio->bi_iter.bi_size = nr_sects << 9; |
Martin K. Petersen | 4363ac7 | 2012-09-18 12:19:27 -0400 | [diff] [blame] | 174 | nr_sects = 0; |
| 175 | } |
| 176 | |
| 177 | atomic_inc(&bb.done); |
| 178 | submit_bio(REQ_WRITE | REQ_WRITE_SAME, bio); |
| 179 | } |
| 180 | |
| 181 | /* Wait for bios in-flight */ |
| 182 | if (!atomic_dec_and_test(&bb.done)) |
Vladimir Davydov | 5577022 | 2013-02-14 18:19:59 +0400 | [diff] [blame] | 183 | wait_for_completion_io(&wait); |
Martin K. Petersen | 4363ac7 | 2012-09-18 12:19:27 -0400 | [diff] [blame] | 184 | |
Christoph Hellwig | 4246a0b | 2015-07-20 15:29:37 +0200 | [diff] [blame] | 185 | if (bb.error) |
| 186 | return bb.error; |
Martin K. Petersen | 4363ac7 | 2012-09-18 12:19:27 -0400 | [diff] [blame] | 187 | return ret; |
| 188 | } |
| 189 | EXPORT_SYMBOL(blkdev_issue_write_same); |
| 190 | |
| 191 | /** |
Ben Hutchings | 291d24f | 2011-03-01 13:45:24 -0500 | [diff] [blame] | 192 | * blkdev_issue_zeroout - generate number of zero filed write bios |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 193 | * @bdev: blockdev to issue |
| 194 | * @sector: start sector |
| 195 | * @nr_sects: number of sectors to write |
| 196 | * @gfp_mask: memory allocation flags (for bio_alloc) |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 197 | * |
| 198 | * Description: |
| 199 | * Generate and issue number of bios with zerofiled pages. |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 200 | */ |
| 201 | |
Fabian Frederick | 3508678 | 2014-05-26 22:19:14 +0200 | [diff] [blame] | 202 | static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, |
| 203 | sector_t nr_sects, gfp_t gfp_mask) |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 204 | { |
Dmitry Monakhov | 18edc8e | 2010-08-06 13:23:25 +0200 | [diff] [blame] | 205 | int ret; |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 206 | struct bio *bio; |
| 207 | struct bio_batch bb; |
Lukas Czerner | 0aeea18 | 2011-03-11 10:23:53 +0100 | [diff] [blame] | 208 | unsigned int sz; |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 209 | DECLARE_COMPLETION_ONSTACK(wait); |
| 210 | |
Lukas Czerner | 0aeea18 | 2011-03-11 10:23:53 +0100 | [diff] [blame] | 211 | atomic_set(&bb.done, 1); |
Christoph Hellwig | 4246a0b | 2015-07-20 15:29:37 +0200 | [diff] [blame] | 212 | bb.error = 0; |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 213 | bb.wait = &wait; |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 214 | |
Dmitry Monakhov | 18edc8e | 2010-08-06 13:23:25 +0200 | [diff] [blame] | 215 | ret = 0; |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 216 | while (nr_sects != 0) { |
| 217 | bio = bio_alloc(gfp_mask, |
| 218 | min(nr_sects, (sector_t)BIO_MAX_PAGES)); |
Dmitry Monakhov | 18edc8e | 2010-08-06 13:23:25 +0200 | [diff] [blame] | 219 | if (!bio) { |
| 220 | ret = -ENOMEM; |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 221 | break; |
Dmitry Monakhov | 18edc8e | 2010-08-06 13:23:25 +0200 | [diff] [blame] | 222 | } |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 223 | |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 224 | bio->bi_iter.bi_sector = sector; |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 225 | bio->bi_bdev = bdev; |
| 226 | bio->bi_end_io = bio_batch_end_io; |
Christoph Hellwig | dd3932e | 2010-09-16 20:51:46 +0200 | [diff] [blame] | 227 | bio->bi_private = &bb; |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 228 | |
Jens Axboe | 0341aaf | 2010-04-29 09:28:21 +0200 | [diff] [blame] | 229 | while (nr_sects != 0) { |
| 230 | sz = min((sector_t) PAGE_SIZE >> 9 , nr_sects); |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 231 | ret = bio_add_page(bio, ZERO_PAGE(0), sz << 9, 0); |
| 232 | nr_sects -= ret >> 9; |
| 233 | sector += ret >> 9; |
| 234 | if (ret < (sz << 9)) |
| 235 | break; |
| 236 | } |
Dmitry Monakhov | 18edc8e | 2010-08-06 13:23:25 +0200 | [diff] [blame] | 237 | ret = 0; |
Lukas Czerner | 0aeea18 | 2011-03-11 10:23:53 +0100 | [diff] [blame] | 238 | atomic_inc(&bb.done); |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 239 | submit_bio(WRITE, bio); |
| 240 | } |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 241 | |
Christoph Hellwig | dd3932e | 2010-09-16 20:51:46 +0200 | [diff] [blame] | 242 | /* Wait for bios in-flight */ |
Lukas Czerner | 0aeea18 | 2011-03-11 10:23:53 +0100 | [diff] [blame] | 243 | if (!atomic_dec_and_test(&bb.done)) |
Vladimir Davydov | 5577022 | 2013-02-14 18:19:59 +0400 | [diff] [blame] | 244 | wait_for_completion_io(&wait); |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 245 | |
Christoph Hellwig | 4246a0b | 2015-07-20 15:29:37 +0200 | [diff] [blame] | 246 | if (bb.error) |
| 247 | return bb.error; |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 248 | return ret; |
| 249 | } |
Martin K. Petersen | 579e8f3 | 2012-09-18 12:19:28 -0400 | [diff] [blame] | 250 | |
| 251 | /** |
| 252 | * blkdev_issue_zeroout - zero-fill a block range |
| 253 | * @bdev: blockdev to write |
| 254 | * @sector: start sector |
| 255 | * @nr_sects: number of sectors to write |
| 256 | * @gfp_mask: memory allocation flags (for bio_alloc) |
Martin K. Petersen | d93ba7a | 2015-01-20 20:06:30 -0500 | [diff] [blame] | 257 | * @discard: whether to discard the block range |
Martin K. Petersen | 579e8f3 | 2012-09-18 12:19:28 -0400 | [diff] [blame] | 258 | * |
| 259 | * Description: |
Martin K. Petersen | d93ba7a | 2015-01-20 20:06:30 -0500 | [diff] [blame] | 260 | * Zero-fill a block range. If the discard flag is set and the block |
| 261 | * device guarantees that subsequent READ operations to the block range |
| 262 | * in question will return zeroes, the blocks will be discarded. Should |
| 263 | * the discard request fail, if the discard flag is not set, or if |
| 264 | * discard_zeroes_data is not supported, this function will resort to |
| 265 | * zeroing the blocks manually, thus provisioning (allocating, |
| 266 | * anchoring) them. If the block device supports the WRITE SAME command |
| 267 | * blkdev_issue_zeroout() will use it to optimize the process of |
| 268 | * clearing the block range. Otherwise the zeroing will be performed |
| 269 | * using regular WRITE calls. |
Martin K. Petersen | 579e8f3 | 2012-09-18 12:19:28 -0400 | [diff] [blame] | 270 | */ |
| 271 | |
| 272 | int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, |
Martin K. Petersen | d93ba7a | 2015-01-20 20:06:30 -0500 | [diff] [blame] | 273 | sector_t nr_sects, gfp_t gfp_mask, bool discard) |
Martin K. Petersen | 579e8f3 | 2012-09-18 12:19:28 -0400 | [diff] [blame] | 274 | { |
Martin K. Petersen | d93ba7a | 2015-01-20 20:06:30 -0500 | [diff] [blame] | 275 | struct request_queue *q = bdev_get_queue(bdev); |
Martin K. Petersen | d93ba7a | 2015-01-20 20:06:30 -0500 | [diff] [blame] | 276 | |
Martin K. Petersen | 9f9ee1f | 2015-02-05 10:14:54 -0700 | [diff] [blame] | 277 | if (discard && blk_queue_discard(q) && q->limits.discard_zeroes_data && |
| 278 | blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, 0) == 0) |
| 279 | return 0; |
Martin K. Petersen | d93ba7a | 2015-01-20 20:06:30 -0500 | [diff] [blame] | 280 | |
Martin K. Petersen | 9f9ee1f | 2015-02-05 10:14:54 -0700 | [diff] [blame] | 281 | if (bdev_write_same(bdev) && |
| 282 | blkdev_issue_write_same(bdev, sector, nr_sects, gfp_mask, |
| 283 | ZERO_PAGE(0)) == 0) |
| 284 | return 0; |
Martin K. Petersen | 579e8f3 | 2012-09-18 12:19:28 -0400 | [diff] [blame] | 285 | |
| 286 | return __blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask); |
| 287 | } |
Dmitry Monakhov | 3f14d79 | 2010-04-28 17:55:09 +0400 | [diff] [blame] | 288 | EXPORT_SYMBOL(blkdev_issue_zeroout); |