Re: [RFC PATCH] Introduce filesystem type tracking

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Matthew Wilcox
Date: Tuesday, May 20, 2008 - 3:00 pm

On Tue, May 20, 2008 at 10:08:04PM +0100, Tom Spink wrote:

Hi Tom,

I spotted one definite bug; on failure, you leave the superblock on
the super_blocks list.

Your locking may well be correct, but it has the hallmarks of being "a bit
tricky" and a bit tricky means potentially buggy.  How about doing the
nesting the other way round, ie take the mutex first, then the spinlock?

The code needs a bit of tweaking because you don't want to put the
superblock on any list where it can be found until it's fully
initialised.  This may not be quite right:


sget is a little more complex ... the fs_supers_lock would need to be
dropped in a lot more places than I've shown here:

@@ -365,11 +372,31 @@ retry:
 retry:
+	mutex_lock(&type->fs_supers_lock);
 	spin_lock(&sb_lock);
	
 		destroy_super(s);
 		return ERR_PTR(err);
 	}
 	s->s_type = type;
 	strlcpy(s->s_id, type->name, sizeof(s->s_id));
+	if (list_empty(&type->fs_supers) && type->init) {
+		spin_unlock(&sb_lock);
+		err = type->init();
+		if (err) {
+			mutex_unlock(&type->fs_supers_lock);
+			destroy_super(s);
+			return ERR_PTR(err);
+		}
+		spin_lock(&sb_lock);
+	}
 	list_add_tail(&s->s_list, &super_blocks);
 	list_add(&s->s_instances, &type->fs_supers);
 	spin_unlock(&sb_lock);
+	mutex_unlock(&type->fs_supers_lock);
 	get_filesystem(type);
 	return s;
}

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH] Introduce filesystem type tracking, Tom Spink, (Mon May 19, 4:22 am)
Re: [RFC PATCH] Introduce filesystem type tracking, Tom Spink, (Tue May 20, 6:06 am)
Re: [RFC PATCH] Introduce filesystem type tracking, Tom Spink, (Tue May 20, 6:50 am)
Re: [RFC PATCH] Introduce filesystem type tracking, Christoph Hellwig, (Tue May 20, 6:57 am)
Re: [RFC PATCH] Introduce filesystem type tracking, Tom Spink, (Tue May 20, 8:18 am)
Re: [RFC PATCH] Introduce filesystem type tracking, Matthew Wilcox, (Tue May 20, 8:34 am)
Re: [RFC PATCH] Introduce filesystem type tracking, Tom Spink, (Tue May 20, 8:36 am)
Re: [RFC PATCH] Introduce filesystem type tracking, Tom Spink, (Tue May 20, 2:08 pm)
Re: [RFC PATCH] Introduce filesystem type tracking, Matthew Wilcox, (Tue May 20, 3:00 pm)
Re: [RFC PATCH] Introduce filesystem type tracking, Tom Spink, (Tue May 20, 3:22 pm)
Re: [RFC PATCH] Introduce filesystem type tracking, Jan Engelhardt, (Wed May 21, 2:42 am)
Re: [RFC PATCH] Introduce filesystem type tracking, Tom Spink, (Wed May 21, 7:49 am)