Skip to content

Commit d2dcd90

Browse files
committed
logfs: destroy the reserved inodes while unmounting
We were assuming that the evict_inode() would never be called on reserved inodes. However, (after the commit 8e22c1a logfs: get rid of magical inodes) while unmounting the file system, in put_super, we call iput() on all of the reserved inodes. The following simple test used to cause a kernel panic on LogFS: 1. Mount a LogFS file system on /mnt 2. Create a file $ touch /mnt/a 3. Try to unmount the FS $ umount /mnt The simple fix would be to drop the assumption and properly destroy the reserved inodes. Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
1 parent dd775ae commit d2dcd90

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎fs/logfs/inode.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,26 @@ static void __logfs_destroy_inode(struct inode *inode)
156156
call_rcu(&inode->i_rcu, logfs_i_callback);
157157
}
158158

159+
static void __logfs_destroy_meta_inode(struct inode *inode)
160+
{
161+
struct logfs_inode *li = logfs_inode(inode);
162+
BUG_ON(li->li_block);
163+
call_rcu(&inode->i_rcu, logfs_i_callback);
164+
}
165+
159166
static void logfs_destroy_inode(struct inode *inode)
160167
{
161168
struct logfs_inode *li = logfs_inode(inode);
162169

170+
if (inode->i_ino < LOGFS_RESERVED_INOS) {
171+
/*
172+
* The reserved inodes are never destroyed unless we are in
173+
* unmont path.
174+
*/
175+
__logfs_destroy_meta_inode(inode);
176+
return;
177+
}
178+
163179
BUG_ON(list_empty(&li->li_freeing_list));
164180
spin_lock(&logfs_inode_lock);
165181
li->li_refcount--;

‎fs/logfs/readwrite.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,6 @@ void logfs_evict_inode(struct inode *inode)
21892189
return;
21902190
}
21912191

2192-
BUG_ON(inode->i_ino < LOGFS_RESERVED_INOS);
21932192
page = inode_to_page(inode);
21942193
BUG_ON(!page); /* FIXME: Use emergency page */
21952194
logfs_put_write_page(page);

‎fs/logfs/segment.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ static struct logfs_area *alloc_area(struct super_block *sb)
886886

887887
static void map_invalidatepage(struct page *page, unsigned long l)
888888
{
889-
BUG();
889+
return;
890890
}
891891

892892
static int map_releasepage(struct page *page, gfp_t g)

0 commit comments

Comments
 (0)