Ocfs2: Journaling i_flags and i_orphaned_slot when adding inode to orphan dir.

Currently, some callers were missing to journal the dirty inode after
adding it to orphan dir.

Now we're going to journal such modifications within the ocfs2_orphan_add()
itself, It's safe to do so, though some existing caller may duplicate this,
and it makes the logic look more straightforward anyway.

Signed-off-by: Tristan Ye <tristan.ye@oracle.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>

authored by Tristan Ye and committed by Joel Becker 3939fda4 b4414eea

+23 -5
+23 -5
fs/ocfs2/namei.c
··· 84 static int ocfs2_orphan_add(struct ocfs2_super *osb, 85 handle_t *handle, 86 struct inode *inode, 87 - struct ocfs2_dinode *fe, 88 char *name, 89 struct ocfs2_dir_lookup_result *lookup, 90 struct inode *orphan_dir_inode); ··· 879 fe = (struct ocfs2_dinode *) fe_bh->b_data; 880 881 if (inode_is_unlinkable(inode)) { 882 - status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name, 883 &orphan_insert, orphan_dir); 884 if (status < 0) { 885 mlog_errno(status); ··· 1300 if (S_ISDIR(new_inode->i_mode) || 1301 (ocfs2_read_links_count(newfe) == 1)) { 1302 status = ocfs2_orphan_add(osb, handle, new_inode, 1303 - newfe, orphan_name, 1304 &orphan_insert, orphan_dir); 1305 if (status < 0) { 1306 mlog_errno(status); ··· 1911 static int ocfs2_orphan_add(struct ocfs2_super *osb, 1912 handle_t *handle, 1913 struct inode *inode, 1914 - struct ocfs2_dinode *fe, 1915 char *name, 1916 struct ocfs2_dir_lookup_result *lookup, 1917 struct inode *orphan_dir_inode) ··· 1919 struct buffer_head *orphan_dir_bh = NULL; 1920 int status = 0; 1921 struct ocfs2_dinode *orphan_fe; 1922 1923 mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); 1924 ··· 1960 goto leave; 1961 } 1962 1963 le32_add_cpu(&fe->i_flags, OCFS2_ORPHANED_FL); 1964 1965 /* Record which orphan dir our inode now resides 1966 * in. delete_inode will use this to determine which orphan 1967 * dir to lock. */ 1968 fe->i_orphaned_slot = cpu_to_le16(osb->slot_num); 1969 1970 mlog(0, "Inode %llu orphaned in slot %d\n", 1971 (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num); ··· 2141 } 2142 2143 di = (struct ocfs2_dinode *)new_di_bh->b_data; 2144 - status = ocfs2_orphan_add(osb, handle, inode, di, orphan_name, 2145 &orphan_insert, orphan_dir); 2146 if (status < 0) { 2147 mlog_errno(status);
··· 84 static int ocfs2_orphan_add(struct ocfs2_super *osb, 85 handle_t *handle, 86 struct inode *inode, 87 + struct buffer_head *fe_bh, 88 char *name, 89 struct ocfs2_dir_lookup_result *lookup, 90 struct inode *orphan_dir_inode); ··· 879 fe = (struct ocfs2_dinode *) fe_bh->b_data; 880 881 if (inode_is_unlinkable(inode)) { 882 + status = ocfs2_orphan_add(osb, handle, inode, fe_bh, orphan_name, 883 &orphan_insert, orphan_dir); 884 if (status < 0) { 885 mlog_errno(status); ··· 1300 if (S_ISDIR(new_inode->i_mode) || 1301 (ocfs2_read_links_count(newfe) == 1)) { 1302 status = ocfs2_orphan_add(osb, handle, new_inode, 1303 + newfe_bh, orphan_name, 1304 &orphan_insert, orphan_dir); 1305 if (status < 0) { 1306 mlog_errno(status); ··· 1911 static int ocfs2_orphan_add(struct ocfs2_super *osb, 1912 handle_t *handle, 1913 struct inode *inode, 1914 + struct buffer_head *fe_bh, 1915 char *name, 1916 struct ocfs2_dir_lookup_result *lookup, 1917 struct inode *orphan_dir_inode) ··· 1919 struct buffer_head *orphan_dir_bh = NULL; 1920 int status = 0; 1921 struct ocfs2_dinode *orphan_fe; 1922 + struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data; 1923 1924 mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); 1925 ··· 1959 goto leave; 1960 } 1961 1962 + /* 1963 + * We're going to journal the change of i_flags and i_orphaned_slot. 1964 + * It's safe anyway, though some callers may duplicate the journaling. 1965 + * Journaling within the func just make the logic look more 1966 + * straightforward. 1967 + */ 1968 + status = ocfs2_journal_access_di(handle, 1969 + INODE_CACHE(inode), 1970 + fe_bh, 1971 + OCFS2_JOURNAL_ACCESS_WRITE); 1972 + if (status < 0) { 1973 + mlog_errno(status); 1974 + goto leave; 1975 + } 1976 + 1977 le32_add_cpu(&fe->i_flags, OCFS2_ORPHANED_FL); 1978 1979 /* Record which orphan dir our inode now resides 1980 * in. delete_inode will use this to determine which orphan 1981 * dir to lock. */ 1982 fe->i_orphaned_slot = cpu_to_le16(osb->slot_num); 1983 + 1984 + ocfs2_journal_dirty(handle, fe_bh); 1985 1986 mlog(0, "Inode %llu orphaned in slot %d\n", 1987 (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num); ··· 2123 } 2124 2125 di = (struct ocfs2_dinode *)new_di_bh->b_data; 2126 + status = ocfs2_orphan_add(osb, handle, inode, new_di_bh, orphan_name, 2127 &orphan_insert, orphan_dir); 2128 if (status < 0) { 2129 mlog_errno(status);