Subject: Re: [PATCH 03/15] [SUNRPC]: Use proc_create() to setup ->proc_fops first

From: Wang Chen <[email-masked]>
Date: Fri, 29 Feb 2008 16:35:17 +0800

Wang Chen said the following on 2008-2-29 13:26:
> David Miller said the following on 2008-2-29 6:02:
>> From: Wang Chen <[email-masked]>
>> Date: Thu, 28 Feb 2008 18:55:40 +0800
>>
>>> Use proc_create() to make sure that ->proc_fops be setup before gluing
>>> PDE to main tree.
>>>
>>> Signed-off-by: Wang Chen <[email-masked]>
>> Applied.
>>
>>> @@ -229,9 +229,8 @@ do_register(const char *name, void *data, const struct file_operations *fops)
>>>  	rpc_proc_init();
>>>  	dprintk("RPC:       registering /proc/net/rpc/%s\n", name);
>>>  
>>> -	ent = create_proc_entry(name, 0, proc_net_rpc);
>>> +	ent = proc_create(name, 0, proc_net_rpc, fops);
>>>  	if (ent) {
>>> -		ent->proc_fops = fops;
>>>  		ent->data = data;
>>>  	}
>>>  	return ent;
>> For this case it appears that ent->data has the same kind of
>> visibility problem that ent->proc_fops does.
>>
> 
> Thanks Dave, I will check whether ->data also has the visibility problem.
> 

I have looked at the proc_create().
The reason for why we need to setup pde->proc_fops in proc_create() before
the pde be visible, is that proc_fops will be setuped in proc_register() and
and NULL of proc_fops will make proc_register() give pde an improper fops.

But, ->data and ->owner will not be affected by this instance.
So, it's safe to setup ->data and ->owner after visibility of pde.