diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2007-06-01 09:11:58 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2007-07-09 03:23:10 -0400 |
commit | bb8d8a6f54c1c84d7c74623491bab043b36a38c5 (patch) | |
tree | 76c62c505df2a1acd090f4aacc63fb9eddd3950f /fs/gfs2/rgrp.c | |
parent | ddf4b426aababdae4cb96326d7aeb9d119f42c50 (diff) |
[GFS2] Fix sign problem in quota/statfs and cleanup _host structures
This patch fixes some sign issues which were accidentally introduced
into the quota & statfs code during the endianess annotation process.
Also included is a general clean up which moves all of the _host
structures out of gfs2_ondisk.h (where they should not have been to
start with) and into the places where they are actually used (often only
one place). Also those _host structures which are not required any more
are removed entirely (which is the eventual plan for all of them).
The conversion routines from ondisk.c are also moved into the places
where they are actually used, which for almost every one, was just one
single place, so all those are now static functions. This also cleans up
the end of gfs2_ondisk.h which no longer needs the #ifdef __KERNEL__.
The net result is a reduction of about 100 lines of code, many functions
now marked static plus the bug fixes as mentioned above. For good
measure I ran the code through sparse after making these changes to
check that there are no warnings generated.
This fixes Red Hat bz #239686
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/rgrp.c')
-rw-r--r-- | fs/gfs2/rgrp.c | 111 |
1 files changed, 76 insertions, 35 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 30eb428065c5..027f6ec5b0d9 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -204,7 +204,7 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) | |||
204 | { | 204 | { |
205 | struct gfs2_sbd *sdp = rgd->rd_sbd; | 205 | struct gfs2_sbd *sdp = rgd->rd_sbd; |
206 | struct gfs2_bitmap *bi = NULL; | 206 | struct gfs2_bitmap *bi = NULL; |
207 | u32 length = rgd->rd_ri.ri_length; | 207 | u32 length = rgd->rd_length; |
208 | u32 count[4], tmp; | 208 | u32 count[4], tmp; |
209 | int buf, x; | 209 | int buf, x; |
210 | 210 | ||
@@ -227,7 +227,7 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) | |||
227 | return; | 227 | return; |
228 | } | 228 | } |
229 | 229 | ||
230 | tmp = rgd->rd_ri.ri_data - | 230 | tmp = rgd->rd_data - |
231 | rgd->rd_rg.rg_free - | 231 | rgd->rd_rg.rg_free - |
232 | rgd->rd_rg.rg_dinodes; | 232 | rgd->rd_rg.rg_dinodes; |
233 | if (count[1] + count[2] != tmp) { | 233 | if (count[1] + count[2] != tmp) { |
@@ -253,10 +253,10 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) | |||
253 | 253 | ||
254 | } | 254 | } |
255 | 255 | ||
256 | static inline int rgrp_contains_block(struct gfs2_rindex_host *ri, u64 block) | 256 | static inline int rgrp_contains_block(struct gfs2_rgrpd *rgd, u64 block) |
257 | { | 257 | { |
258 | u64 first = ri->ri_data0; | 258 | u64 first = rgd->rd_data0; |
259 | u64 last = first + ri->ri_data; | 259 | u64 last = first + rgd->rd_data; |
260 | return first <= block && block < last; | 260 | return first <= block && block < last; |
261 | } | 261 | } |
262 | 262 | ||
@@ -275,7 +275,7 @@ struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk) | |||
275 | spin_lock(&sdp->sd_rindex_spin); | 275 | spin_lock(&sdp->sd_rindex_spin); |
276 | 276 | ||
277 | list_for_each_entry(rgd, &sdp->sd_rindex_mru_list, rd_list_mru) { | 277 | list_for_each_entry(rgd, &sdp->sd_rindex_mru_list, rd_list_mru) { |
278 | if (rgrp_contains_block(&rgd->rd_ri, blk)) { | 278 | if (rgrp_contains_block(rgd, blk)) { |
279 | list_move(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list); | 279 | list_move(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list); |
280 | spin_unlock(&sdp->sd_rindex_spin); | 280 | spin_unlock(&sdp->sd_rindex_spin); |
281 | return rgd; | 281 | return rgd; |
@@ -354,6 +354,15 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp) | |||
354 | mutex_unlock(&sdp->sd_rindex_mutex); | 354 | mutex_unlock(&sdp->sd_rindex_mutex); |
355 | } | 355 | } |
356 | 356 | ||
357 | static void gfs2_rindex_print(const struct gfs2_rgrpd *rgd) | ||
358 | { | ||
359 | printk(KERN_INFO " ri_addr = %llu\n", (unsigned long long)rgd->rd_addr); | ||
360 | printk(KERN_INFO " ri_length = %u\n", rgd->rd_length); | ||
361 | printk(KERN_INFO " ri_data0 = %llu\n", (unsigned long long)rgd->rd_data0); | ||
362 | printk(KERN_INFO " ri_data = %u\n", rgd->rd_data); | ||
363 | printk(KERN_INFO " ri_bitbytes = %u\n", rgd->rd_bitbytes); | ||
364 | } | ||
365 | |||
357 | /** | 366 | /** |
358 | * gfs2_compute_bitstructs - Compute the bitmap sizes | 367 | * gfs2_compute_bitstructs - Compute the bitmap sizes |
359 | * @rgd: The resource group descriptor | 368 | * @rgd: The resource group descriptor |
@@ -367,7 +376,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
367 | { | 376 | { |
368 | struct gfs2_sbd *sdp = rgd->rd_sbd; | 377 | struct gfs2_sbd *sdp = rgd->rd_sbd; |
369 | struct gfs2_bitmap *bi; | 378 | struct gfs2_bitmap *bi; |
370 | u32 length = rgd->rd_ri.ri_length; /* # blocks in hdr & bitmap */ | 379 | u32 length = rgd->rd_length; /* # blocks in hdr & bitmap */ |
371 | u32 bytes_left, bytes; | 380 | u32 bytes_left, bytes; |
372 | int x; | 381 | int x; |
373 | 382 | ||
@@ -378,7 +387,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
378 | if (!rgd->rd_bits) | 387 | if (!rgd->rd_bits) |
379 | return -ENOMEM; | 388 | return -ENOMEM; |
380 | 389 | ||
381 | bytes_left = rgd->rd_ri.ri_bitbytes; | 390 | bytes_left = rgd->rd_bitbytes; |
382 | 391 | ||
383 | for (x = 0; x < length; x++) { | 392 | for (x = 0; x < length; x++) { |
384 | bi = rgd->rd_bits + x; | 393 | bi = rgd->rd_bits + x; |
@@ -399,14 +408,14 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
399 | } else if (x + 1 == length) { | 408 | } else if (x + 1 == length) { |
400 | bytes = bytes_left; | 409 | bytes = bytes_left; |
401 | bi->bi_offset = sizeof(struct gfs2_meta_header); | 410 | bi->bi_offset = sizeof(struct gfs2_meta_header); |
402 | bi->bi_start = rgd->rd_ri.ri_bitbytes - bytes_left; | 411 | bi->bi_start = rgd->rd_bitbytes - bytes_left; |
403 | bi->bi_len = bytes; | 412 | bi->bi_len = bytes; |
404 | /* other blocks */ | 413 | /* other blocks */ |
405 | } else { | 414 | } else { |
406 | bytes = sdp->sd_sb.sb_bsize - | 415 | bytes = sdp->sd_sb.sb_bsize - |
407 | sizeof(struct gfs2_meta_header); | 416 | sizeof(struct gfs2_meta_header); |
408 | bi->bi_offset = sizeof(struct gfs2_meta_header); | 417 | bi->bi_offset = sizeof(struct gfs2_meta_header); |
409 | bi->bi_start = rgd->rd_ri.ri_bitbytes - bytes_left; | 418 | bi->bi_start = rgd->rd_bitbytes - bytes_left; |
410 | bi->bi_len = bytes; | 419 | bi->bi_len = bytes; |
411 | } | 420 | } |
412 | 421 | ||
@@ -418,9 +427,9 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
418 | return -EIO; | 427 | return -EIO; |
419 | } | 428 | } |
420 | bi = rgd->rd_bits + (length - 1); | 429 | bi = rgd->rd_bits + (length - 1); |
421 | if ((bi->bi_start + bi->bi_len) * GFS2_NBBY != rgd->rd_ri.ri_data) { | 430 | if ((bi->bi_start + bi->bi_len) * GFS2_NBBY != rgd->rd_data) { |
422 | if (gfs2_consist_rgrpd(rgd)) { | 431 | if (gfs2_consist_rgrpd(rgd)) { |
423 | gfs2_rindex_print(&rgd->rd_ri); | 432 | gfs2_rindex_print(rgd); |
424 | fs_err(sdp, "start=%u len=%u offset=%u\n", | 433 | fs_err(sdp, "start=%u len=%u offset=%u\n", |
425 | bi->bi_start, bi->bi_len, bi->bi_offset); | 434 | bi->bi_start, bi->bi_len, bi->bi_offset); |
426 | } | 435 | } |
@@ -431,6 +440,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
431 | } | 440 | } |
432 | 441 | ||
433 | /** | 442 | /** |
443 | |||
434 | * gfs2_ri_total - Total up the file system space, according to the rindex. | 444 | * gfs2_ri_total - Total up the file system space, according to the rindex. |
435 | * | 445 | * |
436 | */ | 446 | */ |
@@ -439,7 +449,6 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp) | |||
439 | u64 total_data = 0; | 449 | u64 total_data = 0; |
440 | struct inode *inode = sdp->sd_rindex; | 450 | struct inode *inode = sdp->sd_rindex; |
441 | struct gfs2_inode *ip = GFS2_I(inode); | 451 | struct gfs2_inode *ip = GFS2_I(inode); |
442 | struct gfs2_rindex_host ri; | ||
443 | char buf[sizeof(struct gfs2_rindex)]; | 452 | char buf[sizeof(struct gfs2_rindex)]; |
444 | struct file_ra_state ra_state; | 453 | struct file_ra_state ra_state; |
445 | int error, rgrps; | 454 | int error, rgrps; |
@@ -455,13 +464,23 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp) | |||
455 | sizeof(struct gfs2_rindex)); | 464 | sizeof(struct gfs2_rindex)); |
456 | if (error != sizeof(struct gfs2_rindex)) | 465 | if (error != sizeof(struct gfs2_rindex)) |
457 | break; | 466 | break; |
458 | gfs2_rindex_in(&ri, buf); | 467 | total_data += be32_to_cpu(((struct gfs2_rindex *)buf)->ri_data); |
459 | total_data += ri.ri_data; | ||
460 | } | 468 | } |
461 | mutex_unlock(&sdp->sd_rindex_mutex); | 469 | mutex_unlock(&sdp->sd_rindex_mutex); |
462 | return total_data; | 470 | return total_data; |
463 | } | 471 | } |
464 | 472 | ||
473 | static void gfs2_rindex_in(struct gfs2_rgrpd *rgd, const void *buf) | ||
474 | { | ||
475 | const struct gfs2_rindex *str = buf; | ||
476 | |||
477 | rgd->rd_addr = be64_to_cpu(str->ri_addr); | ||
478 | rgd->rd_length = be32_to_cpu(str->ri_length); | ||
479 | rgd->rd_data0 = be64_to_cpu(str->ri_data0); | ||
480 | rgd->rd_data = be32_to_cpu(str->ri_data); | ||
481 | rgd->rd_bitbytes = be32_to_cpu(str->ri_bitbytes); | ||
482 | } | ||
483 | |||
465 | /** | 484 | /** |
466 | * read_rindex_entry - Pull in a new resource index entry from the disk | 485 | * read_rindex_entry - Pull in a new resource index entry from the disk |
467 | * @gl: The glock covering the rindex inode | 486 | * @gl: The glock covering the rindex inode |
@@ -500,12 +519,12 @@ static int read_rindex_entry(struct gfs2_inode *ip, | |||
500 | list_add_tail(&rgd->rd_list, &sdp->sd_rindex_list); | 519 | list_add_tail(&rgd->rd_list, &sdp->sd_rindex_list); |
501 | list_add_tail(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list); | 520 | list_add_tail(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list); |
502 | 521 | ||
503 | gfs2_rindex_in(&rgd->rd_ri, buf); | 522 | gfs2_rindex_in(rgd, buf); |
504 | error = compute_bitstructs(rgd); | 523 | error = compute_bitstructs(rgd); |
505 | if (error) | 524 | if (error) |
506 | return error; | 525 | return error; |
507 | 526 | ||
508 | error = gfs2_glock_get(sdp, rgd->rd_ri.ri_addr, | 527 | error = gfs2_glock_get(sdp, rgd->rd_addr, |
509 | &gfs2_rgrp_glops, CREATE, &rgd->rd_gl); | 528 | &gfs2_rgrp_glops, CREATE, &rgd->rd_gl); |
510 | if (error) | 529 | if (error) |
511 | return error; | 530 | return error; |
@@ -626,6 +645,28 @@ int gfs2_rindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ri_gh) | |||
626 | return error; | 645 | return error; |
627 | } | 646 | } |
628 | 647 | ||
648 | static void gfs2_rgrp_in(struct gfs2_rgrp_host *rg, const void *buf) | ||
649 | { | ||
650 | const struct gfs2_rgrp *str = buf; | ||
651 | |||
652 | rg->rg_flags = be32_to_cpu(str->rg_flags); | ||
653 | rg->rg_free = be32_to_cpu(str->rg_free); | ||
654 | rg->rg_dinodes = be32_to_cpu(str->rg_dinodes); | ||
655 | rg->rg_igeneration = be64_to_cpu(str->rg_igeneration); | ||
656 | } | ||
657 | |||
658 | static void gfs2_rgrp_out(const struct gfs2_rgrp_host *rg, void *buf) | ||
659 | { | ||
660 | struct gfs2_rgrp *str = buf; | ||
661 | |||
662 | str->rg_flags = cpu_to_be32(rg->rg_flags); | ||
663 | str->rg_free = cpu_to_be32(rg->rg_free); | ||
664 | str->rg_dinodes = cpu_to_be32(rg->rg_dinodes); | ||
665 | str->__pad = cpu_to_be32(0); | ||
666 | str->rg_igeneration = cpu_to_be64(rg->rg_igeneration); | ||
667 | memset(&str->rg_reserved, 0, sizeof(str->rg_reserved)); | ||
668 | } | ||
669 | |||
629 | /** | 670 | /** |
630 | * gfs2_rgrp_bh_get - Read in a RG's header and bitmaps | 671 | * gfs2_rgrp_bh_get - Read in a RG's header and bitmaps |
631 | * @rgd: the struct gfs2_rgrpd describing the RG to read in | 672 | * @rgd: the struct gfs2_rgrpd describing the RG to read in |
@@ -640,7 +681,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) | |||
640 | { | 681 | { |
641 | struct gfs2_sbd *sdp = rgd->rd_sbd; | 682 | struct gfs2_sbd *sdp = rgd->rd_sbd; |
642 | struct gfs2_glock *gl = rgd->rd_gl; | 683 | struct gfs2_glock *gl = rgd->rd_gl; |
643 | unsigned int length = rgd->rd_ri.ri_length; | 684 | unsigned int length = rgd->rd_length; |
644 | struct gfs2_bitmap *bi; | 685 | struct gfs2_bitmap *bi; |
645 | unsigned int x, y; | 686 | unsigned int x, y; |
646 | int error; | 687 | int error; |
@@ -658,7 +699,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) | |||
658 | 699 | ||
659 | for (x = 0; x < length; x++) { | 700 | for (x = 0; x < length; x++) { |
660 | bi = rgd->rd_bits + x; | 701 | bi = rgd->rd_bits + x; |
661 | error = gfs2_meta_read(gl, rgd->rd_ri.ri_addr + x, 0, &bi->bi_bh); | 702 | error = gfs2_meta_read(gl, rgd->rd_addr + x, 0, &bi->bi_bh); |
662 | if (error) | 703 | if (error) |
663 | goto fail; | 704 | goto fail; |
664 | } | 705 | } |
@@ -720,7 +761,7 @@ void gfs2_rgrp_bh_hold(struct gfs2_rgrpd *rgd) | |||
720 | void gfs2_rgrp_bh_put(struct gfs2_rgrpd *rgd) | 761 | void gfs2_rgrp_bh_put(struct gfs2_rgrpd *rgd) |
721 | { | 762 | { |
722 | struct gfs2_sbd *sdp = rgd->rd_sbd; | 763 | struct gfs2_sbd *sdp = rgd->rd_sbd; |
723 | int x, length = rgd->rd_ri.ri_length; | 764 | int x, length = rgd->rd_length; |
724 | 765 | ||
725 | spin_lock(&sdp->sd_rindex_spin); | 766 | spin_lock(&sdp->sd_rindex_spin); |
726 | gfs2_assert_warn(rgd->rd_sbd, rgd->rd_bh_count); | 767 | gfs2_assert_warn(rgd->rd_sbd, rgd->rd_bh_count); |
@@ -743,7 +784,7 @@ void gfs2_rgrp_bh_put(struct gfs2_rgrpd *rgd) | |||
743 | void gfs2_rgrp_repolish_clones(struct gfs2_rgrpd *rgd) | 784 | void gfs2_rgrp_repolish_clones(struct gfs2_rgrpd *rgd) |
744 | { | 785 | { |
745 | struct gfs2_sbd *sdp = rgd->rd_sbd; | 786 | struct gfs2_sbd *sdp = rgd->rd_sbd; |
746 | unsigned int length = rgd->rd_ri.ri_length; | 787 | unsigned int length = rgd->rd_length; |
747 | unsigned int x; | 788 | unsigned int x; |
748 | 789 | ||
749 | for (x = 0; x < length; x++) { | 790 | for (x = 0; x < length; x++) { |
@@ -826,7 +867,7 @@ static struct gfs2_rgrpd *recent_rgrp_first(struct gfs2_sbd *sdp, | |||
826 | goto first; | 867 | goto first; |
827 | 868 | ||
828 | list_for_each_entry(rgd, &sdp->sd_rindex_recent_list, rd_recent) { | 869 | list_for_each_entry(rgd, &sdp->sd_rindex_recent_list, rd_recent) { |
829 | if (rgd->rd_ri.ri_addr == rglast) | 870 | if (rgd->rd_addr == rglast) |
830 | goto out; | 871 | goto out; |
831 | } | 872 | } |
832 | 873 | ||
@@ -1037,7 +1078,7 @@ static int get_local_rgrp(struct gfs2_inode *ip) | |||
1037 | } | 1078 | } |
1038 | 1079 | ||
1039 | out: | 1080 | out: |
1040 | ip->i_last_rg_alloc = rgd->rd_ri.ri_addr; | 1081 | ip->i_last_rg_alloc = rgd->rd_addr; |
1041 | 1082 | ||
1042 | if (begin) { | 1083 | if (begin) { |
1043 | recent_rgrp_add(rgd); | 1084 | recent_rgrp_add(rgd); |
@@ -1128,8 +1169,8 @@ unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, u64 block) | |||
1128 | unsigned int buf; | 1169 | unsigned int buf; |
1129 | unsigned char type; | 1170 | unsigned char type; |
1130 | 1171 | ||
1131 | length = rgd->rd_ri.ri_length; | 1172 | length = rgd->rd_length; |
1132 | rgrp_block = block - rgd->rd_ri.ri_data0; | 1173 | rgrp_block = block - rgd->rd_data0; |
1133 | 1174 | ||
1134 | for (buf = 0; buf < length; buf++) { | 1175 | for (buf = 0; buf < length; buf++) { |
1135 | bi = rgd->rd_bits + buf; | 1176 | bi = rgd->rd_bits + buf; |
@@ -1171,7 +1212,7 @@ static u32 rgblk_search(struct gfs2_rgrpd *rgd, u32 goal, | |||
1171 | unsigned char old_state, unsigned char new_state) | 1212 | unsigned char old_state, unsigned char new_state) |
1172 | { | 1213 | { |
1173 | struct gfs2_bitmap *bi = NULL; | 1214 | struct gfs2_bitmap *bi = NULL; |
1174 | u32 length = rgd->rd_ri.ri_length; | 1215 | u32 length = rgd->rd_length; |
1175 | u32 blk = 0; | 1216 | u32 blk = 0; |
1176 | unsigned int buf, x; | 1217 | unsigned int buf, x; |
1177 | 1218 | ||
@@ -1247,9 +1288,9 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart, | |||
1247 | return NULL; | 1288 | return NULL; |
1248 | } | 1289 | } |
1249 | 1290 | ||
1250 | length = rgd->rd_ri.ri_length; | 1291 | length = rgd->rd_length; |
1251 | 1292 | ||
1252 | rgrp_blk = bstart - rgd->rd_ri.ri_data0; | 1293 | rgrp_blk = bstart - rgd->rd_data0; |
1253 | 1294 | ||
1254 | while (blen--) { | 1295 | while (blen--) { |
1255 | for (buf = 0; buf < length; buf++) { | 1296 | for (buf = 0; buf < length; buf++) { |
@@ -1293,15 +1334,15 @@ u64 gfs2_alloc_data(struct gfs2_inode *ip) | |||
1293 | u32 goal, blk; | 1334 | u32 goal, blk; |
1294 | u64 block; | 1335 | u64 block; |
1295 | 1336 | ||
1296 | if (rgrp_contains_block(&rgd->rd_ri, ip->i_di.di_goal_data)) | 1337 | if (rgrp_contains_block(rgd, ip->i_di.di_goal_data)) |
1297 | goal = ip->i_di.di_goal_data - rgd->rd_ri.ri_data0; | 1338 | goal = ip->i_di.di_goal_data - rgd->rd_data0; |
1298 | else | 1339 | else |
1299 | goal = rgd->rd_last_alloc_data; | 1340 | goal = rgd->rd_last_alloc_data; |
1300 | 1341 | ||
1301 | blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); | 1342 | blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); |
1302 | rgd->rd_last_alloc_data = blk; | 1343 | rgd->rd_last_alloc_data = blk; |
1303 | 1344 | ||
1304 | block = rgd->rd_ri.ri_data0 + blk; | 1345 | block = rgd->rd_data0 + blk; |
1305 | ip->i_di.di_goal_data = block; | 1346 | ip->i_di.di_goal_data = block; |
1306 | 1347 | ||
1307 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); | 1348 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); |
@@ -1337,15 +1378,15 @@ u64 gfs2_alloc_meta(struct gfs2_inode *ip) | |||
1337 | u32 goal, blk; | 1378 | u32 goal, blk; |
1338 | u64 block; | 1379 | u64 block; |
1339 | 1380 | ||
1340 | if (rgrp_contains_block(&rgd->rd_ri, ip->i_di.di_goal_meta)) | 1381 | if (rgrp_contains_block(rgd, ip->i_di.di_goal_meta)) |
1341 | goal = ip->i_di.di_goal_meta - rgd->rd_ri.ri_data0; | 1382 | goal = ip->i_di.di_goal_meta - rgd->rd_data0; |
1342 | else | 1383 | else |
1343 | goal = rgd->rd_last_alloc_meta; | 1384 | goal = rgd->rd_last_alloc_meta; |
1344 | 1385 | ||
1345 | blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); | 1386 | blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); |
1346 | rgd->rd_last_alloc_meta = blk; | 1387 | rgd->rd_last_alloc_meta = blk; |
1347 | 1388 | ||
1348 | block = rgd->rd_ri.ri_data0 + blk; | 1389 | block = rgd->rd_data0 + blk; |
1349 | ip->i_di.di_goal_meta = block; | 1390 | ip->i_di.di_goal_meta = block; |
1350 | 1391 | ||
1351 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); | 1392 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); |
@@ -1387,7 +1428,7 @@ u64 gfs2_alloc_di(struct gfs2_inode *dip, u64 *generation) | |||
1387 | 1428 | ||
1388 | rgd->rd_last_alloc_meta = blk; | 1429 | rgd->rd_last_alloc_meta = blk; |
1389 | 1430 | ||
1390 | block = rgd->rd_ri.ri_data0 + blk; | 1431 | block = rgd->rd_data0 + blk; |
1391 | 1432 | ||
1392 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); | 1433 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); |
1393 | rgd->rd_rg.rg_free--; | 1434 | rgd->rd_rg.rg_free--; |