public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] fs/super.c: Why alloc_super use a static variable default_op?
@ 2007-07-25  3:48 rae l
  2007-07-25  4:14 ` Al Viro
  0 siblings, 1 reply; 7+ messages in thread
From: rae l @ 2007-07-25  3:48 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-kernel

Why alloc_super use a static variable default_op?
the static struct super_operations default_op is just all zeros, and
just referenced as the initial value of a new allocated super_block,
what does it for?

the filesystem dependent code such as ext2_fill_super would fill this
field eventually,
and after carefully checked, it seems no one filesystem would need a
all zero default_op,

as the command output in the kernel source tree:
$ grep -RInw s_op fs/
You could check all the use of s_op.

/**
 *	alloc_super	-	create new superblock
 *	@type:	filesystem type superblock should belong to
 *
 *	Allocates and initializes a new &struct super_block.  alloc_super()
 *	returns a pointer new superblock or %NULL if allocation had failed.
 */
static struct super_block *alloc_super(struct file_system_type *type)
{
	struct super_block *s = kzalloc(sizeof(struct super_block),  GFP_USER);

	static struct super_operations default_op;

	if (s) {
		...
		s->s_op = &default_op;
		s->s_time_gran = 1000000000;
	}
out:
	return s;
}


-- 
Denis Cheng
Linux Application Developer

"One of my most productive days was throwing away 1000 lines of code."
 - Ken Thompson.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-07-25  6:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-25  3:48 [RFC] fs/super.c: Why alloc_super use a static variable default_op? rae l
2007-07-25  4:14 ` Al Viro
2007-07-25  4:29   ` rae l
2007-07-25  4:37     ` Al Viro
2007-07-25  5:21       ` rae l
2007-07-25  6:39         ` Al Viro
2007-07-25  6:43           ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox