Lines Matching +full:wait +full:- +full:on +full:- +full:read
1 // SPDX-License-Identifier: GPL-2.0
13 * inode_dio_wait_interruptible - wait for outstanding DIO requests to finish
14 * @inode: inode to wait for
20 * to i_dio_count, usually by inode->i_mutex.
28 return !inode_dio_finished(inode) ? -ERESTARTSYS : 0; in netfs_inode_dio_wait_interruptible()
31 /* Call with exclusively locked inode->i_rwsem */
34 if (!test_bit(NETFS_ICTX_ODIRECT, &ictx->flags)) in netfs_block_o_direct()
36 clear_bit(NETFS_ICTX_ODIRECT, &ictx->flags); in netfs_block_o_direct()
37 return netfs_inode_dio_wait_interruptible(&ictx->inode); in netfs_block_o_direct()
41 * netfs_start_io_read - declare the file is being used for buffered reads
44 * Declare that a buffered read operation is about to start, and ensure
46 * On exit, the function ensures that the NETFS_ICTX_ODIRECT flag is unset,
47 * and holds a shared lock on inode->i_rwsem to ensure that the flag
49 * In practice, this means that buffered read operations are allowed to
51 * operations need to wait to grab an exclusive lock in order to set
53 * Note that buffered writes and truncates both take a write lock on
54 * inode->i_rwsem, meaning that those are serialised w.r.t. the reads.
57 __acquires(inode->i_rwsem) in netfs_start_io_read()
62 if (down_read_interruptible(&inode->i_rwsem) < 0) in netfs_start_io_read()
63 return -ERESTARTSYS; in netfs_start_io_read()
64 if (test_bit(NETFS_ICTX_ODIRECT, &ictx->flags) == 0) in netfs_start_io_read()
66 up_read(&inode->i_rwsem); in netfs_start_io_read()
69 if (down_write_killable(&inode->i_rwsem) < 0) in netfs_start_io_read()
70 return -ERESTARTSYS; in netfs_start_io_read()
72 up_write(&inode->i_rwsem); in netfs_start_io_read()
73 return -ERESTARTSYS; in netfs_start_io_read()
75 downgrade_write(&inode->i_rwsem); in netfs_start_io_read()
81 * netfs_end_io_read - declare that the buffered read operation is done
84 * Declare that a buffered read operation is done, and release the shared
85 * lock on inode->i_rwsem.
88 __releases(inode->i_rwsem) in netfs_end_io_read()
90 up_read(&inode->i_rwsem); in netfs_end_io_read()
95 * netfs_start_io_write - declare the file is being used for buffered writes
98 * Declare that a buffered read operation is about to start, and ensure
102 __acquires(inode->i_rwsem) in netfs_start_io_write()
106 if (down_write_killable(&inode->i_rwsem) < 0) in netfs_start_io_write()
107 return -ERESTARTSYS; in netfs_start_io_write()
109 up_write(&inode->i_rwsem); in netfs_start_io_write()
110 return -ERESTARTSYS; in netfs_start_io_write()
112 downgrade_write(&inode->i_rwsem); in netfs_start_io_write()
118 * netfs_end_io_write - declare that the buffered write operation is done
122 * lock on inode->i_rwsem.
125 __releases(inode->i_rwsem) in netfs_end_io_write()
127 up_read(&inode->i_rwsem); in netfs_end_io_write()
131 /* Call with exclusively locked inode->i_rwsem */
137 if (!test_bit(NETFS_ICTX_ODIRECT, &ictx->flags)) { in netfs_block_buffered()
138 set_bit(NETFS_ICTX_ODIRECT, &ictx->flags); in netfs_block_buffered()
139 if (inode->i_mapping->nrpages != 0) { in netfs_block_buffered()
140 unmap_mapping_range(inode->i_mapping, 0, 0, 0); in netfs_block_buffered()
141 ret = filemap_fdatawait(inode->i_mapping); in netfs_block_buffered()
143 clear_bit(NETFS_ICTX_ODIRECT, &ictx->flags); in netfs_block_buffered()
152 * netfs_start_io_direct - declare the file is being used for direct i/o
157 * On exit, the function ensures that the NETFS_ICTX_ODIRECT flag is set,
158 * and holds a shared lock on inode->i_rwsem to ensure that the flag
162 * operations need to wait to grab an exclusive lock in order to clear
164 * Note that buffered writes and truncates both take a write lock on
165 * inode->i_rwsem, meaning that those are serialised w.r.t. O_DIRECT.
168 __acquires(inode->i_rwsem) in netfs_start_io_direct()
174 if (down_read_interruptible(&inode->i_rwsem) < 0) in netfs_start_io_direct()
175 return -ERESTARTSYS; in netfs_start_io_direct()
176 if (test_bit(NETFS_ICTX_ODIRECT, &ictx->flags) != 0) in netfs_start_io_direct()
178 up_read(&inode->i_rwsem); in netfs_start_io_direct()
181 if (down_write_killable(&inode->i_rwsem) < 0) in netfs_start_io_direct()
182 return -ERESTARTSYS; in netfs_start_io_direct()
185 up_write(&inode->i_rwsem); in netfs_start_io_direct()
188 downgrade_write(&inode->i_rwsem); in netfs_start_io_direct()
194 * netfs_end_io_direct - declare that the direct i/o operation is done
198 * lock on inode->i_rwsem.
201 __releases(inode->i_rwsem) in netfs_end_io_direct()
203 up_read(&inode->i_rwsem); in netfs_end_io_direct()