diff options
author | Zhao Lei <zhaolei@cn.fujitsu.com> | 2015-03-03 07:42:48 -0500 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2016-01-20 10:22:16 -0500 |
commit | 915e22903cb34619c1a1462ca4248add96fa41d7 (patch) | |
tree | 493ff35e90bf36d273c1eb87a3eca92ff02d3a5f /fs | |
parent | b7178a5f0372a51260cf6e74d828e315e43dfc86 (diff) |
btrfs: use rbio->nr_pages to reduce calculation
We can use rbio->stripe_npages to reduce unnecessary calculation in
many code place.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/raid56.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index c435fe0f86e4..719dbc0d3080 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c | |||
@@ -1174,7 +1174,6 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) | |||
1174 | { | 1174 | { |
1175 | struct btrfs_bio *bbio = rbio->bbio; | 1175 | struct btrfs_bio *bbio = rbio->bbio; |
1176 | void *pointers[rbio->real_stripes]; | 1176 | void *pointers[rbio->real_stripes]; |
1177 | int stripe_len = rbio->stripe_len; | ||
1178 | int nr_data = rbio->nr_data; | 1177 | int nr_data = rbio->nr_data; |
1179 | int stripe; | 1178 | int stripe; |
1180 | int pagenr; | 1179 | int pagenr; |
@@ -1182,7 +1181,6 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) | |||
1182 | int q_stripe = -1; | 1181 | int q_stripe = -1; |
1183 | struct bio_list bio_list; | 1182 | struct bio_list bio_list; |
1184 | struct bio *bio; | 1183 | struct bio *bio; |
1185 | int pages_per_stripe = stripe_len >> PAGE_CACHE_SHIFT; | ||
1186 | int ret; | 1184 | int ret; |
1187 | 1185 | ||
1188 | bio_list_init(&bio_list); | 1186 | bio_list_init(&bio_list); |
@@ -1225,7 +1223,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) | |||
1225 | else | 1223 | else |
1226 | clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags); | 1224 | clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags); |
1227 | 1225 | ||
1228 | for (pagenr = 0; pagenr < pages_per_stripe; pagenr++) { | 1226 | for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) { |
1229 | struct page *p; | 1227 | struct page *p; |
1230 | /* first collect one page from each data stripe */ | 1228 | /* first collect one page from each data stripe */ |
1231 | for (stripe = 0; stripe < nr_data; stripe++) { | 1229 | for (stripe = 0; stripe < nr_data; stripe++) { |
@@ -1267,7 +1265,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) | |||
1267 | * everything else. | 1265 | * everything else. |
1268 | */ | 1266 | */ |
1269 | for (stripe = 0; stripe < rbio->real_stripes; stripe++) { | 1267 | for (stripe = 0; stripe < rbio->real_stripes; stripe++) { |
1270 | for (pagenr = 0; pagenr < pages_per_stripe; pagenr++) { | 1268 | for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) { |
1271 | struct page *page; | 1269 | struct page *page; |
1272 | if (stripe < rbio->nr_data) { | 1270 | if (stripe < rbio->nr_data) { |
1273 | page = page_in_rbio(rbio, stripe, pagenr, 1); | 1271 | page = page_in_rbio(rbio, stripe, pagenr, 1); |
@@ -1291,7 +1289,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) | |||
1291 | if (!bbio->tgtdev_map[stripe]) | 1289 | if (!bbio->tgtdev_map[stripe]) |
1292 | continue; | 1290 | continue; |
1293 | 1291 | ||
1294 | for (pagenr = 0; pagenr < pages_per_stripe; pagenr++) { | 1292 | for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) { |
1295 | struct page *page; | 1293 | struct page *page; |
1296 | if (stripe < rbio->nr_data) { | 1294 | if (stripe < rbio->nr_data) { |
1297 | page = page_in_rbio(rbio, stripe, pagenr, 1); | 1295 | page = page_in_rbio(rbio, stripe, pagenr, 1); |
@@ -1505,7 +1503,6 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio) | |||
1505 | int bios_to_read = 0; | 1503 | int bios_to_read = 0; |
1506 | struct bio_list bio_list; | 1504 | struct bio_list bio_list; |
1507 | int ret; | 1505 | int ret; |
1508 | int nr_pages = DIV_ROUND_UP(rbio->stripe_len, PAGE_CACHE_SIZE); | ||
1509 | int pagenr; | 1506 | int pagenr; |
1510 | int stripe; | 1507 | int stripe; |
1511 | struct bio *bio; | 1508 | struct bio *bio; |
@@ -1524,7 +1521,7 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio) | |||
1524 | * stripe | 1521 | * stripe |
1525 | */ | 1522 | */ |
1526 | for (stripe = 0; stripe < rbio->nr_data; stripe++) { | 1523 | for (stripe = 0; stripe < rbio->nr_data; stripe++) { |
1527 | for (pagenr = 0; pagenr < nr_pages; pagenr++) { | 1524 | for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) { |
1528 | struct page *page; | 1525 | struct page *page; |
1529 | /* | 1526 | /* |
1530 | * we want to find all the pages missing from | 1527 | * we want to find all the pages missing from |
@@ -1800,7 +1797,6 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio) | |||
1800 | int pagenr, stripe; | 1797 | int pagenr, stripe; |
1801 | void **pointers; | 1798 | void **pointers; |
1802 | int faila = -1, failb = -1; | 1799 | int faila = -1, failb = -1; |
1803 | int nr_pages = DIV_ROUND_UP(rbio->stripe_len, PAGE_CACHE_SIZE); | ||
1804 | struct page *page; | 1800 | struct page *page; |
1805 | int err; | 1801 | int err; |
1806 | int i; | 1802 | int i; |
@@ -1823,7 +1819,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio) | |||
1823 | 1819 | ||
1824 | index_rbio_pages(rbio); | 1820 | index_rbio_pages(rbio); |
1825 | 1821 | ||
1826 | for (pagenr = 0; pagenr < nr_pages; pagenr++) { | 1822 | for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) { |
1827 | /* | 1823 | /* |
1828 | * Now we just use bitmap to mark the horizontal stripes in | 1824 | * Now we just use bitmap to mark the horizontal stripes in |
1829 | * which we have data when doing parity scrub. | 1825 | * which we have data when doing parity scrub. |
@@ -1934,7 +1930,7 @@ pstripe: | |||
1934 | * other endio functions will fiddle the uptodate bits | 1930 | * other endio functions will fiddle the uptodate bits |
1935 | */ | 1931 | */ |
1936 | if (rbio->operation == BTRFS_RBIO_WRITE) { | 1932 | if (rbio->operation == BTRFS_RBIO_WRITE) { |
1937 | for (i = 0; i < nr_pages; i++) { | 1933 | for (i = 0; i < rbio->stripe_npages; i++) { |
1938 | if (faila != -1) { | 1934 | if (faila != -1) { |
1939 | page = rbio_stripe_page(rbio, faila, i); | 1935 | page = rbio_stripe_page(rbio, faila, i); |
1940 | SetPageUptodate(page); | 1936 | SetPageUptodate(page); |
@@ -2030,7 +2026,6 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio) | |||
2030 | int bios_to_read = 0; | 2026 | int bios_to_read = 0; |
2031 | struct bio_list bio_list; | 2027 | struct bio_list bio_list; |
2032 | int ret; | 2028 | int ret; |
2033 | int nr_pages = DIV_ROUND_UP(rbio->stripe_len, PAGE_CACHE_SIZE); | ||
2034 | int pagenr; | 2029 | int pagenr; |
2035 | int stripe; | 2030 | int stripe; |
2036 | struct bio *bio; | 2031 | struct bio *bio; |
@@ -2054,7 +2049,7 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio) | |||
2054 | continue; | 2049 | continue; |
2055 | } | 2050 | } |
2056 | 2051 | ||
2057 | for (pagenr = 0; pagenr < nr_pages; pagenr++) { | 2052 | for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) { |
2058 | struct page *p; | 2053 | struct page *p; |
2059 | 2054 | ||
2060 | /* | 2055 | /* |