diff options
Diffstat (limited to 'fs/xfs/xfs_ialloc.c')
-rw-r--r-- | fs/xfs/xfs_ialloc.c | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index e87719c5bebe..5d7f105a1c82 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -52,7 +52,7 @@ xfs_ialloc_cluster_alignment( | |||
52 | { | 52 | { |
53 | if (xfs_sb_version_hasalign(&args->mp->m_sb) && | 53 | if (xfs_sb_version_hasalign(&args->mp->m_sb) && |
54 | args->mp->m_sb.sb_inoalignmt >= | 54 | args->mp->m_sb.sb_inoalignmt >= |
55 | XFS_B_TO_FSBT(args->mp, XFS_INODE_CLUSTER_SIZE(args->mp))) | 55 | XFS_B_TO_FSBT(args->mp, args->mp->m_inode_cluster_size)) |
56 | return args->mp->m_sb.sb_inoalignmt; | 56 | return args->mp->m_sb.sb_inoalignmt; |
57 | return 1; | 57 | return 1; |
58 | } | 58 | } |
@@ -170,27 +170,20 @@ xfs_ialloc_inode_init( | |||
170 | { | 170 | { |
171 | struct xfs_buf *fbuf; | 171 | struct xfs_buf *fbuf; |
172 | struct xfs_dinode *free; | 172 | struct xfs_dinode *free; |
173 | int blks_per_cluster, nbufs, ninodes; | 173 | int nbufs, blks_per_cluster, inodes_per_cluster; |
174 | int version; | 174 | int version; |
175 | int i, j; | 175 | int i, j; |
176 | xfs_daddr_t d; | 176 | xfs_daddr_t d; |
177 | xfs_ino_t ino = 0; | 177 | xfs_ino_t ino = 0; |
178 | 178 | ||
179 | /* | 179 | /* |
180 | * Loop over the new block(s), filling in the inodes. | 180 | * Loop over the new block(s), filling in the inodes. For small block |
181 | * For small block sizes, manipulate the inodes in buffers | 181 | * sizes, manipulate the inodes in buffers which are multiples of the |
182 | * which are multiples of the blocks size. | 182 | * blocks size. |
183 | */ | 183 | */ |
184 | if (mp->m_sb.sb_blocksize >= XFS_INODE_CLUSTER_SIZE(mp)) { | 184 | blks_per_cluster = xfs_icluster_size_fsb(mp); |
185 | blks_per_cluster = 1; | 185 | inodes_per_cluster = blks_per_cluster << mp->m_sb.sb_inopblog; |
186 | nbufs = length; | 186 | nbufs = length / blks_per_cluster; |
187 | ninodes = mp->m_sb.sb_inopblock; | ||
188 | } else { | ||
189 | blks_per_cluster = XFS_INODE_CLUSTER_SIZE(mp) / | ||
190 | mp->m_sb.sb_blocksize; | ||
191 | nbufs = length / blks_per_cluster; | ||
192 | ninodes = blks_per_cluster * mp->m_sb.sb_inopblock; | ||
193 | } | ||
194 | 187 | ||
195 | /* | 188 | /* |
196 | * Figure out what version number to use in the inodes we create. If | 189 | * Figure out what version number to use in the inodes we create. If |
@@ -225,7 +218,7 @@ xfs_ialloc_inode_init( | |||
225 | * they track in the AIL as if they were physically logged. | 218 | * they track in the AIL as if they were physically logged. |
226 | */ | 219 | */ |
227 | if (tp) | 220 | if (tp) |
228 | xfs_icreate_log(tp, agno, agbno, XFS_IALLOC_INODES(mp), | 221 | xfs_icreate_log(tp, agno, agbno, mp->m_ialloc_inos, |
229 | mp->m_sb.sb_inodesize, length, gen); | 222 | mp->m_sb.sb_inodesize, length, gen); |
230 | } else if (xfs_sb_version_hasnlink(&mp->m_sb)) | 223 | } else if (xfs_sb_version_hasnlink(&mp->m_sb)) |
231 | version = 2; | 224 | version = 2; |
@@ -246,7 +239,7 @@ xfs_ialloc_inode_init( | |||
246 | /* Initialize the inode buffers and log them appropriately. */ | 239 | /* Initialize the inode buffers and log them appropriately. */ |
247 | fbuf->b_ops = &xfs_inode_buf_ops; | 240 | fbuf->b_ops = &xfs_inode_buf_ops; |
248 | xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length)); | 241 | xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length)); |
249 | for (i = 0; i < ninodes; i++) { | 242 | for (i = 0; i < inodes_per_cluster; i++) { |
250 | int ioffset = i << mp->m_sb.sb_inodelog; | 243 | int ioffset = i << mp->m_sb.sb_inodelog; |
251 | uint isize = xfs_dinode_size(version); | 244 | uint isize = xfs_dinode_size(version); |
252 | 245 | ||
@@ -329,11 +322,11 @@ xfs_ialloc_ag_alloc( | |||
329 | * Locking will ensure that we don't have two callers in here | 322 | * Locking will ensure that we don't have two callers in here |
330 | * at one time. | 323 | * at one time. |
331 | */ | 324 | */ |
332 | newlen = XFS_IALLOC_INODES(args.mp); | 325 | newlen = args.mp->m_ialloc_inos; |
333 | if (args.mp->m_maxicount && | 326 | if (args.mp->m_maxicount && |
334 | args.mp->m_sb.sb_icount + newlen > args.mp->m_maxicount) | 327 | args.mp->m_sb.sb_icount + newlen > args.mp->m_maxicount) |
335 | return XFS_ERROR(ENOSPC); | 328 | return XFS_ERROR(ENOSPC); |
336 | args.minlen = args.maxlen = XFS_IALLOC_BLOCKS(args.mp); | 329 | args.minlen = args.maxlen = args.mp->m_ialloc_blks; |
337 | /* | 330 | /* |
338 | * First try to allocate inodes contiguous with the last-allocated | 331 | * First try to allocate inodes contiguous with the last-allocated |
339 | * chunk of inodes. If the filesystem is striped, this will fill | 332 | * chunk of inodes. If the filesystem is striped, this will fill |
@@ -343,7 +336,7 @@ xfs_ialloc_ag_alloc( | |||
343 | newino = be32_to_cpu(agi->agi_newino); | 336 | newino = be32_to_cpu(agi->agi_newino); |
344 | agno = be32_to_cpu(agi->agi_seqno); | 337 | agno = be32_to_cpu(agi->agi_seqno); |
345 | args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) + | 338 | args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) + |
346 | XFS_IALLOC_BLOCKS(args.mp); | 339 | args.mp->m_ialloc_blks; |
347 | if (likely(newino != NULLAGINO && | 340 | if (likely(newino != NULLAGINO && |
348 | (args.agbno < be32_to_cpu(agi->agi_length)))) { | 341 | (args.agbno < be32_to_cpu(agi->agi_length)))) { |
349 | args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); | 342 | args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); |
@@ -585,7 +578,7 @@ xfs_ialloc_ag_select( | |||
585 | * Is there enough free space for the file plus a block of | 578 | * Is there enough free space for the file plus a block of |
586 | * inodes? (if we need to allocate some)? | 579 | * inodes? (if we need to allocate some)? |
587 | */ | 580 | */ |
588 | ineed = XFS_IALLOC_BLOCKS(mp); | 581 | ineed = mp->m_ialloc_blks; |
589 | longest = pag->pagf_longest; | 582 | longest = pag->pagf_longest; |
590 | if (!longest) | 583 | if (!longest) |
591 | longest = pag->pagf_flcount > 0; | 584 | longest = pag->pagf_flcount > 0; |
@@ -999,7 +992,7 @@ xfs_dialloc( | |||
999 | * inode. | 992 | * inode. |
1000 | */ | 993 | */ |
1001 | if (mp->m_maxicount && | 994 | if (mp->m_maxicount && |
1002 | mp->m_sb.sb_icount + XFS_IALLOC_INODES(mp) > mp->m_maxicount) { | 995 | mp->m_sb.sb_icount + mp->m_ialloc_inos > mp->m_maxicount) { |
1003 | noroom = 1; | 996 | noroom = 1; |
1004 | okalloc = 0; | 997 | okalloc = 0; |
1005 | } | 998 | } |
@@ -1202,7 +1195,7 @@ xfs_difree( | |||
1202 | * When an inode cluster is free, it becomes eligible for removal | 1195 | * When an inode cluster is free, it becomes eligible for removal |
1203 | */ | 1196 | */ |
1204 | if (!(mp->m_flags & XFS_MOUNT_IKEEP) && | 1197 | if (!(mp->m_flags & XFS_MOUNT_IKEEP) && |
1205 | (rec.ir_freecount == XFS_IALLOC_INODES(mp))) { | 1198 | (rec.ir_freecount == mp->m_ialloc_inos)) { |
1206 | 1199 | ||
1207 | *delete = 1; | 1200 | *delete = 1; |
1208 | *first_ino = XFS_AGINO_TO_INO(mp, agno, rec.ir_startino); | 1201 | *first_ino = XFS_AGINO_TO_INO(mp, agno, rec.ir_startino); |
@@ -1212,7 +1205,7 @@ xfs_difree( | |||
1212 | * AGI and Superblock inode counts, and mark the disk space | 1205 | * AGI and Superblock inode counts, and mark the disk space |
1213 | * to be freed when the transaction is committed. | 1206 | * to be freed when the transaction is committed. |
1214 | */ | 1207 | */ |
1215 | ilen = XFS_IALLOC_INODES(mp); | 1208 | ilen = mp->m_ialloc_inos; |
1216 | be32_add_cpu(&agi->agi_count, -ilen); | 1209 | be32_add_cpu(&agi->agi_count, -ilen); |
1217 | be32_add_cpu(&agi->agi_freecount, -(ilen - 1)); | 1210 | be32_add_cpu(&agi->agi_freecount, -(ilen - 1)); |
1218 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_COUNT | XFS_AGI_FREECOUNT); | 1211 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_COUNT | XFS_AGI_FREECOUNT); |
@@ -1228,9 +1221,9 @@ xfs_difree( | |||
1228 | goto error0; | 1221 | goto error0; |
1229 | } | 1222 | } |
1230 | 1223 | ||
1231 | xfs_bmap_add_free(XFS_AGB_TO_FSB(mp, | 1224 | xfs_bmap_add_free(XFS_AGB_TO_FSB(mp, agno, |
1232 | agno, XFS_INO_TO_AGBNO(mp,rec.ir_startino)), | 1225 | XFS_AGINO_TO_AGBNO(mp, rec.ir_startino)), |
1233 | XFS_IALLOC_BLOCKS(mp), flist, mp); | 1226 | mp->m_ialloc_blks, flist, mp); |
1234 | } else { | 1227 | } else { |
1235 | *delete = 0; | 1228 | *delete = 0; |
1236 | 1229 | ||
@@ -1311,7 +1304,7 @@ xfs_imap_lookup( | |||
1311 | 1304 | ||
1312 | /* check that the returned record contains the required inode */ | 1305 | /* check that the returned record contains the required inode */ |
1313 | if (rec.ir_startino > agino || | 1306 | if (rec.ir_startino > agino || |
1314 | rec.ir_startino + XFS_IALLOC_INODES(mp) <= agino) | 1307 | rec.ir_startino + mp->m_ialloc_inos <= agino) |
1315 | return EINVAL; | 1308 | return EINVAL; |
1316 | 1309 | ||
1317 | /* for untrusted inodes check it is allocated first */ | 1310 | /* for untrusted inodes check it is allocated first */ |
@@ -1384,7 +1377,7 @@ xfs_imap( | |||
1384 | return XFS_ERROR(EINVAL); | 1377 | return XFS_ERROR(EINVAL); |
1385 | } | 1378 | } |
1386 | 1379 | ||
1387 | blks_per_cluster = XFS_INODE_CLUSTER_SIZE(mp) >> mp->m_sb.sb_blocklog; | 1380 | blks_per_cluster = xfs_icluster_size_fsb(mp); |
1388 | 1381 | ||
1389 | /* | 1382 | /* |
1390 | * For bulkstat and handle lookups, we have an untrusted inode number | 1383 | * For bulkstat and handle lookups, we have an untrusted inode number |
@@ -1405,7 +1398,7 @@ xfs_imap( | |||
1405 | * If the inode cluster size is the same as the blocksize or | 1398 | * If the inode cluster size is the same as the blocksize or |
1406 | * smaller we get to the buffer by simple arithmetics. | 1399 | * smaller we get to the buffer by simple arithmetics. |
1407 | */ | 1400 | */ |
1408 | if (XFS_INODE_CLUSTER_SIZE(mp) <= mp->m_sb.sb_blocksize) { | 1401 | if (blks_per_cluster == 1) { |
1409 | offset = XFS_INO_TO_OFFSET(mp, ino); | 1402 | offset = XFS_INO_TO_OFFSET(mp, ino); |
1410 | ASSERT(offset < mp->m_sb.sb_inopblock); | 1403 | ASSERT(offset < mp->m_sb.sb_inopblock); |
1411 | 1404 | ||