Skip to content

Commit

Permalink
new helper: inode_fake_hash()
Browse files Browse the repository at this point in the history
open-coded in a quite a few places...

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Aug 3, 2018
1 parent e950564 commit 5bef915
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fs/hfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry,
HFS_I(inode)->rsrc_inode = dir;
HFS_I(dir)->rsrc_inode = inode;
igrab(dir);
hlist_add_fake(&inode->i_hash);
inode_fake_hash(inode);
mark_inode_dirty(inode);
dont_mount(dentry);
out:
Expand Down
8 changes: 1 addition & 7 deletions fs/jfs/jfs_imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,7 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
/* release the page */
release_metapage(mp);

/*
* __mark_inode_dirty expects inodes to be hashed. Since we don't
* want special inodes in the fileset inode space, we make them
* appear hashed, but do not put on any lists. hlist_del()
* will work fine and require no locking.
*/
hlist_add_fake(&ip->i_hash);
inode_fake_hash(ip);

return (ip);
}
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
inode->i_ino = 0;
inode->i_size = i_size_read(sb->s_bdev->bd_inode);
inode->i_mapping->a_ops = &jfs_metapage_aops;
hlist_add_fake(&inode->i_hash);
inode_fake_hash(inode);
mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);

sbi->direct_inode = inode;
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/xfs_iops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ xfs_setup_inode(

inode_sb_list_add(inode);
/* make the inode look hashed for the writeback code */
hlist_add_fake(&inode->i_hash);
inode_fake_hash(inode);

inode->i_uid = xfs_uid_to_kuid(ip->i_d.di_uid);
inode->i_gid = xfs_gid_to_kgid(ip->i_d.di_gid);
Expand Down
11 changes: 11 additions & 0 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,17 @@ static inline int inode_unhashed(struct inode *inode)
return hlist_unhashed(&inode->i_hash);
}

/*
* __mark_inode_dirty expects inodes to be hashed. Since we don't
* want special inodes in the fileset inode space, we make them
* appear hashed, but do not put on any lists. hlist_del()
* will work fine and require no locking.
*/
static inline void inode_fake_hash(struct inode *inode)
{
hlist_add_fake(&inode->i_hash);
}

/*
* inode->i_mutex nesting subclasses for the lock validator:
*
Expand Down

0 comments on commit 5bef915

Please sign in to comment.