Skip to content

Commit b0683aa

Browse files
author
Al Viro
committed
new helper: end_writeback()
Essentially, the minimal variant of ->evict_inode(). It's a trimmed-down clear_inode(), sans any fs callbacks. Once it returns we know that no async writeback will be happening; every ->evict_inode() instance should do that once and do that before doing anything ->write_inode() could interfere with (e.g. freeing the on-disk inode). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 661074e commit b0683aa

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎fs/hugetlbfs/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static void truncate_hugepages(struct inode *inode, loff_t lstart)
374374
static void hugetlbfs_evict_inode(struct inode *inode)
375375
{
376376
truncate_hugepages(inode, 0);
377-
clear_inode(inode);
377+
end_writeback(inode);
378378
}
379379

380380
static inline void

‎fs/inode.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,18 @@ void __iget(struct inode *inode)
294294
inodes_stat.nr_unused--;
295295
}
296296

297+
void end_writeback(struct inode *inode)
298+
{
299+
might_sleep();
300+
BUG_ON(inode->i_data.nrpages);
301+
BUG_ON(!list_empty(&inode->i_data.private_list));
302+
BUG_ON(!(inode->i_state & I_FREEING));
303+
BUG_ON(inode->i_state & I_CLEAR);
304+
inode_sync_wait(inode);
305+
inode->i_state = I_FREEING | I_CLEAR;
306+
}
307+
EXPORT_SYMBOL(end_writeback);
308+
297309
/**
298310
* clear_inode - clear an inode
299311
* @inode: inode to clear

‎include/linux/fs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,7 @@ extern void unlock_new_inode(struct inode *);
21842184
extern void __iget(struct inode * inode);
21852185
extern void iget_failed(struct inode *);
21862186
extern void clear_inode(struct inode *);
2187+
extern void end_writeback(struct inode *);
21872188
extern void destroy_inode(struct inode *);
21882189
extern void __destroy_inode(struct inode *);
21892190
extern struct inode *new_inode(struct super_block *);

0 commit comments

Comments
 (0)