Thread (35 messages) 35 messages, 3 authors, 2012-08-26

Re: [patch 1/9] procfs: Move /proc/pid/fd[info] handling code to fd.[ch]

From: Al Viro <viro@ZenIV.linux.org.uk>
Date: 2012-08-25 21:52:45
Also in: lkml

On Sat, Aug 25, 2012 at 11:43:25PM +0400, Cyrill Gorcunov wrote:
Would the patch below improve the code? Look, I've not dropped
find_inode_number call since it's a bit unclear for me what
would happen if !child case hit

	child = d_lookup(dir, &qname);
	if (!child) {
		struct dentry *new = d_alloc(dir, &qname);
		if (new) {
			child = instantiate(dir->d_inode, new, task, ptr);
			if (child)
				dput(new);
			else
				child = new;
		}
	}

can we be sure that i_ino won't be zero here?
First of all, ->i_ino is not going to be zero for any procfs inode.
As for !child case, that's possible only if d_lookup() returns NULL
*and* d_alloc() fails.  In that case find_inode_number() will call
d_hash_and_lookup(), which will call d_lookup(), get NULL from it and
return NULL to find_inode_number().  Which will return 0 to the
caller.

AFAICS, if find_inode_number() is called there at all, it will return 0.
IOW, this if (!ino) ino = find_inode_number(...); is a no-op.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help