diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0600265cb9b06f17e63cf4a81d2c80492bdfc53d..3bd0ff63bf30ad2e297e4a0d7b5044c74f237840 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6589,6 +6589,12 @@ static int btrfs_truncate(struct inode *inode) ret = btrfs_orphan_del(trans, inode); if (ret) err = ret; + } else if (ret && inode->i_nlink > 0) { + /* + * Failed to do the truncate, remove us from the in memory + * orphan list. + */ + ret = btrfs_orphan_del(NULL, inode); } ret = btrfs_update_inode(trans, root, inode);