• Darrick J. Wong's avatar
    xfs: make fsmap backend function key parameters const · 7e1826e0
    Darrick J. Wong authored
    There are several GETFSMAP backend functions for XFS to cover the three
    devices and various feature support.  Each of these functions are passed
    pointers to the low and high keys for the dataset that userspace
    requested, and a pointer to scratchpad variables that are used to
    control the iteration and fill out records.  The scratchpad data can be
    changed arbitrarily, but the keys are supposed to remain unchanged (and
    under the control of the outermost loop in xfs_getfsmap).
    
    Unfortunately, the data and rt backends modify the keys that are passed
    in from the main control loop, which causes subsequent calls to return
    incorrect query results.  Specifically, each of those two functions set
    the block number in the high key to the size of their respective device.
    Since fsmap results are sorted in device number order, if the lower
    numbered device is smaller than the higher numbered device, the first
    function will set the high key to the small size, and the key remains
    unchanged as it is passed into the function for the higher numbered
    device.  The second function will then fail to return all of the results
    for the dataset that userspace is asking for because the keyspace is
    incorrectly constrained.
    Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarChandan Babu R <chandanrlinux@gmail.com>
    7e1826e0
xfs_fsmap.c 25.9 KB