aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_bmap.c45
-rw-r--r--fs/xfs/xfs_bmap.h1
-rw-r--r--fs/xfs/xfs_inode.c12
-rw-r--r--fs/xfs/xfs_inode.h6
4 files changed, 38 insertions, 26 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 6154ca030724..5874098ca9cf 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -592,7 +592,9 @@ xfs_bmap_add_extent(
592 if (nextents == 0) { 592 if (nextents == 0) {
593 XFS_BMAP_TRACE_INSERT("insert empty", ip, 0, 1, new, NULL, 593 XFS_BMAP_TRACE_INSERT("insert empty", ip, 0, 1, new, NULL,
594 whichfork); 594 whichfork);
595 xfs_iext_insert(ifp, 0, 1, new); 595 xfs_iext_insert(ip, 0, 1, new,
596 whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0);
597
596 ASSERT(cur == NULL); 598 ASSERT(cur == NULL);
597 ifp->if_lastex = 0; 599 ifp->if_lastex = 0;
598 if (!isnullstartblock(new->br_startblock)) { 600 if (!isnullstartblock(new->br_startblock)) {
@@ -849,7 +851,7 @@ xfs_bmap_add_extent_delay_real(
849 XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC|RC", ip, idx - 1, 851 XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC|RC", ip, idx - 1,
850 XFS_DATA_FORK); 852 XFS_DATA_FORK);
851 XFS_BMAP_TRACE_DELETE("LF|RF|LC|RC", ip, idx, 2, XFS_DATA_FORK); 853 XFS_BMAP_TRACE_DELETE("LF|RF|LC|RC", ip, idx, 2, XFS_DATA_FORK);
852 xfs_iext_remove(ifp, idx, 2); 854 xfs_iext_remove(ip, idx, 2, state);
853 ip->i_df.if_lastex = idx - 1; 855 ip->i_df.if_lastex = idx - 1;
854 ip->i_d.di_nextents--; 856 ip->i_d.di_nextents--;
855 if (cur == NULL) 857 if (cur == NULL)
@@ -895,7 +897,7 @@ xfs_bmap_add_extent_delay_real(
895 XFS_DATA_FORK); 897 XFS_DATA_FORK);
896 ip->i_df.if_lastex = idx - 1; 898 ip->i_df.if_lastex = idx - 1;
897 XFS_BMAP_TRACE_DELETE("LF|RF|LC", ip, idx, 1, XFS_DATA_FORK); 899 XFS_BMAP_TRACE_DELETE("LF|RF|LC", ip, idx, 1, XFS_DATA_FORK);
898 xfs_iext_remove(ifp, idx, 1); 900 xfs_iext_remove(ip, idx, 1, state);
899 if (cur == NULL) 901 if (cur == NULL)
900 rval = XFS_ILOG_DEXT; 902 rval = XFS_ILOG_DEXT;
901 else { 903 else {
@@ -930,7 +932,7 @@ xfs_bmap_add_extent_delay_real(
930 XFS_BMAP_TRACE_POST_UPDATE("LF|RF|RC", ip, idx, XFS_DATA_FORK); 932 XFS_BMAP_TRACE_POST_UPDATE("LF|RF|RC", ip, idx, XFS_DATA_FORK);
931 ip->i_df.if_lastex = idx; 933 ip->i_df.if_lastex = idx;
932 XFS_BMAP_TRACE_DELETE("LF|RF|RC", ip, idx + 1, 1, XFS_DATA_FORK); 934 XFS_BMAP_TRACE_DELETE("LF|RF|RC", ip, idx + 1, 1, XFS_DATA_FORK);
933 xfs_iext_remove(ifp, idx + 1, 1); 935 xfs_iext_remove(ip, idx + 1, 1, state);
934 if (cur == NULL) 936 if (cur == NULL)
935 rval = XFS_ILOG_DEXT; 937 rval = XFS_ILOG_DEXT;
936 else { 938 else {
@@ -1037,7 +1039,7 @@ xfs_bmap_add_extent_delay_real(
1037 xfs_bmbt_set_blockcount(ep, temp); 1039 xfs_bmbt_set_blockcount(ep, temp);
1038 XFS_BMAP_TRACE_INSERT("LF", ip, idx, 1, new, NULL, 1040 XFS_BMAP_TRACE_INSERT("LF", ip, idx, 1, new, NULL,
1039 XFS_DATA_FORK); 1041 XFS_DATA_FORK);
1040 xfs_iext_insert(ifp, idx, 1, new); 1042 xfs_iext_insert(ip, idx, 1, new, state);
1041 ip->i_df.if_lastex = idx; 1043 ip->i_df.if_lastex = idx;
1042 ip->i_d.di_nextents++; 1044 ip->i_d.di_nextents++;
1043 if (cur == NULL) 1045 if (cur == NULL)
@@ -1127,7 +1129,7 @@ xfs_bmap_add_extent_delay_real(
1127 xfs_bmbt_set_blockcount(ep, temp); 1129 xfs_bmbt_set_blockcount(ep, temp);
1128 XFS_BMAP_TRACE_INSERT("RF", ip, idx + 1, 1, new, NULL, 1130 XFS_BMAP_TRACE_INSERT("RF", ip, idx + 1, 1, new, NULL,
1129 XFS_DATA_FORK); 1131 XFS_DATA_FORK);
1130 xfs_iext_insert(ifp, idx + 1, 1, new); 1132 xfs_iext_insert(ip, idx + 1, 1, new, state);
1131 ip->i_df.if_lastex = idx + 1; 1133 ip->i_df.if_lastex = idx + 1;
1132 ip->i_d.di_nextents++; 1134 ip->i_d.di_nextents++;
1133 if (cur == NULL) 1135 if (cur == NULL)
@@ -1182,7 +1184,7 @@ xfs_bmap_add_extent_delay_real(
1182 r[1].br_blockcount = temp2; 1184 r[1].br_blockcount = temp2;
1183 XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 2, &r[0], &r[1], 1185 XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 2, &r[0], &r[1],
1184 XFS_DATA_FORK); 1186 XFS_DATA_FORK);
1185 xfs_iext_insert(ifp, idx + 1, 2, &r[0]); 1187 xfs_iext_insert(ip, idx + 1, 2, &r[0], state);
1186 ip->i_df.if_lastex = idx + 1; 1188 ip->i_df.if_lastex = idx + 1;
1187 ip->i_d.di_nextents++; 1189 ip->i_d.di_nextents++;
1188 if (cur == NULL) 1190 if (cur == NULL)
@@ -1397,7 +1399,7 @@ xfs_bmap_add_extent_unwritten_real(
1397 XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC|RC", ip, idx - 1, 1399 XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC|RC", ip, idx - 1,
1398 XFS_DATA_FORK); 1400 XFS_DATA_FORK);
1399 XFS_BMAP_TRACE_DELETE("LF|RF|LC|RC", ip, idx, 2, XFS_DATA_FORK); 1401 XFS_BMAP_TRACE_DELETE("LF|RF|LC|RC", ip, idx, 2, XFS_DATA_FORK);
1400 xfs_iext_remove(ifp, idx, 2); 1402 xfs_iext_remove(ip, idx, 2, state);
1401 ip->i_df.if_lastex = idx - 1; 1403 ip->i_df.if_lastex = idx - 1;
1402 ip->i_d.di_nextents -= 2; 1404 ip->i_d.di_nextents -= 2;
1403 if (cur == NULL) 1405 if (cur == NULL)
@@ -1447,7 +1449,7 @@ xfs_bmap_add_extent_unwritten_real(
1447 XFS_DATA_FORK); 1449 XFS_DATA_FORK);
1448 ip->i_df.if_lastex = idx - 1; 1450 ip->i_df.if_lastex = idx - 1;
1449 XFS_BMAP_TRACE_DELETE("LF|RF|LC", ip, idx, 1, XFS_DATA_FORK); 1451 XFS_BMAP_TRACE_DELETE("LF|RF|LC", ip, idx, 1, XFS_DATA_FORK);
1450 xfs_iext_remove(ifp, idx, 1); 1452 xfs_iext_remove(ip, idx, 1, state);
1451 ip->i_d.di_nextents--; 1453 ip->i_d.di_nextents--;
1452 if (cur == NULL) 1454 if (cur == NULL)
1453 rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; 1455 rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
@@ -1490,7 +1492,7 @@ xfs_bmap_add_extent_unwritten_real(
1490 XFS_DATA_FORK); 1492 XFS_DATA_FORK);
1491 ip->i_df.if_lastex = idx; 1493 ip->i_df.if_lastex = idx;
1492 XFS_BMAP_TRACE_DELETE("LF|RF|RC", ip, idx + 1, 1, XFS_DATA_FORK); 1494 XFS_BMAP_TRACE_DELETE("LF|RF|RC", ip, idx + 1, 1, XFS_DATA_FORK);
1493 xfs_iext_remove(ifp, idx + 1, 1); 1495 xfs_iext_remove(ip, idx + 1, 1, state);
1494 ip->i_d.di_nextents--; 1496 ip->i_d.di_nextents--;
1495 if (cur == NULL) 1497 if (cur == NULL)
1496 rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; 1498 rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
@@ -1616,7 +1618,7 @@ xfs_bmap_add_extent_unwritten_real(
1616 XFS_BMAP_TRACE_POST_UPDATE("LF", ip, idx, XFS_DATA_FORK); 1618 XFS_BMAP_TRACE_POST_UPDATE("LF", ip, idx, XFS_DATA_FORK);
1617 XFS_BMAP_TRACE_INSERT("LF", ip, idx, 1, new, NULL, 1619 XFS_BMAP_TRACE_INSERT("LF", ip, idx, 1, new, NULL,
1618 XFS_DATA_FORK); 1620 XFS_DATA_FORK);
1619 xfs_iext_insert(ifp, idx, 1, new); 1621 xfs_iext_insert(ip, idx, 1, new, state);
1620 ip->i_df.if_lastex = idx; 1622 ip->i_df.if_lastex = idx;
1621 ip->i_d.di_nextents++; 1623 ip->i_d.di_nextents++;
1622 if (cur == NULL) 1624 if (cur == NULL)
@@ -1702,7 +1704,7 @@ xfs_bmap_add_extent_unwritten_real(
1702 XFS_BMAP_TRACE_POST_UPDATE("RF", ip, idx, XFS_DATA_FORK); 1704 XFS_BMAP_TRACE_POST_UPDATE("RF", ip, idx, XFS_DATA_FORK);
1703 XFS_BMAP_TRACE_INSERT("RF", ip, idx + 1, 1, new, NULL, 1705 XFS_BMAP_TRACE_INSERT("RF", ip, idx + 1, 1, new, NULL,
1704 XFS_DATA_FORK); 1706 XFS_DATA_FORK);
1705 xfs_iext_insert(ifp, idx + 1, 1, new); 1707 xfs_iext_insert(ip, idx + 1, 1, new, state);
1706 ip->i_df.if_lastex = idx + 1; 1708 ip->i_df.if_lastex = idx + 1;
1707 ip->i_d.di_nextents++; 1709 ip->i_d.di_nextents++;
1708 if (cur == NULL) 1710 if (cur == NULL)
@@ -1752,7 +1754,7 @@ xfs_bmap_add_extent_unwritten_real(
1752 r[1].br_state = oldext; 1754 r[1].br_state = oldext;
1753 XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 2, &r[0], &r[1], 1755 XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 2, &r[0], &r[1],
1754 XFS_DATA_FORK); 1756 XFS_DATA_FORK);
1755 xfs_iext_insert(ifp, idx + 1, 2, &r[0]); 1757 xfs_iext_insert(ip, idx + 1, 2, &r[0], state);
1756 ip->i_df.if_lastex = idx + 1; 1758 ip->i_df.if_lastex = idx + 1;
1757 ip->i_d.di_nextents += 2; 1759 ip->i_d.di_nextents += 2;
1758 if (cur == NULL) 1760 if (cur == NULL)
@@ -1918,7 +1920,7 @@ xfs_bmap_add_extent_hole_delay(
1918 XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1, 1920 XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1,
1919 XFS_DATA_FORK); 1921 XFS_DATA_FORK);
1920 XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, XFS_DATA_FORK); 1922 XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, XFS_DATA_FORK);
1921 xfs_iext_remove(ifp, idx, 1); 1923 xfs_iext_remove(ip, idx, 1, state);
1922 ip->i_df.if_lastex = idx - 1; 1924 ip->i_df.if_lastex = idx - 1;
1923 /* DELTA: Two in-core extents were replaced by one. */ 1925 /* DELTA: Two in-core extents were replaced by one. */
1924 temp2 = temp; 1926 temp2 = temp;
@@ -1977,7 +1979,7 @@ xfs_bmap_add_extent_hole_delay(
1977 oldlen = newlen = 0; 1979 oldlen = newlen = 0;
1978 XFS_BMAP_TRACE_INSERT("0", ip, idx, 1, new, NULL, 1980 XFS_BMAP_TRACE_INSERT("0", ip, idx, 1, new, NULL,
1979 XFS_DATA_FORK); 1981 XFS_DATA_FORK);
1980 xfs_iext_insert(ifp, idx, 1, new); 1982 xfs_iext_insert(ip, idx, 1, new, state);
1981 ip->i_df.if_lastex = idx; 1983 ip->i_df.if_lastex = idx;
1982 /* DELTA: A new in-core extent was added in a hole. */ 1984 /* DELTA: A new in-core extent was added in a hole. */
1983 temp2 = new->br_blockcount; 1985 temp2 = new->br_blockcount;
@@ -2033,6 +2035,9 @@ xfs_bmap_add_extent_hole_real(
2033 ep = xfs_iext_get_ext(ifp, idx); 2035 ep = xfs_iext_get_ext(ifp, idx);
2034 state = 0; 2036 state = 0;
2035 2037
2038 if (whichfork == XFS_ATTR_FORK)
2039 state |= BMAP_ATTRFORK;
2040
2036 /* 2041 /*
2037 * Check and set flags if this segment has a left neighbor. 2042 * Check and set flags if this segment has a left neighbor.
2038 */ 2043 */
@@ -2094,7 +2099,7 @@ xfs_bmap_add_extent_hole_real(
2094 XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1, 2099 XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1,
2095 whichfork); 2100 whichfork);
2096 XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, whichfork); 2101 XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, whichfork);
2097 xfs_iext_remove(ifp, idx, 1); 2102 xfs_iext_remove(ip, idx, 1, state);
2098 ifp->if_lastex = idx - 1; 2103 ifp->if_lastex = idx - 1;
2099 XFS_IFORK_NEXT_SET(ip, whichfork, 2104 XFS_IFORK_NEXT_SET(ip, whichfork,
2100 XFS_IFORK_NEXTENTS(ip, whichfork) - 1); 2105 XFS_IFORK_NEXTENTS(ip, whichfork) - 1);
@@ -2205,7 +2210,7 @@ xfs_bmap_add_extent_hole_real(
2205 * Insert a new entry. 2210 * Insert a new entry.
2206 */ 2211 */
2207 XFS_BMAP_TRACE_INSERT("0", ip, idx, 1, new, NULL, whichfork); 2212 XFS_BMAP_TRACE_INSERT("0", ip, idx, 1, new, NULL, whichfork);
2208 xfs_iext_insert(ifp, idx, 1, new); 2213 xfs_iext_insert(ip, idx, 1, new, state);
2209 ifp->if_lastex = idx; 2214 ifp->if_lastex = idx;
2210 XFS_IFORK_NEXT_SET(ip, whichfork, 2215 XFS_IFORK_NEXT_SET(ip, whichfork,
2211 XFS_IFORK_NEXTENTS(ip, whichfork) + 1); 2216 XFS_IFORK_NEXTENTS(ip, whichfork) + 1);
@@ -3147,7 +3152,8 @@ xfs_bmap_del_extent(
3147 * Matches the whole extent. Delete the entry. 3152 * Matches the whole extent. Delete the entry.
3148 */ 3153 */
3149 XFS_BMAP_TRACE_DELETE("3", ip, idx, 1, whichfork); 3154 XFS_BMAP_TRACE_DELETE("3", ip, idx, 1, whichfork);
3150 xfs_iext_remove(ifp, idx, 1); 3155 xfs_iext_remove(ip, idx, 1,
3156 whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0);
3151 ifp->if_lastex = idx; 3157 ifp->if_lastex = idx;
3152 if (delay) 3158 if (delay)
3153 break; 3159 break;
@@ -3317,7 +3323,8 @@ xfs_bmap_del_extent(
3317 XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, whichfork); 3323 XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, whichfork);
3318 XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 1, &new, NULL, 3324 XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 1, &new, NULL,
3319 whichfork); 3325 whichfork);
3320 xfs_iext_insert(ifp, idx + 1, 1, &new); 3326 xfs_iext_insert(ip, idx + 1, 1, &new,
3327 whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0);
3321 ifp->if_lastex = idx + 1; 3328 ifp->if_lastex = idx + 1;
3322 break; 3329 break;
3323 } 3330 }
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index f1ae5a1519c3..3e84e8e8d79e 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -146,6 +146,7 @@ typedef struct xfs_bmalloca {
146#define BMAP_RIGHT_DELAY (1 << 5) 146#define BMAP_RIGHT_DELAY (1 << 5)
147#define BMAP_LEFT_VALID (1 << 6) 147#define BMAP_LEFT_VALID (1 << 6)
148#define BMAP_RIGHT_VALID (1 << 7) 148#define BMAP_RIGHT_VALID (1 << 7)
149#define BMAP_ATTRFORK (1 << 8)
149 150
150#if defined(__KERNEL__) && defined(XFS_BMAP_TRACE) 151#if defined(__KERNEL__) && defined(XFS_BMAP_TRACE)
151/* 152/*
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index b92a4fa2a0a1..614acd508b35 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3300,11 +3300,13 @@ xfs_iext_get_ext(
3300 */ 3300 */
3301void 3301void
3302xfs_iext_insert( 3302xfs_iext_insert(
3303 xfs_ifork_t *ifp, /* inode fork pointer */ 3303 xfs_inode_t *ip, /* incore inode pointer */
3304 xfs_extnum_t idx, /* starting index of new items */ 3304 xfs_extnum_t idx, /* starting index of new items */
3305 xfs_extnum_t count, /* number of inserted items */ 3305 xfs_extnum_t count, /* number of inserted items */
3306 xfs_bmbt_irec_t *new) /* items to insert */ 3306 xfs_bmbt_irec_t *new, /* items to insert */
3307 int state) /* type of extent conversion */
3307{ 3308{
3309 xfs_ifork_t *ifp = (state & BMAP_ATTRFORK) ? ip->i_afp : &ip->i_df;
3308 xfs_extnum_t i; /* extent record index */ 3310 xfs_extnum_t i; /* extent record index */
3309 3311
3310 ASSERT(ifp->if_flags & XFS_IFEXTENTS); 3312 ASSERT(ifp->if_flags & XFS_IFEXTENTS);
@@ -3549,10 +3551,12 @@ xfs_iext_add_indirect_multi(
3549 */ 3551 */
3550void 3552void
3551xfs_iext_remove( 3553xfs_iext_remove(
3552 xfs_ifork_t *ifp, /* inode fork pointer */ 3554 xfs_inode_t *ip, /* incore inode pointer */
3553 xfs_extnum_t idx, /* index to begin removing exts */ 3555 xfs_extnum_t idx, /* index to begin removing exts */
3554 int ext_diff) /* number of extents to remove */ 3556 int ext_diff, /* number of extents to remove */
3557 int state) /* type of extent conversion */
3555{ 3558{
3559 xfs_ifork_t *ifp = (state & BMAP_ATTRFORK) ? ip->i_afp : &ip->i_df;
3556 xfs_extnum_t nextents; /* number of extents in file */ 3560 xfs_extnum_t nextents; /* number of extents in file */
3557 int new_size; /* size of extents after removal */ 3561 int new_size; /* size of extents after removal */
3558 3562
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 41555de1d1db..946a8ca5d9c5 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -577,11 +577,11 @@ int xfs_iread_extents(struct xfs_trans *, struct xfs_inode *, int);
577int xfs_iextents_copy(struct xfs_inode *, xfs_bmbt_rec_t *, int); 577int xfs_iextents_copy(struct xfs_inode *, xfs_bmbt_rec_t *, int);
578 578
579xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t); 579xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t);
580void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t, 580void xfs_iext_insert(xfs_inode_t *, xfs_extnum_t, xfs_extnum_t,
581 xfs_bmbt_irec_t *); 581 xfs_bmbt_irec_t *, int);
582void xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int); 582void xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int);
583void xfs_iext_add_indirect_multi(xfs_ifork_t *, int, xfs_extnum_t, int); 583void xfs_iext_add_indirect_multi(xfs_ifork_t *, int, xfs_extnum_t, int);
584void xfs_iext_remove(xfs_ifork_t *, xfs_extnum_t, int); 584void xfs_iext_remove(xfs_inode_t *, xfs_extnum_t, int, int);
585void xfs_iext_remove_inline(xfs_ifork_t *, xfs_extnum_t, int); 585void xfs_iext_remove_inline(xfs_ifork_t *, xfs_extnum_t, int);
586void xfs_iext_remove_direct(xfs_ifork_t *, xfs_extnum_t, int); 586void xfs_iext_remove_direct(xfs_ifork_t *, xfs_extnum_t, int);
587void xfs_iext_remove_indirect(xfs_ifork_t *, xfs_extnum_t, int); 587void xfs_iext_remove_indirect(xfs_ifork_t *, xfs_extnum_t, int);