diff options
| author | Christoph Hellwig <hch@lst.de> | 2017-02-17 11:21:06 -0500 |
|---|---|---|
| committer | Darrick J. Wong <darrick.wong@oracle.com> | 2017-02-17 19:52:52 -0500 |
| commit | 089ec2f87578b9740f0c27bcea9cc6be59c1ddb0 (patch) | |
| tree | 44247daa7fa4c79330e65ca7281e487f4dbda0bf /fs/xfs/xfs_rtalloc.c | |
| parent | 410d17f67e583559be3a922f8b6cc336331893f3 (diff) | |
xfs: simplify xfs_rtallocate_extent
We can deduce the allocation type from the bno argument, and do the
return without prod much simpler internally.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: fix the macro for the non-rt build]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/xfs_rtalloc.c')
| -rw-r--r-- | fs/xfs/xfs_rtalloc.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 802bcc326d9f..c57aa7f18087 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
| @@ -1093,7 +1093,6 @@ xfs_rtallocate_extent( | |||
| 1093 | xfs_extlen_t minlen, /* minimum length to allocate */ | 1093 | xfs_extlen_t minlen, /* minimum length to allocate */ |
| 1094 | xfs_extlen_t maxlen, /* maximum length to allocate */ | 1094 | xfs_extlen_t maxlen, /* maximum length to allocate */ |
| 1095 | xfs_extlen_t *len, /* out: actual length allocated */ | 1095 | xfs_extlen_t *len, /* out: actual length allocated */ |
| 1096 | xfs_alloctype_t type, /* allocation type XFS_ALLOCTYPE... */ | ||
| 1097 | int wasdel, /* was a delayed allocation extent */ | 1096 | int wasdel, /* was a delayed allocation extent */ |
| 1098 | xfs_extlen_t prod, /* extent product factor */ | 1097 | xfs_extlen_t prod, /* extent product factor */ |
| 1099 | xfs_rtblock_t *rtblock) /* out: start block allocated */ | 1098 | xfs_rtblock_t *rtblock) /* out: start block allocated */ |
| @@ -1123,27 +1122,16 @@ xfs_rtallocate_extent( | |||
| 1123 | } | 1122 | } |
| 1124 | } | 1123 | } |
| 1125 | 1124 | ||
| 1125 | retry: | ||
| 1126 | sumbp = NULL; | 1126 | sumbp = NULL; |
| 1127 | /* | 1127 | if (bno == 0) { |
| 1128 | * Allocate by size, or near another block, or exactly at some block. | ||
| 1129 | */ | ||
| 1130 | switch (type) { | ||
| 1131 | case XFS_ALLOCTYPE_ANY_AG: | ||
| 1132 | error = xfs_rtallocate_extent_size(mp, tp, minlen, maxlen, len, | 1128 | error = xfs_rtallocate_extent_size(mp, tp, minlen, maxlen, len, |
| 1133 | &sumbp, &sb, prod, &r); | 1129 | &sumbp, &sb, prod, &r); |
| 1134 | break; | 1130 | } else { |
| 1135 | case XFS_ALLOCTYPE_NEAR_BNO: | ||
| 1136 | error = xfs_rtallocate_extent_near(mp, tp, bno, minlen, maxlen, | 1131 | error = xfs_rtallocate_extent_near(mp, tp, bno, minlen, maxlen, |
| 1137 | len, &sumbp, &sb, prod, &r); | 1132 | len, &sumbp, &sb, prod, &r); |
| 1138 | break; | ||
| 1139 | case XFS_ALLOCTYPE_THIS_BNO: | ||
| 1140 | error = xfs_rtallocate_extent_exact(mp, tp, bno, minlen, maxlen, | ||
| 1141 | len, &sumbp, &sb, prod, &r); | ||
| 1142 | break; | ||
| 1143 | default: | ||
| 1144 | error = -EIO; | ||
| 1145 | ASSERT(0); | ||
| 1146 | } | 1133 | } |
| 1134 | |||
| 1147 | if (error) | 1135 | if (error) |
| 1148 | return error; | 1136 | return error; |
| 1149 | 1137 | ||
| @@ -1158,7 +1146,11 @@ xfs_rtallocate_extent( | |||
| 1158 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_RES_FREXTENTS, -slen); | 1146 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_RES_FREXTENTS, -slen); |
| 1159 | else | 1147 | else |
| 1160 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_FREXTENTS, -slen); | 1148 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_FREXTENTS, -slen); |
| 1149 | } else if (prod > 1) { | ||
| 1150 | prod = 1; | ||
| 1151 | goto retry; | ||
| 1161 | } | 1152 | } |
| 1153 | |||
| 1162 | *rtblock = r; | 1154 | *rtblock = r; |
| 1163 | return 0; | 1155 | return 0; |
| 1164 | } | 1156 | } |
