45 xfs_ialloc_cluster_alignment(
48 if (xfs_sb_version_hasalign(&args->
mp->m_sb) &&
49 args->
mp->m_sb.sb_inoalignmt >=
51 return args->
mp->m_sb.sb_inoalignmt;
101 if (!error && *stat == 1) {
141 if (!XFS_FORCED_SHUTDOWN(cur->
bc_mp))
147 #define xfs_check_agi_freecount(cur, agi) 0
155 struct xfs_mount *
mp,
156 struct xfs_trans *tp,
164 int blks_per_cluster, nbufs, ninodes;
175 blks_per_cluster = 1;
177 ninodes = mp->m_sb.sb_inopblock;
180 mp->m_sb.sb_blocksize;
181 nbufs = length / blks_per_cluster;
182 ninodes = blks_per_cluster * mp->m_sb.sb_inopblock;
192 if (xfs_sb_version_hasnlink(&mp->m_sb))
197 for (j = 0; j < nbufs; j++) {
202 fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
203 mp->m_bsize * blks_per_cluster, 0);
214 for (i = 0; i < ninodes; i++) {
215 int ioffset = i << mp->m_sb.sb_inodelog;
218 free = xfs_make_iptr(mp, fbuf, i);
253 memset(&args, 0,
sizeof(args));
255 args.
mp = tp->t_mountp;
262 if (args.
mp->m_maxicount &&
263 args.
mp->m_sb.sb_icount + newlen > args.
mp->m_maxicount)
298 args.
minalignslop = xfs_ialloc_cluster_alignment(&args) - 1;
301 args.
minleft = args.
mp->m_in_maxlevels - 1;
317 if (args.
mp->m_sinoalign) {
318 ASSERT(!(args.
mp->m_flags & XFS_MOUNT_NOALIGN));
322 args.
alignment = xfs_ialloc_cluster_alignment(&args);
340 args.
minleft = args.
mp->m_in_maxlevels - 1;
353 args.
alignment = xfs_ialloc_cluster_alignment(&args);
393 for (thisino = newino;
394 thisino < newino + newlen;
433 spin_lock(&mp->m_agirotor_lock);
434 agno = mp->m_agirotor;
435 if (++mp->m_agirotor >= mp->m_maxagi)
437 spin_unlock(&mp->m_agirotor_lock);
470 agcount = mp->m_maxagi;
475 if (pagno >= agcount)
537 if (XFS_FORCED_SHUTDOWN(mp))
614 struct xfs_trans *tp,
619 struct xfs_mount *
mp = tp->t_mountp;
657 int searchdistance = 10;
695 &trec, &doneleft, 1);
700 &rec, &doneright, 0);
718 while (!doneleft || !doneright) {
721 if (!--searchdistance) {
734 if (!doneleft && !doneright) {
839 offset = xfs_lowbit64(rec.
ir_free);
894 struct xfs_trans *tp,
901 struct xfs_mount *
mp = tp->t_mountp;
935 if (mp->m_maxicount &&
980 goto nextag_relse_buffer;
1010 nextag_relse_buffer:
1014 if (++agno == mp->m_sb.sb_agcount)
1016 if (agno == start_agno) {
1018 return noroom ?
ENOSPC : 0;
1042 xfs_ino_t *first_ino)
1065 if (agno >= mp->m_sb.sb_agcount) {
1066 xfs_warn(mp,
"%s: agno >= mp->m_sb.sb_agcount (%d >= %d).",
1067 __func__, agno, mp->m_sb.sb_agcount);
1073 xfs_warn(mp,
"%s: inode != XFS_AGINO_TO_INO() (%llu != %llu).",
1074 __func__, (
unsigned long long)inode,
1080 if (agbno >= mp->m_sb.sb_agblocks) {
1081 xfs_warn(mp,
"%s: agbno >= mp->m_sb.sb_agblocks (%d >= %d).",
1082 __func__, agbno, mp->m_sb.sb_agblocks);
1091 xfs_warn(mp,
"%s: xfs_ialloc_read_agi() returned error %d.",
1111 xfs_warn(mp,
"%s: xfs_inobt_lookup() returned error %d.",
1118 xfs_warn(mp,
"%s: xfs_inobt_get_rec() returned error %d.",
1138 if (!(mp->m_flags & XFS_MOUNT_IKEEP) &&
1160 xfs_warn(mp,
"%s: xfs_btree_delete returned error %d.",
1173 xfs_warn(mp,
"%s: xfs_inobt_update returned error %d.",
1203 struct xfs_mount *
mp,
1204 struct xfs_trans *tp,
1221 "%s: xfs_ialloc_read_agi() returned error %d, agno %d",
1222 __func__, error, agno);
1237 if (!error && i == 0)
1257 *offset_agbno = agbno - *chunk_agbno;
1275 int blks_per_cluster;
1290 if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks ||
1299 if (agno >= mp->m_sb.sb_agcount) {
1301 "%s: agno (%d) >= mp->m_sb.sb_agcount (%d)",
1302 __func__, agno, mp->m_sb.sb_agcount);
1304 if (agbno >= mp->m_sb.sb_agblocks) {
1306 "%s: agbno (0x%llx) >= mp->m_sb.sb_agblocks (0x%lx)",
1307 __func__, (
unsigned long long)agbno,
1308 (
unsigned long)mp->m_sb.sb_agblocks);
1312 "%s: ino (0x%llx) != XFS_AGINO_TO_INO() (0x%llx)",
1332 &chunk_agbno, &offset_agbno, flags);
1357 if (mp->m_inoalign_mask) {
1358 offset_agbno = agbno & mp->m_inoalign_mask;
1359 chunk_agbno = agbno - offset_agbno;
1362 &chunk_agbno, &offset_agbno, flags);
1368 ASSERT(agbno >= chunk_agbno);
1369 cluster_agbno = chunk_agbno +
1370 ((offset_agbno / blks_per_cluster) * blks_per_cluster);
1371 offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +
1387 "%s: (im_blkno (0x%llx) + im_len (0x%llx)) > sb_dblocks (0x%llx)",
1388 __func__, (
unsigned long long) imap->
im_blkno,
1389 (
unsigned long long) imap->
im_len,
1409 maxleafents = (1LL << XFS_INO_AGINO_BITS(mp)) >>
1411 minleafrecs = mp->m_alloc_mnr[0];
1412 minnoderecs = mp->m_alloc_mnr[1];
1413 maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs;
1414 for (level = 1; maxblocks > 1; level++)
1415 maxblocks = (maxblocks + minnoderecs - 1) / minnoderecs;
1416 mp->m_in_maxlevels =
level;
1430 static const short offsets[] = {
1472 #define xfs_check_agi_unlinked(agi)
1480 struct xfs_mount *
mp,
1481 struct xfs_trans *tp,
1491 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
1497 ASSERT(!xfs_buf_geterror(*bpp));
1522 struct xfs_mount *
mp,
1523 struct xfs_trans *tp,
1548 XFS_FORCED_SHUTDOWN(mp));