diff options
Diffstat (limited to 'fs/gfs2/bmap.c')
-rw-r--r-- | fs/gfs2/bmap.c | 179 |
1 files changed, 87 insertions, 92 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 06e9a8cb45e9..8240c1ff94f4 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c | |||
@@ -38,8 +38,8 @@ struct metapath { | |||
38 | }; | 38 | }; |
39 | 39 | ||
40 | typedef int (*block_call_t) (struct gfs2_inode *ip, struct buffer_head *dibh, | 40 | typedef int (*block_call_t) (struct gfs2_inode *ip, struct buffer_head *dibh, |
41 | struct buffer_head *bh, u64 *top, | 41 | struct buffer_head *bh, __be64 *top, |
42 | u64 *bottom, unsigned int height, | 42 | __be64 *bottom, unsigned int height, |
43 | void *data); | 43 | void *data); |
44 | 44 | ||
45 | struct strip_mine { | 45 | struct strip_mine { |
@@ -163,6 +163,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) | |||
163 | if (ip->i_di.di_size) { | 163 | if (ip->i_di.di_size) { |
164 | *(__be64 *)(di + 1) = cpu_to_be64(block); | 164 | *(__be64 *)(di + 1) = cpu_to_be64(block); |
165 | ip->i_di.di_blocks++; | 165 | ip->i_di.di_blocks++; |
166 | gfs2_set_inode_blocks(&ip->i_inode); | ||
166 | di->di_blocks = cpu_to_be64(ip->i_di.di_blocks); | 167 | di->di_blocks = cpu_to_be64(ip->i_di.di_blocks); |
167 | } | 168 | } |
168 | 169 | ||
@@ -230,7 +231,7 @@ static int build_height(struct inode *inode, unsigned height) | |||
230 | struct buffer_head *blocks[GFS2_MAX_META_HEIGHT]; | 231 | struct buffer_head *blocks[GFS2_MAX_META_HEIGHT]; |
231 | struct gfs2_dinode *di; | 232 | struct gfs2_dinode *di; |
232 | int error; | 233 | int error; |
233 | u64 *bp; | 234 | __be64 *bp; |
234 | u64 bn; | 235 | u64 bn; |
235 | unsigned n; | 236 | unsigned n; |
236 | 237 | ||
@@ -255,7 +256,7 @@ static int build_height(struct inode *inode, unsigned height) | |||
255 | GFS2_FORMAT_IN); | 256 | GFS2_FORMAT_IN); |
256 | gfs2_buffer_clear_tail(blocks[n], | 257 | gfs2_buffer_clear_tail(blocks[n], |
257 | sizeof(struct gfs2_meta_header)); | 258 | sizeof(struct gfs2_meta_header)); |
258 | bp = (u64 *)(blocks[n]->b_data + | 259 | bp = (__be64 *)(blocks[n]->b_data + |
259 | sizeof(struct gfs2_meta_header)); | 260 | sizeof(struct gfs2_meta_header)); |
260 | *bp = cpu_to_be64(blocks[n+1]->b_blocknr); | 261 | *bp = cpu_to_be64(blocks[n+1]->b_blocknr); |
261 | brelse(blocks[n]); | 262 | brelse(blocks[n]); |
@@ -272,6 +273,7 @@ static int build_height(struct inode *inode, unsigned height) | |||
272 | *(__be64 *)(di + 1) = cpu_to_be64(bn); | 273 | *(__be64 *)(di + 1) = cpu_to_be64(bn); |
273 | ip->i_di.di_height += new_height; | 274 | ip->i_di.di_height += new_height; |
274 | ip->i_di.di_blocks += new_height; | 275 | ip->i_di.di_blocks += new_height; |
276 | gfs2_set_inode_blocks(&ip->i_inode); | ||
275 | di->di_height = cpu_to_be16(ip->i_di.di_height); | 277 | di->di_height = cpu_to_be16(ip->i_di.di_height); |
276 | di->di_blocks = cpu_to_be64(ip->i_di.di_blocks); | 278 | di->di_blocks = cpu_to_be64(ip->i_di.di_blocks); |
277 | brelse(dibh); | 279 | brelse(dibh); |
@@ -360,15 +362,15 @@ static void find_metapath(struct gfs2_inode *ip, u64 block, | |||
360 | * metadata tree. | 362 | * metadata tree. |
361 | */ | 363 | */ |
362 | 364 | ||
363 | static inline u64 *metapointer(struct buffer_head *bh, int *boundary, | 365 | static inline __be64 *metapointer(struct buffer_head *bh, int *boundary, |
364 | unsigned int height, const struct metapath *mp) | 366 | unsigned int height, const struct metapath *mp) |
365 | { | 367 | { |
366 | unsigned int head_size = (height > 0) ? | 368 | unsigned int head_size = (height > 0) ? |
367 | sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_dinode); | 369 | sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_dinode); |
368 | u64 *ptr; | 370 | __be64 *ptr; |
369 | *boundary = 0; | 371 | *boundary = 0; |
370 | ptr = ((u64 *)(bh->b_data + head_size)) + mp->mp_list[height]; | 372 | ptr = ((__be64 *)(bh->b_data + head_size)) + mp->mp_list[height]; |
371 | if (ptr + 1 == (u64 *)(bh->b_data + bh->b_size)) | 373 | if (ptr + 1 == (__be64 *)(bh->b_data + bh->b_size)) |
372 | *boundary = 1; | 374 | *boundary = 1; |
373 | return ptr; | 375 | return ptr; |
374 | } | 376 | } |
@@ -394,7 +396,7 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh, | |||
394 | int *new, u64 *block) | 396 | int *new, u64 *block) |
395 | { | 397 | { |
396 | int boundary; | 398 | int boundary; |
397 | u64 *ptr = metapointer(bh, &boundary, height, mp); | 399 | __be64 *ptr = metapointer(bh, &boundary, height, mp); |
398 | 400 | ||
399 | if (*ptr) { | 401 | if (*ptr) { |
400 | *block = be64_to_cpu(*ptr); | 402 | *block = be64_to_cpu(*ptr); |
@@ -415,17 +417,35 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh, | |||
415 | 417 | ||
416 | *ptr = cpu_to_be64(*block); | 418 | *ptr = cpu_to_be64(*block); |
417 | ip->i_di.di_blocks++; | 419 | ip->i_di.di_blocks++; |
420 | gfs2_set_inode_blocks(&ip->i_inode); | ||
418 | 421 | ||
419 | *new = 1; | 422 | *new = 1; |
420 | return 0; | 423 | return 0; |
421 | } | 424 | } |
422 | 425 | ||
426 | static inline void bmap_lock(struct inode *inode, int create) | ||
427 | { | ||
428 | struct gfs2_inode *ip = GFS2_I(inode); | ||
429 | if (create) | ||
430 | down_write(&ip->i_rw_mutex); | ||
431 | else | ||
432 | down_read(&ip->i_rw_mutex); | ||
433 | } | ||
434 | |||
435 | static inline void bmap_unlock(struct inode *inode, int create) | ||
436 | { | ||
437 | struct gfs2_inode *ip = GFS2_I(inode); | ||
438 | if (create) | ||
439 | up_write(&ip->i_rw_mutex); | ||
440 | else | ||
441 | up_read(&ip->i_rw_mutex); | ||
442 | } | ||
443 | |||
423 | /** | 444 | /** |
424 | * gfs2_block_pointers - Map a block from an inode to a disk block | 445 | * gfs2_block_map - Map a block from an inode to a disk block |
425 | * @inode: The inode | 446 | * @inode: The inode |
426 | * @lblock: The logical block number | 447 | * @lblock: The logical block number |
427 | * @map_bh: The bh to be mapped | 448 | * @bh_map: The bh to be mapped |
428 | * @mp: metapath to use | ||
429 | * | 449 | * |
430 | * Find the block number on the current device which corresponds to an | 450 | * Find the block number on the current device which corresponds to an |
431 | * inode's block. If the block had to be created, "new" will be set. | 451 | * inode's block. If the block had to be created, "new" will be set. |
@@ -433,8 +453,8 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh, | |||
433 | * Returns: errno | 453 | * Returns: errno |
434 | */ | 454 | */ |
435 | 455 | ||
436 | static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create, | 456 | int gfs2_block_map(struct inode *inode, u64 lblock, int create, |
437 | struct buffer_head *bh_map, struct metapath *mp) | 457 | struct buffer_head *bh_map) |
438 | { | 458 | { |
439 | struct gfs2_inode *ip = GFS2_I(inode); | 459 | struct gfs2_inode *ip = GFS2_I(inode); |
440 | struct gfs2_sbd *sdp = GFS2_SB(inode); | 460 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
@@ -448,57 +468,61 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create, | |||
448 | u64 dblock = 0; | 468 | u64 dblock = 0; |
449 | int boundary; | 469 | int boundary; |
450 | unsigned int maxlen = bh_map->b_size >> inode->i_blkbits; | 470 | unsigned int maxlen = bh_map->b_size >> inode->i_blkbits; |
471 | struct metapath mp; | ||
472 | u64 size; | ||
451 | 473 | ||
452 | BUG_ON(maxlen == 0); | 474 | BUG_ON(maxlen == 0); |
453 | 475 | ||
454 | if (gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip))) | 476 | if (gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip))) |
455 | return 0; | 477 | return 0; |
456 | 478 | ||
479 | bmap_lock(inode, create); | ||
480 | clear_buffer_mapped(bh_map); | ||
481 | clear_buffer_new(bh_map); | ||
482 | clear_buffer_boundary(bh_map); | ||
457 | bsize = gfs2_is_dir(ip) ? sdp->sd_jbsize : sdp->sd_sb.sb_bsize; | 483 | bsize = gfs2_is_dir(ip) ? sdp->sd_jbsize : sdp->sd_sb.sb_bsize; |
458 | 484 | size = (lblock + 1) * bsize; | |
459 | height = calc_tree_height(ip, (lblock + 1) * bsize); | 485 | |
460 | if (ip->i_di.di_height < height) { | 486 | if (size > ip->i_di.di_size) { |
461 | if (!create) | 487 | height = calc_tree_height(ip, size); |
462 | return 0; | 488 | if (ip->i_di.di_height < height) { |
463 | 489 | if (!create) | |
464 | error = build_height(inode, height); | 490 | goto out_ok; |
465 | if (error) | 491 | |
466 | return error; | 492 | error = build_height(inode, height); |
493 | if (error) | ||
494 | goto out_fail; | ||
495 | } | ||
467 | } | 496 | } |
468 | 497 | ||
469 | find_metapath(ip, lblock, mp); | 498 | find_metapath(ip, lblock, &mp); |
470 | end_of_metadata = ip->i_di.di_height - 1; | 499 | end_of_metadata = ip->i_di.di_height - 1; |
471 | |||
472 | error = gfs2_meta_inode_buffer(ip, &bh); | 500 | error = gfs2_meta_inode_buffer(ip, &bh); |
473 | if (error) | 501 | if (error) |
474 | return error; | 502 | goto out_fail; |
475 | 503 | ||
476 | for (x = 0; x < end_of_metadata; x++) { | 504 | for (x = 0; x < end_of_metadata; x++) { |
477 | lookup_block(ip, bh, x, mp, create, &new, &dblock); | 505 | lookup_block(ip, bh, x, &mp, create, &new, &dblock); |
478 | brelse(bh); | 506 | brelse(bh); |
479 | if (!dblock) | 507 | if (!dblock) |
480 | return 0; | 508 | goto out_ok; |
481 | 509 | ||
482 | error = gfs2_meta_indirect_buffer(ip, x+1, dblock, new, &bh); | 510 | error = gfs2_meta_indirect_buffer(ip, x+1, dblock, new, &bh); |
483 | if (error) | 511 | if (error) |
484 | return error; | 512 | goto out_fail; |
485 | } | 513 | } |
486 | 514 | ||
487 | boundary = lookup_block(ip, bh, end_of_metadata, mp, create, &new, &dblock); | 515 | boundary = lookup_block(ip, bh, end_of_metadata, &mp, create, &new, &dblock); |
488 | clear_buffer_mapped(bh_map); | ||
489 | clear_buffer_new(bh_map); | ||
490 | clear_buffer_boundary(bh_map); | ||
491 | |||
492 | if (dblock) { | 516 | if (dblock) { |
493 | map_bh(bh_map, inode->i_sb, dblock); | 517 | map_bh(bh_map, inode->i_sb, dblock); |
494 | if (boundary) | 518 | if (boundary) |
495 | set_buffer_boundary(bh); | 519 | set_buffer_boundary(bh_map); |
496 | if (new) { | 520 | if (new) { |
497 | struct buffer_head *dibh; | 521 | struct buffer_head *dibh; |
498 | error = gfs2_meta_inode_buffer(ip, &dibh); | 522 | error = gfs2_meta_inode_buffer(ip, &dibh); |
499 | if (!error) { | 523 | if (!error) { |
500 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | 524 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
501 | gfs2_dinode_out(&ip->i_di, dibh->b_data); | 525 | gfs2_dinode_out(ip, dibh->b_data); |
502 | brelse(dibh); | 526 | brelse(dibh); |
503 | } | 527 | } |
504 | set_buffer_new(bh_map); | 528 | set_buffer_new(bh_map); |
@@ -507,8 +531,8 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create, | |||
507 | while(--maxlen && !buffer_boundary(bh_map)) { | 531 | while(--maxlen && !buffer_boundary(bh_map)) { |
508 | u64 eblock; | 532 | u64 eblock; |
509 | 533 | ||
510 | mp->mp_list[end_of_metadata]++; | 534 | mp.mp_list[end_of_metadata]++; |
511 | boundary = lookup_block(ip, bh, end_of_metadata, mp, 0, &new, &eblock); | 535 | boundary = lookup_block(ip, bh, end_of_metadata, &mp, 0, &new, &eblock); |
512 | if (eblock != ++dblock) | 536 | if (eblock != ++dblock) |
513 | break; | 537 | break; |
514 | bh_map->b_size += (1 << inode->i_blkbits); | 538 | bh_map->b_size += (1 << inode->i_blkbits); |
@@ -518,43 +542,15 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create, | |||
518 | } | 542 | } |
519 | out_brelse: | 543 | out_brelse: |
520 | brelse(bh); | 544 | brelse(bh); |
521 | return 0; | 545 | out_ok: |
522 | } | 546 | error = 0; |
523 | 547 | out_fail: | |
524 | |||
525 | static inline void bmap_lock(struct inode *inode, int create) | ||
526 | { | ||
527 | struct gfs2_inode *ip = GFS2_I(inode); | ||
528 | if (create) | ||
529 | down_write(&ip->i_rw_mutex); | ||
530 | else | ||
531 | down_read(&ip->i_rw_mutex); | ||
532 | } | ||
533 | |||
534 | static inline void bmap_unlock(struct inode *inode, int create) | ||
535 | { | ||
536 | struct gfs2_inode *ip = GFS2_I(inode); | ||
537 | if (create) | ||
538 | up_write(&ip->i_rw_mutex); | ||
539 | else | ||
540 | up_read(&ip->i_rw_mutex); | ||
541 | } | ||
542 | |||
543 | int gfs2_block_map(struct inode *inode, u64 lblock, int create, | ||
544 | struct buffer_head *bh) | ||
545 | { | ||
546 | struct metapath mp; | ||
547 | int ret; | ||
548 | |||
549 | bmap_lock(inode, create); | ||
550 | ret = gfs2_block_pointers(inode, lblock, create, bh, &mp); | ||
551 | bmap_unlock(inode, create); | 548 | bmap_unlock(inode, create); |
552 | return ret; | 549 | return error; |
553 | } | 550 | } |
554 | 551 | ||
555 | int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen) | 552 | int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen) |
556 | { | 553 | { |
557 | struct metapath mp; | ||
558 | struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 }; | 554 | struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 }; |
559 | int ret; | 555 | int ret; |
560 | int create = *new; | 556 | int create = *new; |
@@ -564,9 +560,7 @@ int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsi | |||
564 | BUG_ON(!new); | 560 | BUG_ON(!new); |
565 | 561 | ||
566 | bh.b_size = 1 << (inode->i_blkbits + 5); | 562 | bh.b_size = 1 << (inode->i_blkbits + 5); |
567 | bmap_lock(inode, create); | 563 | ret = gfs2_block_map(inode, lblock, create, &bh); |
568 | ret = gfs2_block_pointers(inode, lblock, create, &bh, &mp); | ||
569 | bmap_unlock(inode, create); | ||
570 | *extlen = bh.b_size >> inode->i_blkbits; | 564 | *extlen = bh.b_size >> inode->i_blkbits; |
571 | *dblock = bh.b_blocknr; | 565 | *dblock = bh.b_blocknr; |
572 | if (buffer_new(&bh)) | 566 | if (buffer_new(&bh)) |
@@ -600,7 +594,7 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh, | |||
600 | { | 594 | { |
601 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 595 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
602 | struct buffer_head *bh = NULL; | 596 | struct buffer_head *bh = NULL; |
603 | u64 *top, *bottom; | 597 | __be64 *top, *bottom; |
604 | u64 bn; | 598 | u64 bn; |
605 | int error; | 599 | int error; |
606 | int mh_size = sizeof(struct gfs2_meta_header); | 600 | int mh_size = sizeof(struct gfs2_meta_header); |
@@ -611,17 +605,17 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh, | |||
611 | return error; | 605 | return error; |
612 | dibh = bh; | 606 | dibh = bh; |
613 | 607 | ||
614 | top = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0]; | 608 | top = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0]; |
615 | bottom = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs; | 609 | bottom = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs; |
616 | } else { | 610 | } else { |
617 | error = gfs2_meta_indirect_buffer(ip, height, block, 0, &bh); | 611 | error = gfs2_meta_indirect_buffer(ip, height, block, 0, &bh); |
618 | if (error) | 612 | if (error) |
619 | return error; | 613 | return error; |
620 | 614 | ||
621 | top = (u64 *)(bh->b_data + mh_size) + | 615 | top = (__be64 *)(bh->b_data + mh_size) + |
622 | (first ? mp->mp_list[height] : 0); | 616 | (first ? mp->mp_list[height] : 0); |
623 | 617 | ||
624 | bottom = (u64 *)(bh->b_data + mh_size) + sdp->sd_inptrs; | 618 | bottom = (__be64 *)(bh->b_data + mh_size) + sdp->sd_inptrs; |
625 | } | 619 | } |
626 | 620 | ||
627 | error = bc(ip, dibh, bh, top, bottom, height, data); | 621 | error = bc(ip, dibh, bh, top, bottom, height, data); |
@@ -660,7 +654,7 @@ out: | |||
660 | */ | 654 | */ |
661 | 655 | ||
662 | static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, | 656 | static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, |
663 | struct buffer_head *bh, u64 *top, u64 *bottom, | 657 | struct buffer_head *bh, __be64 *top, __be64 *bottom, |
664 | unsigned int height, void *data) | 658 | unsigned int height, void *data) |
665 | { | 659 | { |
666 | struct strip_mine *sm = data; | 660 | struct strip_mine *sm = data; |
@@ -668,7 +662,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, | |||
668 | struct gfs2_rgrp_list rlist; | 662 | struct gfs2_rgrp_list rlist; |
669 | u64 bn, bstart; | 663 | u64 bn, bstart; |
670 | u32 blen; | 664 | u32 blen; |
671 | u64 *p; | 665 | __be64 *p; |
672 | unsigned int rg_blocks = 0; | 666 | unsigned int rg_blocks = 0; |
673 | int metadata; | 667 | int metadata; |
674 | unsigned int revokes = 0; | 668 | unsigned int revokes = 0; |
@@ -770,6 +764,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, | |||
770 | if (!ip->i_di.di_blocks) | 764 | if (!ip->i_di.di_blocks) |
771 | gfs2_consist_inode(ip); | 765 | gfs2_consist_inode(ip); |
772 | ip->i_di.di_blocks--; | 766 | ip->i_di.di_blocks--; |
767 | gfs2_set_inode_blocks(&ip->i_inode); | ||
773 | } | 768 | } |
774 | if (bstart) { | 769 | if (bstart) { |
775 | if (metadata) | 770 | if (metadata) |
@@ -778,9 +773,9 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, | |||
778 | gfs2_free_data(ip, bstart, blen); | 773 | gfs2_free_data(ip, bstart, blen); |
779 | } | 774 | } |
780 | 775 | ||
781 | ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); | 776 | ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds(); |
782 | 777 | ||
783 | gfs2_dinode_out(&ip->i_di, dibh->b_data); | 778 | gfs2_dinode_out(ip, dibh->b_data); |
784 | 779 | ||
785 | up_write(&ip->i_rw_mutex); | 780 | up_write(&ip->i_rw_mutex); |
786 | 781 | ||
@@ -819,7 +814,7 @@ static int do_grow(struct gfs2_inode *ip, u64 size) | |||
819 | if (error) | 814 | if (error) |
820 | goto out; | 815 | goto out; |
821 | 816 | ||
822 | error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid); | 817 | error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid); |
823 | if (error) | 818 | if (error) |
824 | goto out_gunlock_q; | 819 | goto out_gunlock_q; |
825 | 820 | ||
@@ -853,14 +848,14 @@ static int do_grow(struct gfs2_inode *ip, u64 size) | |||
853 | } | 848 | } |
854 | 849 | ||
855 | ip->i_di.di_size = size; | 850 | ip->i_di.di_size = size; |
856 | ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); | 851 | ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds(); |
857 | 852 | ||
858 | error = gfs2_meta_inode_buffer(ip, &dibh); | 853 | error = gfs2_meta_inode_buffer(ip, &dibh); |
859 | if (error) | 854 | if (error) |
860 | goto out_end_trans; | 855 | goto out_end_trans; |
861 | 856 | ||
862 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | 857 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
863 | gfs2_dinode_out(&ip->i_di, dibh->b_data); | 858 | gfs2_dinode_out(ip, dibh->b_data); |
864 | brelse(dibh); | 859 | brelse(dibh); |
865 | 860 | ||
866 | out_end_trans: | 861 | out_end_trans: |
@@ -968,9 +963,9 @@ static int trunc_start(struct gfs2_inode *ip, u64 size) | |||
968 | 963 | ||
969 | if (gfs2_is_stuffed(ip)) { | 964 | if (gfs2_is_stuffed(ip)) { |
970 | ip->i_di.di_size = size; | 965 | ip->i_di.di_size = size; |
971 | ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); | 966 | ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds(); |
972 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | 967 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
973 | gfs2_dinode_out(&ip->i_di, dibh->b_data); | 968 | gfs2_dinode_out(ip, dibh->b_data); |
974 | gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode) + size); | 969 | gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode) + size); |
975 | error = 1; | 970 | error = 1; |
976 | 971 | ||
@@ -980,10 +975,10 @@ static int trunc_start(struct gfs2_inode *ip, u64 size) | |||
980 | 975 | ||
981 | if (!error) { | 976 | if (!error) { |
982 | ip->i_di.di_size = size; | 977 | ip->i_di.di_size = size; |
983 | ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); | 978 | ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds(); |
984 | ip->i_di.di_flags |= GFS2_DIF_TRUNC_IN_PROG; | 979 | ip->i_di.di_flags |= GFS2_DIF_TRUNC_IN_PROG; |
985 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | 980 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
986 | gfs2_dinode_out(&ip->i_di, dibh->b_data); | 981 | gfs2_dinode_out(ip, dibh->b_data); |
987 | } | 982 | } |
988 | } | 983 | } |
989 | 984 | ||
@@ -1053,11 +1048,11 @@ static int trunc_end(struct gfs2_inode *ip) | |||
1053 | ip->i_num.no_addr; | 1048 | ip->i_num.no_addr; |
1054 | gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); | 1049 | gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); |
1055 | } | 1050 | } |
1056 | ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); | 1051 | ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds(); |
1057 | ip->i_di.di_flags &= ~GFS2_DIF_TRUNC_IN_PROG; | 1052 | ip->i_di.di_flags &= ~GFS2_DIF_TRUNC_IN_PROG; |
1058 | 1053 | ||
1059 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | 1054 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
1060 | gfs2_dinode_out(&ip->i_di, dibh->b_data); | 1055 | gfs2_dinode_out(ip, dibh->b_data); |
1061 | brelse(dibh); | 1056 | brelse(dibh); |
1062 | 1057 | ||
1063 | out: | 1058 | out: |
@@ -1109,7 +1104,7 @@ int gfs2_truncatei(struct gfs2_inode *ip, u64 size) | |||
1109 | { | 1104 | { |
1110 | int error; | 1105 | int error; |
1111 | 1106 | ||
1112 | if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_di.di_mode))) | 1107 | if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_inode.i_mode))) |
1113 | return -EINVAL; | 1108 | return -EINVAL; |
1114 | 1109 | ||
1115 | if (size > ip->i_di.di_size) | 1110 | if (size > ip->i_di.di_size) |