Lines Matching refs:rgd
101 struct gfs2_sbd *sdp = rbm->rgd->rd_sbd; in gfs2_setbit()
106 (unsigned long long)rbm->rgd->rd_addr, bi->bi_start, in gfs2_setbit()
112 gfs2_consist_rgrpd(rbm->rgd); in gfs2_setbit()
273 if (!rgrp_contains_block(rbm->rgd, block)) in gfs2_rbm_from_block()
276 rbm->offset = block - rbm->rgd->rd_data0; in gfs2_rbm_from_block()
284 rbm->bii = rbm->offset / rbm->rgd->rd_sbd->sd_blocks_per_bitmap; in gfs2_rbm_from_block()
285 rbm->offset -= rbm->bii * rbm->rgd->rd_sbd->sd_blocks_per_bitmap; in gfs2_rbm_from_block()
307 if (rbm->bii == rbm->rgd->rd_length - 1) /* at the last bitmap */ in gfs2_rbm_incr()
419 static u32 gfs2_bitcount(struct gfs2_rgrpd *rgd, const u8 *buffer, in gfs2_bitcount() argument
449 void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) in gfs2_rgrp_verify() argument
451 struct gfs2_sbd *sdp = rgd->rd_sbd; in gfs2_rgrp_verify()
453 u32 length = rgd->rd_length; in gfs2_rgrp_verify()
461 bi = rgd->rd_bits + buf; in gfs2_rgrp_verify()
463 count[x] += gfs2_bitcount(rgd, in gfs2_rgrp_verify()
469 if (count[0] != rgd->rd_free) { in gfs2_rgrp_verify()
470 if (gfs2_consist_rgrpd(rgd)) in gfs2_rgrp_verify()
472 count[0], rgd->rd_free); in gfs2_rgrp_verify()
476 tmp = rgd->rd_data - rgd->rd_free - rgd->rd_dinodes; in gfs2_rgrp_verify()
478 if (gfs2_consist_rgrpd(rgd)) in gfs2_rgrp_verify()
484 if (count[2] + count[3] != rgd->rd_dinodes) { in gfs2_rgrp_verify()
485 if (gfs2_consist_rgrpd(rgd)) in gfs2_rgrp_verify()
487 count[2] + count[3], rgd->rd_dinodes); in gfs2_rgrp_verify()
549 struct gfs2_rgrpd *rgd; in gfs2_rgrpd_get_first() local
553 rgd = rb_entry(n, struct gfs2_rgrpd, rd_node); in gfs2_rgrpd_get_first()
556 return rgd; in gfs2_rgrpd_get_first()
566 struct gfs2_rgrpd *gfs2_rgrpd_get_next(struct gfs2_rgrpd *rgd) in gfs2_rgrpd_get_next() argument
568 struct gfs2_sbd *sdp = rgd->rd_sbd; in gfs2_rgrpd_get_next()
572 n = rb_next(&rgd->rd_node); in gfs2_rgrpd_get_next()
576 if (unlikely(&rgd->rd_node == n)) { in gfs2_rgrpd_get_next()
580 rgd = rb_entry(n, struct gfs2_rgrpd, rd_node); in gfs2_rgrpd_get_next()
582 return rgd; in gfs2_rgrpd_get_next()
592 void gfs2_free_clones(struct gfs2_rgrpd *rgd) in gfs2_free_clones() argument
596 for (x = 0; x < rgd->rd_length; x++) { in gfs2_free_clones()
597 struct gfs2_bitmap *bi = rgd->rd_bits + x; in gfs2_free_clones()
631 struct gfs2_rgrpd *rgd; in __rs_deltree() local
636 rgd = rs->rs_rbm.rgd; in __rs_deltree()
638 rb_erase(&rs->rs_node, &rgd->rd_rstree); in __rs_deltree()
644 struct gfs2_rbm last_rbm = { .rgd = rs->rs_rbm.rgd, }; in __rs_deltree()
648 BUG_ON(rs->rs_rbm.rgd->rd_reserved < rs->rs_free); in __rs_deltree()
649 rs->rs_rbm.rgd->rd_reserved -= rs->rs_free; in __rs_deltree()
654 rgd->rd_extfail_pt += rs->rs_free; in __rs_deltree()
673 struct gfs2_rgrpd *rgd; in gfs2_rs_deltree() local
675 rgd = rs->rs_rbm.rgd; in gfs2_rs_deltree()
676 if (rgd) { in gfs2_rs_deltree()
677 spin_lock(&rgd->rd_rsspin); in gfs2_rs_deltree()
680 spin_unlock(&rgd->rd_rsspin); in gfs2_rs_deltree()
707 static void return_all_reservations(struct gfs2_rgrpd *rgd) in return_all_reservations() argument
712 spin_lock(&rgd->rd_rsspin); in return_all_reservations()
713 while ((n = rb_first(&rgd->rd_rstree))) { in return_all_reservations()
717 spin_unlock(&rgd->rd_rsspin); in return_all_reservations()
723 struct gfs2_rgrpd *rgd; in gfs2_clear_rgrpd() local
727 rgd = rb_entry(n, struct gfs2_rgrpd, rd_node); in gfs2_clear_rgrpd()
728 gl = rgd->rd_gl; in gfs2_clear_rgrpd()
733 glock_clear_object(gl, rgd); in gfs2_clear_rgrpd()
734 gfs2_rgrp_brelse(rgd); in gfs2_clear_rgrpd()
738 gfs2_free_clones(rgd); in gfs2_clear_rgrpd()
739 kfree(rgd->rd_bits); in gfs2_clear_rgrpd()
740 rgd->rd_bits = NULL; in gfs2_clear_rgrpd()
741 return_all_reservations(rgd); in gfs2_clear_rgrpd()
742 kmem_cache_free(gfs2_rgrpd_cachep, rgd); in gfs2_clear_rgrpd()
746 static void gfs2_rindex_print(const struct gfs2_rgrpd *rgd) in gfs2_rindex_print() argument
748 struct gfs2_sbd *sdp = rgd->rd_sbd; in gfs2_rindex_print()
750 fs_info(sdp, "ri_addr = %llu\n", (unsigned long long)rgd->rd_addr); in gfs2_rindex_print()
751 fs_info(sdp, "ri_length = %u\n", rgd->rd_length); in gfs2_rindex_print()
752 fs_info(sdp, "ri_data0 = %llu\n", (unsigned long long)rgd->rd_data0); in gfs2_rindex_print()
753 fs_info(sdp, "ri_data = %u\n", rgd->rd_data); in gfs2_rindex_print()
754 fs_info(sdp, "ri_bitbytes = %u\n", rgd->rd_bitbytes); in gfs2_rindex_print()
766 static int compute_bitstructs(struct gfs2_rgrpd *rgd) in compute_bitstructs() argument
768 struct gfs2_sbd *sdp = rgd->rd_sbd; in compute_bitstructs()
770 u32 length = rgd->rd_length; /* # blocks in hdr & bitmap */ in compute_bitstructs()
777 rgd->rd_bits = kcalloc(length, sizeof(struct gfs2_bitmap), GFP_NOFS); in compute_bitstructs()
778 if (!rgd->rd_bits) in compute_bitstructs()
781 bytes_left = rgd->rd_bitbytes; in compute_bitstructs()
784 bi = rgd->rd_bits + x; in compute_bitstructs()
805 bi->bi_start = rgd->rd_bitbytes - bytes_left; in compute_bitstructs()
813 bi->bi_start = rgd->rd_bitbytes - bytes_left; in compute_bitstructs()
822 gfs2_consist_rgrpd(rgd); in compute_bitstructs()
825 bi = rgd->rd_bits + (length - 1); in compute_bitstructs()
826 if ((bi->bi_start + bi->bi_bytes) * GFS2_NBBY != rgd->rd_data) { in compute_bitstructs()
827 if (gfs2_consist_rgrpd(rgd)) { in compute_bitstructs()
828 gfs2_rindex_print(rgd); in compute_bitstructs()
865 static int rgd_insert(struct gfs2_rgrpd *rgd) in rgd_insert() argument
867 struct gfs2_sbd *sdp = rgd->rd_sbd; in rgd_insert()
876 if (rgd->rd_addr < cur->rd_addr) in rgd_insert()
878 else if (rgd->rd_addr > cur->rd_addr) in rgd_insert()
884 rb_link_node(&rgd->rd_node, parent, newn); in rgd_insert()
885 rb_insert_color(&rgd->rd_node, &sdp->sd_rindex_tree); in rgd_insert()
904 struct gfs2_rgrpd *rgd; in read_rindex_entry() local
915 rgd = kmem_cache_zalloc(gfs2_rgrpd_cachep, GFP_NOFS); in read_rindex_entry()
917 if (!rgd) in read_rindex_entry()
920 rgd->rd_sbd = sdp; in read_rindex_entry()
921 rgd->rd_addr = be64_to_cpu(buf.ri_addr); in read_rindex_entry()
922 rgd->rd_length = be32_to_cpu(buf.ri_length); in read_rindex_entry()
923 rgd->rd_data0 = be64_to_cpu(buf.ri_data0); in read_rindex_entry()
924 rgd->rd_data = be32_to_cpu(buf.ri_data); in read_rindex_entry()
925 rgd->rd_bitbytes = be32_to_cpu(buf.ri_bitbytes); in read_rindex_entry()
926 spin_lock_init(&rgd->rd_rsspin); in read_rindex_entry()
928 error = compute_bitstructs(rgd); in read_rindex_entry()
932 error = gfs2_glock_get(sdp, rgd->rd_addr, in read_rindex_entry()
933 &gfs2_rgrp_glops, CREATE, &rgd->rd_gl); in read_rindex_entry()
937 rgd->rd_rgl = (struct gfs2_rgrp_lvb *)rgd->rd_gl->gl_lksb.sb_lvbptr; in read_rindex_entry()
938 rgd->rd_flags &= ~(GFS2_RDF_UPTODATE | GFS2_RDF_PREFERRED); in read_rindex_entry()
939 if (rgd->rd_data > sdp->sd_max_rg_data) in read_rindex_entry()
940 sdp->sd_max_rg_data = rgd->rd_data; in read_rindex_entry()
942 error = rgd_insert(rgd); in read_rindex_entry()
945 glock_set_object(rgd->rd_gl, rgd); in read_rindex_entry()
946 rgd->rd_gl->gl_vm.start = (rgd->rd_addr * bsize) & PAGE_MASK; in read_rindex_entry()
947 rgd->rd_gl->gl_vm.end = PAGE_ALIGN((rgd->rd_addr + in read_rindex_entry()
948 rgd->rd_length) * bsize) - 1; in read_rindex_entry()
953 gfs2_glock_put(rgd->rd_gl); in read_rindex_entry()
956 kfree(rgd->rd_bits); in read_rindex_entry()
957 rgd->rd_bits = NULL; in read_rindex_entry()
958 kmem_cache_free(gfs2_rgrpd_cachep, rgd); in read_rindex_entry()
972 struct gfs2_rgrpd *rgd, *first; in set_rgrp_preferences() local
977 rgd = gfs2_rgrpd_get_first(sdp); in set_rgrp_preferences()
979 rgd = gfs2_rgrpd_get_next(rgd); in set_rgrp_preferences()
980 first = rgd; in set_rgrp_preferences()
983 rgd->rd_flags |= GFS2_RDF_PREFERRED; in set_rgrp_preferences()
985 rgd = gfs2_rgrpd_get_next(rgd); in set_rgrp_preferences()
986 if (!rgd || rgd == first) in set_rgrp_preferences()
989 } while (rgd && rgd != first); in set_rgrp_preferences()
1059 static void gfs2_rgrp_in(struct gfs2_rgrpd *rgd, const void *buf) in gfs2_rgrp_in() argument
1066 rgd->rd_flags &= GFS2_RDF_MASK; in gfs2_rgrp_in()
1067 rgd->rd_flags |= rg_flags; in gfs2_rgrp_in()
1068 rgd->rd_free = be32_to_cpu(str->rg_free); in gfs2_rgrp_in()
1069 rgd->rd_dinodes = be32_to_cpu(str->rg_dinodes); in gfs2_rgrp_in()
1070 rgd->rd_igeneration = be64_to_cpu(str->rg_igeneration); in gfs2_rgrp_in()
1086 static void gfs2_rgrp_out(struct gfs2_rgrpd *rgd, void *buf) in gfs2_rgrp_out() argument
1088 struct gfs2_rgrpd *next = gfs2_rgrpd_get_next(rgd); in gfs2_rgrp_out()
1092 str->rg_flags = cpu_to_be32(rgd->rd_flags & ~GFS2_RDF_MASK); in gfs2_rgrp_out()
1093 str->rg_free = cpu_to_be32(rgd->rd_free); in gfs2_rgrp_out()
1094 str->rg_dinodes = cpu_to_be32(rgd->rd_dinodes); in gfs2_rgrp_out()
1097 else if (next->rd_addr > rgd->rd_addr) in gfs2_rgrp_out()
1098 str->rg_skip = cpu_to_be32(next->rd_addr - rgd->rd_addr); in gfs2_rgrp_out()
1099 str->rg_igeneration = cpu_to_be64(rgd->rd_igeneration); in gfs2_rgrp_out()
1100 str->rg_data0 = cpu_to_be64(rgd->rd_data0); in gfs2_rgrp_out()
1101 str->rg_data = cpu_to_be32(rgd->rd_data); in gfs2_rgrp_out()
1102 str->rg_bitbytes = cpu_to_be32(rgd->rd_bitbytes); in gfs2_rgrp_out()
1108 gfs2_rgrp_ondisk2lvb(rgd->rd_rgl, buf); in gfs2_rgrp_out()
1111 static int gfs2_rgrp_lvb_valid(struct gfs2_rgrpd *rgd) in gfs2_rgrp_lvb_valid() argument
1113 struct gfs2_rgrp_lvb *rgl = rgd->rd_rgl; in gfs2_rgrp_lvb_valid()
1114 struct gfs2_rgrp *str = (struct gfs2_rgrp *)rgd->rd_bits[0].bi_bh->b_data; in gfs2_rgrp_lvb_valid()
1115 struct gfs2_sbd *sdp = rgd->rd_sbd; in gfs2_rgrp_lvb_valid()
1120 (unsigned long long)rgd->rd_addr, in gfs2_rgrp_lvb_valid()
1126 (unsigned long long)rgd->rd_addr, in gfs2_rgrp_lvb_valid()
1132 (unsigned long long)rgd->rd_addr, in gfs2_rgrp_lvb_valid()
1139 (unsigned long long)rgd->rd_addr, in gfs2_rgrp_lvb_valid()
1147 static u32 count_unlinked(struct gfs2_rgrpd *rgd) in count_unlinked() argument
1150 const u32 length = rgd->rd_length; in count_unlinked()
1154 for (i = 0, bi = rgd->rd_bits; i < length; i++, bi++) { in count_unlinked()
1182 static int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) in gfs2_rgrp_bh_get() argument
1184 struct gfs2_sbd *sdp = rgd->rd_sbd; in gfs2_rgrp_bh_get()
1185 struct gfs2_glock *gl = rgd->rd_gl; in gfs2_rgrp_bh_get()
1186 unsigned int length = rgd->rd_length; in gfs2_rgrp_bh_get()
1191 if (rgd->rd_bits[0].bi_bh != NULL) in gfs2_rgrp_bh_get()
1195 bi = rgd->rd_bits + x; in gfs2_rgrp_bh_get()
1196 error = gfs2_meta_read(gl, rgd->rd_addr + x, 0, 0, &bi->bi_bh); in gfs2_rgrp_bh_get()
1202 bi = rgd->rd_bits + y; in gfs2_rgrp_bh_get()
1213 if (!(rgd->rd_flags & GFS2_RDF_UPTODATE)) { in gfs2_rgrp_bh_get()
1215 clear_bit(GBF_FULL, &rgd->rd_bits[x].bi_flags); in gfs2_rgrp_bh_get()
1216 gfs2_rgrp_in(rgd, (rgd->rd_bits[0].bi_bh)->b_data); in gfs2_rgrp_bh_get()
1217 rgd->rd_flags |= (GFS2_RDF_UPTODATE | GFS2_RDF_CHECK); in gfs2_rgrp_bh_get()
1218 rgd->rd_free_clone = rgd->rd_free; in gfs2_rgrp_bh_get()
1220 rgd->rd_extfail_pt = rgd->rd_free; in gfs2_rgrp_bh_get()
1222 if (cpu_to_be32(GFS2_MAGIC) != rgd->rd_rgl->rl_magic) { in gfs2_rgrp_bh_get()
1223 rgd->rd_rgl->rl_unlinked = cpu_to_be32(count_unlinked(rgd)); in gfs2_rgrp_bh_get()
1224 gfs2_rgrp_ondisk2lvb(rgd->rd_rgl, in gfs2_rgrp_bh_get()
1225 rgd->rd_bits[0].bi_bh->b_data); in gfs2_rgrp_bh_get()
1228 if (!gfs2_rgrp_lvb_valid(rgd)){ in gfs2_rgrp_bh_get()
1229 gfs2_consist_rgrpd(rgd); in gfs2_rgrp_bh_get()
1233 if (rgd->rd_rgl->rl_unlinked == 0) in gfs2_rgrp_bh_get()
1234 rgd->rd_flags &= ~GFS2_RDF_CHECK; in gfs2_rgrp_bh_get()
1240 bi = rgd->rd_bits + x; in gfs2_rgrp_bh_get()
1249 static int update_rgrp_lvb(struct gfs2_rgrpd *rgd) in update_rgrp_lvb() argument
1253 if (rgd->rd_flags & GFS2_RDF_UPTODATE) in update_rgrp_lvb()
1256 if (cpu_to_be32(GFS2_MAGIC) != rgd->rd_rgl->rl_magic) in update_rgrp_lvb()
1257 return gfs2_rgrp_bh_get(rgd); in update_rgrp_lvb()
1259 rl_flags = be32_to_cpu(rgd->rd_rgl->rl_flags); in update_rgrp_lvb()
1261 rgd->rd_flags &= GFS2_RDF_MASK; in update_rgrp_lvb()
1262 rgd->rd_flags |= (rl_flags | GFS2_RDF_CHECK); in update_rgrp_lvb()
1263 if (rgd->rd_rgl->rl_unlinked == 0) in update_rgrp_lvb()
1264 rgd->rd_flags &= ~GFS2_RDF_CHECK; in update_rgrp_lvb()
1265 rgd->rd_free = be32_to_cpu(rgd->rd_rgl->rl_free); in update_rgrp_lvb()
1266 rgd->rd_free_clone = rgd->rd_free; in update_rgrp_lvb()
1267 rgd->rd_dinodes = be32_to_cpu(rgd->rd_rgl->rl_dinodes); in update_rgrp_lvb()
1268 rgd->rd_igeneration = be64_to_cpu(rgd->rd_rgl->rl_igeneration); in update_rgrp_lvb()
1274 struct gfs2_rgrpd *rgd = gh->gh_gl->gl_object; in gfs2_rgrp_go_lock() local
1275 struct gfs2_sbd *sdp = rgd->rd_sbd; in gfs2_rgrp_go_lock()
1279 return gfs2_rgrp_bh_get(rgd); in gfs2_rgrp_go_lock()
1288 void gfs2_rgrp_brelse(struct gfs2_rgrpd *rgd) in gfs2_rgrp_brelse() argument
1290 int x, length = rgd->rd_length; in gfs2_rgrp_brelse()
1293 struct gfs2_bitmap *bi = rgd->rd_bits + x; in gfs2_rgrp_brelse()
1310 struct gfs2_rgrpd *rgd = gh->gh_gl->gl_object; in gfs2_rgrp_go_unlock() local
1314 if (rgd && demote_requested) in gfs2_rgrp_go_unlock()
1315 gfs2_rgrp_brelse(rgd); in gfs2_rgrp_go_unlock()
1399 struct gfs2_rgrpd *rgd; in gfs2_fitrim() local
1431 rgd = gfs2_blk2rgrpd(sdp, start, 0); in gfs2_fitrim()
1440 ret = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &gh); in gfs2_fitrim()
1444 if (!(rgd->rd_flags & GFS2_RGF_TRIMMED)) { in gfs2_fitrim()
1446 for (x = 0; x < rgd->rd_length; x++) { in gfs2_fitrim()
1447 struct gfs2_bitmap *bi = rgd->rd_bits + x; in gfs2_fitrim()
1449 rgd->rd_data0, NULL, bi, minlen, in gfs2_fitrim()
1461 bh = rgd->rd_bits[0].bi_bh; in gfs2_fitrim()
1462 rgd->rd_flags |= GFS2_RGF_TRIMMED; in gfs2_fitrim()
1463 gfs2_trans_add_meta(rgd->rd_gl, bh); in gfs2_fitrim()
1464 gfs2_rgrp_out(rgd, bh->b_data); in gfs2_fitrim()
1470 if (rgd == rgd_end) in gfs2_fitrim()
1473 rgd = gfs2_rgrpd_get_next(rgd); in gfs2_fitrim()
1494 struct gfs2_rgrpd *rgd = rs->rs_rbm.rgd; in rs_insert() local
1499 spin_lock(&rgd->rd_rsspin); in rs_insert()
1500 newn = &rgd->rd_rstree.rb_node; in rs_insert()
1512 spin_unlock(&rgd->rd_rsspin); in rs_insert()
1519 rb_insert_color(&rs->rs_node, &rgd->rd_rstree); in rs_insert()
1522 rgd->rd_reserved += rs->rs_free; /* blocks reserved */ in rs_insert()
1523 spin_unlock(&rgd->rd_rsspin); in rs_insert()
1539 static inline u32 rgd_free(struct gfs2_rgrpd *rgd, struct gfs2_blkreserv *rs) in rgd_free() argument
1543 if (WARN_ON_ONCE(rgd->rd_reserved < rs->rs_free)) in rgd_free()
1545 tot_reserved = rgd->rd_reserved - rs->rs_free; in rgd_free()
1547 if (rgd->rd_free_clone < tot_reserved) in rgd_free()
1550 tot_free = rgd->rd_free_clone - tot_reserved; in rgd_free()
1563 static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip, in rg_mblk_search() argument
1566 struct gfs2_rbm rbm = { .rgd = rgd, }; in rg_mblk_search()
1570 u32 free_blocks = rgd_free(rgd, rs); in rg_mblk_search()
1580 if ((rgd->rd_free_clone < rgd->rd_reserved) || (free_blocks < extlen)) in rg_mblk_search()
1584 if (rgrp_contains_block(rgd, ip->i_goal)) in rg_mblk_search()
1587 goal = rgd->rd_last_alloc + rgd->rd_data0; in rg_mblk_search()
1598 if (goal == rgd->rd_last_alloc + rgd->rd_data0) in rg_mblk_search()
1599 rgd->rd_last_alloc = 0; in rg_mblk_search()
1616 static u64 gfs2_next_unreserved_block(struct gfs2_rgrpd *rgd, u64 block, in gfs2_next_unreserved_block() argument
1624 spin_lock(&rgd->rd_rsspin); in gfs2_next_unreserved_block()
1625 n = rgd->rd_rstree.rb_node; in gfs2_next_unreserved_block()
1647 spin_unlock(&rgd->rd_rsspin); in gfs2_next_unreserved_block()
1691 nblock = gfs2_next_unreserved_block(rbm->rgd, block, extlen, ip); in gfs2_reservation_check_and_update()
1739 struct gfs2_extent maxext = { .rbm.rgd = rbm->rgd, }; in gfs2_rbm_find()
1787 if (rbm->bii == rbm->rgd->rd_length) in gfs2_rbm_find()
1810 *minext < rbm->rgd->rd_extfail_pt) in gfs2_rbm_find()
1811 rbm->rgd->rd_extfail_pt = *minext; in gfs2_rbm_find()
1834 static void try_rgrp_unlink(struct gfs2_rgrpd *rgd, u64 *last_unlinked, u64 skip) in try_rgrp_unlink() argument
1837 struct gfs2_sbd *sdp = rgd->rd_sbd; in try_rgrp_unlink()
1842 struct gfs2_rbm rbm = { .rgd = rgd, .bii = 0, .offset = 0 }; in try_rgrp_unlink()
1886 rgd->rd_flags &= ~GFS2_RDF_CHECK; in try_rgrp_unlink()
1917 static bool gfs2_rgrp_congested(const struct gfs2_rgrpd *rgd, int loops) in gfs2_rgrp_congested() argument
1919 const struct gfs2_glock *gl = rgd->rd_gl; in gfs2_rgrp_congested()
1976 rs->rs_rbm.rgd->rd_gl->gl_dstamp)); in gfs2_rgrp_used_recently()
1992 struct gfs2_rgrpd *rgd = *pos; in gfs2_select_rgrp() local
1993 struct gfs2_sbd *sdp = rgd->rd_sbd; in gfs2_select_rgrp()
1995 rgd = gfs2_rgrpd_get_next(rgd); in gfs2_select_rgrp()
1996 if (rgd == NULL) in gfs2_select_rgrp()
1997 rgd = gfs2_rgrpd_get_first(sdp); in gfs2_select_rgrp()
1998 *pos = rgd; in gfs2_select_rgrp()
1999 if (rgd != begin) /* If we didn't wrap */ in gfs2_select_rgrp()
2010 static inline int fast_to_acquire(struct gfs2_rgrpd *rgd) in fast_to_acquire() argument
2012 struct gfs2_glock *gl = rgd->rd_gl; in fast_to_acquire()
2018 if (rgd->rd_flags & GFS2_RDF_PREFERRED) in fast_to_acquire()
2054 begin = rs->rs_rbm.rgd; in gfs2_inplace_reserve()
2055 } else if (rs->rs_rbm.rgd && in gfs2_inplace_reserve()
2056 rgrp_contains_block(rs->rs_rbm.rgd, ip->i_goal)) { in gfs2_inplace_reserve()
2057 begin = rs->rs_rbm.rgd; in gfs2_inplace_reserve()
2060 rs->rs_rbm.rgd = begin = gfs2_blk2rgrpd(sdp, ip->i_goal, 1); in gfs2_inplace_reserve()
2064 if (rs->rs_rbm.rgd == NULL) in gfs2_inplace_reserve()
2070 if (!gfs2_glock_is_locked_by_me(rs->rs_rbm.rgd->rd_gl)) { in gfs2_inplace_reserve()
2076 !fast_to_acquire(rs->rs_rbm.rgd)) in gfs2_inplace_reserve()
2080 gfs2_rgrp_congested(rs->rs_rbm.rgd, loops)) in gfs2_inplace_reserve()
2083 error = gfs2_glock_nq_init(rs->rs_rbm.rgd->rd_gl, in gfs2_inplace_reserve()
2089 gfs2_rgrp_congested(rs->rs_rbm.rgd, loops)) in gfs2_inplace_reserve()
2092 error = update_rgrp_lvb(rs->rs_rbm.rgd); in gfs2_inplace_reserve()
2101 if ((rs->rs_rbm.rgd->rd_flags & (GFS2_RGF_NOALLOC | in gfs2_inplace_reserve()
2103 (loops == 0 && ap->target > rs->rs_rbm.rgd->rd_extfail_pt)) in gfs2_inplace_reserve()
2107 gfs2_rgrp_bh_get(rs->rs_rbm.rgd); in gfs2_inplace_reserve()
2111 rg_mblk_search(rs->rs_rbm.rgd, ip, ap); in gfs2_inplace_reserve()
2118 free_blocks = rgd_free(rs->rs_rbm.rgd, rs); in gfs2_inplace_reserve()
2127 if (rs->rs_rbm.rgd->rd_flags & GFS2_RDF_CHECK) in gfs2_inplace_reserve()
2128 try_rgrp_unlink(rs->rs_rbm.rgd, &last_unlinked, in gfs2_inplace_reserve()
2140 if (gfs2_select_rgrp(&rs->rs_rbm.rgd, begin)) in gfs2_inplace_reserve()
2190 struct gfs2_rbm pos = { .rgd = rbm->rgd, }; in gfs2_alloc_extent()
2197 gfs2_trans_add_meta(rbm->rgd->rd_gl, rbm_bi(rbm)->bi_bh); in gfs2_alloc_extent()
2204 gfs2_trans_add_meta(pos.rgd->rd_gl, rbm_bi(&pos)->bi_bh); in gfs2_alloc_extent()
2220 static void rgblk_free(struct gfs2_sbd *sdp, struct gfs2_rgrpd *rgd, in rgblk_free() argument
2226 rbm.rgd = rgd; in rgblk_free()
2239 gfs2_trans_add_meta(rbm.rgd->rd_gl, bi->bi_bh); in rgblk_free()
2258 struct gfs2_rgrpd *rgd = gl->gl_object; in gfs2_rgrp_dump() local
2262 if (rgd == NULL) in gfs2_rgrp_dump()
2266 (unsigned long long)rgd->rd_addr, rgd->rd_flags, in gfs2_rgrp_dump()
2267 rgd->rd_free, rgd->rd_free_clone, rgd->rd_dinodes, in gfs2_rgrp_dump()
2268 rgd->rd_reserved, rgd->rd_extfail_pt); in gfs2_rgrp_dump()
2269 if (rgd->rd_sbd->sd_args.ar_rgrplvb) { in gfs2_rgrp_dump()
2270 struct gfs2_rgrp_lvb *rgl = rgd->rd_rgl; in gfs2_rgrp_dump()
2277 spin_lock(&rgd->rd_rsspin); in gfs2_rgrp_dump()
2278 for (n = rb_first(&rgd->rd_rstree); n; n = rb_next(&trs->rs_node)) { in gfs2_rgrp_dump()
2282 spin_unlock(&rgd->rd_rsspin); in gfs2_rgrp_dump()
2285 static void gfs2_rgrp_error(struct gfs2_rgrpd *rgd) in gfs2_rgrp_error() argument
2287 struct gfs2_sbd *sdp = rgd->rd_sbd; in gfs2_rgrp_error()
2291 (unsigned long long)rgd->rd_addr); in gfs2_rgrp_error()
2294 gfs2_rgrp_dump(NULL, rgd->rd_gl, fs_id_buf); in gfs2_rgrp_error()
2295 rgd->rd_flags |= GFS2_RDF_ERROR; in gfs2_rgrp_error()
2313 struct gfs2_rgrpd *rgd = rbm->rgd; in gfs2_adjust_reservation() local
2318 spin_lock(&rgd->rd_rsspin); in gfs2_adjust_reservation()
2325 rgd->rd_reserved -= rlen; in gfs2_adjust_reservation()
2336 spin_unlock(&rgd->rd_rsspin); in gfs2_adjust_reservation()
2360 if (!dinode && rgrp_contains_block(rbm->rgd, ip->i_goal)) in gfs2_set_alloc_start()
2363 goal = rbm->rgd->rd_last_alloc + rbm->rgd->rd_data0; in gfs2_set_alloc_start()
2387 struct gfs2_rbm rbm = { .rgd = ip->i_res.rs_rbm.rgd, }; in gfs2_alloc_blocks()
2404 test_bit(GBF_FULL, &rbm.rgd->rd_bits->bi_flags), in gfs2_alloc_blocks()
2405 rbm.rgd->rd_extfail_pt); in gfs2_alloc_blocks()
2411 rbm.rgd->rd_last_alloc = block - rbm.rgd->rd_data0; in gfs2_alloc_blocks()
2430 if (rbm.rgd->rd_free < *nblocks) { in gfs2_alloc_blocks()
2435 rbm.rgd->rd_free -= *nblocks; in gfs2_alloc_blocks()
2437 rbm.rgd->rd_dinodes++; in gfs2_alloc_blocks()
2438 *generation = rbm.rgd->rd_igeneration++; in gfs2_alloc_blocks()
2440 *generation = rbm.rgd->rd_igeneration++; in gfs2_alloc_blocks()
2443 gfs2_trans_add_meta(rbm.rgd->rd_gl, rbm.rgd->rd_bits[0].bi_bh); in gfs2_alloc_blocks()
2444 gfs2_rgrp_out(rbm.rgd, rbm.rgd->rd_bits[0].bi_bh->b_data); in gfs2_alloc_blocks()
2452 rbm.rgd->rd_free_clone -= *nblocks; in gfs2_alloc_blocks()
2453 trace_gfs2_block_alloc(ip, rbm.rgd, block, *nblocks, in gfs2_alloc_blocks()
2459 gfs2_rgrp_error(rbm.rgd); in gfs2_alloc_blocks()
2473 void __gfs2_free_blocks(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd, in __gfs2_free_blocks() argument
2478 rgblk_free(sdp, rgd, bstart, blen, GFS2_BLKST_FREE); in __gfs2_free_blocks()
2479 trace_gfs2_block_alloc(ip, rgd, bstart, blen, GFS2_BLKST_FREE); in __gfs2_free_blocks()
2480 rgd->rd_free += blen; in __gfs2_free_blocks()
2481 rgd->rd_flags &= ~GFS2_RGF_TRIMMED; in __gfs2_free_blocks()
2482 gfs2_trans_add_meta(rgd->rd_gl, rgd->rd_bits[0].bi_bh); in __gfs2_free_blocks()
2483 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); in __gfs2_free_blocks()
2499 void gfs2_free_meta(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd, in gfs2_free_meta() argument
2504 __gfs2_free_blocks(ip, rgd, bstart, blen, 1); in gfs2_free_meta()
2513 struct gfs2_rgrpd *rgd; in gfs2_unlink_di() local
2516 rgd = gfs2_blk2rgrpd(sdp, blkno, true); in gfs2_unlink_di()
2517 if (!rgd) in gfs2_unlink_di()
2519 rgblk_free(sdp, rgd, blkno, 1, GFS2_BLKST_UNLINKED); in gfs2_unlink_di()
2520 trace_gfs2_block_alloc(ip, rgd, blkno, 1, GFS2_BLKST_UNLINKED); in gfs2_unlink_di()
2521 gfs2_trans_add_meta(rgd->rd_gl, rgd->rd_bits[0].bi_bh); in gfs2_unlink_di()
2522 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); in gfs2_unlink_di()
2523 be32_add_cpu(&rgd->rd_rgl->rl_unlinked, 1); in gfs2_unlink_di()
2526 void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip) in gfs2_free_di() argument
2528 struct gfs2_sbd *sdp = rgd->rd_sbd; in gfs2_free_di()
2530 rgblk_free(sdp, rgd, ip->i_no_addr, 1, GFS2_BLKST_FREE); in gfs2_free_di()
2531 if (!rgd->rd_dinodes) in gfs2_free_di()
2532 gfs2_consist_rgrpd(rgd); in gfs2_free_di()
2533 rgd->rd_dinodes--; in gfs2_free_di()
2534 rgd->rd_free++; in gfs2_free_di()
2536 gfs2_trans_add_meta(rgd->rd_gl, rgd->rd_bits[0].bi_bh); in gfs2_free_di()
2537 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); in gfs2_free_di()
2538 be32_add_cpu(&rgd->rd_rgl->rl_unlinked, -1); in gfs2_free_di()
2541 trace_gfs2_block_alloc(ip, rgd, ip->i_no_addr, 1, GFS2_BLKST_FREE); in gfs2_free_di()
2559 struct gfs2_rgrpd *rgd; in gfs2_check_blk_type() local
2564 rgd = gfs2_blk2rgrpd(sdp, no_addr, 1); in gfs2_check_blk_type()
2565 if (!rgd) in gfs2_check_blk_type()
2568 error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_SHARED, 0, &rgd_gh); in gfs2_check_blk_type()
2572 rbm.rgd = rgd; in gfs2_check_blk_type()
2601 struct gfs2_rgrpd *rgd; in gfs2_rlist_add() local
2614 rgd = rlist->rl_rgd[rlist->rl_rgrps - 1]; in gfs2_rlist_add()
2615 if (rgrp_contains_block(rgd, block)) in gfs2_rlist_add()
2617 rgd = gfs2_blk2rgrpd(sdp, block, 1); in gfs2_rlist_add()
2619 rgd = ip->i_res.rs_rbm.rgd; in gfs2_rlist_add()
2620 if (!rgd || !rgrp_contains_block(rgd, block)) in gfs2_rlist_add()
2621 rgd = gfs2_blk2rgrpd(sdp, block, 1); in gfs2_rlist_add()
2624 if (!rgd) { in gfs2_rlist_add()
2631 if (rlist->rl_rgd[x] == rgd) { in gfs2_rlist_add()
2654 rlist->rl_rgd[rlist->rl_rgrps++] = rgd; in gfs2_rlist_add()