Commit 915e2290 authored by Zhao Lei's avatar Zhao Lei Committed by Chris Mason

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: default avatarZhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent b7178a5f
...@@ -1174,7 +1174,6 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) ...@@ -1174,7 +1174,6 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
{ {
struct btrfs_bio *bbio = rbio->bbio; struct btrfs_bio *bbio = rbio->bbio;
void *pointers[rbio->real_stripes]; void *pointers[rbio->real_stripes];
int stripe_len = rbio->stripe_len;
int nr_data = rbio->nr_data; int nr_data = rbio->nr_data;
int stripe; int stripe;
int pagenr; int pagenr;
...@@ -1182,7 +1181,6 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) ...@@ -1182,7 +1181,6 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
int q_stripe = -1; int q_stripe = -1;
struct bio_list bio_list; struct bio_list bio_list;
struct bio *bio; struct bio *bio;
int pages_per_stripe = stripe_len >> PAGE_CACHE_SHIFT;
int ret; int ret;
bio_list_init(&bio_list); bio_list_init(&bio_list);
...@@ -1225,7 +1223,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) ...@@ -1225,7 +1223,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
else else
clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags); clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags);
for (pagenr = 0; pagenr < pages_per_stripe; pagenr++) { for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) {
struct page *p; struct page *p;
/* first collect one page from each data stripe */ /* first collect one page from each data stripe */
for (stripe = 0; stripe < nr_data; stripe++) { for (stripe = 0; stripe < nr_data; stripe++) {
...@@ -1267,7 +1265,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) ...@@ -1267,7 +1265,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
* everything else. * everything else.
*/ */
for (stripe = 0; stripe < rbio->real_stripes; stripe++) { for (stripe = 0; stripe < rbio->real_stripes; stripe++) {
for (pagenr = 0; pagenr < pages_per_stripe; pagenr++) { for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) {
struct page *page; struct page *page;
if (stripe < rbio->nr_data) { if (stripe < rbio->nr_data) {
page = page_in_rbio(rbio, stripe, pagenr, 1); page = page_in_rbio(rbio, stripe, pagenr, 1);
...@@ -1291,7 +1289,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) ...@@ -1291,7 +1289,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
if (!bbio->tgtdev_map[stripe]) if (!bbio->tgtdev_map[stripe])
continue; continue;
for (pagenr = 0; pagenr < pages_per_stripe; pagenr++) { for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) {
struct page *page; struct page *page;
if (stripe < rbio->nr_data) { if (stripe < rbio->nr_data) {
page = page_in_rbio(rbio, stripe, pagenr, 1); page = page_in_rbio(rbio, stripe, pagenr, 1);
...@@ -1505,7 +1503,6 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio) ...@@ -1505,7 +1503,6 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio)
int bios_to_read = 0; int bios_to_read = 0;
struct bio_list bio_list; struct bio_list bio_list;
int ret; int ret;
int nr_pages = DIV_ROUND_UP(rbio->stripe_len, PAGE_CACHE_SIZE);
int pagenr; int pagenr;
int stripe; int stripe;
struct bio *bio; struct bio *bio;
...@@ -1524,7 +1521,7 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio) ...@@ -1524,7 +1521,7 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio)
* stripe * stripe
*/ */
for (stripe = 0; stripe < rbio->nr_data; stripe++) { for (stripe = 0; stripe < rbio->nr_data; stripe++) {
for (pagenr = 0; pagenr < nr_pages; pagenr++) { for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) {
struct page *page; struct page *page;
/* /*
* we want to find all the pages missing from * 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,7 +1797,6 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
int pagenr, stripe; int pagenr, stripe;
void **pointers; void **pointers;
int faila = -1, failb = -1; int faila = -1, failb = -1;
int nr_pages = DIV_ROUND_UP(rbio->stripe_len, PAGE_CACHE_SIZE);
struct page *page; struct page *page;
int err; int err;
int i; int i;
...@@ -1823,7 +1819,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio) ...@@ -1823,7 +1819,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
index_rbio_pages(rbio); index_rbio_pages(rbio);
for (pagenr = 0; pagenr < nr_pages; pagenr++) { for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) {
/* /*
* Now we just use bitmap to mark the horizontal stripes in * Now we just use bitmap to mark the horizontal stripes in
* which we have data when doing parity scrub. * which we have data when doing parity scrub.
...@@ -1934,7 +1930,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio) ...@@ -1934,7 +1930,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
* other endio functions will fiddle the uptodate bits * other endio functions will fiddle the uptodate bits
*/ */
if (rbio->operation == BTRFS_RBIO_WRITE) { if (rbio->operation == BTRFS_RBIO_WRITE) {
for (i = 0; i < nr_pages; i++) { for (i = 0; i < rbio->stripe_npages; i++) {
if (faila != -1) { if (faila != -1) {
page = rbio_stripe_page(rbio, faila, i); page = rbio_stripe_page(rbio, faila, i);
SetPageUptodate(page); SetPageUptodate(page);
...@@ -2030,7 +2026,6 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio) ...@@ -2030,7 +2026,6 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)
int bios_to_read = 0; int bios_to_read = 0;
struct bio_list bio_list; struct bio_list bio_list;
int ret; int ret;
int nr_pages = DIV_ROUND_UP(rbio->stripe_len, PAGE_CACHE_SIZE);
int pagenr; int pagenr;
int stripe; int stripe;
struct bio *bio; struct bio *bio;
...@@ -2054,7 +2049,7 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio) ...@@ -2054,7 +2049,7 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)
continue; continue;
} }
for (pagenr = 0; pagenr < nr_pages; pagenr++) { for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) {
struct page *p; struct page *p;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment