Skip to contentSkip to conversation

block bits for 3.1-rc

GIT PULL In review Jens Axboe 5 participants 14 messages Aug 19, 2011 – Aug 23, 2011

Subsystems (5)
lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

Hi Linus,

This is a lot larger than it usually would be at this time. The reason is mostly the expedited merge window overlapping with my vacation. That said, the traffic in this branch in the last few weeks has only been fixes and it's continually been in linux-next and run on my various machines. So I'm quite confident that it's sound.

So what's in here:

- A few fixes for some cdrom corner cases.
- Flush fixing for stacked devices
- Revert of the CFQ meta data special treatment patch, it's been shown to regress a kernel build workload by about 10%. More investigation is needed, for 3.1 lets just back it out.
- bsg helper library, moving the FC class code into the block layer for proper sharing with eg iscsi/SAS.
- Nicer loop multi device handling code, and loop deadlock fix.
- Two fixups for xen-blkfront, one for xen-blkback.
- Fixups for rq_affinity changes that went into 3.1-rc1.
- Fixup for CFQ
- Support for properly tracing FLUSH and FUA commands with blktrace.

Diffstat looks large because of the bsg-lib addition, apart from that it's mostly smallish stuff.

Please pull.

git://git.kernel.dk/linux-block.git for-linus

Andrew Morton (1):
drivers/cdrom/cdrom.c: relax check on dvd manufacturer value

Axel Lin (1):
block: swim3: fix unterminated of_device_id table

H Hartley Sweeten (1):
drivers/block/drbd/drbd_nl.c: use bitmap_parse instead of __bitmap_parse

Herbert Poetzl (1):
block/genhd.c: remove useless cast in diskstats_show()

Jeff Moyer (2):
allow blk_flush_policy to return REQ_FSEQ_DATA independent of *FLUSH
block: fix flush machinery for stacking drivers with differring flush flags

Jens Axboe (3):
bsg-lib: add module.h include
Merge branch 'stable/for-jens' of git://git.kernel.org/.../konrad/xen into for-linus Revert "cfq: Remove special treatment for metadata rqs."

Kay Sievers (4):
loop: replace linked list of allocated devices with an idr index
loop: add management interface for on-demand device allocation
loop: add BLK_DEV_LOOP_MIN_COUNT=%i to allow distros 0 pre-allocated loop devices
loop: fix deadlock when sysfs and LOOP_CLR_FD race against each other

Konrad Rzeszutek Wilk (1):
xen/blkback: Make description more obvious.

Matthew Wilcox (1):
Move some REQ flags to the common bio/request area

Mike Christie (1):
block: add bsg helper library

Namhyung Kim (1):
blktrace: add FLUSH/FUA support

Shaohua Li (2):
blk-throttle: correctly determine sync bio
block: improve rq_affinity placement

Stefan Bader (2):
xen-blkfront: Drop name and minor adjustments for emulated scsi devices
xen-blkfront: Fix one off warning about name clash

Tao Ma (1):
block: Make rq_affinity = 1 work as expected

Vivek Goyal (2):
cfq-iosched: Reduce linked group count upon group destruction
cfq-iosched: Add documentation about idling

 Documentation/block/cfq-iosched.txt |   71 +++++++++
 Documentation/kernel-parameters.txt |    9 +-
 block/Kconfig                       |   10 ++
 block/Makefile                      |    1 +
 block/blk-core.c                    |    8 +-
 block/blk-flush.c                   |   25 +++-
 block/blk-softirq.c                 |    8 +
 block/blk-throttle.c                |    4 +-
 block/blk.h                         |    2 +
 block/bsg-lib.c                     |  298 +++++++++++++++++++++++++++++++++++
 block/cfq-iosched.c                 |   21 +++
 block/genhd.c                       |    8 +-
 drivers/block/Kconfig               |   17 ++-
 drivers/block/drbd/drbd_nl.c        |    4 +-
 drivers/block/loop.c                |  297 ++++++++++++++++++++++++-----------
 drivers/block/swim3.c               |    1 +
 drivers/block/xen-blkfront.c        |    6 +-
 drivers/cdrom/cdrom.c               |    8 +-
 include/linux/blk_types.h           |    7 +-
 include/linux/blkdev.h              |    5 +
 include/linux/blktrace_api.h        |    5 +-
 include/linux/bsg-lib.h             |   73 +++++++++
 include/linux/loop.h                |    5 +-
 include/linux/miscdevice.h          |    1 +
 include/trace/events/block.h        |   20 ++-
 kernel/trace/blktrace.c             |   21 ++-
 26 files changed, 800 insertions(+), 135 deletions(-)
 create mode 100644 block/bsg-lib.c
 create mode 100644 include/linux/bsg-lib.h
Signature · 1 line
Jens Axboe
#1 lore raw
Quoted 2 lines · Jens Axboe

This is a lot larger than it usually would be at this time.

Grr, grr, grr.

I took it, but I want you to *jump* if we have any problems..

Linus

author
#2 lore raw
Quoted 7 lines · Linus Torvalds
Quoted 2 lines · Jens Axboe

This is a lot larger than it usually would be at this time.

Grr, grr, grr.

I took it, but I want you to *jump* if we have any problems..

Sir, yes sir.

I realize it's way too large, and that's exactly why I let it simmer for a lot longer than usual post -rc1 pull requests. Next time please coordinate the merge window with my vacation, thanks!

Signature · 1 line
Jens Axboe
#3 lore raw
In reply to Jens Axboe
Quoted 3 lines · Jens Axboe

- Revert of the CFQ meta data special treatment patch, it's been shown to regress a kernel build workload by about 10%. More investigation is needed, for 3.1 lets just back it out.

Sorry, but you can't simply do that without any coordination. We have added that marker to xfs now that the stupid special casing stopped, and turning it back on will cause us massive slowdows. Next time please better coordinate this with its users. In fact I have never seen this patch or a discussion on any mailinglist.

#4 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 3 lines · Jens Axboe

- Revert of the CFQ meta data special treatment patch, it's been shown to regress a kernel build workload by about 10%. More investigation is needed, for 3.1 lets just back it out.

Sorry, but you can't simply do that without any coordination.  We have added that marker to xfs now that the stupid special casing stopped, and turning it back on will cause us massive slowdows.  Next time please better coordinate this with its users.  In fact I have never seen this patch or a discussion on any mailinglist.

lkml.org archive doesn't have the full thread for some reason, but here it is:
http://www.gossamer-threads.com/lists/linux/kernel/1420370

author
#5 lore raw
In reply to Christoph Hellwig
Quoted 10 lines · Christoph Hellwig
Quoted 3 lines · Jens Axboe

- Revert of the CFQ meta data special treatment patch, it's been shown to regress a kernel build workload by about 10%. More investigation is needed, for 3.1 lets just back it out.

Sorry, but you can't simply do that without any coordination. We have added that marker to xfs now that the stupid special casing stopped, and turning it back on will cause us massive slowdows. Next time please better coordinate this with its users. In fact I have never seen this patch or a discussion on any mailinglist.

The discussion was on lkml, as Mike points out. But yes, short time to react. Since I can't easily cater to both cases right now, how about we add a temporary second meta flag that is only used for tracing?

REQ_META = (__REQ_META | __REQ_META_TRACE),
RET_META_TRACE = __REQ_META_TRACE,

You get the idea. Not super pretty, but it should solve the immediate issue.

Signature · 1 line
Jens Axboe
#6 lore raw
Quoted 9 lines · Jens Axboe

The discussion was on lkml, as Mike points out. But yes, short time to react. Since I can't easily cater to both cases right now, how about we add a temporary second meta flag that is only used for tracing?

REQ_META = (__REQ_META | __REQ_META_TRACE),
RET_META_TRACE = __REQ_META_TRACE,

You get the idea. Not super pretty, but it should solve the immediate issue.

I'd do it the other way around and add a new REQ_META_BOOST flag to the old callers. I'll cook up a patch on the airport / on my flight if you want.

author
#7 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · Jens Axboe

The discussion was on lkml, as Mike points out. But yes, short time to react. Since I can't easily cater to both cases right now, how about we add a temporary second meta flag that is only used for tracing?

REQ_META = (__REQ_META | __REQ_META_TRACE),
RET_META_TRACE = __REQ_META_TRACE,

Quoted 6 lines
Quoted 2 lines

You get the idea. Not super pretty, but it should solve the immediate issue.

I'd do it the other way around and add a new REQ_META_BOOST flag to the old callers. I'll cook up a patch on the airport / on my flight if you want.

That would work fine as well, please do cook up the patch if you have flight time anyway :-)

Signature · 1 line
Jens Axboe
#8 lore raw

PATCH 1/2 block: remove READ_META and WRITE_META

Replace all occurnanced of the undocumented READ_META with READ | REQ_META and remove the unused WRITE_META define.

fs/ext3/inode.c +2 -2
Index: linux-2.6/fs/ext3/inode.c
===================================================================
@@ -1134,7 +1134,7 @@ struct buffer_head *ext3_bread(handle_t
 		return bh;
 	if (buffer_uptodate(bh))
 		return bh;
-	ll_rw_block(READ_META, 1, &bh);
+	ll_rw_block(READ | REQ_META, 1, &bh);
 	wait_on_buffer(bh);
 	if (buffer_uptodate(bh))
 		return bh;
@@ -2807,7 +2807,7 @@ make_io:
 		trace_ext3_load_inode(inode);
 		get_bh(bh);
 		bh->b_end_io = end_buffer_read_sync;
-		submit_bh(READ_META, bh);
+		submit_bh(READ | REQ_META, bh);
 		wait_on_buffer(bh);
 		if (!buffer_uptodate(bh)) {
 			ext3_error(inode->i_sb, "ext3_get_inode_loc",
fs/ext3/namei.c +1 -1
Index: linux-2.6/fs/ext3/namei.c
===================================================================
@@ -922,7 +922,7 @@ restart:
 				bh = ext3_getblk(NULL, dir, b++, 0, &err);
 				bh_use[ra_max] = bh;
 				if (bh)
-					ll_rw_block(READ_META, 1, &bh);
+					ll_rw_block(READ | REQ_META, 1, &bh);
 			}
 		}
 		if ((bh = bh_use[ra_ptr++]) == NULL)
fs/ext4/inode.c +2 -2
Index: linux-2.6/fs/ext4/inode.c
===================================================================
@@ -650,7 +650,7 @@ struct buffer_head *ext4_bread(handle_t
 		return bh;
 	if (buffer_uptodate(bh))
 		return bh;
-	ll_rw_block(READ_META, 1, &bh);
+	ll_rw_block(READ | REQ_META, 1, &bh);
 	wait_on_buffer(bh);
 	if (buffer_uptodate(bh))
 		return bh;
@@ -3301,7 +3301,7 @@ make_io:
 		trace_ext4_load_inode(inode);
 		get_bh(bh);
 		bh->b_end_io = end_buffer_read_sync;
-		submit_bh(READ_META, bh);
+		submit_bh(READ | REQ_META, bh);
 		wait_on_buffer(bh);
 		if (!buffer_uptodate(bh)) {
 			EXT4_ERROR_INODE_BLOCK(inode, block,
fs/ext4/namei.c +1 -1
Index: linux-2.6/fs/ext4/namei.c
===================================================================
@@ -922,7 +922,7 @@ restart:
 				bh = ext4_getblk(NULL, dir, b++, 0, &err);
 				bh_use[ra_max] = bh;
 				if (bh)
-					ll_rw_block(READ_META, 1, &bh);
+					ll_rw_block(READ | REQ_META, 1, &bh);
 			}
 		}
 		if ((bh = bh_use[ra_ptr++]) == NULL)
fs/gfs2/quota.c +1 -1
Index: linux-2.6/fs/gfs2/quota.c
===================================================================
@@ -709,7 +709,7 @@ get_a_page:
 		set_buffer_uptodate(bh);
 
 	if (!buffer_uptodate(bh)) {
-		ll_rw_block(READ_META, 1, &bh);
+		ll_rw_block(READ | REQ_META, 1, &bh);
 		wait_on_buffer(bh);
 		if (!buffer_uptodate(bh))
 			goto unlock_out;
include/linux/fs.h +0 -2
Index: linux-2.6/include/linux/fs.h
===================================================================
@@ -162,10 +162,8 @@ struct inodes_stat_t {
 #define READA			RWA_MASK
 
 #define READ_SYNC		(READ | REQ_SYNC)
-#define READ_META		(READ | REQ_META)
 #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_FLUSH)
 #define WRITE_FUA		(WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA)
 #define WRITE_FLUSH_FUA		(WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA)
#9 lore raw

PATCH 2/2 block: separate priority boosting from REQ_META

In reply to Jens Axboe

Add a new REQ_PRIO to let requests preempt others in the cfq I/O schedule, and lave REQ_META purely for marking requests as metadata in blktrace.

All existing callers of REQ_META except for XFS are updated to also set REQ_PRIO for now.

block/cfq-iosched.c +10 -10
Index: linux-2.6/block/cfq-iosched.c
===================================================================
@@ -130,8 +130,8 @@ struct cfq_queue {
 	unsigned long slice_end;
 	long slice_resid;
 
-	/* pending metadata requests */
-	int meta_pending;
+	/* pending priority requests */
+	int prio_pending;
 	/* number of requests that are on the dispatch list or inside driver */
 	int dispatched;
 
@@ -684,8 +684,8 @@ cfq_choose_req(struct cfq_data *cfqd, st
 	if (rq_is_sync(rq1) != rq_is_sync(rq2))
 		return rq_is_sync(rq1) ? rq1 : rq2;
 
-	if ((rq1->cmd_flags ^ rq2->cmd_flags) & REQ_META)
-		return rq1->cmd_flags & REQ_META ? rq1 : rq2;
+	if ((rq1->cmd_flags ^ rq2->cmd_flags) & REQ_PRIO)
+		return rq1->cmd_flags & REQ_PRIO ? rq1 : rq2;
 
 	s1 = blk_rq_pos(rq1);
 	s2 = blk_rq_pos(rq2);
@@ -1612,9 +1612,9 @@ static void cfq_remove_request(struct re
 	cfqq->cfqd->rq_queued--;
 	cfq_blkiocg_update_io_remove_stats(&(RQ_CFQG(rq))->blkg,
 					rq_data_dir(rq), rq_is_sync(rq));
-	if (rq->cmd_flags & REQ_META) {
-		WARN_ON(!cfqq->meta_pending);
-		cfqq->meta_pending--;
+	if (rq->cmd_flags & REQ_PRIO) {
+		WARN_ON(!cfqq->prio_pending);
+		cfqq->prio_pending--;
 	}
 }
 
@@ -3372,7 +3372,7 @@ cfq_should_preempt(struct cfq_data *cfqd
 	 * So both queues are sync. Let the new request get disk time if
 	 * it's a metadata request and the current queue is doing regular IO.
 	 */
-	if ((rq->cmd_flags & REQ_META) && !cfqq->meta_pending)
+	if ((rq->cmd_flags & REQ_PRIO) && !cfqq->prio_pending)
 		return true;
 
 	/*
@@ -3439,8 +3439,8 @@ cfq_rq_enqueued(struct cfq_data *cfqd, s
 	struct cfq_io_context *cic = RQ_CIC(rq);
 
 	cfqd->rq_queued++;
-	if (rq->cmd_flags & REQ_META)
-		cfqq->meta_pending++;
+	if (rq->cmd_flags & REQ_PRIO)
+		cfqq->prio_pending++;
 
 	cfq_update_io_thinktime(cfqd, cfqq, cic);
 	cfq_update_io_seektime(cfqd, cfqq, rq);
drivers/mmc/card/block.c +3 -0
Index: linux-2.6/drivers/mmc/card/block.c
===================================================================
@@ -926,6 +926,9 @@ static void mmc_blk_rw_rq_prep(struct mm
 	/*
 	 * Reliable writes are used to implement Forced Unit Access and
 	 * REQ_META accesses, and are supported only on MMCs.
+	 *
+	 * XXX: this really needs a good explanation of why REQ_META
+	 * is treated special.
 	 */
 	bool do_rel_wr = ((req->cmd_flags & REQ_FUA) ||
 			  (req->cmd_flags & REQ_META)) &&
fs/ext3/inode.c +2 -2
Index: linux-2.6/fs/ext3/inode.c
===================================================================
@@ -1134,7 +1134,7 @@ struct buffer_head *ext3_bread(handle_t
 		return bh;
 	if (buffer_uptodate(bh))
 		return bh;
-	ll_rw_block(READ | REQ_META, 1, &bh);
+	ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh);
 	wait_on_buffer(bh);
 	if (buffer_uptodate(bh))
 		return bh;
@@ -2807,7 +2807,7 @@ make_io:
 		trace_ext3_load_inode(inode);
 		get_bh(bh);
 		bh->b_end_io = end_buffer_read_sync;
-		submit_bh(READ | REQ_META, bh);
+		submit_bh(READ | REQ_META | REQ_PRIO, bh);
 		wait_on_buffer(bh);
 		if (!buffer_uptodate(bh)) {
 			ext3_error(inode->i_sb, "ext3_get_inode_loc",
fs/ext3/namei.c +2 -1
Index: linux-2.6/fs/ext3/namei.c
===================================================================
@@ -922,7 +922,8 @@ restart:
 				bh = ext3_getblk(NULL, dir, b++, 0, &err);
 				bh_use[ra_max] = bh;
 				if (bh)
-					ll_rw_block(READ | REQ_META, 1, &bh);
+					ll_rw_block(READ | REQ_META | REQ_PRIO,
+						    1, &bh);
 			}
 		}
 		if ((bh = bh_use[ra_ptr++]) == NULL)
fs/ext4/inode.c +2 -2
Index: linux-2.6/fs/ext4/inode.c
===================================================================
@@ -650,7 +650,7 @@ struct buffer_head *ext4_bread(handle_t
 		return bh;
 	if (buffer_uptodate(bh))
 		return bh;
-	ll_rw_block(READ | REQ_META, 1, &bh);
+	ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh);
 	wait_on_buffer(bh);
 	if (buffer_uptodate(bh))
 		return bh;
@@ -3301,7 +3301,7 @@ make_io:
 		trace_ext4_load_inode(inode);
 		get_bh(bh);
 		bh->b_end_io = end_buffer_read_sync;
-		submit_bh(READ | REQ_META, bh);
+		submit_bh(READ | REQ_META | REQ_PRIO, bh);
 		wait_on_buffer(bh);
 		if (!buffer_uptodate(bh)) {
 			EXT4_ERROR_INODE_BLOCK(inode, block,
fs/ext4/namei.c +2 -1
Index: linux-2.6/fs/ext4/namei.c
===================================================================
@@ -922,7 +922,8 @@ restart:
 				bh = ext4_getblk(NULL, dir, b++, 0, &err);
 				bh_use[ra_max] = bh;
 				if (bh)
-					ll_rw_block(READ | REQ_META, 1, &bh);
+					ll_rw_block(READ | REQ_META | REQ_PRIO,
+						    1, &bh);
 			}
 		}
 		if ((bh = bh_use[ra_ptr++]) == NULL)
fs/gfs2/log.c +2 -2
Index: linux-2.6/fs/gfs2/log.c
===================================================================
@@ -624,9 +624,9 @@ static void log_write_header(struct gfs2
 	bh->b_end_io = end_buffer_write_sync;
 	get_bh(bh);
 	if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags))
-		submit_bh(WRITE_SYNC | REQ_META, bh);
+		submit_bh(WRITE_SYNC | REQ_META | REQ_PRIO, bh);
 	else
-		submit_bh(WRITE_FLUSH_FUA | REQ_META, bh);
+		submit_bh(WRITE_FLUSH_FUA | REQ_META | REQ_PRIO, bh);
 	wait_on_buffer(bh);
 
 	if (!buffer_uptodate(bh))
fs/gfs2/meta_io.c +3 -3
Index: linux-2.6/fs/gfs2/meta_io.c
===================================================================
@@ -37,7 +37,7 @@ static int gfs2_aspace_writepage(struct
 {
 	struct buffer_head *bh, *head;
 	int nr_underway = 0;
-	int write_op = REQ_META |
+	int write_op = REQ_META | REQ_PRIO |
 		(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);
 
 	BUG_ON(!PageLocked(page));
@@ -225,7 +225,7 @@ int gfs2_meta_read(struct gfs2_glock *gl
 	}
 	bh->b_end_io = end_buffer_read_sync;
 	get_bh(bh);
-	submit_bh(READ_SYNC | REQ_META, bh);
+	submit_bh(READ_SYNC | REQ_META | REQ_PRIO, bh);
 	if (!(flags & DIO_WAIT))
 		return 0;
 
@@ -435,7 +435,7 @@ struct buffer_head *gfs2_meta_ra(struct
 	if (buffer_uptodate(first_bh))
 		goto out;
 	if (!buffer_locked(first_bh))
-		ll_rw_block(READ_SYNC | REQ_META, 1, &first_bh);
+		ll_rw_block(READ_SYNC | REQ_META | REQ_PRIO, 1, &first_bh);
 
 	dblock++;
 	extlen--;
fs/gfs2/ops_fstype.c +1 -1
Index: linux-2.6/fs/gfs2/ops_fstype.c
===================================================================
@@ -224,7 +224,7 @@ static int gfs2_read_super(struct gfs2_s
 
 	bio->bi_end_io = end_bio_io_page;
 	bio->bi_private = page;
-	submit_bio(READ_SYNC | REQ_META, bio);
+	submit_bio(READ_SYNC | REQ_META | REQ_PRIO, bio);
 	wait_on_page_locked(page);
 	bio_put(bio);
 	if (!PageUptodate(page)) {
fs/gfs2/quota.c +1 -1
Index: linux-2.6/fs/gfs2/quota.c
===================================================================
@@ -709,7 +709,7 @@ get_a_page:
 		set_buffer_uptodate(bh);
 
 	if (!buffer_uptodate(bh)) {
-		ll_rw_block(READ | REQ_META, 1, &bh);
+		ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh);
 		wait_on_buffer(bh);
 		if (!buffer_uptodate(bh))
 			goto unlock_out;
include/linux/blk_types.h +3 -1
Index: linux-2.6/include/linux/blk_types.h
===================================================================
@@ -124,6 +124,7 @@ enum rq_flag_bits {
 
 	__REQ_SYNC,		/* request is sync (sync write or read) */
 	__REQ_META,		/* metadata io request */
+	__REQ_PRIO,
 	__REQ_DISCARD,		/* request to discard sectors */
 	__REQ_SECURE,		/* secure discard (used with __REQ_DISCARD) */
 
@@ -161,13 +162,14 @@ enum rq_flag_bits {
 #define REQ_FAILFAST_DRIVER	(1 << __REQ_FAILFAST_DRIVER)
 #define REQ_SYNC		(1 << __REQ_SYNC)
 #define REQ_META		(1 << __REQ_META)
+#define REQ_PRIO		(1 << __REQ_PRIO)
 #define REQ_DISCARD		(1 << __REQ_DISCARD)
 #define REQ_NOIDLE		(1 << __REQ_NOIDLE)
 
 #define REQ_FAILFAST_MASK \
 	(REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)
 #define REQ_COMMON_MASK \
-	(REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_DISCARD | \
+	(REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_PRIO | REQ_DISCARD | \
 	 REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE)
 #define REQ_CLONE_MASK		REQ_COMMON_MASK
 
#10 lore raw

Re: [PATCH 2/2] block: separate priority boosting from REQ_META

Hello,

Quoted 8 lines · Christoph Hellwig

Add a new REQ_PRIO to let requests preempt others in the cfq I/O schedule, and lave REQ_META purely for marking requests as metadata in blktrace.

All existing callers of REQ_META except for XFS are updated to also set REQ_PRIO for now.

snipped...

include/linux/blk_types.h enum rq_flag_bits { · line 127

Quoted 9 lines

Index: linux-2.6/include/linux/blk_types.h
===================================================================

include/linux/blk_types.h +1 -0
@@ -124,6 +124,7 @@ enum rq_flag_bits {
 
 	__REQ_SYNC,		/* request is sync (sync write or read) */
 	__REQ_META,		/* metadata io request */
+	__REQ_PRIO,

It'd be better if it's commented too, IMHO.

Quoted 9 lines
include/linux/blk_types.h +1 -0
 	__REQ_DISCARD,		/* request to discard sectors */
 	__REQ_SECURE,		/* secure discard (used with __REQ_DISCARD) */
 
@@ -161,13 +162,14 @@ enum rq_flag_bits {
 #define REQ_FAILFAST_DRIVER	(1 << __REQ_FAILFAST_DRIVER)
 #define REQ_SYNC		(1 << __REQ_SYNC)
 #define REQ_META		(1 << __REQ_META)
+#define REQ_PRIO		(1 << __REQ_PRIO)
 #define REQ_DISCARD		(1 << __REQ_DISCARD)

include/linux/blk_types.h enum rq_flag_bits { · line 175

Quoted 10 lines
include/linux/blk_types.h +1 -1
 #define REQ_NOIDLE		(1 << __REQ_NOIDLE)
 
 #define REQ_FAILFAST_MASK \
 	(REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)
 #define REQ_COMMON_MASK \
-	(REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_DISCARD | \
+	(REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_PRIO | REQ_DISCARD | \
 	 REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE)
 #define REQ_CLONE_MASK		REQ_COMMON_MASK
 

I think you need to include REQ_META into REQ_COMMON_MASK in order to track those requests using blktrace.

Thanks.

#11 lore raw

PATCH v2 2/2 block: separate priority boosting from REQ_META

Add a new REQ_PRIO to let requests preempt others in the cfq I/O schedule, and lave REQ_META purely for marking requests as metadata in blktrace.

All existing callers of REQ_META except for XFS are updated to also set REQ_PRIO for now.

block/cfq-iosched.c +10 -10
Index: linux-2.6/block/cfq-iosched.c
===================================================================
@@ -130,8 +130,8 @@ struct cfq_queue {
 	unsigned long slice_end;
 	long slice_resid;
 
-	/* pending metadata requests */
-	int meta_pending;
+	/* pending priority requests */
+	int prio_pending;
 	/* number of requests that are on the dispatch list or inside driver */
 	int dispatched;
 
@@ -684,8 +684,8 @@ cfq_choose_req(struct cfq_data *cfqd, st
 	if (rq_is_sync(rq1) != rq_is_sync(rq2))
 		return rq_is_sync(rq1) ? rq1 : rq2;
 
-	if ((rq1->cmd_flags ^ rq2->cmd_flags) & REQ_META)
-		return rq1->cmd_flags & REQ_META ? rq1 : rq2;
+	if ((rq1->cmd_flags ^ rq2->cmd_flags) & REQ_PRIO)
+		return rq1->cmd_flags & REQ_PRIO ? rq1 : rq2;
 
 	s1 = blk_rq_pos(rq1);
 	s2 = blk_rq_pos(rq2);
@@ -1612,9 +1612,9 @@ static void cfq_remove_request(struct re
 	cfqq->cfqd->rq_queued--;
 	cfq_blkiocg_update_io_remove_stats(&(RQ_CFQG(rq))->blkg,
 					rq_data_dir(rq), rq_is_sync(rq));
-	if (rq->cmd_flags & REQ_META) {
-		WARN_ON(!cfqq->meta_pending);
-		cfqq->meta_pending--;
+	if (rq->cmd_flags & REQ_PRIO) {
+		WARN_ON(!cfqq->prio_pending);
+		cfqq->prio_pending--;
 	}
 }
 
@@ -3372,7 +3372,7 @@ cfq_should_preempt(struct cfq_data *cfqd
 	 * So both queues are sync. Let the new request get disk time if
 	 * it's a metadata request and the current queue is doing regular IO.
 	 */
-	if ((rq->cmd_flags & REQ_META) && !cfqq->meta_pending)
+	if ((rq->cmd_flags & REQ_PRIO) && !cfqq->prio_pending)
 		return true;
 
 	/*
@@ -3439,8 +3439,8 @@ cfq_rq_enqueued(struct cfq_data *cfqd, s
 	struct cfq_io_context *cic = RQ_CIC(rq);
 
 	cfqd->rq_queued++;
-	if (rq->cmd_flags & REQ_META)
-		cfqq->meta_pending++;
+	if (rq->cmd_flags & REQ_PRIO)
+		cfqq->prio_pending++;
 
 	cfq_update_io_thinktime(cfqd, cfqq, cic);
 	cfq_update_io_seektime(cfqd, cfqq, rq);
drivers/mmc/card/block.c +3 -0
Index: linux-2.6/drivers/mmc/card/block.c
===================================================================
@@ -926,6 +926,9 @@ static void mmc_blk_rw_rq_prep(struct mm
 	/*
 	 * Reliable writes are used to implement Forced Unit Access and
 	 * REQ_META accesses, and are supported only on MMCs.
+	 *
+	 * XXX: this really needs a good explanation of why REQ_META
+	 * is treated special.
 	 */
 	bool do_rel_wr = ((req->cmd_flags & REQ_FUA) ||
 			  (req->cmd_flags & REQ_META)) &&
fs/ext3/inode.c +2 -2
Index: linux-2.6/fs/ext3/inode.c
===================================================================
@@ -1134,7 +1134,7 @@ struct buffer_head *ext3_bread(handle_t
 		return bh;
 	if (buffer_uptodate(bh))
 		return bh;
-	ll_rw_block(READ | REQ_META, 1, &bh);
+	ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh);
 	wait_on_buffer(bh);
 	if (buffer_uptodate(bh))
 		return bh;
@@ -2807,7 +2807,7 @@ make_io:
 		trace_ext3_load_inode(inode);
 		get_bh(bh);
 		bh->b_end_io = end_buffer_read_sync;
-		submit_bh(READ | REQ_META, bh);
+		submit_bh(READ | REQ_META | REQ_PRIO, bh);
 		wait_on_buffer(bh);
 		if (!buffer_uptodate(bh)) {
 			ext3_error(inode->i_sb, "ext3_get_inode_loc",
fs/ext3/namei.c +2 -1
Index: linux-2.6/fs/ext3/namei.c
===================================================================
@@ -922,7 +922,8 @@ restart:
 				bh = ext3_getblk(NULL, dir, b++, 0, &err);
 				bh_use[ra_max] = bh;
 				if (bh)
-					ll_rw_block(READ | REQ_META, 1, &bh);
+					ll_rw_block(READ | REQ_META | REQ_PRIO,
+						    1, &bh);
 			}
 		}
 		if ((bh = bh_use[ra_ptr++]) == NULL)
fs/ext4/inode.c +2 -2
Index: linux-2.6/fs/ext4/inode.c
===================================================================
@@ -650,7 +650,7 @@ struct buffer_head *ext4_bread(handle_t
 		return bh;
 	if (buffer_uptodate(bh))
 		return bh;
-	ll_rw_block(READ | REQ_META, 1, &bh);
+	ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh);
 	wait_on_buffer(bh);
 	if (buffer_uptodate(bh))
 		return bh;
@@ -3301,7 +3301,7 @@ make_io:
 		trace_ext4_load_inode(inode);
 		get_bh(bh);
 		bh->b_end_io = end_buffer_read_sync;
-		submit_bh(READ | REQ_META, bh);
+		submit_bh(READ | REQ_META | REQ_PRIO, bh);
 		wait_on_buffer(bh);
 		if (!buffer_uptodate(bh)) {
 			EXT4_ERROR_INODE_BLOCK(inode, block,
fs/ext4/namei.c +2 -1
Index: linux-2.6/fs/ext4/namei.c
===================================================================
@@ -922,7 +922,8 @@ restart:
 				bh = ext4_getblk(NULL, dir, b++, 0, &err);
 				bh_use[ra_max] = bh;
 				if (bh)
-					ll_rw_block(READ | REQ_META, 1, &bh);
+					ll_rw_block(READ | REQ_META | REQ_PRIO,
+						    1, &bh);
 			}
 		}
 		if ((bh = bh_use[ra_ptr++]) == NULL)
fs/gfs2/log.c +2 -2
Index: linux-2.6/fs/gfs2/log.c
===================================================================
@@ -624,9 +624,9 @@ static void log_write_header(struct gfs2
 	bh->b_end_io = end_buffer_write_sync;
 	get_bh(bh);
 	if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags))
-		submit_bh(WRITE_SYNC | REQ_META, bh);
+		submit_bh(WRITE_SYNC | REQ_META | REQ_PRIO, bh);
 	else
-		submit_bh(WRITE_FLUSH_FUA | REQ_META, bh);
+		submit_bh(WRITE_FLUSH_FUA | REQ_META | REQ_PRIO, bh);
 	wait_on_buffer(bh);
 
 	if (!buffer_uptodate(bh))
fs/gfs2/meta_io.c +3 -3
Index: linux-2.6/fs/gfs2/meta_io.c
===================================================================
@@ -37,7 +37,7 @@ static int gfs2_aspace_writepage(struct
 {
 	struct buffer_head *bh, *head;
 	int nr_underway = 0;
-	int write_op = REQ_META |
+	int write_op = REQ_META | REQ_PRIO |
 		(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);
 
 	BUG_ON(!PageLocked(page));
@@ -225,7 +225,7 @@ int gfs2_meta_read(struct gfs2_glock *gl
 	}
 	bh->b_end_io = end_buffer_read_sync;
 	get_bh(bh);
-	submit_bh(READ_SYNC | REQ_META, bh);
+	submit_bh(READ_SYNC | REQ_META | REQ_PRIO, bh);
 	if (!(flags & DIO_WAIT))
 		return 0;
 
@@ -435,7 +435,7 @@ struct buffer_head *gfs2_meta_ra(struct
 	if (buffer_uptodate(first_bh))
 		goto out;
 	if (!buffer_locked(first_bh))
-		ll_rw_block(READ_SYNC | REQ_META, 1, &first_bh);
+		ll_rw_block(READ_SYNC | REQ_META | REQ_PRIO, 1, &first_bh);
 
 	dblock++;
 	extlen--;
fs/gfs2/ops_fstype.c +1 -1
Index: linux-2.6/fs/gfs2/ops_fstype.c
===================================================================
@@ -224,7 +224,7 @@ static int gfs2_read_super(struct gfs2_s
 
 	bio->bi_end_io = end_bio_io_page;
 	bio->bi_private = page;
-	submit_bio(READ_SYNC | REQ_META, bio);
+	submit_bio(READ_SYNC | REQ_META | REQ_PRIO, bio);
 	wait_on_page_locked(page);
 	bio_put(bio);
 	if (!PageUptodate(page)) {
fs/gfs2/quota.c +1 -1
Index: linux-2.6/fs/gfs2/quota.c
===================================================================
@@ -709,7 +709,7 @@ get_a_page:
 		set_buffer_uptodate(bh);
 
 	if (!buffer_uptodate(bh)) {
-		ll_rw_block(READ | REQ_META, 1, &bh);
+		ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh);
 		wait_on_buffer(bh);
 		if (!buffer_uptodate(bh))
 			goto unlock_out;
include/linux/blk_types.h +4 -2
Index: linux-2.6/include/linux/blk_types.h
===================================================================
@@ -124,6 +124,7 @@ enum rq_flag_bits {
 
 	__REQ_SYNC,		/* request is sync (sync write or read) */
 	__REQ_META,		/* metadata io request */
+	__REQ_PRIO,		/* boost priority in cfq */
 	__REQ_DISCARD,		/* request to discard sectors */
 	__REQ_SECURE,		/* secure discard (used with __REQ_DISCARD) */
 
@@ -161,14 +162,15 @@ enum rq_flag_bits {
 #define REQ_FAILFAST_DRIVER	(1 << __REQ_FAILFAST_DRIVER)
 #define REQ_SYNC		(1 << __REQ_SYNC)
 #define REQ_META		(1 << __REQ_META)
+#define REQ_PRIO		(1 << __REQ_PRIO)
 #define REQ_DISCARD		(1 << __REQ_DISCARD)
 #define REQ_NOIDLE		(1 << __REQ_NOIDLE)
 
 #define REQ_FAILFAST_MASK \
 	(REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)
 #define REQ_COMMON_MASK \
-	(REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_DISCARD | \
-	 REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE)
+	(REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_PRIO | \
+	 REQ_DISCARD | REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE)
 #define REQ_CLONE_MASK		REQ_COMMON_MASK
 
 #define REQ_RAHEAD		(1 << __REQ_RAHEAD)
Reviewed-by on v2 2/2
#12 lore raw

Re: [PATCH 2/2 v2] block: separate priority boosting from REQ_META

2011-08-23 (화), 06:09 -0400, Christoph Hellwig:

Quoted 7 lines

Add a new REQ_PRIO to let requests preempt others in the cfq I/O schedule, and lave REQ_META purely for marking requests as metadata in blktrace.

All existing callers of REQ_META except for XFS are updated to also set REQ_PRIO for now.

Thanks.

Signature · 2 lines
Regards,
Namhyung Kim
author Applied
#13 lore raw

Re: [PATCH 2/2 v2] block: separate priority boosting from REQ_META

In reply to Christoph Hellwig
Quoted 5 lines · Christoph Hellwig

Add a new REQ_PRIO to let requests preempt others in the cfq I/O schedule, and lave REQ_META purely for marking requests as metadata in blktrace.

All existing callers of REQ_META except for XFS are updated to also set REQ_PRIO for now.

Thanks, applied 1/2 and this one to for-linus.

Signature · 1 line
Jens Axboe