linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: James Morris <jmorris@namei.org>
Cc: Josef Jeff Sipek <jsipek@cs.sunysb.edu>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	akpm@osdl.org, viro@ftp.linux.org.uk, hch@infradead.org
Subject: Re: [PATCH 08 of 23] isofs: change uses of f_{dentry, vfsmnt} to use f_path
Date: Sat, 21 Oct 2006 17:11:40 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0610211702410.3962@g5.osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0610211909210.17454@d.namei>



On Sat, 21 Oct 2006, James Morris wrote:
>
> What about something like:
> 
> static inline struct inode *fpath_ino(struct file *file)
> {
> 	return file->f_path.dentry->d_inode;
> }

Generally, unless it saves a _lot_ of typing, we've tried to avoid 
gratuitous hiding of details. And "ino" isn't a good name, it's something 
we've traditionally used for the inode _number_. So it would be 
"fpath_inode()" or "file_inode()" or something.

As it is, the difference between

	file->f_dentry->d_inode
	fpath_inode(file)

is not really enough of a win to merit hiding that it's doing two pointer 
dereferences. Now, whether the extra five characters ("path.") merit it, I 
don't know.  I suspect not. If the line turns long, it's often more 
readable to just add a local variable or two, and do

	struct dentry *dentry = file->f_[path.]dentry;
	struct inode *inode = dentry->d_inode;

which in some situations allow for other readability improvements too (eg 
maybe "dentry" or "inode" is used multiple times).

If this was something where we'd expect things to change in the future, 
maybe it would be worth it for _that_ reason. That doesn't sound very 
likely, though - these things have been fairly stable, and even this patch 
is really about syntactic cleanup than any real change.

Adding these kinds of "abstraction layers" is something that people are 
taught is good, but I personally tend to think that it makes it less 
obvious at the code level what the "costs" are. Unless you know things 
intimately, you really have no way of judging whether "fpath_inode()" is 
something expensive or not. 

I dunno. 

		Linus

  reply	other threads:[~2006-10-22  0:11 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-21  6:17 [PATCH 00 of 23] struct file: Use struct path Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 01 of 23] VFS: change struct file to use " Josef Jeff Sipek
2006-10-21  7:22   ` Andrew Morton
2006-10-21  7:28     ` Josef Sipek
2006-10-23 11:47       ` Martin Waitz
2006-10-24  9:03         ` Josef Sipek
2006-10-21  6:17 ` [PATCH 02 of 23] sysfs: change uses of f_{dentry, vfsmnt} to use f_path Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 03 of 23] proc: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 04 of 23] ext2: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 05 of 23] ext3: " Josef Jeff Sipek
2006-10-21 12:51   ` Robert Peterson
2006-10-21 18:26     ` Josef Sipek
2006-10-21  6:17 ` [PATCH 06 of 23] ext4: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 07 of 23] fat: change uses of f_{dentry,vfsmnt} " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 08 of 23] isofs: change uses of f_{dentry, vfsmnt} " Josef Jeff Sipek
2006-10-21 23:13   ` James Morris
2006-10-22  0:11     ` Linus Torvalds [this message]
2006-10-21  6:17 ` [PATCH 09 of 23] nfs: change uses of f_{dentry,vfsmnt} " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 10 of 23] nfsd: change uses of f_{dentry, vfsmnt} " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 11 of 23] ntfs: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 12 of 23] i386: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 13 of 23] x86_64: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 14 of 23] kernel: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 15 of 23] mm: change uses of f_{dentry,vfsmnt} " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 16 of 23] 9p: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 17 of 23] affs: change uses of f_{dentry, vfsmnt} " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 18 of 23] autofs: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 19 of 23] autofs4: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 20 of 23] configfs: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 21 of 23] cifs: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 22 of 23] ecryptfs: " Josef Jeff Sipek
2006-10-21  6:17 ` [PATCH 23 of 23] xfs: change uses of f_{dentry,vfsmnt} " Josef Jeff Sipek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0610211702410.3962@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=akpm@osdl.org \
    --cc=hch@infradead.org \
    --cc=jmorris@namei.org \
    --cc=jsipek@cs.sunysb.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).