On Mon, 2010-11-22 at 23:20 +0200, Alexander Kolesen wrote: > > I haven't dug too far into this yet, but I suspect that > > aaead25b954879e1a708ff2f3602f494c18d20b5 is related. > > > > commit aaead25b954879e1a708ff2f3602f494c18d20b5 > > Author: Christoph Hellwig <hch@xxxxxx> > > Date: Mon Oct 4 14:25:33 2010 +0200 > > > > writeback: always use sb->s_bdi for writeback purposes > > > > I'll have to look at what happens when a device is unplugged to see if > > JFS is missing something, or it's more of a generic problem. I'm open > > to suggestions from anybody on cc. > > > > Thanks, > > Shaggy > > > > I've tested kernel before and after this commit. Yes, it reproduced after, > and didn't reproduced before. I recreated the problem on ext3 as well, so it's not specific to JFS. I see three potential ways to fix this. 1. bdi_prune_sb() could set sb->s_bdi to &default_backing_dev_info rather than NULL 2. inode_to_bdi() could return &default_backing_dev_info (or inode->i_mapping->backing_dev_info) if sb->s_bdi is NULL. 3. the callers of inode_to_bdi() could check for s_bdi being NULL and exit gracefully. It seems that Jens and Christoph have ideas about cleaning up the bdi stuff, so this may be a short-term fix. Here's a patch for option 2. --------------------------------- fs: avoid null pointer dereference when a block device is unplugged Physically unplugging a block device when a file system is mounted can result in sb->s_bdi being set to NULL. The callers of inode_to_bdi() expect a non-NULL pointer. Return &default_backing_dev_info instead of NULL. Signed-off-by: Dave Kleikamp <shaggy@xxxxxxxxxxxxxxxxxx> --- fs/fs-writeback.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 3d06ccc..5f8cc5d 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -76,7 +76,7 @@ static inline struct backing_dev_info *inode_to_bdi(struct inode *inode) if (strcmp(sb->s_type->name, "bdev") == 0) return inode->i_mapping->backing_dev_info; - return sb->s_bdi; + return sb->s_bdi ? sb->s_bdi : &default_backing_dev_info; } static inline struct inode *wb_inode(struct list_head *head) -- Dave Kleikamp IBM Linux Technology Center -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html