Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

inode: remove __I_DIO_WAKEUP

Afaict, we can just rely on inode->i_dio_count for waiting instead of
this awkward indirection through __I_DIO_WAKEUP. This survives LTP dio
and xfstests dio tests.

Link: https://lore.kernel.org/r/20240816-vfs-misc-dio-v1-1-80fe21a2c710@kernel.org
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+19 -34
+11 -12
fs/inode.c
··· 2500 2500 /* 2501 2501 * Direct i/o helper functions 2502 2502 */ 2503 - static void __inode_dio_wait(struct inode *inode) 2503 + bool inode_dio_finished(const struct inode *inode) 2504 2504 { 2505 - wait_queue_head_t *wq = bit_waitqueue(&inode->i_state, __I_DIO_WAKEUP); 2506 - DEFINE_WAIT_BIT(q, &inode->i_state, __I_DIO_WAKEUP); 2507 - 2508 - do { 2509 - prepare_to_wait(wq, &q.wq_entry, TASK_UNINTERRUPTIBLE); 2510 - if (atomic_read(&inode->i_dio_count)) 2511 - schedule(); 2512 - } while (atomic_read(&inode->i_dio_count)); 2513 - finish_wait(wq, &q.wq_entry); 2505 + return atomic_read(&inode->i_dio_count) == 0; 2514 2506 } 2507 + EXPORT_SYMBOL(inode_dio_finished); 2515 2508 2516 2509 /** 2517 2510 * inode_dio_wait - wait for outstanding DIO requests to finish ··· 2518 2525 */ 2519 2526 void inode_dio_wait(struct inode *inode) 2520 2527 { 2521 - if (atomic_read(&inode->i_dio_count)) 2522 - __inode_dio_wait(inode); 2528 + wait_var_event(&inode->i_dio_count, inode_dio_finished(inode)); 2523 2529 } 2524 2530 EXPORT_SYMBOL(inode_dio_wait); 2531 + 2532 + void inode_dio_wait_interruptible(struct inode *inode) 2533 + { 2534 + wait_var_event_interruptible(&inode->i_dio_count, 2535 + inode_dio_finished(inode)); 2536 + } 2537 + EXPORT_SYMBOL(inode_dio_wait_interruptible); 2525 2538 2526 2539 /* 2527 2540 * inode_set_flags - atomically set some inode flags
+5 -17
fs/netfs/locking.c
··· 19 19 * Must be called under a lock that serializes taking new references 20 20 * to i_dio_count, usually by inode->i_mutex. 21 21 */ 22 - static int inode_dio_wait_interruptible(struct inode *inode) 22 + static int netfs_inode_dio_wait_interruptible(struct inode *inode) 23 23 { 24 - if (!atomic_read(&inode->i_dio_count)) 24 + if (inode_dio_finished(inode)) 25 25 return 0; 26 26 27 - wait_queue_head_t *wq = bit_waitqueue(&inode->i_state, __I_DIO_WAKEUP); 28 - DEFINE_WAIT_BIT(q, &inode->i_state, __I_DIO_WAKEUP); 29 - 30 - for (;;) { 31 - prepare_to_wait(wq, &q.wq_entry, TASK_INTERRUPTIBLE); 32 - if (!atomic_read(&inode->i_dio_count)) 33 - break; 34 - if (signal_pending(current)) 35 - break; 36 - schedule(); 37 - } 38 - finish_wait(wq, &q.wq_entry); 39 - 40 - return atomic_read(&inode->i_dio_count) ? -ERESTARTSYS : 0; 27 + inode_dio_wait_interruptible(inode); 28 + return !inode_dio_finished(inode) ? -ERESTARTSYS : 0; 41 29 } 42 30 43 31 /* Call with exclusively locked inode->i_rwsem */ ··· 34 46 if (!test_bit(NETFS_ICTX_ODIRECT, &ictx->flags)) 35 47 return 0; 36 48 clear_bit(NETFS_ICTX_ODIRECT, &ictx->flags); 37 - return inode_dio_wait_interruptible(&ictx->inode); 49 + return netfs_inode_dio_wait_interruptible(&ictx->inode); 38 50 } 39 51 40 52 /**
+3 -5
include/linux/fs.h
··· 2373 2373 * 2374 2374 * I_REFERENCED Marks the inode as recently references on the LRU list. 2375 2375 * 2376 - * I_DIO_WAKEUP Never set. Only used as a key for wait_on_bit(). 2377 - * 2378 2376 * I_WB_SWITCH Cgroup bdi_writeback switching in progress. Used to 2379 2377 * synchronize competing switching instances and to tell 2380 2378 * wb stat updates to grab the i_pages lock. See ··· 2407 2409 #define __I_SYNC 7 2408 2410 #define I_SYNC (1 << __I_SYNC) 2409 2411 #define I_REFERENCED (1 << 8) 2410 - #define __I_DIO_WAKEUP 9 2411 - #define I_DIO_WAKEUP (1 << __I_DIO_WAKEUP) 2412 2412 #define I_LINKABLE (1 << 10) 2413 2413 #define I_DIRTY_TIME (1 << 11) 2414 2414 #define I_WB_SWITCH (1 << 13) ··· 3223 3227 } 3224 3228 #endif 3225 3229 3230 + bool inode_dio_finished(const struct inode *inode); 3226 3231 void inode_dio_wait(struct inode *inode); 3232 + void inode_dio_wait_interruptible(struct inode *inode); 3227 3233 3228 3234 /** 3229 3235 * inode_dio_begin - signal start of a direct I/O requests ··· 3249 3251 static inline void inode_dio_end(struct inode *inode) 3250 3252 { 3251 3253 if (atomic_dec_and_test(&inode->i_dio_count)) 3252 - wake_up_bit(&inode->i_state, __I_DIO_WAKEUP); 3254 + wake_up_var(&inode->i_dio_count); 3253 3255 } 3254 3256 3255 3257 extern void inode_set_flags(struct inode *inode, unsigned int flags,