Lines Matching +full:wait +full:- +full:on +full:- +full:write

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.
24 if (!atomic_read(&inode->i_dio_count)) in inode_dio_wait_interruptible()
27 wait_queue_head_t *wq = bit_waitqueue(&inode->i_state, __I_DIO_WAKEUP); in inode_dio_wait_interruptible()
28 DEFINE_WAIT_BIT(q, &inode->i_state, __I_DIO_WAKEUP); in inode_dio_wait_interruptible()
32 if (!atomic_read(&inode->i_dio_count)) in inode_dio_wait_interruptible()
40 return atomic_read(&inode->i_dio_count) ? -ERESTARTSYS : 0; in inode_dio_wait_interruptible()
43 /* Call with exclusively locked inode->i_rwsem */
46 if (!test_bit(NETFS_ICTX_ODIRECT, &ictx->flags)) in netfs_block_o_direct()
48 clear_bit(NETFS_ICTX_ODIRECT, &ictx->flags); in netfs_block_o_direct()
49 return inode_dio_wait_interruptible(&ictx->inode); in netfs_block_o_direct()
53 * netfs_start_io_read - declare the file is being used for buffered reads
58 * On exit, the function ensures that the NETFS_ICTX_ODIRECT flag is unset,
59 * and holds a shared lock on inode->i_rwsem to ensure that the flag
63 * operations need to wait to grab an exclusive lock in order to set
65 * Note that buffered writes and truncates both take a write lock on
66 * inode->i_rwsem, meaning that those are serialised w.r.t. the reads.
69 __acquires(inode->i_rwsem) in netfs_start_io_read()
74 if (down_read_interruptible(&inode->i_rwsem) < 0) in netfs_start_io_read()
75 return -ERESTARTSYS; in netfs_start_io_read()
76 if (test_bit(NETFS_ICTX_ODIRECT, &ictx->flags) == 0) in netfs_start_io_read()
78 up_read(&inode->i_rwsem); in netfs_start_io_read()
81 if (down_write_killable(&inode->i_rwsem) < 0) in netfs_start_io_read()
82 return -ERESTARTSYS; in netfs_start_io_read()
84 up_write(&inode->i_rwsem); in netfs_start_io_read()
85 return -ERESTARTSYS; in netfs_start_io_read()
87 downgrade_write(&inode->i_rwsem); in netfs_start_io_read()
93 * netfs_end_io_read - declare that the buffered read operation is done
97 * lock on inode->i_rwsem.
100 __releases(inode->i_rwsem) in netfs_end_io_read()
102 up_read(&inode->i_rwsem); in netfs_end_io_read()
107 * netfs_start_io_write - declare the file is being used for buffered writes
114 __acquires(inode->i_rwsem) in netfs_start_io_write()
118 if (down_write_killable(&inode->i_rwsem) < 0) in netfs_start_io_write()
119 return -ERESTARTSYS; in netfs_start_io_write()
121 up_write(&inode->i_rwsem); in netfs_start_io_write()
122 return -ERESTARTSYS; in netfs_start_io_write()
129 * netfs_end_io_write - declare that the buffered write operation is done
132 * Declare that a buffered write operation is done, and release the
133 * lock on inode->i_rwsem.
136 __releases(inode->i_rwsem) in netfs_end_io_write()
138 up_write(&inode->i_rwsem); in netfs_end_io_write()
142 /* Call with exclusively locked inode->i_rwsem */
148 if (!test_bit(NETFS_ICTX_ODIRECT, &ictx->flags)) { in netfs_block_buffered()
149 set_bit(NETFS_ICTX_ODIRECT, &ictx->flags); in netfs_block_buffered()
150 if (inode->i_mapping->nrpages != 0) { in netfs_block_buffered()
151 unmap_mapping_range(inode->i_mapping, 0, 0, 0); in netfs_block_buffered()
152 ret = filemap_fdatawait(inode->i_mapping); in netfs_block_buffered()
154 clear_bit(NETFS_ICTX_ODIRECT, &ictx->flags); in netfs_block_buffered()
163 * netfs_start_io_direct - declare the file is being used for direct i/o
168 * On exit, the function ensures that the NETFS_ICTX_ODIRECT flag is set,
169 * and holds a shared lock on inode->i_rwsem to ensure that the flag
173 * operations need to wait to grab an exclusive lock in order to clear
175 * Note that buffered writes and truncates both take a write lock on
176 * inode->i_rwsem, meaning that those are serialised w.r.t. O_DIRECT.
179 __acquires(inode->i_rwsem) in netfs_start_io_direct()
185 if (down_read_interruptible(&inode->i_rwsem) < 0) in netfs_start_io_direct()
186 return -ERESTARTSYS; in netfs_start_io_direct()
187 if (test_bit(NETFS_ICTX_ODIRECT, &ictx->flags) != 0) in netfs_start_io_direct()
189 up_read(&inode->i_rwsem); in netfs_start_io_direct()
192 if (down_write_killable(&inode->i_rwsem) < 0) in netfs_start_io_direct()
193 return -ERESTARTSYS; in netfs_start_io_direct()
196 up_write(&inode->i_rwsem); in netfs_start_io_direct()
199 downgrade_write(&inode->i_rwsem); in netfs_start_io_direct()
205 * netfs_end_io_direct - declare that the direct i/o operation is done
209 * lock on inode->i_rwsem.
212 __releases(inode->i_rwsem) in netfs_end_io_direct()
214 up_read(&inode->i_rwsem); in netfs_end_io_direct()