Skip to content

Commit 019ff2d

Browse files
committed
[XFS] Fix a problem in aligning inode allocations to stripe unit
boundaries. SGI-PV: 951862 SGI-Modid: xfs-linux-melb:xfs-kern:25726a Signed-off-by: Nathan Scott <[email protected]>
1 parent 8c0b511 commit 019ff2d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

fs/xfs/xfs_ialloc.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ xfs_ialloc_ag_alloc(
158158
*/
159159
agi = XFS_BUF_TO_AGI(agbp);
160160
newino = be32_to_cpu(agi->agi_newino);
161-
if(likely(newino != NULLAGINO)) {
162-
args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) +
163-
XFS_IALLOC_BLOCKS(args.mp);
161+
args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) +
162+
XFS_IALLOC_BLOCKS(args.mp);
163+
if (likely(newino != NULLAGINO &&
164+
(args.agbno < be32_to_cpu(agi->agi_length)))) {
164165
args.fsbno = XFS_AGB_TO_FSB(args.mp,
165166
be32_to_cpu(agi->agi_seqno), args.agbno);
166167
args.type = XFS_ALLOCTYPE_THIS_BNO;
@@ -182,8 +183,8 @@ xfs_ialloc_ag_alloc(
182183
* Set the alignment for the allocation.
183184
* If stripe alignment is turned on then align at stripe unit
184185
* boundary.
185-
* If the cluster size is smaller than a filesystem block
186-
* then we're doing I/O for inodes in filesystem block size
186+
* If the cluster size is smaller than a filesystem block
187+
* then we're doing I/O for inodes in filesystem block size
187188
* pieces, so don't need alignment anyway.
188189
*/
189190
isaligned = 0;
@@ -192,7 +193,7 @@ xfs_ialloc_ag_alloc(
192193
args.alignment = args.mp->m_dalign;
193194
isaligned = 1;
194195
} else if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) &&
195-
args.mp->m_sb.sb_inoalignmt >=
196+
args.mp->m_sb.sb_inoalignmt >=
196197
XFS_B_TO_FSBT(args.mp,
197198
XFS_INODE_CLUSTER_SIZE(args.mp)))
198199
args.alignment = args.mp->m_sb.sb_inoalignmt;
@@ -220,7 +221,7 @@ xfs_ialloc_ag_alloc(
220221
if ((error = xfs_alloc_vextent(&args)))
221222
return error;
222223
}
223-
224+
224225
/*
225226
* If stripe alignment is turned on, then try again with cluster
226227
* alignment.

0 commit comments

Comments
 (0)