Skip to content

Commit

Permalink
logfs: destroy the reserved inodes while unmounting
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
joshi-prasad committed Apr 2, 2012
1 parent dd775ae commit d2dcd90
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
16 changes: 16 additions & 0 deletions fs/logfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,26 @@ static void __logfs_destroy_inode(struct inode *inode)
call_rcu(&inode->i_rcu, logfs_i_callback);
}

static void __logfs_destroy_meta_inode(struct inode *inode)
{
struct logfs_inode *li = logfs_inode(inode);
BUG_ON(li->li_block);
call_rcu(&inode->i_rcu, logfs_i_callback);
}

static void logfs_destroy_inode(struct inode *inode)
{
struct logfs_inode *li = logfs_inode(inode);

if (inode->i_ino < LOGFS_RESERVED_INOS) {
/*
* The reserved inodes are never destroyed unless we are in
* unmont path.
*/
__logfs_destroy_meta_inode(inode);
return;
}

BUG_ON(list_empty(&li->li_freeing_list));
spin_lock(&logfs_inode_lock);
li->li_refcount--;
Expand Down
1 change: 0 additions & 1 deletion fs/logfs/readwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,6 @@ void logfs_evict_inode(struct inode *inode)
return;
}

BUG_ON(inode->i_ino < LOGFS_RESERVED_INOS);
page = inode_to_page(inode);
BUG_ON(!page); /* FIXME: Use emergency page */
logfs_put_write_page(page);
Expand Down
2 changes: 1 addition & 1 deletion fs/logfs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ static struct logfs_area *alloc_area(struct super_block *sb)

static void map_invalidatepage(struct page *page, unsigned long l)
{
BUG();
return;
}

static int map_releasepage(struct page *page, gfp_t g)
Expand Down

0 comments on commit d2dcd90

Please sign in to comment.