btrfs: add block plug for .writepages
PATCH 1/1 btrfs: add block plug for .writepages
Add block plug for btrfs .writepages. Block plug is helpful to reduce block lock contention.
--- fs/btrfs/extent_io.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
fs/btrfs/extent_io.c +4 -0
@@ -2388,6 +2388,7 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,pgoff_t end;/* Inclusive */ int scanned =0 ;int tag; +struct blk_plug plug;pagevec_init (&pvec,0 );if (wbc->range_cyclic) {
@@ -2405,6 +2406,8 @@ static int extent_write_cache_pages(struct extent_io_tree *tree, retry:if (wbc->sync_mode ==WB_SYNC_ALL )tag_pages_for_writeback (mapping, index, end); + +blk_start_plug (&plug);while (!done && !nr_to_write_done && (index <= end) && (nr_pages =pagevec_lookup_tag (&pvec, mapping, &index, tag,min (end - index, (pgoff_t )PAGEVEC_SIZE -1 ) +1 ))) {
@@ -2468,6 +2471,7 @@ retry:pagevec_release (&pvec);cond_resched (); } +blk_finish_plug (&plug);if (!scanned && !done) {/* * We hit the last page and there is more work to be done: wrap
Signature · 1 line
1.7.4.4
Quoted 29 lines · Namjae Jeon
Add block plug for btrfs .writepages. Block plug is helpful to reduce block lock contention.
Signed-off-by Namjae Jeon <[email protected]>--- fs/btrfs/extent_io.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)fs/btrfs/extent_io.c +3
-0@@ -2388,6 +2388,7 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,pgoff_t end;/* Inclusive */ int scanned =0 ;int tag; +struct blk_plug plug;pagevec_init (&pvec,0 );if (wbc->range_cyclic) {@@ -2405,6 +2406,8 @@ static int extent_write_cache_pages(struct extent_io_tree *tree, retry:if (wbc->sync_mode ==WB_SYNC_ALL )tag_pages_for_writeback (mapping, index, end); + +blk_start_plug (&plug);while (!done && !nr_to_write_done && (index <= end) && (nr_pages =pagevec_lookup_tag (&pvec, mapping, &index, tag,min (end - index, (pgoff_t )PAGEVEC_SIZE -1 ) +1 ))) {
fs/btrfs/extent_io.c retry: · line 2477
Quoted 7 lines
fs/btrfs/extent_io.c +1
-0@@ -2468,6 +2471,7 @@ retry:pagevec_release (&pvec);cond_resched (); } +blk_finish_plug (&plug);if (!scanned && !done) {/* * We hit the last page and there is more work to be done: wrap
Thanks for the patch, but we actually do this at a lower level in btrfs. The actual IO can be done to multiple block devices, so we try to plug for each device individually.
-chris
2011/11/1 Chris Mason <[email protected]>:
Quoted 42 lines · Namjae Jeon
Quoted 29 lines
Add block plug for btrfs .writepages. Block plug is helpful to reduce block lock contention.
Signed-off-by Namjae Jeon <[email protected]>---
fs/btrfs/extent_io.c | 4 ++++1 files changed, 4 insertions(+), 0 deletions(-)fs/btrfs/extent_io.c +0
-0@@ -2388,6 +2388,7 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,
pgoff_tend; /* Inclusive */
int scanned = 0;
int tag;
+ structblk_plugplug;
pagevec_init(&pvec, 0);
if (wbc->range_cyclic) {fs/btrfs/extent_io.c +0
-0@@ -2405,6 +2406,8 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,retry:
if (wbc->sync_mode==WB_SYNC_ALL)tag_pages_for_writeback(mapping, index, end); +
+blk_start_plug(&plug);
while (!done && !nr_to_write_done && (index <= end) && (nr_pages=pagevec_lookup_tag(&pvec, mapping, &index, tag, min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) {fs/btrfs/extent_io.c retry: · line 2477
Quoted 7 lines
fs/btrfs/extent_io.c +1
-0@@ -2468,6 +2471,7 @@ retry: pagevec_release(&pvec); cond_resched(); } + blk_finish_plug(&plug); if (!scanned && !done) { /** We hit the last page and there is more work to be done: wrap Thanks for the patch, but we actually do this at a lower level in btrfs. The actual IO can be done to multiple block devices, so we try to plug for each device individually.
Quoted 3 lines
-chris
Hi. Chris.
I got your point. pending bio is operated by worker_loop thread. But Is block plug needed in extent_readpages ?
Thanks.
2011/11/1 NamJae Jeon <[email protected]>:
Quoted 43 lines
2011/11/1 Chris Mason <[email protected]>:
Quoted 42 lines · Namjae Jeon
Quoted 29 lines
Add block plug for btrfs .writepages. Block plug is helpful to reduce block lock contention.
Signed-off-by Namjae Jeon <[email protected]>---
fs/btrfs/extent_io.c | 4 ++++1 files changed, 4 insertions(+), 0 deletions(-)fs/btrfs/extent_io.c +0
-0@@ -2388,6 +2388,7 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,
pgoff_tend; /* Inclusive */
int scanned = 0;
int tag;
+ structblk_plugplug;
pagevec_init(&pvec, 0);
if (wbc->range_cyclic) {fs/btrfs/extent_io.c +0
-0@@ -2405,6 +2406,8 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,retry:
if (wbc->sync_mode==WB_SYNC_ALL)tag_pages_for_writeback(mapping, index, end); +
+blk_start_plug(&plug);
while (!done && !nr_to_write_done && (index <= end) && (nr_pages=pagevec_lookup_tag(&pvec, mapping, &index, tag, min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) {fs/btrfs/extent_io.c retry: · line 2477
Quoted 7 lines
fs/btrfs/extent_io.c +1
-0@@ -2468,6 +2471,7 @@ retry: pagevec_release(&pvec); cond_resched(); } + blk_finish_plug(&plug); if (!scanned && !done) { /** We hit the last page and there is more work to be done: wrap Thanks for the patch, but we actually do this at a lower level in btrfs. The actual IO can be done to multiple block devices, so we try to plug for each device individually.
Quoted 7 lines
Quoted 3 lines
-chris
Hi. Chris.
I got your point. pending bio is operated by
worker_loopthread. But Is block plug needed inextent_readpages?
.readpages are called in readahead, where we already have block plug.
2011/11/1 Shaohua Li <[email protected]>:
Quoted 47 lines
2011/11/1 NamJae Jeon <[email protected]>:
Quoted 46 lines
2011/11/1 Chris Mason <[email protected]>:
Quoted 45 lines · Namjae Jeon
Quoted 29 lines
Add block plug for btrfs .writepages. Block plug is helpful to reduce block lock contention.
Signed-off-by Namjae Jeon <[email protected]>---
fs/btrfs/extent_io.c | 4 ++++1 files changed, 4 insertions(+), 0 deletions(-)fs/btrfs/extent_io.c +0
-0@@ -2388,6 +2388,7 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,
pgoff_tend; /* Inclusive */
int scanned = 0;
int tag;
+ structblk_plugplug;
pagevec_init(&pvec, 0);
if (wbc->range_cyclic) {fs/btrfs/extent_io.c +0
-0@@ -2405,6 +2406,8 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,retry:
if (wbc->sync_mode==WB_SYNC_ALL)tag_pages_for_writeback(mapping, index, end); +
+blk_start_plug(&plug);
while (!done && !nr_to_write_done && (index <= end) && (nr_pages=pagevec_lookup_tag(&pvec, mapping, &index, tag, min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) {fs/btrfs/extent_io.c retry: · line 2477
Quoted 7 lines
fs/btrfs/extent_io.c +1
-0@@ -2468,6 +2471,7 @@ retry: pagevec_release(&pvec); cond_resched(); } + blk_finish_plug(&plug); if (!scanned && !done) { /** We hit the last page and there is more work to be done: wrap Thanks for the patch, but we actually do this at a lower level in btrfs. The actual IO can be done to multiple block devices, so we try to plug for each device individually.
-chris
Quoted 6 lines
Quoted 4 lines
Hi. Chris.
I got your point. pending bio is operated by
worker_loopthread. But Is block plug needed inextent_readpages?.readpages are called in readahead, where we already have block plug.
Thanks for your reply. I checked it.
block plug in mpage_readpages is not needed also.