ocfs2: add functions to add and remove inode in orphan dir
PATCH v6 2/9 ocfs2: add functions to add and remove inode in orphan dir
Add functions to add inode to orphan dir and remove inode in orphan dir. Here we do not call ocfs2_prepare_orphan_dir and ocfs2_orphan_add directly. Because append O_DIRECT will add inode to orphan two and may result in more than one orphan entry for the same inode.
Signed-off-by Joseph Qi <[email protected]>
Cc Weiwei Wang <[email protected]>
--- fs/ocfs2/inode.c | 2 +- fs/ocfs2/journal.h | 5 ++ fs/ocfs2/namei.c | 248 ++++++++++++++++++++++++++++++++++++++++++++++------ fs/ocfs2/namei.h | 8 +- fs/ocfs2/ocfs2_fs.h | 6 +- 5 files changed, 239 insertions(+), 30 deletions(-)
fs/ocfs2/inode.c +1 -1
@@ -648,7 +648,7 @@ static int ocfs2_remove_inode(struct inode *inode,if (!(OCFS2_I (inode)->ip_flags &OCFS2_INODE_SKIP_ORPHAN_DIR )) { status =ocfs2_orphan_del (osb, handle, orphan_dir_inode, inode, - orphan_dir_bh); + orphan_dir_bh, false);if (status <0 ) {mlog_errno (status); goto bail_commit;
fs/ocfs2/journal.h +5 -0
@@ -472,6 +472,11 @@ static inline int ocfs2_unlink_credits(struct super_block *sb)* orphan dir index leaf */ #define OCFS2_DELETE_INODE_CREDITS (3 * OCFS2_INODE_UPDATE_CREDITS + 4) +/* dinode + orphan dir dinode + extent tree leaf block + orphan dir entry + +* orphan dir index root + orphan dir index leaf */ +#define OCFS2_INODE_ADD_TO_ORPHAN_CREDITS (2 * OCFS2_INODE_UPDATE_CREDITS + 4) +#define OCFS2_INODE_DEL_FROM_ORPHAN_CREDITS OCFS2_INODE_ADD_TO_ORPHAN_CREDITS +/* dinode update, old dir dinode update, new dir dinode update, old * dir dir entry, new dir dir entry, dir entry update for renaming * directory + target unlink + 3 x dir index leaves */
fs/ocfs2/namei.c +221 -27
385 lines not on this page · raw message
fs/ocfs2/namei.h +7 -1
@@ -34,10 +34,16 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,handle_t *handle, struct inode *orphan_dir_inode, struct inode *inode, - struct buffer_head *orphan_dir_bh); + struct buffer_head *orphan_dir_bh, + bool dio);int ocfs2_create_inode_in_orphan (struct inode *dir,int mode,struct inode **new_inode); +int ocfs2_add_inode_to_orphan (struct ocfs2_super *osb, +struct inode *inode); +int ocfs2_del_inode_from_orphan (struct ocfs2_super *osb, +struct inode *inode,int update_isize, +loff_t end);int ocfs2_mv_orphaned_inode_to_new (struct inode *dir,struct inode *new_inode,struct dentry *new_dentry);
fs/ocfs2/ocfs2_fs.h +5 -1
@@ -229,6 +229,8 @@#define OCFS2_CHAIN_FL (0x00000400)/* Chain allocator */ #define OCFS2_DEALLOC_FL (0x00000800)/* Truncate log */ #define OCFS2_QUOTA_FL (0x00001000)/* Quota file */ +#define OCFS2_DIO_ORPHANED_FL (0X00002000)/* On the orphan list especially +* for dio */ /* * Flags on ocfs2_dinode.i_dyn_features
@@ -729,7 +731,9 @@ struct ocfs2_dinode {inode belongs to. Only valid if allocated from a discontiguous block group */ -/*A0*/ __le64 i_reserved2[3 ]; +/*A0*/ __le16 i_dio_orphaned_slot;/* only used for append dio write */ +__le16 i_reserved1[3 ]; +__le64 i_reserved2[2 ];/*B8*/ union {__le64 i_pad1;/* Generic way to refer to this 64bit union */
Signature · 1 line
1.8.4.3