Skip to content

Commit

Permalink
vfs: Rename end_writeback() to clear_inode()
Browse files Browse the repository at this point in the history
After we moved inode_sync_wait() from end_writeback() it doesn't make sense
to call the function end_writeback() anymore. Rename it to clear_inode()
which well says what the function really does - set I_CLEAR flag.

Signed-off-by: Jan Kara <[email protected]>
Signed-off-by: Fengguang Wu <[email protected]>
  • Loading branch information
jankara authored and Fengguang Wu committed May 6, 2012
1 parent 7994e6f commit dbd5768
Show file tree
Hide file tree
Showing 52 changed files with 68 additions and 70 deletions.
16 changes: 7 additions & 9 deletions Documentation/filesystems/porting
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ in the beginning of ->setattr unconditionally.
be used instead. It gets called whenever the inode is evicted, whether it has
remaining links or not. Caller does *not* evict the pagecache or inode-associated
metadata buffers; getting rid of those is responsibility of method, as it had
been for ->delete_inode().
been for ->delete_inode(). Caller makes sure async writeback cannot be running
for the inode while (or after) ->evict_inode() is called.

->drop_inode() returns int now; it's called on final iput() with
inode->i_lock held and it returns true if filesystems wants the inode to be
Expand All @@ -306,14 +307,11 @@ updated appropriately. generic_delete_inode() is also alive and it consists
simply of return 1. Note that all actual eviction work is done by caller after
->drop_inode() returns.

clear_inode() is gone; use end_writeback() instead. As before, it must
be called exactly once on each call of ->evict_inode() (as it used to be for
each call of ->delete_inode()). Unlike before, if you are using inode-associated
metadata buffers (i.e. mark_buffer_dirty_inode()), it's your responsibility to
call invalidate_inode_buffers() before end_writeback().
No async writeback (and thus no calls of ->write_inode()) will happen
after end_writeback() returns, so actions that should not overlap with ->write_inode()
(e.g. freeing on-disk inode if i_nlink is 0) ought to be done after that call.
As before, clear_inode() must be called exactly once on each call of
->evict_inode() (as it used to be for each call of ->delete_inode()). Unlike
before, if you are using inode-associated metadata buffers (i.e.
mark_buffer_dirty_inode()), it's your responsibility to call
invalidate_inode_buffers() before clear_inode().

NOTE: checking i_nlink in the beginning of ->write_inode() and bailing out
if it's zero is not *and* *never* *had* *been* enough. Final unlink() and iput()
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static void
spufs_evict_inode(struct inode *inode)
{
struct spufs_inode_info *ei = SPUFS_I(inode);
end_writeback(inode);
clear_inode(inode);
if (ei->i_ctx)
put_spu_context(ei->i_ctx);
if (ei->i_gang)
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/hypfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode)

static void hypfs_evict_inode(struct inode *inode)
{
end_writeback(inode);
clear_inode(inode);
kfree(inode->i_private);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ void v9fs_evict_inode(struct inode *inode)
struct v9fs_inode *v9inode = V9FS_I(inode);

truncate_inode_pages(inode->i_mapping, 0);
end_writeback(inode);
clear_inode(inode);
filemap_fdatawrite(inode->i_mapping);

#ifdef CONFIG_9P_FSCACHE
Expand Down
2 changes: 1 addition & 1 deletion fs/affs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ affs_evict_inode(struct inode *inode)
}

invalidate_inode_buffers(inode);
end_writeback(inode);
clear_inode(inode);
affs_free_prealloc(inode);
cache_page = (unsigned long)AFFS_I(inode)->i_lc;
if (cache_page) {
Expand Down
2 changes: 1 addition & 1 deletion fs/afs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ void afs_evict_inode(struct inode *inode)
ASSERTCMP(inode->i_ino, ==, vnode->fid.vnode);

truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);

afs_give_up_callback(vnode);

Expand Down
2 changes: 1 addition & 1 deletion fs/autofs4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static int autofs4_show_options(struct seq_file *m, struct dentry *root)

static void autofs4_evict_inode(struct inode *inode)
{
end_writeback(inode);
clear_inode(inode);
kfree(inode->i_private);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/bfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static void bfs_evict_inode(struct inode *inode)

truncate_inode_pages(&inode->i_data, 0);
invalidate_inode_buffers(inode);
end_writeback(inode);
clear_inode(inode);

if (inode->i_nlink)
return;
Expand Down
2 changes: 1 addition & 1 deletion fs/binfmt_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)

static void bm_evict_inode(struct inode *inode)
{
end_writeback(inode);
clear_inode(inode);
kfree(inode->i_private);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ static void bdev_evict_inode(struct inode *inode)
struct list_head *p;
truncate_inode_pages(&inode->i_data, 0);
invalidate_inode_buffers(inode); /* is it needed here? */
end_writeback(inode);
clear_inode(inode);
spin_lock(&bdev_lock);
while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) {
__bd_forget(list_entry(p, struct inode, i_devices));
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3756,7 +3756,7 @@ void btrfs_evict_inode(struct inode *inode)
btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr);
no_delete:
end_writeback(inode);
clear_inode(inode);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static void
cifs_evict_inode(struct inode *inode)
{
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
cifs_fscache_release_inode_cookie(inode);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/coda/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static void coda_put_super(struct super_block *sb)
static void coda_evict_inode(struct inode *inode)
{
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
coda_cache_clear_inode(inode);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/ecryptfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static int ecryptfs_statfs(struct dentry *dentry, struct kstatfs *buf)
static void ecryptfs_evict_inode(struct inode *inode)
{
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
iput(ecryptfs_inode_to_lower(inode));
}

Expand Down
4 changes: 2 additions & 2 deletions fs/exofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ void exofs_evict_inode(struct inode *inode)
goto no_delete;

inode->i_size = 0;
end_writeback(inode);
clear_inode(inode);

/* if we are deleting an obj that hasn't been created yet, wait.
* This also makes sure that create_done cannot be called with an
Expand Down Expand Up @@ -1503,5 +1503,5 @@ void exofs_evict_inode(struct inode *inode)
return;

no_delete:
end_writeback(inode);
clear_inode(inode);
}
2 changes: 1 addition & 1 deletion fs/ext2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void ext2_evict_inode(struct inode * inode)
}

invalidate_inode_buffers(inode);
end_writeback(inode);
clear_inode(inode);

ext2_discard_reservation(inode);
rsv = EXT2_I(inode)->i_block_alloc_info;
Expand Down
6 changes: 3 additions & 3 deletions fs/ext3/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,18 @@ void ext3_evict_inode (struct inode *inode)
if (ext3_mark_inode_dirty(handle, inode)) {
/* If that failed, just dquot_drop() and be done with that */
dquot_drop(inode);
end_writeback(inode);
clear_inode(inode);
} else {
ext3_xattr_delete_inode(handle, inode);
dquot_free_inode(inode);
dquot_drop(inode);
end_writeback(inode);
clear_inode(inode);
ext3_free_inode(handle, inode);
}
ext3_journal_stop(handle);
return;
no_delete:
end_writeback(inode);
clear_inode(inode);
dquot_drop(inode);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ static void destroy_inodecache(void)
void ext4_clear_inode(struct inode *inode)
{
invalidate_inode_buffers(inode);
end_writeback(inode);
clear_inode(inode);
dquot_drop(inode);
ext4_discard_preallocations(inode);
if (EXT4_I(inode)->jinode) {
Expand Down
2 changes: 1 addition & 1 deletion fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ static void fat_evict_inode(struct inode *inode)
fat_truncate_blocks(inode, 0);
}
invalidate_inode_buffers(inode);
end_writeback(inode);
clear_inode(inode);
fat_cache_inval_inode(inode);
fat_detach(inode);
}
Expand Down
2 changes: 1 addition & 1 deletion fs/freevxfs/vxfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,6 @@ void
vxfs_evict_inode(struct inode *ip)
{
truncate_inode_pages(&ip->i_data, 0);
end_writeback(ip);
clear_inode(ip);
call_rcu(&ip->i_rcu, vxfs_i_callback);
}
2 changes: 1 addition & 1 deletion fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static void fuse_destroy_inode(struct inode *inode)
static void fuse_evict_inode(struct inode *inode)
{
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
if (inode->i_sb->s_flags & MS_ACTIVE) {
struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_inode *fi = get_fuse_inode(inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ static void gfs2_evict_inode(struct inode *inode)
out:
/* Case 3 starts here */
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
gfs2_dir_hash_inval(ip);
ip->i_gl->gl_object = NULL;
flush_delayed_work_sync(&ip->i_gl->gl_work);
Expand Down
2 changes: 1 addition & 1 deletion fs/hfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry,
void hfs_evict_inode(struct inode *inode)
{
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
if (HFS_IS_RSRC(inode) && HFS_I(inode)->rsrc_inode) {
HFS_I(HFS_I(inode)->rsrc_inode)->rsrc_inode = NULL;
iput(HFS_I(inode)->rsrc_inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/hfsplus/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static void hfsplus_evict_inode(struct inode *inode)
{
dprint(DBG_INODE, "hfsplus_evict_inode: %lu\n", inode->i_ino);
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
if (HFSPLUS_IS_RSRC(inode)) {
HFSPLUS_I(HFSPLUS_I(inode)->rsrc_inode)->rsrc_inode = NULL;
iput(HFSPLUS_I(inode)->rsrc_inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/hostfs/hostfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static struct inode *hostfs_alloc_inode(struct super_block *sb)
static void hostfs_evict_inode(struct inode *inode)
{
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
if (HOSTFS_I(inode)->fd != -1) {
close_file(&HOSTFS_I(inode)->fd);
HOSTFS_I(inode)->fd = -1;
Expand Down
2 changes: 1 addition & 1 deletion fs/hpfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void hpfs_write_if_changed(struct inode *inode)
void hpfs_evict_inode(struct inode *inode)
{
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
if (!inode->i_nlink) {
hpfs_lock(inode->i_sb);
hpfs_remove_fnode(inode->i_sb, inode->i_ino);
Expand Down
2 changes: 1 addition & 1 deletion fs/hppfs/hppfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ static struct inode *hppfs_alloc_inode(struct super_block *sb)

void hppfs_evict_inode(struct inode *ino)
{
end_writeback(ino);
clear_inode(ino);
dput(HPPFS_I(ino)->proc_dentry);
mntput(ino->i_sb->s_fs_info);
}
Expand Down
2 changes: 1 addition & 1 deletion fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ static void truncate_hugepages(struct inode *inode, loff_t lstart)
static void hugetlbfs_evict_inode(struct inode *inode)
{
truncate_hugepages(inode, 0);
end_writeback(inode);
clear_inode(inode);
}

static inline void
Expand Down
6 changes: 3 additions & 3 deletions fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void __remove_inode_hash(struct inode *inode)
}
EXPORT_SYMBOL(__remove_inode_hash);

void end_writeback(struct inode *inode)
void clear_inode(struct inode *inode)
{
might_sleep();
/*
Expand All @@ -503,7 +503,7 @@ void end_writeback(struct inode *inode)
/* don't need i_lock here, no concurrent mods to i_state */
inode->i_state = I_FREEING | I_CLEAR;
}
EXPORT_SYMBOL(end_writeback);
EXPORT_SYMBOL(clear_inode);

/*
* Free the inode passed in, removing it from the lists it is still connected
Expand Down Expand Up @@ -537,7 +537,7 @@ static void evict(struct inode *inode)
} else {
if (inode->i_data.nrpages)
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
}
if (S_ISBLK(inode->i_mode) && inode->i_bdev)
bd_forget(inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/jffs2/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void jffs2_evict_inode (struct inode *inode)
jffs2_dbg(1, "%s(): ino #%lu mode %o\n",
__func__, inode->i_ino, inode->i_mode);
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
jffs2_do_clear_inode(c, f);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void jfs_evict_inode(struct inode *inode)
} else {
truncate_inode_pages(&inode->i_data, 0);
}
end_writeback(inode);
clear_inode(inode);
dquot_drop(inode);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/logfs/readwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,7 @@ void logfs_evict_inode(struct inode *inode)
}
}
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);

/* Cheaper version of write_inode. All changes are concealed in
* aliases, which are moved back. No write to the medium happens.
Expand Down
2 changes: 1 addition & 1 deletion fs/minix/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static void minix_evict_inode(struct inode *inode)
minix_truncate(inode);
}
invalidate_inode_buffers(inode);
end_writeback(inode);
clear_inode(inode);
if (!inode->i_nlink)
minix_free_inode(inode);
}
Expand Down
2 changes: 1 addition & 1 deletion fs/ncpfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static void
ncp_evict_inode(struct inode *inode)
{
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);

if (S_ISDIR(inode->i_mode)) {
DDPRINTK("ncp_evict_inode: put directory %ld\n", inode->i_ino);
Expand Down
4 changes: 2 additions & 2 deletions fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static void nfs_clear_inode(struct inode *inode)
void nfs_evict_inode(struct inode *inode)
{
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
nfs_clear_inode(inode);
}

Expand Down Expand Up @@ -1500,7 +1500,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
void nfs4_evict_inode(struct inode *inode)
{
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
pnfs_return_layout(inode);
pnfs_destroy_layout(NFS_I(inode));
/* If we are holding a delegation, return it! */
Expand Down
4 changes: 2 additions & 2 deletions fs/nilfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ void nilfs_evict_inode(struct inode *inode)
if (inode->i_nlink || !ii->i_root || unlikely(is_bad_inode(inode))) {
if (inode->i_data.nrpages)
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
clear_inode(inode);
nilfs_clear_inode(inode);
return;
}
Expand All @@ -746,7 +746,7 @@ void nilfs_evict_inode(struct inode *inode)
/* TODO: some of the following operations may fail. */
nilfs_truncate_bmap(ii, 0);
nilfs_mark_inode_dirty(inode);
end_writeback(inode);
clear_inode(inode);

ret = nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino);
if (!ret)
Expand Down
Loading

0 comments on commit dbd5768

Please sign in to comment.