Skip to content

Commit dd3932e

Browse files
Christoph HellwigJens Axboe
authored andcommitted
block: remove BLKDEV_IFL_WAIT
All the blkdev_issue_* helpers can only sanely be used for synchronous caller. To issue cache flushes or barriers asynchronously the caller needs to set up a bio by itself with a completion callback to move the asynchronous state machine ahead. So drop the BLKDEV_IFL_WAIT flag that is always specified when calling blkdev_issue_* and also remove the now unused flags argument to blkdev_issue_flush and blkdev_issue_zeroout. For blkdev_issue_discard we need to keep it for the secure discard flag, which gains a more descriptive name and loses the bitops vs flag confusion. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 parent 8786fb7 commit dd3932e

19 files changed

Lines changed: 47 additions & 71 deletions

File tree

‎block/blk-flush.c‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ static void bio_end_flush(struct bio *bio, int err)
205205
* @bdev: blockdev to issue flush for
206206
* @gfp_mask: memory allocation flags (for bio_alloc)
207207
* @error_sector: error sector
208-
* @flags: BLKDEV_IFL_* flags to control behaviour
209208
*
210209
* Description:
211210
* Issue a flush for the block device in question. Caller can supply
@@ -214,7 +213,7 @@ static void bio_end_flush(struct bio *bio, int err)
214213
* request was pushed in some internal queue for later handling.
215214
*/
216215
int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
217-
sector_t *error_sector, unsigned long flags)
216+
sector_t *error_sector)
218217
{
219218
DECLARE_COMPLETION_ONSTACK(wait);
220219
struct request_queue *q;
@@ -240,21 +239,19 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
240239
bio = bio_alloc(gfp_mask, 0);
241240
bio->bi_end_io = bio_end_flush;
242241
bio->bi_bdev = bdev;
243-
if (test_bit(BLKDEV_WAIT, &flags))
244-
bio->bi_private = &wait;
242+
bio->bi_private = &wait;
245243

246244
bio_get(bio);
247245
submit_bio(WRITE_FLUSH, bio);
248-
if (test_bit(BLKDEV_WAIT, &flags)) {
249-
wait_for_completion(&wait);
250-
/*
251-
* The driver must store the error location in ->bi_sector, if
252-
* it supports it. For non-stacked drivers, this should be
253-
* copied from blk_rq_pos(rq).
254-
*/
255-
if (error_sector)
256-
*error_sector = bio->bi_sector;
257-
}
246+
wait_for_completion(&wait);
247+
248+
/*
249+
* The driver must store the error location in ->bi_sector, if
250+
* it supports it. For non-stacked drivers, this should be
251+
* copied from blk_rq_pos(rq).
252+
*/
253+
if (error_sector)
254+
*error_sector = bio->bi_sector;
258255

259256
if (!bio_flagged(bio, BIO_UPTODATE))
260257
ret = -EIO;

‎block/blk-lib.c‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
6161
max_discard_sectors &= ~(disc_sects - 1);
6262
}
6363

64-
if (flags & BLKDEV_IFL_SECURE) {
64+
if (flags & BLKDEV_DISCARD_SECURE) {
6565
if (!blk_queue_secdiscard(q))
6666
return -EOPNOTSUPP;
6767
type |= REQ_SECURE;
@@ -77,8 +77,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
7777
bio->bi_sector = sector;
7878
bio->bi_end_io = blkdev_discard_end_io;
7979
bio->bi_bdev = bdev;
80-
if (flags & BLKDEV_IFL_WAIT)
81-
bio->bi_private = &wait;
80+
bio->bi_private = &wait;
8281

8382
if (nr_sects > max_discard_sectors) {
8483
bio->bi_size = max_discard_sectors << 9;
@@ -92,8 +91,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
9291
bio_get(bio);
9392
submit_bio(type, bio);
9493

95-
if (flags & BLKDEV_IFL_WAIT)
96-
wait_for_completion(&wait);
94+
wait_for_completion(&wait);
9795

9896
if (bio_flagged(bio, BIO_EOPNOTSUPP))
9997
ret = -EOPNOTSUPP;
@@ -139,7 +137,6 @@ static void bio_batch_end_io(struct bio *bio, int err)
139137
* @sector: start sector
140138
* @nr_sects: number of sectors to write
141139
* @gfp_mask: memory allocation flags (for bio_alloc)
142-
* @flags: BLKDEV_IFL_* flags to control behaviour
143140
*
144141
* Description:
145142
* Generate and issue number of bios with zerofiled pages.
@@ -148,7 +145,7 @@ static void bio_batch_end_io(struct bio *bio, int err)
148145
*/
149146

150147
int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
151-
sector_t nr_sects, gfp_t gfp_mask, unsigned long flags)
148+
sector_t nr_sects, gfp_t gfp_mask)
152149
{
153150
int ret;
154151
struct bio *bio;
@@ -174,8 +171,7 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
174171
bio->bi_sector = sector;
175172
bio->bi_bdev = bdev;
176173
bio->bi_end_io = bio_batch_end_io;
177-
if (flags & BLKDEV_IFL_WAIT)
178-
bio->bi_private = &bb;
174+
bio->bi_private = &bb;
179175

180176
while (nr_sects != 0) {
181177
sz = min((sector_t) PAGE_SIZE >> 9 , nr_sects);
@@ -193,10 +189,9 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
193189
submit_bio(WRITE, bio);
194190
}
195191

196-
if (flags & BLKDEV_IFL_WAIT)
197-
/* Wait for bios in-flight */
198-
while ( issued != atomic_read(&bb.done))
199-
wait_for_completion(&wait);
192+
/* Wait for bios in-flight */
193+
while (issued != atomic_read(&bb.done))
194+
wait_for_completion(&wait);
200195

201196
if (!test_bit(BIO_UPTODATE, &bb.flags))
202197
/* One of bios in the batch was completed with error.*/

‎block/ioctl.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static int blkdev_reread_part(struct block_device *bdev)
116116
static int blk_ioctl_discard(struct block_device *bdev, uint64_t start,
117117
uint64_t len, int secure)
118118
{
119-
unsigned long flags = BLKDEV_IFL_WAIT;
119+
unsigned long flags = 0;
120120

121121
if (start & 511)
122122
return -EINVAL;
@@ -128,7 +128,7 @@ static int blk_ioctl_discard(struct block_device *bdev, uint64_t start,
128128
if (start + len > (bdev->bd_inode->i_size >> 9))
129129
return -EINVAL;
130130
if (secure)
131-
flags |= BLKDEV_IFL_SECURE;
131+
flags |= BLKDEV_DISCARD_SECURE;
132132
return blkdev_issue_discard(bdev, start, len, GFP_KERNEL, flags);
133133
}
134134

‎drivers/block/drbd/drbd_int.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,8 +2321,7 @@ static inline void drbd_md_flush(struct drbd_conf *mdev)
23212321
if (test_bit(MD_NO_BARRIER, &mdev->flags))
23222322
return;
23232323

2324-
r = blkdev_issue_flush(mdev->ldev->md_bdev, GFP_KERNEL, NULL,
2325-
BLKDEV_IFL_WAIT);
2324+
r = blkdev_issue_flush(mdev->ldev->md_bdev, GFP_KERNEL, NULL);
23262325
if (r) {
23272326
set_bit(MD_NO_BARRIER, &mdev->flags);
23282327
dev_err(DEV, "meta data flush failed with status %d, disabling md-flushes\n", r);

‎drivers/block/drbd/drbd_receiver.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ static enum finish_epoch drbd_flush_after_epoch(struct drbd_conf *mdev, struct d
975975

976976
if (mdev->write_ordering >= WO_bdev_flush && get_ldev(mdev)) {
977977
rv = blkdev_issue_flush(mdev->ldev->backing_bdev, GFP_KERNEL,
978-
NULL, BLKDEV_IFL_WAIT);
978+
NULL);
979979
if (rv) {
980980
dev_err(DEV, "local disk flush failed with status %d\n", rv);
981981
/* would rather check on EOPNOTSUPP, but that is not reliable.

‎fs/block_dev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ int blkdev_fsync(struct file *filp, int datasync)
370370
*/
371371
mutex_unlock(&bd_inode->i_mutex);
372372

373-
error = blkdev_issue_flush(bdev, GFP_KERNEL, NULL, BLKDEV_IFL_WAIT);
373+
error = blkdev_issue_flush(bdev, GFP_KERNEL, NULL);
374374
if (error == -EOPNOTSUPP)
375375
error = 0;
376376

‎fs/btrfs/extent-tree.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,8 +1695,7 @@ static int remove_extent_backref(struct btrfs_trans_handle *trans,
16951695
static void btrfs_issue_discard(struct block_device *bdev,
16961696
u64 start, u64 len)
16971697
{
1698-
blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL,
1699-
BLKDEV_IFL_WAIT);
1698+
blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL, 0);
17001699
}
17011700

17021701
static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,

‎fs/ext3/fsync.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ int ext3_sync_file(struct file *file, int datasync)
9090
* storage
9191
*/
9292
if (needs_barrier)
93-
blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL,
94-
BLKDEV_IFL_WAIT);
93+
blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
9594
return ret;
9695
}

‎fs/ext4/fsync.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,9 @@ int ext4_sync_file(struct file *file, int datasync)
128128
(journal->j_fs_dev != journal->j_dev) &&
129129
(journal->j_flags & JBD2_BARRIER))
130130
blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL,
131-
NULL, BLKDEV_IFL_WAIT);
131+
NULL);
132132
ret = jbd2_log_wait_commit(journal, commit_tid);
133133
} else if (journal->j_flags & JBD2_BARRIER)
134-
blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL,
135-
BLKDEV_IFL_WAIT);
134+
blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
136135
return ret;
137136
}

‎fs/ext4/mballoc.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,8 +2566,7 @@ static inline void ext4_issue_discard(struct super_block *sb,
25662566
discard_block = block + ext4_group_first_block_no(sb, block_group);
25672567
trace_ext4_discard_blocks(sb,
25682568
(unsigned long long) discard_block, count);
2569-
ret = sb_issue_discard(sb, discard_block, count, GFP_NOFS,
2570-
BLKDEV_IFL_WAIT);
2569+
ret = sb_issue_discard(sb, discard_block, count, GFP_NOFS, 0);
25712570
if (ret == EOPNOTSUPP) {
25722571
ext4_warning(sb, "discard not supported, disabling");
25732572
clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD);

0 commit comments

Comments
 (0)