• D
    xfs, dax: introduce xfs_break_dax_layouts() · d6dc57e2
    Dan Williams 提交于
    xfs_break_dax_layouts(), similar to xfs_break_leased_layouts(), scans
    for busy / pinned dax pages and waits for those pages to go idle before
    any potential extent unmap operation.
    
    dax_layout_busy_page() handles synchronizing against new page-busy
    events (get_user_pages). It invalidates all mappings to trigger the
    get_user_pages slow path which will eventually block on the xfs inode
    lock held in XFS_MMAPLOCK_EXCL mode. If dax_layout_busy_page() finds a
    busy page it returns it for xfs to wait for the page-idle event that
    will fire when the page reference count reaches 1 (recall ZONE_DEVICE
    pages are idle at count 1, see generic_dax_pagefree()).
    
    While waiting, the XFS_MMAPLOCK_EXCL lock is dropped in order to not
    deadlock the process that might be trying to elevate the page count of
    more pages before arranging for any of them to go idle. I.e. the typical
    case of submitting I/O is that iov_iter_get_pages() elevates the
    reference count of all pages in the I/O before starting I/O on the first
    page. The process of elevating the reference count of all pages involved
    in an I/O may cause faults that need to take XFS_MMAPLOCK_EXCL.
    
    Although XFS_MMAPLOCK_EXCL is dropped while waiting, XFS_IOLOCK_EXCL is
    held while sleeping. We need this to prevent starvation of the truncate
    path as continuous submission of direct-I/O could starve the truncate
    path indefinitely if the lock is dropped.
    
    Cc: Dave Chinner <david@fromorbit.com>
    Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
    Reported-by: NJan Kara <jack@suse.cz>
    Reviewed-by: NJan Kara <jack@suse.cz>
    Reviewed-by: NChristoph Hellwig <hch@lst.de>
    Acked-by: NDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: NDan Williams <dan.j.williams@intel.com>
    d6dc57e2
xfs_file.c 30.4 KB