Skip to content

Commit

Permalink
new helper: end_writeback()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Al Viro committed Aug 9, 2010
1 parent 661074e commit b0683aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ static void truncate_hugepages(struct inode *inode, loff_t lstart)
static void hugetlbfs_evict_inode(struct inode *inode)
{
truncate_hugepages(inode, 0);
clear_inode(inode);
end_writeback(inode);
}

static inline void
Expand Down
12 changes: 12 additions & 0 deletions fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,18 @@ void __iget(struct inode *inode)
inodes_stat.nr_unused--;
}

void end_writeback(struct inode *inode)
{
might_sleep();
BUG_ON(inode->i_data.nrpages);
BUG_ON(!list_empty(&inode->i_data.private_list));
BUG_ON(!(inode->i_state & I_FREEING));
BUG_ON(inode->i_state & I_CLEAR);
inode_sync_wait(inode);
inode->i_state = I_FREEING | I_CLEAR;
}
EXPORT_SYMBOL(end_writeback);

/**
* clear_inode - clear an inode
* @inode: inode to clear
Expand Down
1 change: 1 addition & 0 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,7 @@ extern void unlock_new_inode(struct inode *);
extern void __iget(struct inode * inode);
extern void iget_failed(struct inode *);
extern void clear_inode(struct inode *);
extern void end_writeback(struct inode *);
extern void destroy_inode(struct inode *);
extern void __destroy_inode(struct inode *);
extern struct inode *new_inode(struct super_block *);
Expand Down

0 comments on commit b0683aa

Please sign in to comment.