aboutsummaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/inode.c')
-rw-r--r--fs/inode.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/fs/inode.c b/fs/inode.c
index f0335fc315ed..c99163b1b310 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1836,3 +1836,50 @@ bool inode_owner_or_capable(const struct inode *inode)
1836 return false; 1836 return false;
1837} 1837}
1838EXPORT_SYMBOL(inode_owner_or_capable); 1838EXPORT_SYMBOL(inode_owner_or_capable);
1839
1840/*
1841 * Direct i/o helper functions
1842 */
1843static void __inode_dio_wait(struct inode *inode)
1844{
1845 wait_queue_head_t *wq = bit_waitqueue(&inode->i_state, __I_DIO_WAKEUP);
1846 DEFINE_WAIT_BIT(q, &inode->i_state, __I_DIO_WAKEUP);
1847
1848 do {
1849 prepare_to_wait(wq, &q.wait, TASK_UNINTERRUPTIBLE);
1850 if (atomic_read(&inode->i_dio_count))
1851 schedule();
1852 } while (atomic_read(&inode->i_dio_count));
1853 finish_wait(wq, &q.wait);
1854}
1855
1856/**
1857 * inode_dio_wait - wait for outstanding DIO requests to finish
1858 * @inode: inode to wait for
1859 *
1860 * Waits for all pending direct I/O requests to finish so that we can
1861 * proceed with a truncate or equivalent operation.
1862 *
1863 * Must be called under a lock that serializes taking new references
1864 * to i_dio_count, usually by inode->i_mutex.
1865 */
1866void inode_dio_wait(struct inode *inode)
1867{
1868 if (atomic_read(&inode->i_dio_count))
1869 __inode_dio_wait(inode);
1870}
1871EXPORT_SYMBOL(inode_dio_wait);
1872
1873/*
1874 * inode_dio_done - signal finish of a direct I/O requests
1875 * @inode: inode the direct I/O happens on
1876 *
1877 * This is called once we've finished processing a direct I/O request,
1878 * and is used to wake up callers waiting for direct I/O to be quiesced.
1879 */
1880void inode_dio_done(struct inode *inode)
1881{
1882 if (atomic_dec_and_test(&inode->i_dio_count))
1883 wake_up_bit(&inode->i_state, __I_DIO_WAKEUP);
1884}
1885EXPORT_SYMBOL(inode_dio_done);