summaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-06-28 15:53:17 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2018-08-03 15:55:30 -0400
commitc2b6d621c4ffe9936adf7a55c8b1c769672c306f (patch)
treed13dbb52a33dd594a78b8996132c7e7bba6f296f /include/linux/fs.h
parentc971e6a006175bd0f195c6346c4e8bc4089bec00 (diff)
new primitive: discard_new_inode()
We don't want open-by-handle picking half-set-up in-core struct inode from e.g. mkdir() having failed halfway through. In other words, we don't want such inodes returned by iget_locked() on their way to extinction. However, we can't just have them unhashed - otherwise open-by-handle immediately *after* that would've ended up creating a new in-core inode over the on-disk one that is in process of being freed right under us. Solution: new flag (I_CREATING) set by insert_inode_locked() and removed by unlock_new_inode() and a new primitive (discard_new_inode()) to be used by such halfway-through-setup failure exits instead of unlock_new_inode() / iput() combinations. That primitive unlocks new inode, but leaves I_CREATING in place. iget_locked() treats finding an I_CREATING inode as failure (-ESTALE, once we sort out the error propagation). insert_inode_locked() treats the same as instant -EBUSY. ilookup() treats those as icache miss. [Fix by Dan Carpenter <dan.carpenter@oracle.com> folded in] Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5c91108846db..a42600565925 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2016,6 +2016,8 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
2016 * I_OVL_INUSE Used by overlayfs to get exclusive ownership on upper 2016 * I_OVL_INUSE Used by overlayfs to get exclusive ownership on upper
2017 * and work dirs among overlayfs mounts. 2017 * and work dirs among overlayfs mounts.
2018 * 2018 *
2019 * I_CREATING New object's inode in the middle of setting up.
2020 *
2019 * Q: What is the difference between I_WILL_FREE and I_FREEING? 2021 * Q: What is the difference between I_WILL_FREE and I_FREEING?
2020 */ 2022 */
2021#define I_DIRTY_SYNC (1 << 0) 2023#define I_DIRTY_SYNC (1 << 0)
@@ -2036,7 +2038,8 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
2036#define __I_DIRTY_TIME_EXPIRED 12 2038#define __I_DIRTY_TIME_EXPIRED 12
2037#define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED) 2039#define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED)
2038#define I_WB_SWITCH (1 << 13) 2040#define I_WB_SWITCH (1 << 13)
2039#define I_OVL_INUSE (1 << 14) 2041#define I_OVL_INUSE (1 << 14)
2042#define I_CREATING (1 << 15)
2040 2043
2041#define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC) 2044#define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
2042#define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES) 2045#define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES)
@@ -2919,6 +2922,7 @@ extern void lockdep_annotate_inode_mutex_key(struct inode *inode);
2919static inline void lockdep_annotate_inode_mutex_key(struct inode *inode) { }; 2922static inline void lockdep_annotate_inode_mutex_key(struct inode *inode) { };
2920#endif 2923#endif
2921extern void unlock_new_inode(struct inode *); 2924extern void unlock_new_inode(struct inode *);
2925extern void discard_new_inode(struct inode *);
2922extern unsigned int get_next_ino(void); 2926extern unsigned int get_next_ino(void);
2923extern void evict_inodes(struct super_block *sb); 2927extern void evict_inodes(struct super_block *sb);
2924 2928