diff options
-rw-r--r-- | fs/xfs/xfs_bmap.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 3e9c278a8f78..dc3afd7739ff 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -1038,17 +1038,34 @@ xfs_bmap_add_extent_delay_real( | |||
1038 | * Filling in the middle part of a previous delayed allocation. | 1038 | * Filling in the middle part of a previous delayed allocation. |
1039 | * Contiguity is impossible here. | 1039 | * Contiguity is impossible here. |
1040 | * This case is avoided almost all the time. | 1040 | * This case is avoided almost all the time. |
1041 | * | ||
1042 | * We start with a delayed allocation: | ||
1043 | * | ||
1044 | * +ddddddddddddddddddddddddddddddddddddddddddddddddddddddd+ | ||
1045 | * PREV @ idx | ||
1046 | * | ||
1047 | * and we are allocating: | ||
1048 | * +rrrrrrrrrrrrrrrrr+ | ||
1049 | * new | ||
1050 | * | ||
1051 | * and we set it up for insertion as: | ||
1052 | * +ddddddddddddddddddd+rrrrrrrrrrrrrrrrr+ddddddddddddddddd+ | ||
1053 | * new | ||
1054 | * PREV @ idx LEFT RIGHT | ||
1055 | * inserted at idx + 1 | ||
1041 | */ | 1056 | */ |
1042 | temp = new->br_startoff - PREV.br_startoff; | 1057 | temp = new->br_startoff - PREV.br_startoff; |
1043 | trace_xfs_bmap_pre_update(ip, idx, 0, _THIS_IP_); | ||
1044 | xfs_bmbt_set_blockcount(ep, temp); | ||
1045 | r[0] = *new; | ||
1046 | r[1].br_state = PREV.br_state; | ||
1047 | r[1].br_startblock = 0; | ||
1048 | r[1].br_startoff = new_endoff; | ||
1049 | temp2 = PREV.br_startoff + PREV.br_blockcount - new_endoff; | 1058 | temp2 = PREV.br_startoff + PREV.br_blockcount - new_endoff; |
1050 | r[1].br_blockcount = temp2; | 1059 | trace_xfs_bmap_pre_update(ip, idx, 0, _THIS_IP_); |
1051 | xfs_iext_insert(ip, idx + 1, 2, &r[0], state); | 1060 | xfs_bmbt_set_blockcount(ep, temp); /* truncate PREV */ |
1061 | LEFT = *new; | ||
1062 | RIGHT.br_state = PREV.br_state; | ||
1063 | RIGHT.br_startblock = nullstartblock( | ||
1064 | (int)xfs_bmap_worst_indlen(ip, temp2)); | ||
1065 | RIGHT.br_startoff = new_endoff; | ||
1066 | RIGHT.br_blockcount = temp2; | ||
1067 | /* insert LEFT (r[0]) and RIGHT (r[1]) at the same time */ | ||
1068 | xfs_iext_insert(ip, idx + 1, 2, &LEFT, state); | ||
1052 | ip->i_df.if_lastex = idx + 1; | 1069 | ip->i_df.if_lastex = idx + 1; |
1053 | ip->i_d.di_nextents++; | 1070 | ip->i_d.di_nextents++; |
1054 | if (cur == NULL) | 1071 | if (cur == NULL) |