linux/fs/xfs/libxfs
Darrick J. Wong b1712ec30d xfs: fix high key handling in the rt allocator's query_range function
[ Upstream commit d88850bd55 ]

Fix some off-by-one errors in xfs_rtalloc_query_range.  The highest key
in the realtime bitmap is always one less than the number of rt extents,
which means that the key clamp at the start of the function is wrong.
The 4th argument to xfs_rtfind_forw is the highest rt extent that we
want to probe, which means that passing 1 less than the high key is
wrong.  Finally, drop the rem variable that controls the loop because we
can compare the iteration point (rtstart) against the high key directly.

The sordid history of this function is that the original commit (fb3c3)
incorrectly passed (high_rec->ar_startblock - 1) as the 'limit' parameter
to xfs_rtfind_forw.  This was wrong because the "high key" is supposed
to be the largest key for which the caller wants result rows, not the
key for the first row that could possibly be outside the range that the
caller wants to see.

A subsequent attempt (8ad56) to strengthen the parameter checking added
incorrect clamping of the parameters to the number of rt blocks in the
system (despite the bitmap functions all taking units of rt extents) to
avoid querying ranges past the end of rt bitmap file but failed to fix
the incorrect _rtfind_forw parameter.  The original _rtfind_forw
parameter error then survived the conversion of the startblock and
blockcount fields to rt extents (a0e5c), and the most recent off-by-one
fix (a3a37) thought it was patching a problem when the end of the rt
volume is not in use, but none of these fixes actually solved the
original problem that the author was confused about the "limit" argument
to xfs_rtfind_forw.

Sadly, all four of these patches were written by this author and even
his own usage of this function and rt testing were inadequate to get
this fixed quickly.

Original-problem: fb3c3de2f6 ("xfs: add a couple of queries to iterate free extents in the rtbitmap")
Not-fixed-by: 8ad560d256 ("xfs: strengthen rtalloc query range checks")
Not-fixed-by: a0e5c435ba ("xfs: fix xfs_rtalloc_rec units")
Fixes: a3a374bf18 ("xfs: fix off-by-one error in xfs_rtalloc_query_range")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-29 09:57:48 +01:00
..
xfs_ag.c xfs: remove unused flags arg from xfs_get_aghdr_buf() 2019-10-06 15:39:05 -07:00
xfs_ag.h xfs: add a new ioctl to describe allocation group geometry 2019-04-14 18:15:57 -07:00
xfs_ag_resv.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_ag_resv.h xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_alloc.c xfs: add agf freeblocks verify in xfs_agf_verify 2020-06-30 15:37:13 -04:00
xfs_alloc.h xfs: revert 1baa2800e6 ("xfs: remove the unused XFS_ALLOC_USERDATA flag") 2019-09-23 13:05:00 -07:00
xfs_alloc_btree.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_alloc_btree.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_attr.c xfs: allocate xattr buffer on demand 2019-08-30 22:43:57 -07:00
xfs_attr.h xfs: clear kernel only flags in XFS_IOC_ATTRMULTI_BY_HANDLE 2020-03-05 16:43:51 +01:00
xfs_attr_leaf.c xfs: fix attr leaf header freemap.size underflow 2020-10-01 13:17:19 +02:00
xfs_attr_leaf.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_attr_remote.c xfs: make attr lookup returns consistent 2019-08-30 22:43:57 -07:00
xfs_attr_remote.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_attr_sf.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_bit.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_bit.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_bmap.c xfs: fix realtime file data space leak 2020-10-01 13:17:22 +02:00
xfs_bmap.h xfs: move local to extent inode logging into bmap helper 2019-10-09 08:54:30 -07:00
xfs_bmap_btree.c xfs: fix sign handling problem in xfs_bmbt_diff_two_keys 2019-08-28 08:31:01 -07:00
xfs_bmap_btree.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_btree.c xfs: remove all *_ITER_ABORT values 2019-08-29 21:22:41 -07:00
xfs_btree.h xfs: remove all *_ITER_CONTINUE values 2019-08-30 22:43:56 -07:00
xfs_cksum.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xfs_da_btree.c fs: xfs: Remove KM_NOSLEEP and KM_SLEEP. 2019-08-26 12:06:22 -07:00
xfs_da_btree.h xfs: allocate xattr buffer on demand 2019-08-30 22:43:57 -07:00
xfs_da_format.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_da_format.h xfs: factor xfs_da3_blkinfo verification into common helper 2019-02-11 16:07:01 -08:00
xfs_defer.c fs: xfs: Remove KM_NOSLEEP and KM_SLEEP. 2019-08-26 12:06:22 -07:00
xfs_defer.h xfs: streamline defer op type handling 2018-12-12 08:47:16 -08:00
xfs_dir2.c fs: xfs: Remove KM_NOSLEEP and KM_SLEEP. 2019-08-26 12:06:22 -07:00
xfs_dir2.h xfs: check directory name validity 2019-02-11 16:06:40 -08:00
xfs_dir2_block.c xfs: move local to extent inode logging into bmap helper 2019-10-09 08:54:30 -07:00
xfs_dir2_data.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_dir2_leaf.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_dir2_node.c xfs: don't ever return a stale pointer from __xfs_dir3_free_read 2020-10-01 13:17:42 +02:00
xfs_dir2_priv.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_dir2_sf.c xfs: fix inode fork extent count overflow 2020-10-01 13:17:13 +02:00
xfs_dquot_buf.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_errortag.h xfs: cache unlinked pointers in an rhashtable 2019-02-11 16:07:01 -08:00
xfs_format.h xfs: move xfs_ino_geometry to xfs_shared.h 2019-06-28 19:25:35 -07:00
xfs_fs.h xfs: change the seconds fields in xfs_bulkstat to signed 2019-10-15 08:46:07 -07:00
xfs_health.h xfs: introduce new v5 bulkstat structure 2019-07-03 20:36:26 -07:00
xfs_ialloc.c xfs: fix off-by-one in inode alloc block reservation calculation 2020-09-17 13:47:46 +02:00
xfs_ialloc.h xfs: refactor inode geometry setup routines 2019-06-12 08:37:40 -07:00
xfs_ialloc_btree.c xfs: create simplified inode walk function 2019-07-02 09:40:05 -07:00
xfs_ialloc_btree.h xfs: create simplified inode walk function 2019-07-02 09:40:05 -07:00
xfs_iext_tree.c xfs: fix inode fork extent count overflow 2020-10-01 13:17:13 +02:00
xfs_inode_buf.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_inode_buf.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_inode_fork.c xfs: fix inode fork extent count overflow 2020-10-01 13:17:13 +02:00
xfs_inode_fork.h xfs: fix inode fork extent count overflow 2020-10-01 13:17:13 +02:00
xfs_log_format.h xfs: refactor unmount record write 2018-07-23 09:08:01 -07:00
xfs_log_recover.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_log_rlimit.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_quota_defs.h xfs: change some error-less functions to void types 2019-05-01 20:26:30 -07:00
xfs_refcount.c xfs: remove unnecessary int returns from deferred refcount functions 2019-08-28 08:31:02 -07:00
xfs_refcount.h xfs: remove unnecessary int returns from deferred refcount functions 2019-08-28 08:31:02 -07:00
xfs_refcount_btree.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_refcount_btree.h xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_rmap.c xfs: remove all *_ITER_CONTINUE values 2019-08-30 22:43:56 -07:00
xfs_rmap.h xfs: reinitialize rm_flags when unpacking an offset into an rmap irec 2019-08-28 08:31:02 -07:00
xfs_rmap_btree.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_rmap_btree.h xfs: pass transaction lock while setting up agresv on cyclic metadata 2018-07-29 22:37:08 -07:00
xfs_rtbitmap.c xfs: fix high key handling in the rt allocator's query_range function 2020-10-29 09:57:48 +01:00
xfs_sb.c xfs: log proper length of superblock 2019-09-24 08:00:36 -07:00
xfs_sb.h xfs: change some error-less functions to void types 2019-05-01 20:26:30 -07:00
xfs_shared.h xfs: remove all *_ITER_CONTINUE values 2019-08-30 22:43:56 -07:00
xfs_symlink_remote.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_trans_inode.c xfs: Don't allow logging of XFS_ISTALE inodes 2020-09-03 11:26:44 +02:00
xfs_trans_resv.c xfs: fix log reservation overflows when allocating large rt extents 2020-10-01 13:17:24 +02:00
xfs_trans_resv.h xfs: convert to SPDX license tags 2018-06-06 14:17:53 -07:00
xfs_trans_space.h xfs: fix off-by-one in inode alloc block reservation calculation 2020-09-17 13:47:46 +02:00
xfs_types.c xfs: remove unused header files 2019-06-28 19:30:43 -07:00
xfs_types.h xfs: add kmem allocation trace points 2019-08-26 17:43:14 -07:00