diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-05-31 12:22:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-31 14:41:36 -0400 |
commit | 1d59d61f606547f0712aa6971f91f71154071c99 (patch) | |
tree | cb2fd4b9ce3e3ee9440d566d43ea350221edfc8e /fs/inode.c | |
parent | 2d117403b30cd7301af60d7d54b279a9f566d10d (diff) |
NFS: Ensure that setattr and getattr wait for O_DIRECT write completion
Use the same mechanism as the block devices are using, but move the
helper functions from fs/direct-io.c into fs/inode.c to remove the
dependency on CONFIG_BLOCK.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Fred Isaman <iisaman@netapp.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/inode.c')
-rw-r--r-- | fs/inode.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/fs/inode.c b/fs/inode.c index 6bc8761cc333..c474c1d7062b 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -1748,3 +1748,50 @@ bool inode_owner_or_capable(const struct inode *inode) | |||
1748 | return false; | 1748 | return false; |
1749 | } | 1749 | } |
1750 | EXPORT_SYMBOL(inode_owner_or_capable); | 1750 | EXPORT_SYMBOL(inode_owner_or_capable); |
1751 | |||
1752 | /* | ||
1753 | * Direct i/o helper functions | ||
1754 | */ | ||
1755 | static void __inode_dio_wait(struct inode *inode) | ||
1756 | { | ||
1757 | wait_queue_head_t *wq = bit_waitqueue(&inode->i_state, __I_DIO_WAKEUP); | ||
1758 | DEFINE_WAIT_BIT(q, &inode->i_state, __I_DIO_WAKEUP); | ||
1759 | |||
1760 | do { | ||
1761 | prepare_to_wait(wq, &q.wait, TASK_UNINTERRUPTIBLE); | ||
1762 | if (atomic_read(&inode->i_dio_count)) | ||
1763 | schedule(); | ||
1764 | } while (atomic_read(&inode->i_dio_count)); | ||
1765 | finish_wait(wq, &q.wait); | ||
1766 | } | ||
1767 | |||
1768 | /** | ||
1769 | * inode_dio_wait - wait for outstanding DIO requests to finish | ||
1770 | * @inode: inode to wait for | ||
1771 | * | ||
1772 | * Waits for all pending direct I/O requests to finish so that we can | ||
1773 | * proceed with a truncate or equivalent operation. | ||
1774 | * | ||
1775 | * Must be called under a lock that serializes taking new references | ||
1776 | * to i_dio_count, usually by inode->i_mutex. | ||
1777 | */ | ||
1778 | void inode_dio_wait(struct inode *inode) | ||
1779 | { | ||
1780 | if (atomic_read(&inode->i_dio_count)) | ||
1781 | __inode_dio_wait(inode); | ||
1782 | } | ||
1783 | EXPORT_SYMBOL(inode_dio_wait); | ||
1784 | |||
1785 | /* | ||
1786 | * inode_dio_done - signal finish of a direct I/O requests | ||
1787 | * @inode: inode the direct I/O happens on | ||
1788 | * | ||
1789 | * This is called once we've finished processing a direct I/O request, | ||
1790 | * and is used to wake up callers waiting for direct I/O to be quiesced. | ||
1791 | */ | ||
1792 | void inode_dio_done(struct inode *inode) | ||
1793 | { | ||
1794 | if (atomic_dec_and_test(&inode->i_dio_count)) | ||
1795 | wake_up_bit(&inode->i_state, __I_DIO_WAKEUP); | ||
1796 | } | ||
1797 | EXPORT_SYMBOL(inode_dio_done); | ||