lkml.org 
[lkml]   [2014]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 01/13] vfs: add d_is_dir()
Date
J. Bruce Fields <bfields@fieldses.org> wrote:

> On Fri, Feb 07, 2014 at 05:48:59PM +0100, Miklos Szeredi wrote:
> > From: Miklos Szeredi <mszeredi@suse.cz>
> >
> > Add d_is_dir(dentry) helper which is analogous to S_ISDIR().
>
> While trying to get up to speed I notice that these flags were
> introduced by b18825a7c8e37a7cf6abb97a12a6ad71af160de7 "VFS: Put a small
> type field into struct dentry::d_flags" whose changelog tells me "what"
> but not "why". So out of curiosity: was that some kind of optimization,
> or was there some other reason for it?

The idea is to put into the dentry information about objects that pathwalk
specifically needs to know about, ie. negative dentries, dirs, automount
points and symlinks so that you don't have to look this up in the inode.

We can use this to distinguish lookupable dirs from nonlookupable dirs
(ie. automounts), thereby subsuming the can_lookup query.

However, the real power comes in support for fs unioning. There are two
additional uses for this field:

(1) Whiteout dentry type. An additional type is added for this field which
causes d_is_negative() to return true, but can be distinguished when
trying to decide whether to look in a lower layer or not.

(2) Fallthroughs. Whilst the dentry may appear negative by virtue of having
a NULL d_inode pointer, it does in fact correspond to a real object on a
lower layer. The type of the lower object is set in this field so that
pathwalk can immediately know how to deal with it.

David


\
 
 \ /
  Last update: 2014-02-07 21:41    [W:0.296 / U:0.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site