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 | |
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>
-rw-r--r-- | fs/xfs/xfs_bmap_util.c | 13 | ||||
-rw-r--r-- | fs/xfs/xfs_rtalloc.c | 24 | ||||
-rw-r--r-- | fs/xfs/xfs_rtalloc.h | 3 |
3 files changed, 13 insertions, 27 deletions
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 6be5f26783a1..8b75dcea5966 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c | |||
@@ -88,7 +88,6 @@ int | |||
88 | xfs_bmap_rtalloc( | 88 | xfs_bmap_rtalloc( |
89 | struct xfs_bmalloca *ap) /* bmap alloc argument struct */ | 89 | struct xfs_bmalloca *ap) /* bmap alloc argument struct */ |
90 | { | 90 | { |
91 | xfs_alloctype_t atype = 0; /* type for allocation routines */ | ||
92 | int error; /* error return value */ | 91 | int error; /* error return value */ |
93 | xfs_mount_t *mp; /* mount point structure */ | 92 | xfs_mount_t *mp; /* mount point structure */ |
94 | xfs_extlen_t prod = 0; /* product factor for allocators */ | 93 | xfs_extlen_t prod = 0; /* product factor for allocators */ |
@@ -155,18 +154,14 @@ xfs_bmap_rtalloc( | |||
155 | /* | 154 | /* |
156 | * Realtime allocation, done through xfs_rtallocate_extent. | 155 | * Realtime allocation, done through xfs_rtallocate_extent. |
157 | */ | 156 | */ |
158 | atype = ap->blkno == 0 ? XFS_ALLOCTYPE_ANY_AG : XFS_ALLOCTYPE_NEAR_BNO; | ||
159 | do_div(ap->blkno, mp->m_sb.sb_rextsize); | 157 | do_div(ap->blkno, mp->m_sb.sb_rextsize); |
160 | rtb = ap->blkno; | 158 | rtb = ap->blkno; |
161 | ap->length = ralen; | 159 | ap->length = ralen; |
162 | if ((error = xfs_rtallocate_extent(ap->tp, ap->blkno, 1, ap->length, | 160 | error = xfs_rtallocate_extent(ap->tp, ap->blkno, 1, ap->length, |
163 | &ralen, atype, ap->wasdel, prod, &rtb))) | 161 | &ralen, ap->wasdel, prod, &rtb); |
164 | return error; | 162 | if (error) |
165 | if (rtb == NULLFSBLOCK && prod > 1 && | ||
166 | (error = xfs_rtallocate_extent(ap->tp, ap->blkno, 1, | ||
167 | ap->length, &ralen, atype, | ||
168 | ap->wasdel, 1, &rtb))) | ||
169 | return error; | 163 | return error; |
164 | |||
170 | ap->blkno = rtb; | 165 | ap->blkno = rtb; |
171 | if (ap->blkno != NULLFSBLOCK) { | 166 | if (ap->blkno != NULLFSBLOCK) { |
172 | ap->blkno *= mp->m_sb.sb_rextsize; | 167 | ap->blkno *= mp->m_sb.sb_rextsize; |
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 | } |
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h index 355dd9e1cb64..51dd3c726608 100644 --- a/fs/xfs/xfs_rtalloc.h +++ b/fs/xfs/xfs_rtalloc.h | |||
@@ -40,7 +40,6 @@ xfs_rtallocate_extent( | |||
40 | xfs_extlen_t minlen, /* minimum length to allocate */ | 40 | xfs_extlen_t minlen, /* minimum length to allocate */ |
41 | xfs_extlen_t maxlen, /* maximum length to allocate */ | 41 | xfs_extlen_t maxlen, /* maximum length to allocate */ |
42 | xfs_extlen_t *len, /* out: actual length allocated */ | 42 | xfs_extlen_t *len, /* out: actual length allocated */ |
43 | xfs_alloctype_t type, /* allocation type XFS_ALLOCTYPE... */ | ||
44 | int wasdel, /* was a delayed allocation extent */ | 43 | int wasdel, /* was a delayed allocation extent */ |
45 | xfs_extlen_t prod, /* extent product factor */ | 44 | xfs_extlen_t prod, /* extent product factor */ |
46 | xfs_rtblock_t *rtblock); /* out: start block allocated */ | 45 | xfs_rtblock_t *rtblock); /* out: start block allocated */ |
@@ -122,7 +121,7 @@ int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp, | |||
122 | 121 | ||
123 | 122 | ||
124 | #else | 123 | #else |
125 | # define xfs_rtallocate_extent(t,b,min,max,l,a,f,p,rb) (ENOSYS) | 124 | # define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb) (ENOSYS) |
126 | # define xfs_rtfree_extent(t,b,l) (ENOSYS) | 125 | # define xfs_rtfree_extent(t,b,l) (ENOSYS) |
127 | # define xfs_rtpick_extent(m,t,l,rb) (ENOSYS) | 126 | # define xfs_rtpick_extent(m,t,l,rb) (ENOSYS) |
128 | # define xfs_growfs_rt(mp,in) (ENOSYS) | 127 | # define xfs_growfs_rt(mp,in) (ENOSYS) |