linux/fs/xfs/libxfs
Chandan Rajendra 8ee9fdbebc xfs: Use xfs_icluster_size_fsb() to calculate inode chunk alignment
On a ppc64 system, executing generic/256 test with 32k block size gives the following call trace,

XFS: Assertion failed: args->maxlen > 0, file: /root/repos/linux/fs/xfs/libxfs/xfs_alloc.c, line: 2026

kernel BUG at /root/repos/linux/fs/xfs/xfs_message.c:113!
Oops: Exception in kernel mode, sig: 5 [#1]
SMP NR_CPUS=2048
DEBUG_PAGEALLOC
NUMA
pSeries
Modules linked in:
CPU: 2 PID: 19361 Comm: mkdir Not tainted 4.10.0-rc5 #58
task: c000000102606d80 task.stack: c0000001026b8000
NIP: c0000000004ef798 LR: c0000000004ef798 CTR: c00000000082b290
REGS: c0000001026bb090 TRAP: 0700   Not tainted  (4.10.0-rc5)
MSR: 8000000000029032 <SF,EE,ME,IR,DR,RI>
CR: 28004428  XER: 00000000
CFAR: c0000000004ef180 SOFTE: 1
GPR00: c0000000004ef798 c0000001026bb310 c000000001157300 ffffffffffffffea
GPR04: 000000000000000a c0000001026bb130 0000000000000000 ffffffffffffffc0
GPR08: 00000000000000d1 0000000000000021 00000000ffffffd1 c000000000dd4990
GPR12: 0000000022004444 c00000000fe00800 0000000020000000 0000000000000000
GPR16: 0000000000000000 0000000043a606fc 0000000043a76c08 0000000043a1b3d0
GPR20: 000001002a35cd60 c0000001026bbb80 0000000000000000 0000000000000001
GPR24: 0000000000000240 0000000000000004 c00000062dc55000 0000000000000000
GPR28: 0000000000000004 c00000062ecd9200 0000000000000000 c0000001026bb6c0
NIP [c0000000004ef798] .assfail+0x28/0x30
LR [c0000000004ef798] .assfail+0x28/0x30
Call Trace:
[c0000001026bb310] [c0000000004ef798] .assfail+0x28/0x30 (unreliable)
[c0000001026bb380] [c000000000455d74] .xfs_alloc_space_available+0x194/0x1b0
[c0000001026bb410] [c00000000045b914] .xfs_alloc_fix_freelist+0x144/0x480
[c0000001026bb580] [c00000000045c368] .xfs_alloc_vextent+0x698/0xa90
[c0000001026bb650] [c0000000004a6200] .xfs_ialloc_ag_alloc+0x170/0x820
[c0000001026bb7c0] [c0000000004a9098] .xfs_dialloc+0x158/0x320
[c0000001026bb8a0] [c0000000004e628c] .xfs_ialloc+0x7c/0x610
[c0000001026bb990] [c0000000004e8138] .xfs_dir_ialloc+0xa8/0x2f0
[c0000001026bbaa0] [c0000000004e8814] .xfs_create+0x494/0x790
[c0000001026bbbf0] [c0000000004e5ebc] .xfs_generic_create+0x2bc/0x410
[c0000001026bbce0] [c0000000002b4a34] .vfs_mkdir+0x154/0x230
[c0000001026bbd70] [c0000000002bc444] .SyS_mkdirat+0x94/0x120
[c0000001026bbe30] [c00000000000b760] system_call+0x38/0xfc
Instruction dump:
4e800020 60000000 7c0802a6 7c862378 3c82ffca 7ca72b78 38841c18 7c651b78
38600000 f8010010 f821ff91 4bfff94d <0fe00000> 60000000 7c0802a6 7c892378

When block size is larger than inode cluster size, the call to
XFS_B_TO_FSBT(mp, mp->m_inode_cluster_size) returns 0. Also, mkfs.xfs
would have set xfs_sb->sb_inoalignmt to 0. This causes
xfs_ialloc_cluster_alignment() to return 0.  Due to this
args.minalignslop (in xfs_ialloc_ag_alloc()) gets the unsigned
equivalent of -1 assigned to it. This later causes alloc_len in
xfs_alloc_space_available() to have a value of 0. In such a scenario
when args.total is also 0, the assert statement "ASSERT(args->maxlen >
0);" fails.

This commit fixes the bug by replacing the call to XFS_B_TO_FSBT() in
xfs_ialloc_cluster_alignment() with a call to xfs_icluster_size_fsb().

Suggested-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2017-02-16 17:20:38 -08:00
..
xfs_ag_resv.c xfs: use per-AG reservations for the finobt 2017-01-25 07:49:35 -08:00
xfs_ag_resv.h xfs: set up per-AG free space reservations 2016-09-19 10:30:52 +10:00
xfs_alloc_btree.c Merge branch 'xfs-4.10-misc-fixes-4' into for-next 2016-12-09 16:56:26 +11:00
xfs_alloc_btree.h
xfs_alloc.c xfs: improve handling of busy extents in the low-level allocator 2017-02-09 10:50:25 -08:00
xfs_alloc.h xfs: adjust allocation length in xfs_alloc_space_available 2017-01-09 13:37:44 -08:00
xfs_attr_leaf.c xfs: ignore leaf attr ichdr.count in verifier during log replay 2016-12-09 16:49:47 +11:00
xfs_attr_leaf.h Merge branch 'xfs-4.10-misc-fixes-3' into for-next 2016-12-07 17:42:30 +11:00
xfs_attr_remote.c xfs: rename flist/free_list to dfops 2016-08-03 11:19:29 +10:00
xfs_attr_remote.h
xfs_attr_sf.h xfs: move struct xfs_attr_shortform to xfs_da_format.h 2016-02-08 15:00:01 +11:00
xfs_attr.c xfs: remove racy hasattr check from attr ops 2017-01-25 07:53:43 -08:00
xfs_bit.c libxfs: Optimize the loop for xfs_bitmap_empty 2016-01-04 16:10:19 +11:00
xfs_bit.h
xfs_bmap_btree.c xfs: remove boilerplate around xfs_btree_init_block 2017-01-30 16:32:24 -08:00
xfs_bmap_btree.h
xfs_bmap.c xfs: split indlen reservations fairly when under reserved 2017-02-16 17:20:12 -08:00
xfs_bmap.h xfs: fix COW writeback race 2017-01-23 10:55:07 -08:00
xfs_btree.c xfs: filter out obviously bad btree pointers 2017-02-02 15:13:58 -08:00
xfs_btree.h xfs: filter out obviously bad btree pointers 2017-02-02 15:13:58 -08:00
xfs_cksum.h xfs: optimise CRC updates 2016-12-05 14:40:32 +11:00
xfs_da_btree.c xfs: fail _dir_open when readahead fails 2017-02-02 15:13:58 -08:00
xfs_da_btree.h xfs: fail _dir_open when readahead fails 2017-02-02 15:13:58 -08:00
xfs_da_format.c xfs: kill xfs_dir2_inou_t 2016-07-20 11:48:31 +10:00
xfs_da_format.h xfs: fix attr shortform structure alignment on cris 2016-08-03 10:59:42 +10:00
xfs_defer.c xfs: defer should abort intent items if the trans roll fails 2016-10-24 14:21:18 +11:00
xfs_defer.h xfs: implement deferred bmbt map/unmap operations 2016-10-04 11:05:44 -07:00
xfs_dir2_block.c xfs: print name of verifier if it fails 2016-01-04 16:10:19 +11:00
xfs_dir2_data.c Merge branch 'xfs-4.10-misc-fixes-3' into for-next 2016-12-07 17:42:30 +11:00
xfs_dir2_leaf.c xfs: print name of verifier if it fails 2016-01-04 16:10:19 +11:00
xfs_dir2_node.c xfs: verify free block header fields 2017-02-02 15:14:00 -08:00
xfs_dir2_priv.h xfs: move dir_ino_validate declaration per xfsprogs 2016-11-08 11:59:12 +11:00
xfs_dir2_sf.c xfs: kill xfs_dir2_inou_t 2016-07-20 11:48:31 +10:00
xfs_dir2.c xfs: fix xfs_mode_to_ftype() prototype 2017-01-18 12:39:21 -08:00
xfs_dir2.h xfs: fix xfs_mode_to_ftype() prototype 2017-01-18 12:39:21 -08:00
xfs_dquot_buf.c libxfs: clean up _calc_dquots_per_chunk 2016-10-20 15:46:18 +11:00
xfs_format.h libxfs: v3 inodes are only valid on crc-enabled filesystems 2016-10-20 15:48:38 +11:00
xfs_fs.h xfs: create a separate cow extent size hint for the allocator 2016-10-05 16:26:26 -07:00
xfs_ialloc_btree.c xfs: use per-AG reservations for the finobt 2017-01-25 07:49:35 -08:00
xfs_ialloc_btree.h xfs: use per-AG reservations for the finobt 2017-01-25 07:49:35 -08:00
xfs_ialloc.c xfs: Use xfs_icluster_size_fsb() to calculate inode chunk alignment 2017-02-16 17:20:38 -08:00
xfs_ialloc.h xfs: rename flist/free_list to dfops 2016-08-03 11:19:29 +10:00
xfs_inode_buf.c xfs: sanity check inode di_mode 2017-01-17 11:42:22 -08:00
xfs_inode_buf.h libxfs: convert ushort to unsigned short 2016-11-08 11:55:48 +11:00
xfs_inode_fork.c xfs: check for obviously bad level values in the bmbt root 2017-02-02 15:13:59 -08:00
xfs_inode_fork.h xfs: new inode extent list lookup helpers 2016-11-24 11:39:32 +11:00
xfs_log_format.h libxfs: convert ushort to unsigned short 2016-11-08 11:55:48 +11:00
xfs_log_recover.h xfs: remove unused struct declarations 2017-01-30 16:32:25 -08:00
xfs_log_rlimit.c xfs: move most of xfs_sb.h to xfs_format.h 2014-11-28 14:27:09 +11:00
xfs_quota_defs.h xfs: wire up Q_XGETNEXTQUOTA / get_nextdqblk 2016-02-08 11:27:38 +11:00
xfs_refcount_btree.c xfs: use the actual AG length when reserving blocks 2017-01-03 18:39:33 -08:00
xfs_refcount_btree.h xfs: use the actual AG length when reserving blocks 2017-01-03 18:39:33 -08:00
xfs_refcount.c xfs: rework refcount cow recovery error handling 2016-10-10 17:23:07 +11:00
xfs_refcount.h xfs: store in-progress CoW allocations in the refcount btree 2016-10-05 16:26:05 -07:00
xfs_rmap_btree.c xfs: use the actual AG length when reserving blocks 2017-01-03 18:39:33 -08:00
xfs_rmap_btree.h xfs: use the actual AG length when reserving blocks 2017-01-03 18:39:33 -08:00
xfs_rmap.c xfs: convert unwritten status of reverse mappings for shared files 2016-10-05 16:26:29 -07:00
xfs_rmap.h xfs: use interval query for rmap alloc operations on shared files 2016-10-05 16:26:29 -07:00
xfs_rtbitmap.c libxfs: fix whitespace problems 2016-11-08 11:56:13 +11:00
xfs_sb.c xfs: verify dirblocklog correctly 2017-01-24 12:23:33 -08:00
xfs_sb.h xfs: remove unused function definitions 2016-02-08 14:58:07 +11:00
xfs_shared.h xfs: define the on-disk refcount btree format 2016-10-03 09:11:18 -07:00
xfs_symlink_remote.c xfs: print name of verifier if it fails 2016-01-04 16:10:19 +11:00
xfs_trans_resv.c xfs: increase log reservations for reflink 2016-10-05 16:26:29 -07:00
xfs_trans_resv.h xfs: increase log reservations for reflink 2016-10-05 16:26:29 -07:00
xfs_trans_space.h xfs: implement swapext for rmap filesystems 2016-10-05 16:26:32 -07:00
xfs_types.h Merge branch 'xfs-4.10-extent-lookup' into for-next 2016-11-24 11:41:59 +11:00