diff options
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index e546a33214c..452a291383a 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -29,15 +29,11 @@ | |||
29 | #include "xfs_bmap_btree.h" | 29 | #include "xfs_bmap_btree.h" |
30 | #include "xfs_alloc_btree.h" | 30 | #include "xfs_alloc_btree.h" |
31 | #include "xfs_ialloc_btree.h" | 31 | #include "xfs_ialloc_btree.h" |
32 | #include "xfs_dir2_sf.h" | ||
33 | #include "xfs_dinode.h" | 32 | #include "xfs_dinode.h" |
34 | #include "xfs_inode.h" | 33 | #include "xfs_inode.h" |
35 | #include "xfs_btree.h" | 34 | #include "xfs_btree.h" |
36 | #include "xfs_mount.h" | 35 | #include "xfs_mount.h" |
37 | #include "xfs_itable.h" | 36 | #include "xfs_itable.h" |
38 | #include "xfs_dir2_data.h" | ||
39 | #include "xfs_dir2_leaf.h" | ||
40 | #include "xfs_dir2_block.h" | ||
41 | #include "xfs_inode_item.h" | 37 | #include "xfs_inode_item.h" |
42 | #include "xfs_extfree_item.h" | 38 | #include "xfs_extfree_item.h" |
43 | #include "xfs_alloc.h" | 39 | #include "xfs_alloc.h" |
@@ -94,6 +90,7 @@ xfs_bmap_add_attrfork_local( | |||
94 | */ | 90 | */ |
95 | STATIC int /* error */ | 91 | STATIC int /* error */ |
96 | xfs_bmap_add_extent_delay_real( | 92 | xfs_bmap_add_extent_delay_real( |
93 | struct xfs_trans *tp, /* transaction pointer */ | ||
97 | xfs_inode_t *ip, /* incore inode pointer */ | 94 | xfs_inode_t *ip, /* incore inode pointer */ |
98 | xfs_extnum_t *idx, /* extent number to update/insert */ | 95 | xfs_extnum_t *idx, /* extent number to update/insert */ |
99 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ | 96 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ |
@@ -417,7 +414,7 @@ xfs_bmap_add_attrfork_local( | |||
417 | 414 | ||
418 | if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip)) | 415 | if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip)) |
419 | return 0; | 416 | return 0; |
420 | if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) { | 417 | if (S_ISDIR(ip->i_d.di_mode)) { |
421 | mp = ip->i_mount; | 418 | mp = ip->i_mount; |
422 | memset(&dargs, 0, sizeof(dargs)); | 419 | memset(&dargs, 0, sizeof(dargs)); |
423 | dargs.dp = ip; | 420 | dargs.dp = ip; |
@@ -439,6 +436,7 @@ xfs_bmap_add_attrfork_local( | |||
439 | */ | 436 | */ |
440 | STATIC int /* error */ | 437 | STATIC int /* error */ |
441 | xfs_bmap_add_extent( | 438 | xfs_bmap_add_extent( |
439 | struct xfs_trans *tp, /* transaction pointer */ | ||
442 | xfs_inode_t *ip, /* incore inode pointer */ | 440 | xfs_inode_t *ip, /* incore inode pointer */ |
443 | xfs_extnum_t *idx, /* extent number to update/insert */ | 441 | xfs_extnum_t *idx, /* extent number to update/insert */ |
444 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ | 442 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ |
@@ -524,7 +522,7 @@ xfs_bmap_add_extent( | |||
524 | if (cur) | 522 | if (cur) |
525 | ASSERT(cur->bc_private.b.flags & | 523 | ASSERT(cur->bc_private.b.flags & |
526 | XFS_BTCUR_BPRV_WASDEL); | 524 | XFS_BTCUR_BPRV_WASDEL); |
527 | error = xfs_bmap_add_extent_delay_real(ip, | 525 | error = xfs_bmap_add_extent_delay_real(tp, ip, |
528 | idx, &cur, new, &da_new, | 526 | idx, &cur, new, &da_new, |
529 | first, flist, &logflags); | 527 | first, flist, &logflags); |
530 | } else { | 528 | } else { |
@@ -561,7 +559,7 @@ xfs_bmap_add_extent( | |||
561 | int tmp_logflags; /* partial log flag return val */ | 559 | int tmp_logflags; /* partial log flag return val */ |
562 | 560 | ||
563 | ASSERT(cur == NULL); | 561 | ASSERT(cur == NULL); |
564 | error = xfs_bmap_extents_to_btree(ip->i_transp, ip, first, | 562 | error = xfs_bmap_extents_to_btree(tp, ip, first, |
565 | flist, &cur, da_old > 0, &tmp_logflags, whichfork); | 563 | flist, &cur, da_old > 0, &tmp_logflags, whichfork); |
566 | logflags |= tmp_logflags; | 564 | logflags |= tmp_logflags; |
567 | if (error) | 565 | if (error) |
@@ -604,6 +602,7 @@ done: | |||
604 | */ | 602 | */ |
605 | STATIC int /* error */ | 603 | STATIC int /* error */ |
606 | xfs_bmap_add_extent_delay_real( | 604 | xfs_bmap_add_extent_delay_real( |
605 | struct xfs_trans *tp, /* transaction pointer */ | ||
607 | xfs_inode_t *ip, /* incore inode pointer */ | 606 | xfs_inode_t *ip, /* incore inode pointer */ |
608 | xfs_extnum_t *idx, /* extent number to update/insert */ | 607 | xfs_extnum_t *idx, /* extent number to update/insert */ |
609 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ | 608 | xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ |
@@ -901,7 +900,7 @@ xfs_bmap_add_extent_delay_real( | |||
901 | } | 900 | } |
902 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && | 901 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && |
903 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { | 902 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { |
904 | error = xfs_bmap_extents_to_btree(ip->i_transp, ip, | 903 | error = xfs_bmap_extents_to_btree(tp, ip, |
905 | first, flist, &cur, 1, &tmp_rval, | 904 | first, flist, &cur, 1, &tmp_rval, |
906 | XFS_DATA_FORK); | 905 | XFS_DATA_FORK); |
907 | rval |= tmp_rval; | 906 | rval |= tmp_rval; |
@@ -984,7 +983,7 @@ xfs_bmap_add_extent_delay_real( | |||
984 | } | 983 | } |
985 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && | 984 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && |
986 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { | 985 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { |
987 | error = xfs_bmap_extents_to_btree(ip->i_transp, ip, | 986 | error = xfs_bmap_extents_to_btree(tp, ip, |
988 | first, flist, &cur, 1, &tmp_rval, | 987 | first, flist, &cur, 1, &tmp_rval, |
989 | XFS_DATA_FORK); | 988 | XFS_DATA_FORK); |
990 | rval |= tmp_rval; | 989 | rval |= tmp_rval; |
@@ -1052,7 +1051,7 @@ xfs_bmap_add_extent_delay_real( | |||
1052 | } | 1051 | } |
1053 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && | 1052 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && |
1054 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { | 1053 | ip->i_d.di_nextents > ip->i_df.if_ext_max) { |
1055 | error = xfs_bmap_extents_to_btree(ip->i_transp, ip, | 1054 | error = xfs_bmap_extents_to_btree(tp, ip, |
1056 | first, flist, &cur, 1, &tmp_rval, | 1055 | first, flist, &cur, 1, &tmp_rval, |
1057 | XFS_DATA_FORK); | 1056 | XFS_DATA_FORK); |
1058 | rval |= tmp_rval; | 1057 | rval |= tmp_rval; |
@@ -2871,8 +2870,8 @@ xfs_bmap_del_extent( | |||
2871 | len = del->br_blockcount; | 2870 | len = del->br_blockcount; |
2872 | do_div(bno, mp->m_sb.sb_rextsize); | 2871 | do_div(bno, mp->m_sb.sb_rextsize); |
2873 | do_div(len, mp->m_sb.sb_rextsize); | 2872 | do_div(len, mp->m_sb.sb_rextsize); |
2874 | if ((error = xfs_rtfree_extent(ip->i_transp, bno, | 2873 | error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len); |
2875 | (xfs_extlen_t)len))) | 2874 | if (error) |
2876 | goto done; | 2875 | goto done; |
2877 | do_fx = 0; | 2876 | do_fx = 0; |
2878 | nblks = len * mp->m_sb.sb_rextsize; | 2877 | nblks = len * mp->m_sb.sb_rextsize; |
@@ -3345,8 +3344,7 @@ xfs_bmap_local_to_extents( | |||
3345 | * We don't want to deal with the case of keeping inode data inline yet. | 3344 | * We don't want to deal with the case of keeping inode data inline yet. |
3346 | * So sending the data fork of a regular inode is invalid. | 3345 | * So sending the data fork of a regular inode is invalid. |
3347 | */ | 3346 | */ |
3348 | ASSERT(!((ip->i_d.di_mode & S_IFMT) == S_IFREG && | 3347 | ASSERT(!(S_ISREG(ip->i_d.di_mode) && whichfork == XFS_DATA_FORK)); |
3349 | whichfork == XFS_DATA_FORK)); | ||
3350 | ifp = XFS_IFORK_PTR(ip, whichfork); | 3348 | ifp = XFS_IFORK_PTR(ip, whichfork); |
3351 | ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL); | 3349 | ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL); |
3352 | flags = 0; | 3350 | flags = 0; |
@@ -3385,8 +3383,7 @@ xfs_bmap_local_to_extents( | |||
3385 | ASSERT(args.len == 1); | 3383 | ASSERT(args.len == 1); |
3386 | *firstblock = args.fsbno; | 3384 | *firstblock = args.fsbno; |
3387 | bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); | 3385 | bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); |
3388 | memcpy((char *)XFS_BUF_PTR(bp), ifp->if_u1.if_data, | 3386 | memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes); |
3389 | ifp->if_bytes); | ||
3390 | xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); | 3387 | xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); |
3391 | xfs_bmap_forkoff_reset(args.mp, ip, whichfork); | 3388 | xfs_bmap_forkoff_reset(args.mp, ip, whichfork); |
3392 | xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); | 3389 | xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); |
@@ -4053,7 +4050,7 @@ xfs_bmap_one_block( | |||
4053 | 4050 | ||
4054 | #ifndef DEBUG | 4051 | #ifndef DEBUG |
4055 | if (whichfork == XFS_DATA_FORK) { | 4052 | if (whichfork == XFS_DATA_FORK) { |
4056 | return ((ip->i_d.di_mode & S_IFMT) == S_IFREG) ? | 4053 | return S_ISREG(ip->i_d.di_mode) ? |
4057 | (ip->i_size == ip->i_mount->m_sb.sb_blocksize) : | 4054 | (ip->i_size == ip->i_mount->m_sb.sb_blocksize) : |
4058 | (ip->i_d.di_size == ip->i_mount->m_sb.sb_blocksize); | 4055 | (ip->i_d.di_size == ip->i_mount->m_sb.sb_blocksize); |
4059 | } | 4056 | } |
@@ -4080,7 +4077,7 @@ xfs_bmap_sanity_check( | |||
4080 | { | 4077 | { |
4081 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); | 4078 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); |
4082 | 4079 | ||
4083 | if (be32_to_cpu(block->bb_magic) != XFS_BMAP_MAGIC || | 4080 | if (block->bb_magic != cpu_to_be32(XFS_BMAP_MAGIC) || |
4084 | be16_to_cpu(block->bb_level) != level || | 4081 | be16_to_cpu(block->bb_level) != level || |
4085 | be16_to_cpu(block->bb_numrecs) == 0 || | 4082 | be16_to_cpu(block->bb_numrecs) == 0 || |
4086 | be16_to_cpu(block->bb_numrecs) > mp->m_bmap_dmxr[level != 0]) | 4083 | be16_to_cpu(block->bb_numrecs) > mp->m_bmap_dmxr[level != 0]) |
@@ -4662,7 +4659,7 @@ xfs_bmapi( | |||
4662 | if (!wasdelay && (flags & XFS_BMAPI_PREALLOC)) | 4659 | if (!wasdelay && (flags & XFS_BMAPI_PREALLOC)) |
4663 | got.br_state = XFS_EXT_UNWRITTEN; | 4660 | got.br_state = XFS_EXT_UNWRITTEN; |
4664 | } | 4661 | } |
4665 | error = xfs_bmap_add_extent(ip, &lastx, &cur, &got, | 4662 | error = xfs_bmap_add_extent(tp, ip, &lastx, &cur, &got, |
4666 | firstblock, flist, &tmp_logflags, | 4663 | firstblock, flist, &tmp_logflags, |
4667 | whichfork); | 4664 | whichfork); |
4668 | logflags |= tmp_logflags; | 4665 | logflags |= tmp_logflags; |
@@ -4763,7 +4760,7 @@ xfs_bmapi( | |||
4763 | mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN) | 4760 | mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN) |
4764 | ? XFS_EXT_NORM | 4761 | ? XFS_EXT_NORM |
4765 | : XFS_EXT_UNWRITTEN; | 4762 | : XFS_EXT_UNWRITTEN; |
4766 | error = xfs_bmap_add_extent(ip, &lastx, &cur, mval, | 4763 | error = xfs_bmap_add_extent(tp, ip, &lastx, &cur, mval, |
4767 | firstblock, flist, &tmp_logflags, | 4764 | firstblock, flist, &tmp_logflags, |
4768 | whichfork); | 4765 | whichfork); |
4769 | logflags |= tmp_logflags; | 4766 | logflags |= tmp_logflags; |
@@ -5117,7 +5114,7 @@ xfs_bunmapi( | |||
5117 | del.br_blockcount = mod; | 5114 | del.br_blockcount = mod; |
5118 | } | 5115 | } |
5119 | del.br_state = XFS_EXT_UNWRITTEN; | 5116 | del.br_state = XFS_EXT_UNWRITTEN; |
5120 | error = xfs_bmap_add_extent(ip, &lastx, &cur, &del, | 5117 | error = xfs_bmap_add_extent(tp, ip, &lastx, &cur, &del, |
5121 | firstblock, flist, &logflags, | 5118 | firstblock, flist, &logflags, |
5122 | XFS_DATA_FORK); | 5119 | XFS_DATA_FORK); |
5123 | if (error) | 5120 | if (error) |
@@ -5175,18 +5172,18 @@ xfs_bunmapi( | |||
5175 | } | 5172 | } |
5176 | prev.br_state = XFS_EXT_UNWRITTEN; | 5173 | prev.br_state = XFS_EXT_UNWRITTEN; |
5177 | lastx--; | 5174 | lastx--; |
5178 | error = xfs_bmap_add_extent(ip, &lastx, &cur, | 5175 | error = xfs_bmap_add_extent(tp, ip, &lastx, |
5179 | &prev, firstblock, flist, &logflags, | 5176 | &cur, &prev, firstblock, flist, |
5180 | XFS_DATA_FORK); | 5177 | &logflags, XFS_DATA_FORK); |
5181 | if (error) | 5178 | if (error) |
5182 | goto error0; | 5179 | goto error0; |
5183 | goto nodelete; | 5180 | goto nodelete; |
5184 | } else { | 5181 | } else { |
5185 | ASSERT(del.br_state == XFS_EXT_NORM); | 5182 | ASSERT(del.br_state == XFS_EXT_NORM); |
5186 | del.br_state = XFS_EXT_UNWRITTEN; | 5183 | del.br_state = XFS_EXT_UNWRITTEN; |
5187 | error = xfs_bmap_add_extent(ip, &lastx, &cur, | 5184 | error = xfs_bmap_add_extent(tp, ip, &lastx, |
5188 | &del, firstblock, flist, &logflags, | 5185 | &cur, &del, firstblock, flist, |
5189 | XFS_DATA_FORK); | 5186 | &logflags, XFS_DATA_FORK); |
5190 | if (error) | 5187 | if (error) |
5191 | goto error0; | 5188 | goto error0; |
5192 | goto nodelete; | 5189 | goto nodelete; |