|
@@ -2013,6 +2013,13 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
|
|
|
err = ext4_reserve_inode_write(handle, inode, &iloc);
|
|
|
if (err)
|
|
|
goto out_unlock;
|
|
|
+ /*
|
|
|
+ * Due to previous errors inode may be already a part of on-disk
|
|
|
+ * orphan list. If so skip on-disk list modification.
|
|
|
+ */
|
|
|
+ if (NEXT_ORPHAN(inode) && NEXT_ORPHAN(inode) <=
|
|
|
+ (le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count)))
|
|
|
+ goto mem_insert;
|
|
|
|
|
|
/* Insert this inode at the head of the on-disk orphan list... */
|
|
|
NEXT_ORPHAN(inode) = le32_to_cpu(EXT4_SB(sb)->s_es->s_last_orphan);
|
|
@@ -2030,6 +2037,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
|
|
|
*
|
|
|
* This is safe: on error we're going to ignore the orphan list
|
|
|
* anyway on the next recovery. */
|
|
|
+mem_insert:
|
|
|
if (!err)
|
|
|
list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan);
|
|
|
|