aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Monakhov <dmonakhov@openvz.org>2010-04-28 09:55:06 -0400
committerJens Axboe <jens.axboe@oracle.com>2010-04-28 13:47:36 -0400
commitfbd9b09a177a481eda256447c881f014f29034fe (patch)
treeef7e213045382f82a1e3e3cf134d196a1045dd7a
parent6b4517a7913a09d3259bb1d21c9cb300f12294bd (diff)
blkdev: generalize flags for blkdev_issue_fn functions
The patch just convert all blkdev_issue_xxx function to common set of flags. Wait/allocation semantics preserved. Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--block/blk-barrier.c20
-rw-r--r--block/ioctl.c2
-rw-r--r--drivers/block/drbd/drbd_int.h3
-rw-r--r--drivers/block/drbd/drbd_receiver.c3
-rw-r--r--fs/block_dev.c3
-rw-r--r--fs/btrfs/extent-tree.c2
-rw-r--r--fs/ext3/fsync.c3
-rw-r--r--fs/ext4/fsync.c6
-rw-r--r--fs/gfs2/rgrp.c5
-rw-r--r--fs/jbd2/checkpoint.c3
-rw-r--r--fs/jbd2/commit.c6
-rw-r--r--fs/reiserfs/file.c3
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c3
-rw-r--r--include/linux/blkdev.h18
-rw-r--r--mm/swapfile.c9
15 files changed, 55 insertions, 34 deletions
diff --git a/block/blk-barrier.c b/block/blk-barrier.c
index 6d88544b677f..cf14311b98fc 100644
--- a/block/blk-barrier.c
+++ b/block/blk-barrier.c
@@ -293,19 +293,22 @@ static void bio_end_empty_barrier(struct bio *bio, int err)
293/** 293/**
294 * blkdev_issue_flush - queue a flush 294 * blkdev_issue_flush - queue a flush
295 * @bdev: blockdev to issue flush for 295 * @bdev: blockdev to issue flush for
296 * @gfp_mask: memory allocation flags (for bio_alloc)
296 * @error_sector: error sector 297 * @error_sector: error sector
298 * @flags: BLKDEV_IFL_* flags to control behaviour
297 * 299 *
298 * Description: 300 * Description:
299 * Issue a flush for the block device in question. Caller can supply 301 * Issue a flush for the block device in question. Caller can supply
300 * room for storing the error offset in case of a flush error, if they 302 * room for storing the error offset in case of a flush error, if they
301 * wish to. 303 * wish to.
302 */ 304 */
303int blkdev_issue_flush(struct block_device *bdev, sector_t *error_sector) 305int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
306 sector_t *error_sector, unsigned long flags)
304{ 307{
305 DECLARE_COMPLETION_ONSTACK(wait); 308 DECLARE_COMPLETION_ONSTACK(wait);
306 struct request_queue *q; 309 struct request_queue *q;
307 struct bio *bio; 310 struct bio *bio;
308 int ret; 311 int ret = 0;
309 312
310 if (bdev->bd_disk == NULL) 313 if (bdev->bd_disk == NULL)
311 return -ENXIO; 314 return -ENXIO;
@@ -314,7 +317,7 @@ int blkdev_issue_flush(struct block_device *bdev, sector_t *error_sector)
314 if (!q) 317 if (!q)
315 return -ENXIO; 318 return -ENXIO;
316 319
317 bio = bio_alloc(GFP_KERNEL, 0); 320 bio = bio_alloc(gfp_mask, 0);
318 bio->bi_end_io = bio_end_empty_barrier; 321 bio->bi_end_io = bio_end_empty_barrier;
319 bio->bi_private = &wait; 322 bio->bi_private = &wait;
320 bio->bi_bdev = bdev; 323 bio->bi_bdev = bdev;
@@ -330,7 +333,6 @@ int blkdev_issue_flush(struct block_device *bdev, sector_t *error_sector)
330 if (error_sector) 333 if (error_sector)
331 *error_sector = bio->bi_sector; 334 *error_sector = bio->bi_sector;
332 335
333 ret = 0;
334 if (bio_flagged(bio, BIO_EOPNOTSUPP)) 336 if (bio_flagged(bio, BIO_EOPNOTSUPP))
335 ret = -EOPNOTSUPP; 337 ret = -EOPNOTSUPP;
336 else if (!bio_flagged(bio, BIO_UPTODATE)) 338 else if (!bio_flagged(bio, BIO_UPTODATE))
@@ -362,17 +364,17 @@ static void blkdev_discard_end_io(struct bio *bio, int err)
362 * @sector: start sector 364 * @sector: start sector
363 * @nr_sects: number of sectors to discard 365 * @nr_sects: number of sectors to discard
364 * @gfp_mask: memory allocation flags (for bio_alloc) 366 * @gfp_mask: memory allocation flags (for bio_alloc)
365 * @flags: DISCARD_FL_* flags to control behaviour 367 * @flags: BLKDEV_IFL_* flags to control behaviour
366 * 368 *
367 * Description: 369 * Description:
368 * Issue a discard request for the sectors in question. 370 * Issue a discard request for the sectors in question.
369 */ 371 */
370int blkdev_issue_discard(struct block_device *bdev, sector_t sector, 372int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
371 sector_t nr_sects, gfp_t gfp_mask, int flags) 373 sector_t nr_sects, gfp_t gfp_mask, unsigned long flags)
372{ 374{
373 DECLARE_COMPLETION_ONSTACK(wait); 375 DECLARE_COMPLETION_ONSTACK(wait);
374 struct request_queue *q = bdev_get_queue(bdev); 376 struct request_queue *q = bdev_get_queue(bdev);
375 int type = flags & DISCARD_FL_BARRIER ? 377 int type = flags & BLKDEV_IFL_BARRIER ?
376 DISCARD_BARRIER : DISCARD_NOBARRIER; 378 DISCARD_BARRIER : DISCARD_NOBARRIER;
377 struct bio *bio; 379 struct bio *bio;
378 struct page *page; 380 struct page *page;
@@ -395,7 +397,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
395 bio->bi_sector = sector; 397 bio->bi_sector = sector;
396 bio->bi_end_io = blkdev_discard_end_io; 398 bio->bi_end_io = blkdev_discard_end_io;
397 bio->bi_bdev = bdev; 399 bio->bi_bdev = bdev;
398 if (flags & DISCARD_FL_WAIT) 400 if (flags & BLKDEV_IFL_WAIT)
399 bio->bi_private = &wait; 401 bio->bi_private = &wait;
400 402
401 /* 403 /*
@@ -426,7 +428,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
426 bio_get(bio); 428 bio_get(bio);
427 submit_bio(type, bio); 429 submit_bio(type, bio);
428 430
429 if (flags & DISCARD_FL_WAIT) 431 if (flags & BLKDEV_IFL_WAIT)
430 wait_for_completion(&wait); 432 wait_for_completion(&wait);
431 433
432 if (bio_flagged(bio, BIO_EOPNOTSUPP)) 434 if (bio_flagged(bio, BIO_EOPNOTSUPP))
diff --git a/block/ioctl.c b/block/ioctl.c
index 8905d2a2a717..e8eb679f2f9b 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -126,7 +126,7 @@ static int blk_ioctl_discard(struct block_device *bdev, uint64_t start,
126 if (start + len > (bdev->bd_inode->i_size >> 9)) 126 if (start + len > (bdev->bd_inode->i_size >> 9))
127 return -EINVAL; 127 return -EINVAL;
128 return blkdev_issue_discard(bdev, start, len, GFP_KERNEL, 128 return blkdev_issue_discard(bdev, start, len, GFP_KERNEL,
129 DISCARD_FL_WAIT); 129 BLKDEV_IFL_WAIT);
130} 130}
131 131
132static int put_ushort(unsigned long arg, unsigned short val) 132static int put_ushort(unsigned long arg, unsigned short val)
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index e5e86a781820..d6f1ae342b1d 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -2251,7 +2251,8 @@ static inline void drbd_md_flush(struct drbd_conf *mdev)
2251 if (test_bit(MD_NO_BARRIER, &mdev->flags)) 2251 if (test_bit(MD_NO_BARRIER, &mdev->flags))
2252 return; 2252 return;
2253 2253
2254 r = blkdev_issue_flush(mdev->ldev->md_bdev, NULL); 2254 r = blkdev_issue_flush(mdev->ldev->md_bdev, GFP_KERNEL, NULL,
2255 BLKDEV_IFL_WAIT);
2255 if (r) { 2256 if (r) {
2256 set_bit(MD_NO_BARRIER, &mdev->flags); 2257 set_bit(MD_NO_BARRIER, &mdev->flags);
2257 dev_err(DEV, "meta data flush failed with status %d, disabling md-flushes\n", r); 2258 dev_err(DEV, "meta data flush failed with status %d, disabling md-flushes\n", r);
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index ed9f1de24a71..54f56ea8a786 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -945,7 +945,8 @@ static enum finish_epoch drbd_flush_after_epoch(struct drbd_conf *mdev, struct d
945 int rv; 945 int rv;
946 946
947 if (mdev->write_ordering >= WO_bdev_flush && get_ldev(mdev)) { 947 if (mdev->write_ordering >= WO_bdev_flush && get_ldev(mdev)) {
948 rv = blkdev_issue_flush(mdev->ldev->backing_bdev, NULL); 948 rv = blkdev_issue_flush(mdev->ldev->backing_bdev, GFP_KERNEL,
949 NULL, BLKDEV_IFL_WAIT);
949 if (rv) { 950 if (rv) {
950 dev_err(DEV, "local disk flush failed with status %d\n", rv); 951 dev_err(DEV, "local disk flush failed with status %d\n", rv);
951 /* would rather check on EOPNOTSUPP, but that is not reliable. 952 /* would rather check on EOPNOTSUPP, but that is not reliable.
diff --git a/fs/block_dev.c b/fs/block_dev.c
index ea8385ea58ab..dd769304382e 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -413,7 +413,8 @@ int blkdev_fsync(struct file *filp, struct dentry *dentry, int datasync)
413 if (error) 413 if (error)
414 return error; 414 return error;
415 415
416 error = blkdev_issue_flush(bdev, NULL); 416 error = blkdev_issue_flush(bdev, GFP_KERNEL, NULL,
417 (BLKDEV_IFL_WAIT));
417 if (error == -EOPNOTSUPP) 418 if (error == -EOPNOTSUPP)
418 error = 0; 419 error = 0;
419 return error; 420 return error;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index b34d32fdaaec..c6a4f459ad76 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1589,7 +1589,7 @@ static void btrfs_issue_discard(struct block_device *bdev,
1589 u64 start, u64 len) 1589 u64 start, u64 len)
1590{ 1590{
1591 blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL, 1591 blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL,
1592 DISCARD_FL_BARRIER); 1592 BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER);
1593} 1593}
1594 1594
1595static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr, 1595static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
diff --git a/fs/ext3/fsync.c b/fs/ext3/fsync.c
index 8209f266e9ad..9492f6003ef9 100644
--- a/fs/ext3/fsync.c
+++ b/fs/ext3/fsync.c
@@ -91,7 +91,8 @@ int ext3_sync_file(struct file * file, struct dentry *dentry, int datasync)
91 * storage 91 * storage
92 */ 92 */
93 if (test_opt(inode->i_sb, BARRIER)) 93 if (test_opt(inode->i_sb, BARRIER))
94 blkdev_issue_flush(inode->i_sb->s_bdev, NULL); 94 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL,
95 BLKDEV_IFL_WAIT);
95out: 96out:
96 return ret; 97 return ret;
97} 98}
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index 0d0c3239c1cd..ef3d980e67cb 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -100,9 +100,11 @@ int ext4_sync_file(struct file *file, struct dentry *dentry, int datasync)
100 if (ext4_should_writeback_data(inode) && 100 if (ext4_should_writeback_data(inode) &&
101 (journal->j_fs_dev != journal->j_dev) && 101 (journal->j_fs_dev != journal->j_dev) &&
102 (journal->j_flags & JBD2_BARRIER)) 102 (journal->j_flags & JBD2_BARRIER))
103 blkdev_issue_flush(inode->i_sb->s_bdev, NULL); 103 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL,
104 NULL, BLKDEV_IFL_WAIT);
104 jbd2_log_wait_commit(journal, commit_tid); 105 jbd2_log_wait_commit(journal, commit_tid);
105 } else if (journal->j_flags & JBD2_BARRIER) 106 } else if (journal->j_flags & JBD2_BARRIER)
106 blkdev_issue_flush(inode->i_sb->s_bdev, NULL); 107 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL,
108 BLKDEV_IFL_WAIT);
107 return ret; 109 return ret;
108} 110}
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 503b842f3ba2..bf011dc63471 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -854,7 +854,8 @@ static void gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,
854 if ((start + nr_sects) != blk) { 854 if ((start + nr_sects) != blk) {
855 rv = blkdev_issue_discard(bdev, start, 855 rv = blkdev_issue_discard(bdev, start,
856 nr_sects, GFP_NOFS, 856 nr_sects, GFP_NOFS,
857 DISCARD_FL_BARRIER); 857 BLKDEV_IFL_WAIT |
858 BLKDEV_IFL_BARRIER);
858 if (rv) 859 if (rv)
859 goto fail; 860 goto fail;
860 nr_sects = 0; 861 nr_sects = 0;
@@ -869,7 +870,7 @@ start_new_extent:
869 } 870 }
870 if (nr_sects) { 871 if (nr_sects) {
871 rv = blkdev_issue_discard(bdev, start, nr_sects, GFP_NOFS, 872 rv = blkdev_issue_discard(bdev, start, nr_sects, GFP_NOFS,
872 DISCARD_FL_BARRIER); 873 BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER);
873 if (rv) 874 if (rv)
874 goto fail; 875 goto fail;
875 } 876 }
diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index 30beb11ef928..076d1cc44f95 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -530,7 +530,8 @@ int jbd2_cleanup_journal_tail(journal_t *journal)
530 */ 530 */
531 if ((journal->j_fs_dev != journal->j_dev) && 531 if ((journal->j_fs_dev != journal->j_dev) &&
532 (journal->j_flags & JBD2_BARRIER)) 532 (journal->j_flags & JBD2_BARRIER))
533 blkdev_issue_flush(journal->j_fs_dev, NULL); 533 blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL,
534 BLKDEV_IFL_WAIT);
534 if (!(journal->j_flags & JBD2_ABORT)) 535 if (!(journal->j_flags & JBD2_ABORT))
535 jbd2_journal_update_superblock(journal, 1); 536 jbd2_journal_update_superblock(journal, 1);
536 return 0; 537 return 0;
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 671da7fb7ffd..75716d3d2be0 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -717,7 +717,8 @@ start_journal_io:
717 if (commit_transaction->t_flushed_data_blocks && 717 if (commit_transaction->t_flushed_data_blocks &&
718 (journal->j_fs_dev != journal->j_dev) && 718 (journal->j_fs_dev != journal->j_dev) &&
719 (journal->j_flags & JBD2_BARRIER)) 719 (journal->j_flags & JBD2_BARRIER))
720 blkdev_issue_flush(journal->j_fs_dev, NULL); 720 blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL,
721 BLKDEV_IFL_WAIT);
721 722
722 /* Done it all: now write the commit record asynchronously. */ 723 /* Done it all: now write the commit record asynchronously. */
723 if (JBD2_HAS_INCOMPAT_FEATURE(journal, 724 if (JBD2_HAS_INCOMPAT_FEATURE(journal,
@@ -727,7 +728,8 @@ start_journal_io:
727 if (err) 728 if (err)
728 __jbd2_journal_abort_hard(journal); 729 __jbd2_journal_abort_hard(journal);
729 if (journal->j_flags & JBD2_BARRIER) 730 if (journal->j_flags & JBD2_BARRIER)
730 blkdev_issue_flush(journal->j_dev, NULL); 731 blkdev_issue_flush(journal->j_dev, GFP_KERNEL, NULL,
732 BLKDEV_IFL_WAIT);
731 } 733 }
732 734
733 err = journal_finish_inode_data_buffers(journal, commit_transaction); 735 err = journal_finish_inode_data_buffers(journal, commit_transaction);
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 1d9c12714c5c..9977df9f3a54 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -147,7 +147,8 @@ static int reiserfs_sync_file(struct file *filp,
147 barrier_done = reiserfs_commit_for_inode(inode); 147 barrier_done = reiserfs_commit_for_inode(inode);
148 reiserfs_write_unlock(inode->i_sb); 148 reiserfs_write_unlock(inode->i_sb);
149 if (barrier_done != 1 && reiserfs_barrier_flush(inode->i_sb)) 149 if (barrier_done != 1 && reiserfs_barrier_flush(inode->i_sb))
150 blkdev_issue_flush(inode->i_sb->s_bdev, NULL); 150 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL,
151 BLKDEV_IFL_WAIT);
151 if (barrier_done < 0) 152 if (barrier_done < 0)
152 return barrier_done; 153 return barrier_done;
153 return (err < 0) ? -EIO : 0; 154 return (err < 0) ? -EIO : 0;
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 52e06b487ced..2b177c778ba7 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -725,7 +725,8 @@ void
725xfs_blkdev_issue_flush( 725xfs_blkdev_issue_flush(
726 xfs_buftarg_t *buftarg) 726 xfs_buftarg_t *buftarg)
727{ 727{
728 blkdev_issue_flush(buftarg->bt_bdev, NULL); 728 blkdev_issue_flush(buftarg->bt_bdev, GFP_KERNEL, NULL,
729 BLKDEV_IFL_WAIT);
729} 730}
730 731
731STATIC void 732STATIC void
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 5cf17a49ce38..59b9aed0ee7d 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -998,12 +998,16 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
998 return NULL; 998 return NULL;
999 return bqt->tag_index[tag]; 999 return bqt->tag_index[tag];
1000} 1000}
1001 1001enum{
1002extern int blkdev_issue_flush(struct block_device *, sector_t *); 1002 BLKDEV_WAIT, /* wait for completion */
1003#define DISCARD_FL_WAIT 0x01 /* wait for completion */ 1003 BLKDEV_BARRIER, /*issue request with barrier */
1004#define DISCARD_FL_BARRIER 0x02 /* issue DISCARD_BARRIER request */ 1004};
1005extern int blkdev_issue_discard(struct block_device *, sector_t sector, 1005#define BLKDEV_IFL_WAIT (1 << BLKDEV_WAIT)
1006 sector_t nr_sects, gfp_t, int flags); 1006#define BLKDEV_IFL_BARRIER (1 << BLKDEV_BARRIER)
1007extern int blkdev_issue_flush(struct block_device *, gfp_t, sector_t *,
1008 unsigned long);
1009extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
1010 sector_t nr_sects, gfp_t gfp_mask, unsigned long flags);
1007 1011
1008static inline int sb_issue_discard(struct super_block *sb, 1012static inline int sb_issue_discard(struct super_block *sb,
1009 sector_t block, sector_t nr_blocks) 1013 sector_t block, sector_t nr_blocks)
@@ -1011,7 +1015,7 @@ static inline int sb_issue_discard(struct super_block *sb,
1011 block <<= (sb->s_blocksize_bits - 9); 1015 block <<= (sb->s_blocksize_bits - 9);
1012 nr_blocks <<= (sb->s_blocksize_bits - 9); 1016 nr_blocks <<= (sb->s_blocksize_bits - 9);
1013 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL, 1017 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL,
1014 DISCARD_FL_BARRIER); 1018 BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER);
1015} 1019}
1016 1020
1017extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm); 1021extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm);
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 6cd0a8f90dc7..eb086e0f4dcc 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -139,7 +139,8 @@ static int discard_swap(struct swap_info_struct *si)
139 nr_blocks = ((sector_t)se->nr_pages - 1) << (PAGE_SHIFT - 9); 139 nr_blocks = ((sector_t)se->nr_pages - 1) << (PAGE_SHIFT - 9);
140 if (nr_blocks) { 140 if (nr_blocks) {
141 err = blkdev_issue_discard(si->bdev, start_block, 141 err = blkdev_issue_discard(si->bdev, start_block,
142 nr_blocks, GFP_KERNEL, DISCARD_FL_BARRIER); 142 nr_blocks, GFP_KERNEL,
143 BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER);
143 if (err) 144 if (err)
144 return err; 145 return err;
145 cond_resched(); 146 cond_resched();
@@ -150,7 +151,8 @@ static int discard_swap(struct swap_info_struct *si)
150 nr_blocks = (sector_t)se->nr_pages << (PAGE_SHIFT - 9); 151 nr_blocks = (sector_t)se->nr_pages << (PAGE_SHIFT - 9);
151 152
152 err = blkdev_issue_discard(si->bdev, start_block, 153 err = blkdev_issue_discard(si->bdev, start_block,
153 nr_blocks, GFP_KERNEL, DISCARD_FL_BARRIER); 154 nr_blocks, GFP_KERNEL,
155 BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER);
154 if (err) 156 if (err)
155 break; 157 break;
156 158
@@ -189,7 +191,8 @@ static void discard_swap_cluster(struct swap_info_struct *si,
189 start_block <<= PAGE_SHIFT - 9; 191 start_block <<= PAGE_SHIFT - 9;
190 nr_blocks <<= PAGE_SHIFT - 9; 192 nr_blocks <<= PAGE_SHIFT - 9;
191 if (blkdev_issue_discard(si->bdev, start_block, 193 if (blkdev_issue_discard(si->bdev, start_block,
192 nr_blocks, GFP_NOIO, DISCARD_FL_BARRIER)) 194 nr_blocks, GFP_NOIO, BLKDEV_IFL_WAIT |
195 BLKDEV_IFL_BARRIER))
193 break; 196 break;
194 } 197 }
195 198