Skip to content

Commit

Permalink
block: kill off REQ_UNPLUG
Browse files Browse the repository at this point in the history
With the plugging now being explicitly controlled by the
submitter, callers need not pass down unplugging hints
to the block layer. If they want to unplug, it's because they
manually plugged on their own - in which case, they should just
unplug at will.

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
  • Loading branch information
Jens Axboe committed Mar 10, 2011
1 parent cf15900 commit 721a960
Show file tree
Hide file tree
Showing 24 changed files with 43 additions and 75 deletions.
2 changes: 1 addition & 1 deletion block/blk-core.c
Expand Up @@ -1290,7 +1290,7 @@ static int __make_request(struct request_queue *q, struct bio *bio)
}

plug = current->plug;
if (plug && !sync) {
if (plug) {
if (!plug->should_sort && !list_empty(&plug->list)) {
struct request *__rq;

Expand Down
2 changes: 1 addition & 1 deletion drivers/block/drbd/drbd_actlog.c
Expand Up @@ -80,7 +80,7 @@ static int _drbd_md_sync_page_io(struct drbd_conf *mdev,

if ((rw & WRITE) && !test_bit(MD_NO_FUA, &mdev->flags))
rw |= REQ_FUA;
rw |= REQ_UNPLUG | REQ_SYNC;
rw |= REQ_SYNC;

bio = bio_alloc(GFP_NOIO, 1);
bio->bi_bdev = bdev->md_bdev;
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/drbd/drbd_int.h
Expand Up @@ -377,7 +377,7 @@ union p_header {
#define DP_HARDBARRIER 1 /* depricated */
#define DP_RW_SYNC 2 /* equals REQ_SYNC */
#define DP_MAY_SET_IN_SYNC 4
#define DP_UNPLUG 8 /* equals REQ_UNPLUG */
#define DP_UNPLUG 8 /* not used anymore */
#define DP_FUA 16 /* equals REQ_FUA */
#define DP_FLUSH 32 /* equals REQ_FLUSH */
#define DP_DISCARD 64 /* equals REQ_DISCARD */
Expand Down
3 changes: 1 addition & 2 deletions drivers/block/drbd/drbd_main.c
Expand Up @@ -2477,12 +2477,11 @@ static u32 bio_flags_to_wire(struct drbd_conf *mdev, unsigned long bi_rw)
{
if (mdev->agreed_pro_version >= 95)
return (bi_rw & REQ_SYNC ? DP_RW_SYNC : 0) |
(bi_rw & REQ_UNPLUG ? DP_UNPLUG : 0) |
(bi_rw & REQ_FUA ? DP_FUA : 0) |
(bi_rw & REQ_FLUSH ? DP_FLUSH : 0) |
(bi_rw & REQ_DISCARD ? DP_DISCARD : 0);
else
return bi_rw & (REQ_SYNC | REQ_UNPLUG) ? DP_RW_SYNC : 0;
return bi_rw & REQ_SYNC ? DP_RW_SYNC : 0;
}

/* Used to send write requests
Expand Down
9 changes: 1 addition & 8 deletions drivers/block/drbd/drbd_receiver.c
Expand Up @@ -1100,8 +1100,6 @@ int drbd_submit_ee(struct drbd_conf *mdev, struct drbd_epoch_entry *e,
/* > e->sector, unless this is the first bio */
bio->bi_sector = sector;
bio->bi_bdev = mdev->ldev->backing_bdev;
/* we special case some flags in the multi-bio case, see below
* (REQ_UNPLUG) */
bio->bi_rw = rw;
bio->bi_private = e;
bio->bi_end_io = drbd_endio_sec;
Expand Down Expand Up @@ -1130,10 +1128,6 @@ int drbd_submit_ee(struct drbd_conf *mdev, struct drbd_epoch_entry *e,
bios = bios->bi_next;
bio->bi_next = NULL;

/* strip off REQ_UNPLUG unless it is the last bio */
if (bios)
bio->bi_rw &= ~REQ_UNPLUG;

drbd_generic_make_request(mdev, fault_type, bio);
} while (bios);
return 0;
Expand Down Expand Up @@ -1621,12 +1615,11 @@ static unsigned long write_flags_to_bio(struct drbd_conf *mdev, u32 dpf)
{
if (mdev->agreed_pro_version >= 95)
return (dpf & DP_RW_SYNC ? REQ_SYNC : 0) |
(dpf & DP_UNPLUG ? REQ_UNPLUG : 0) |
(dpf & DP_FUA ? REQ_FUA : 0) |
(dpf & DP_FLUSH ? REQ_FUA : 0) |
(dpf & DP_DISCARD ? REQ_DISCARD : 0);
else
return dpf & DP_RW_SYNC ? (REQ_SYNC | REQ_UNPLUG) : 0;
return dpf & DP_RW_SYNC ? REQ_SYNC : 0;
}

/* mirrored write */
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/bitmap.c
Expand Up @@ -347,7 +347,7 @@ static void write_page(struct bitmap *bitmap, struct page *page, int wait)
atomic_inc(&bitmap->pending_writes);
set_buffer_locked(bh);
set_buffer_mapped(bh);
submit_bh(WRITE | REQ_UNPLUG | REQ_SYNC, bh);
submit_bh(WRITE | REQ_SYNC, bh);
bh = bh->b_this_page;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-io.c
Expand Up @@ -352,7 +352,7 @@ static void dispatch_io(int rw, unsigned int num_regions,
BUG_ON(num_regions > DM_IO_MAX_REGIONS);

if (sync)
rw |= REQ_SYNC | REQ_UNPLUG;
rw |= REQ_SYNC;

/*
* For multiple regions we need to be careful to rewind
Expand Down
5 changes: 1 addition & 4 deletions drivers/md/dm-kcopyd.c
Expand Up @@ -356,11 +356,8 @@ static int run_io_job(struct kcopyd_job *job)

if (job->rw == READ)
r = dm_io(&io_req, 1, &job->source, NULL);
else {
if (job->num_dests > 1)
io_req.bi_rw |= REQ_UNPLUG;
else
r = dm_io(&io_req, job->num_dests, job->dests, NULL);
}

return r;
}
Expand Down
5 changes: 2 additions & 3 deletions drivers/md/md.c
Expand Up @@ -777,8 +777,7 @@ void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev,
bio->bi_end_io = super_written;

atomic_inc(&mddev->pending_writes);
submit_bio(REQ_WRITE | REQ_SYNC | REQ_UNPLUG | REQ_FLUSH | REQ_FUA,
bio);
submit_bio(REQ_WRITE | REQ_SYNC | REQ_FLUSH | REQ_FUA, bio);
}

void md_super_wait(mddev_t *mddev)
Expand Down Expand Up @@ -806,7 +805,7 @@ int sync_page_io(mdk_rdev_t *rdev, sector_t sector, int size,
struct completion event;
int ret;

rw |= REQ_SYNC | REQ_UNPLUG;
rw |= REQ_SYNC;

bio->bi_bdev = (metadata_op && rdev->meta_bdev) ?
rdev->meta_bdev : rdev->bdev;
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/extent_io.c
Expand Up @@ -2182,7 +2182,7 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
unsigned long nr_written = 0;

if (wbc->sync_mode == WB_SYNC_ALL)
write_flags = WRITE_SYNC_PLUG;
write_flags = WRITE_SYNC;
else
write_flags = WRITE;

Expand Down
14 changes: 4 additions & 10 deletions fs/buffer.c
Expand Up @@ -767,7 +767,7 @@ static int fsync_buffers_list(spinlock_t *lock, struct list_head *list)
* still in flight on potentially older
* contents.
*/
write_dirty_buffer(bh, WRITE_SYNC_PLUG);
write_dirty_buffer(bh, WRITE_SYNC);

/*
* Kick off IO for the previous mapping. Note
Expand Down Expand Up @@ -1602,14 +1602,8 @@ EXPORT_SYMBOL(unmap_underlying_metadata);
* prevents this contention from occurring.
*
* If block_write_full_page() is called with wbc->sync_mode ==
* WB_SYNC_ALL, the writes are posted using WRITE_SYNC_PLUG; this
* causes the writes to be flagged as synchronous writes, but the
* block device queue will NOT be unplugged, since usually many pages
* will be pushed to the out before the higher-level caller actually
* waits for the writes to be completed. The various wait functions,
* such as wait_on_writeback_range() will ultimately call sync_page()
* which will ultimately call blk_run_backing_dev(), which will end up
* unplugging the device queue.
* WB_SYNC_ALL, the writes are posted using WRITE_SYNC; this
* causes the writes to be flagged as synchronous writes.
*/
static int __block_write_full_page(struct inode *inode, struct page *page,
get_block_t *get_block, struct writeback_control *wbc,
Expand All @@ -1622,7 +1616,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
const unsigned blocksize = 1 << inode->i_blkbits;
int nr_underway = 0;
int write_op = (wbc->sync_mode == WB_SYNC_ALL ?
WRITE_SYNC_PLUG : WRITE);
WRITE_SYNC : WRITE);

BUG_ON(!PageLocked(page));

Expand Down
2 changes: 1 addition & 1 deletion fs/direct-io.c
Expand Up @@ -1173,7 +1173,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
struct dio *dio;

if (rw & WRITE)
rw = WRITE_ODIRECT_PLUG;
rw = WRITE_ODIRECT;

if (bdev)
bdev_blkbits = blksize_bits(bdev_logical_block_size(bdev));
Expand Down
3 changes: 1 addition & 2 deletions fs/ext4/page-io.c
Expand Up @@ -310,8 +310,7 @@ static int io_submit_init(struct ext4_io_submit *io,
io_end->offset = (page->index << PAGE_CACHE_SHIFT) + bh_offset(bh);

io->io_bio = bio;
io->io_op = (wbc->sync_mode == WB_SYNC_ALL ?
WRITE_SYNC_PLUG : WRITE);
io->io_op = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);
io->io_next_block = bh->b_blocknr;
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions fs/gfs2/log.c
Expand Up @@ -121,7 +121,7 @@ __acquires(&sdp->sd_log_lock)
lock_buffer(bh);
if (test_clear_buffer_dirty(bh)) {
bh->b_end_io = end_buffer_write_sync;
submit_bh(WRITE_SYNC_PLUG, bh);
submit_bh(WRITE_SYNC, bh);
} else {
unlock_buffer(bh);
brelse(bh);
Expand Down Expand Up @@ -647,7 +647,7 @@ static void gfs2_ordered_write(struct gfs2_sbd *sdp)
lock_buffer(bh);
if (buffer_mapped(bh) && test_clear_buffer_dirty(bh)) {
bh->b_end_io = end_buffer_write_sync;
submit_bh(WRITE_SYNC_PLUG, bh);
submit_bh(WRITE_SYNC, bh);
} else {
unlock_buffer(bh);
brelse(bh);
Expand Down
12 changes: 6 additions & 6 deletions fs/gfs2/lops.c
Expand Up @@ -200,7 +200,7 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp)
}

gfs2_log_unlock(sdp);
submit_bh(WRITE_SYNC_PLUG, bh);
submit_bh(WRITE_SYNC, bh);
gfs2_log_lock(sdp);

n = 0;
Expand All @@ -210,7 +210,7 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp)
gfs2_log_unlock(sdp);
lock_buffer(bd2->bd_bh);
bh = gfs2_log_fake_buf(sdp, bd2->bd_bh);
submit_bh(WRITE_SYNC_PLUG, bh);
submit_bh(WRITE_SYNC, bh);
gfs2_log_lock(sdp);
if (++n >= num)
break;
Expand Down Expand Up @@ -352,7 +352,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
sdp->sd_log_num_revoke--;

if (offset + sizeof(u64) > sdp->sd_sb.sb_bsize) {
submit_bh(WRITE_SYNC_PLUG, bh);
submit_bh(WRITE_SYNC, bh);

bh = gfs2_log_get_buf(sdp);
mh = (struct gfs2_meta_header *)bh->b_data;
Expand All @@ -369,7 +369,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
}
gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke);

submit_bh(WRITE_SYNC_PLUG, bh);
submit_bh(WRITE_SYNC, bh);
}

static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
Expand Down Expand Up @@ -571,7 +571,7 @@ static void gfs2_write_blocks(struct gfs2_sbd *sdp, struct buffer_head *bh,
ptr = bh_log_ptr(bh);

get_bh(bh);
submit_bh(WRITE_SYNC_PLUG, bh);
submit_bh(WRITE_SYNC, bh);
gfs2_log_lock(sdp);
while(!list_empty(list)) {
bd = list_entry(list->next, struct gfs2_bufdata, bd_le.le_list);
Expand All @@ -597,7 +597,7 @@ static void gfs2_write_blocks(struct gfs2_sbd *sdp, struct buffer_head *bh,
} else {
bh1 = gfs2_log_fake_buf(sdp, bd->bd_bh);
}
submit_bh(WRITE_SYNC_PLUG, bh1);
submit_bh(WRITE_SYNC, bh1);
gfs2_log_lock(sdp);
ptr += 2;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/meta_io.c
Expand Up @@ -37,7 +37,7 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb
struct buffer_head *bh, *head;
int nr_underway = 0;
int write_op = REQ_META |
(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC_PLUG : WRITE);
(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);

BUG_ON(!PageLocked(page));
BUG_ON(!page_has_buffers(page));
Expand Down
2 changes: 1 addition & 1 deletion fs/jbd/commit.c
Expand Up @@ -333,7 +333,7 @@ void journal_commit_transaction(journal_t *journal)
* instead we rely on sync_buffer() doing the unplug for us.
*/
if (commit_transaction->t_synchronous_commit)
write_op = WRITE_SYNC_PLUG;
write_op = WRITE_SYNC;
spin_lock(&commit_transaction->t_handle_lock);
while (commit_transaction->t_updates) {
DEFINE_WAIT(wait);
Expand Down
6 changes: 3 additions & 3 deletions fs/jbd2/commit.c
Expand Up @@ -137,9 +137,9 @@ static int journal_submit_commit_record(journal_t *journal,
if (journal->j_flags & JBD2_BARRIER &&
!JBD2_HAS_INCOMPAT_FEATURE(journal,
JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT))
ret = submit_bh(WRITE_SYNC_PLUG | WRITE_FLUSH_FUA, bh);
ret = submit_bh(WRITE_SYNC | WRITE_FLUSH_FUA, bh);
else
ret = submit_bh(WRITE_SYNC_PLUG, bh);
ret = submit_bh(WRITE_SYNC, bh);

*cbh = bh;
return ret;
Expand Down Expand Up @@ -369,7 +369,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
* instead we rely on sync_buffer() doing the unplug for us.
*/
if (commit_transaction->t_synchronous_commit)
write_op = WRITE_SYNC_PLUG;
write_op = WRITE_SYNC;
trace_jbd2_commit_locking(journal, commit_transaction);
stats.run.rs_wait = commit_transaction->t_max_wait;
stats.run.rs_locked = jiffies;
Expand Down
2 changes: 1 addition & 1 deletion fs/nilfs2/segbuf.c
Expand Up @@ -509,7 +509,7 @@ static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf,
* Last BIO is always sent through the following
* submission.
*/
rw |= REQ_SYNC | REQ_UNPLUG;
rw |= REQ_SYNC;
res = nilfs_segbuf_submit_bio(segbuf, &wi, rw);
}

Expand Down
3 changes: 1 addition & 2 deletions fs/xfs/linux-2.6/xfs_aops.c
Expand Up @@ -413,8 +413,7 @@ xfs_submit_ioend_bio(
if (xfs_ioend_new_eof(ioend))
xfs_mark_inode_dirty(XFS_I(ioend->io_inode));

submit_bio(wbc->sync_mode == WB_SYNC_ALL ?
WRITE_SYNC_PLUG : WRITE, bio);
submit_bio(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE, bio);
}

STATIC struct bio *
Expand Down
2 changes: 0 additions & 2 deletions include/linux/blk_types.h
Expand Up @@ -128,7 +128,6 @@ enum rq_flag_bits {
__REQ_NOIDLE, /* don't anticipate more IO after this one */

/* bio only flags */
__REQ_UNPLUG, /* unplug the immediately after submission */
__REQ_RAHEAD, /* read ahead, can fail anytime */
__REQ_THROTTLED, /* This bio has already been subjected to
* throttling rules. Don't do it again. */
Expand Down Expand Up @@ -172,7 +171,6 @@ enum rq_flag_bits {
REQ_NOIDLE | REQ_FLUSH | REQ_FUA)
#define REQ_CLONE_MASK REQ_COMMON_MASK

#define REQ_UNPLUG (1 << __REQ_UNPLUG)
#define REQ_RAHEAD (1 << __REQ_RAHEAD)
#define REQ_THROTTLED (1 << __REQ_THROTTLED)

Expand Down
28 changes: 9 additions & 19 deletions include/linux/fs.h
Expand Up @@ -135,16 +135,10 @@ struct inodes_stat_t {
* block layer could (in theory) choose to ignore this
* request if it runs into resource problems.
* WRITE A normal async write. Device will be plugged.
* WRITE_SYNC_PLUG Synchronous write. Identical to WRITE, but passes down
* WRITE_SYNC Synchronous write. Identical to WRITE, but passes down
* the hint that someone will be waiting on this IO
* shortly. The device must still be unplugged explicitly,
* WRITE_SYNC_PLUG does not do this as we could be
* submitting more writes before we actually wait on any
* of them.
* WRITE_SYNC Like WRITE_SYNC_PLUG, but also unplugs the device
* immediately after submission. The write equivalent
* of READ_SYNC.
* WRITE_ODIRECT_PLUG Special case write for O_DIRECT only.
* shortly. The write equivalent of READ_SYNC.
* WRITE_ODIRECT Special case write for O_DIRECT only.
* WRITE_FLUSH Like WRITE_SYNC but with preceding cache flush.
* WRITE_FUA Like WRITE_SYNC but data is guaranteed to be on
* non-volatile media on completion.
Expand All @@ -160,18 +154,14 @@ struct inodes_stat_t {
#define WRITE RW_MASK
#define READA RWA_MASK

#define READ_SYNC (READ | REQ_SYNC | REQ_UNPLUG)
#define READ_SYNC (READ | REQ_SYNC)
#define READ_META (READ | REQ_META)
#define WRITE_SYNC_PLUG (WRITE | REQ_SYNC | REQ_NOIDLE)
#define WRITE_SYNC (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_UNPLUG)
#define WRITE_ODIRECT_PLUG (WRITE | REQ_SYNC)
#define WRITE_SYNC (WRITE | REQ_SYNC | REQ_NOIDLE)
#define WRITE_ODIRECT (WRITE | REQ_SYNC)
#define WRITE_META (WRITE | REQ_META)
#define WRITE_FLUSH (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_UNPLUG | \
REQ_FLUSH)
#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_UNPLUG | \
REQ_FUA)
#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_UNPLUG | \
REQ_FLUSH | REQ_FUA)
#define WRITE_FLUSH (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH)
#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA)
#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA)

#define SEL_IN 1
#define SEL_OUT 2
Expand Down
2 changes: 1 addition & 1 deletion kernel/power/block_io.c
Expand Up @@ -28,7 +28,7 @@
static int submit(int rw, struct block_device *bdev, sector_t sector,
struct page *page, struct bio **bio_chain)
{
const int bio_rw = rw | REQ_SYNC | REQ_UNPLUG;
const int bio_rw = rw | REQ_SYNC;
struct bio *bio;

bio = bio_alloc(__GFP_WAIT | __GFP_HIGH, 1);
Expand Down
2 changes: 1 addition & 1 deletion mm/page_io.c
Expand Up @@ -106,7 +106,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
goto out;
}
if (wbc->sync_mode == WB_SYNC_ALL)
rw |= REQ_SYNC | REQ_UNPLUG;
rw |= REQ_SYNC;
count_vm_event(PSWPOUT);
set_page_writeback(page);
unlock_page(page);
Expand Down

0 comments on commit 721a960

Please sign in to comment.