diff options
Diffstat (limited to 'fs/gfs2/rgrp.c')
-rw-r--r-- | fs/gfs2/rgrp.c | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 2d90fb253505..8b01c635d925 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -269,16 +269,14 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) | |||
269 | bi->bi_len, x); | 269 | bi->bi_len, x); |
270 | } | 270 | } |
271 | 271 | ||
272 | if (count[0] != rgd->rd_rg.rg_free) { | 272 | if (count[0] != rgd->rd_free) { |
273 | if (gfs2_consist_rgrpd(rgd)) | 273 | if (gfs2_consist_rgrpd(rgd)) |
274 | fs_err(sdp, "free data mismatch: %u != %u\n", | 274 | fs_err(sdp, "free data mismatch: %u != %u\n", |
275 | count[0], rgd->rd_rg.rg_free); | 275 | count[0], rgd->rd_free); |
276 | return; | 276 | return; |
277 | } | 277 | } |
278 | 278 | ||
279 | tmp = rgd->rd_data - | 279 | tmp = rgd->rd_data - rgd->rd_free - rgd->rd_dinodes; |
280 | rgd->rd_rg.rg_free - | ||
281 | rgd->rd_rg.rg_dinodes; | ||
282 | if (count[1] + count[2] != tmp) { | 280 | if (count[1] + count[2] != tmp) { |
283 | if (gfs2_consist_rgrpd(rgd)) | 281 | if (gfs2_consist_rgrpd(rgd)) |
284 | fs_err(sdp, "used data mismatch: %u != %u\n", | 282 | fs_err(sdp, "used data mismatch: %u != %u\n", |
@@ -286,10 +284,10 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) | |||
286 | return; | 284 | return; |
287 | } | 285 | } |
288 | 286 | ||
289 | if (count[3] != rgd->rd_rg.rg_dinodes) { | 287 | if (count[3] != rgd->rd_dinodes) { |
290 | if (gfs2_consist_rgrpd(rgd)) | 288 | if (gfs2_consist_rgrpd(rgd)) |
291 | fs_err(sdp, "used metadata mismatch: %u != %u\n", | 289 | fs_err(sdp, "used metadata mismatch: %u != %u\n", |
292 | count[3], rgd->rd_rg.rg_dinodes); | 290 | count[3], rgd->rd_dinodes); |
293 | return; | 291 | return; |
294 | } | 292 | } |
295 | 293 | ||
@@ -501,7 +499,7 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp) | |||
501 | for (rgrps = 0;; rgrps++) { | 499 | for (rgrps = 0;; rgrps++) { |
502 | loff_t pos = rgrps * sizeof(struct gfs2_rindex); | 500 | loff_t pos = rgrps * sizeof(struct gfs2_rindex); |
503 | 501 | ||
504 | if (pos + sizeof(struct gfs2_rindex) >= ip->i_di.di_size) | 502 | if (pos + sizeof(struct gfs2_rindex) >= ip->i_disksize) |
505 | break; | 503 | break; |
506 | error = gfs2_internal_read(ip, &ra_state, buf, &pos, | 504 | error = gfs2_internal_read(ip, &ra_state, buf, &pos, |
507 | sizeof(struct gfs2_rindex)); | 505 | sizeof(struct gfs2_rindex)); |
@@ -590,7 +588,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip) | |||
590 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 588 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
591 | struct inode *inode = &ip->i_inode; | 589 | struct inode *inode = &ip->i_inode; |
592 | struct file_ra_state ra_state; | 590 | struct file_ra_state ra_state; |
593 | u64 rgrp_count = ip->i_di.di_size; | 591 | u64 rgrp_count = ip->i_disksize; |
594 | int error; | 592 | int error; |
595 | 593 | ||
596 | if (do_div(rgrp_count, sizeof(struct gfs2_rindex))) { | 594 | if (do_div(rgrp_count, sizeof(struct gfs2_rindex))) { |
@@ -634,7 +632,7 @@ static int gfs2_ri_update_special(struct gfs2_inode *ip) | |||
634 | for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { | 632 | for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { |
635 | /* Ignore partials */ | 633 | /* Ignore partials */ |
636 | if ((sdp->sd_rgrps + 1) * sizeof(struct gfs2_rindex) > | 634 | if ((sdp->sd_rgrps + 1) * sizeof(struct gfs2_rindex) > |
637 | ip->i_di.di_size) | 635 | ip->i_disksize) |
638 | break; | 636 | break; |
639 | error = read_rindex_entry(ip, &ra_state); | 637 | error = read_rindex_entry(ip, &ra_state); |
640 | if (error) { | 638 | if (error) { |
@@ -692,7 +690,6 @@ int gfs2_rindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ri_gh) | |||
692 | static void gfs2_rgrp_in(struct gfs2_rgrpd *rgd, const void *buf) | 690 | static void gfs2_rgrp_in(struct gfs2_rgrpd *rgd, const void *buf) |
693 | { | 691 | { |
694 | const struct gfs2_rgrp *str = buf; | 692 | const struct gfs2_rgrp *str = buf; |
695 | struct gfs2_rgrp_host *rg = &rgd->rd_rg; | ||
696 | u32 rg_flags; | 693 | u32 rg_flags; |
697 | 694 | ||
698 | rg_flags = be32_to_cpu(str->rg_flags); | 695 | rg_flags = be32_to_cpu(str->rg_flags); |
@@ -700,24 +697,23 @@ static void gfs2_rgrp_in(struct gfs2_rgrpd *rgd, const void *buf) | |||
700 | rgd->rd_flags |= GFS2_RDF_NOALLOC; | 697 | rgd->rd_flags |= GFS2_RDF_NOALLOC; |
701 | else | 698 | else |
702 | rgd->rd_flags &= ~GFS2_RDF_NOALLOC; | 699 | rgd->rd_flags &= ~GFS2_RDF_NOALLOC; |
703 | rg->rg_free = be32_to_cpu(str->rg_free); | 700 | rgd->rd_free = be32_to_cpu(str->rg_free); |
704 | rg->rg_dinodes = be32_to_cpu(str->rg_dinodes); | 701 | rgd->rd_dinodes = be32_to_cpu(str->rg_dinodes); |
705 | rg->rg_igeneration = be64_to_cpu(str->rg_igeneration); | 702 | rgd->rd_igeneration = be64_to_cpu(str->rg_igeneration); |
706 | } | 703 | } |
707 | 704 | ||
708 | static void gfs2_rgrp_out(struct gfs2_rgrpd *rgd, void *buf) | 705 | static void gfs2_rgrp_out(struct gfs2_rgrpd *rgd, void *buf) |
709 | { | 706 | { |
710 | struct gfs2_rgrp *str = buf; | 707 | struct gfs2_rgrp *str = buf; |
711 | struct gfs2_rgrp_host *rg = &rgd->rd_rg; | ||
712 | u32 rg_flags = 0; | 708 | u32 rg_flags = 0; |
713 | 709 | ||
714 | if (rgd->rd_flags & GFS2_RDF_NOALLOC) | 710 | if (rgd->rd_flags & GFS2_RDF_NOALLOC) |
715 | rg_flags |= GFS2_RGF_NOALLOC; | 711 | rg_flags |= GFS2_RGF_NOALLOC; |
716 | str->rg_flags = cpu_to_be32(rg_flags); | 712 | str->rg_flags = cpu_to_be32(rg_flags); |
717 | str->rg_free = cpu_to_be32(rg->rg_free); | 713 | str->rg_free = cpu_to_be32(rgd->rd_free); |
718 | str->rg_dinodes = cpu_to_be32(rg->rg_dinodes); | 714 | str->rg_dinodes = cpu_to_be32(rgd->rd_dinodes); |
719 | str->__pad = cpu_to_be32(0); | 715 | str->__pad = cpu_to_be32(0); |
720 | str->rg_igeneration = cpu_to_be64(rg->rg_igeneration); | 716 | str->rg_igeneration = cpu_to_be64(rgd->rd_igeneration); |
721 | memset(&str->rg_reserved, 0, sizeof(str->rg_reserved)); | 717 | memset(&str->rg_reserved, 0, sizeof(str->rg_reserved)); |
722 | } | 718 | } |
723 | 719 | ||
@@ -776,7 +772,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) | |||
776 | } | 772 | } |
777 | 773 | ||
778 | spin_lock(&sdp->sd_rindex_spin); | 774 | spin_lock(&sdp->sd_rindex_spin); |
779 | rgd->rd_free_clone = rgd->rd_rg.rg_free; | 775 | rgd->rd_free_clone = rgd->rd_free; |
780 | rgd->rd_bh_count++; | 776 | rgd->rd_bh_count++; |
781 | spin_unlock(&sdp->sd_rindex_spin); | 777 | spin_unlock(&sdp->sd_rindex_spin); |
782 | 778 | ||
@@ -850,7 +846,7 @@ void gfs2_rgrp_repolish_clones(struct gfs2_rgrpd *rgd) | |||
850 | } | 846 | } |
851 | 847 | ||
852 | spin_lock(&sdp->sd_rindex_spin); | 848 | spin_lock(&sdp->sd_rindex_spin); |
853 | rgd->rd_free_clone = rgd->rd_rg.rg_free; | 849 | rgd->rd_free_clone = rgd->rd_free; |
854 | spin_unlock(&sdp->sd_rindex_spin); | 850 | spin_unlock(&sdp->sd_rindex_spin); |
855 | } | 851 | } |
856 | 852 | ||
@@ -1403,8 +1399,8 @@ u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n) | |||
1403 | block = rgd->rd_data0 + blk; | 1399 | block = rgd->rd_data0 + blk; |
1404 | ip->i_goal = block; | 1400 | ip->i_goal = block; |
1405 | 1401 | ||
1406 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free >= *n); | 1402 | gfs2_assert_withdraw(sdp, rgd->rd_free >= *n); |
1407 | rgd->rd_rg.rg_free -= *n; | 1403 | rgd->rd_free -= *n; |
1408 | 1404 | ||
1409 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); | 1405 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); |
1410 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); | 1406 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); |
@@ -1445,10 +1441,10 @@ u64 gfs2_alloc_di(struct gfs2_inode *dip, u64 *generation) | |||
1445 | 1441 | ||
1446 | block = rgd->rd_data0 + blk; | 1442 | block = rgd->rd_data0 + blk; |
1447 | 1443 | ||
1448 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); | 1444 | gfs2_assert_withdraw(sdp, rgd->rd_free); |
1449 | rgd->rd_rg.rg_free--; | 1445 | rgd->rd_free--; |
1450 | rgd->rd_rg.rg_dinodes++; | 1446 | rgd->rd_dinodes++; |
1451 | *generation = rgd->rd_rg.rg_igeneration++; | 1447 | *generation = rgd->rd_igeneration++; |
1452 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); | 1448 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); |
1453 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); | 1449 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); |
1454 | 1450 | ||
@@ -1481,7 +1477,7 @@ void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen) | |||
1481 | if (!rgd) | 1477 | if (!rgd) |
1482 | return; | 1478 | return; |
1483 | 1479 | ||
1484 | rgd->rd_rg.rg_free += blen; | 1480 | rgd->rd_free += blen; |
1485 | 1481 | ||
1486 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); | 1482 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); |
1487 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); | 1483 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); |
@@ -1509,7 +1505,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen) | |||
1509 | if (!rgd) | 1505 | if (!rgd) |
1510 | return; | 1506 | return; |
1511 | 1507 | ||
1512 | rgd->rd_rg.rg_free += blen; | 1508 | rgd->rd_free += blen; |
1513 | 1509 | ||
1514 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); | 1510 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); |
1515 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); | 1511 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); |
@@ -1546,10 +1542,10 @@ static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, u64 blkno) | |||
1546 | return; | 1542 | return; |
1547 | gfs2_assert_withdraw(sdp, rgd == tmp_rgd); | 1543 | gfs2_assert_withdraw(sdp, rgd == tmp_rgd); |
1548 | 1544 | ||
1549 | if (!rgd->rd_rg.rg_dinodes) | 1545 | if (!rgd->rd_dinodes) |
1550 | gfs2_consist_rgrpd(rgd); | 1546 | gfs2_consist_rgrpd(rgd); |
1551 | rgd->rd_rg.rg_dinodes--; | 1547 | rgd->rd_dinodes--; |
1552 | rgd->rd_rg.rg_free++; | 1548 | rgd->rd_free++; |
1553 | 1549 | ||
1554 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); | 1550 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); |
1555 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); | 1551 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); |