diff options
Diffstat (limited to 'fs/inode.c')
-rw-r--r-- | fs/inode.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/fs/inode.c b/fs/inode.c index 258ec22bb298..2bee20ae3d65 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -286,11 +286,9 @@ static void init_once(void *foo) | |||
286 | */ | 286 | */ |
287 | void __iget(struct inode *inode) | 287 | void __iget(struct inode *inode) |
288 | { | 288 | { |
289 | if (atomic_read(&inode->i_count)) { | 289 | if (atomic_inc_return(&inode->i_count) != 1) |
290 | atomic_inc(&inode->i_count); | ||
291 | return; | 290 | return; |
292 | } | 291 | |
293 | atomic_inc(&inode->i_count); | ||
294 | if (!(inode->i_state & (I_DIRTY|I_SYNC))) | 292 | if (!(inode->i_state & (I_DIRTY|I_SYNC))) |
295 | list_move(&inode->i_list, &inode_in_use); | 293 | list_move(&inode->i_list, &inode_in_use); |
296 | inodes_stat.nr_unused--; | 294 | inodes_stat.nr_unused--; |
@@ -1608,3 +1606,23 @@ void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev) | |||
1608 | inode->i_ino); | 1606 | inode->i_ino); |
1609 | } | 1607 | } |
1610 | EXPORT_SYMBOL(init_special_inode); | 1608 | EXPORT_SYMBOL(init_special_inode); |
1609 | |||
1610 | /** | ||
1611 | * Init uid,gid,mode for new inode according to posix standards | ||
1612 | * @inode: New inode | ||
1613 | * @dir: Directory inode | ||
1614 | * @mode: mode of the new inode | ||
1615 | */ | ||
1616 | void inode_init_owner(struct inode *inode, const struct inode *dir, | ||
1617 | mode_t mode) | ||
1618 | { | ||
1619 | inode->i_uid = current_fsuid(); | ||
1620 | if (dir && dir->i_mode & S_ISGID) { | ||
1621 | inode->i_gid = dir->i_gid; | ||
1622 | if (S_ISDIR(mode)) | ||
1623 | mode |= S_ISGID; | ||
1624 | } else | ||
1625 | inode->i_gid = current_fsgid(); | ||
1626 | inode->i_mode = mode; | ||
1627 | } | ||
1628 | EXPORT_SYMBOL(inode_init_owner); | ||