aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2015-01-29 07:02:27 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-02-22 11:38:15 -0500
commit155e35d4daa804582f75acaa2c74ec797a89c615 (patch)
tree322e9d089bd5610164aeadf164a237328cb0b19c
parentce7b9facdf43b42fb95bdff9069aefeddb7d0a69 (diff)
VFS: Introduce inode-getting helpers for layered/unioned fs environments
Introduce some function for getting the inode (and also the dentry) in an environment where layered/unioned filesystems are in operation. The problem is that we have places where we need *both* the union dentry and the lower source or workspace inode or dentry available, but we can only have a handle on one of them. Therefore we need to derive the handle to the other from that. The idea is to introduce an extra field in struct dentry that allows the union dentry to refer to and pin the lower dentry. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--include/linux/dcache.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 92c08cf7670e..047c0db5763f 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -464,4 +464,61 @@ static inline unsigned long vfs_pressure_ratio(unsigned long val)
464{ 464{
465 return mult_frac(val, sysctl_vfs_cache_pressure, 100); 465 return mult_frac(val, sysctl_vfs_cache_pressure, 100);
466} 466}
467
468/**
469 * d_inode - Get the actual inode of this dentry
470 * @dentry: The dentry to query
471 *
472 * This is the helper normal filesystems should use to get at their own inodes
473 * in their own dentries and ignore the layering superimposed upon them.
474 */
475static inline struct inode *d_inode(const struct dentry *dentry)
476{
477 return dentry->d_inode;
478}
479
480/**
481 * d_inode_rcu - Get the actual inode of this dentry with ACCESS_ONCE()
482 * @dentry: The dentry to query
483 *
484 * This is the helper normal filesystems should use to get at their own inodes
485 * in their own dentries and ignore the layering superimposed upon them.
486 */
487static inline struct inode *d_inode_rcu(const struct dentry *dentry)
488{
489 return ACCESS_ONCE(dentry->d_inode);
490}
491
492/**
493 * d_backing_inode - Get upper or lower inode we should be using
494 * @upper: The upper layer
495 *
496 * This is the helper that should be used to get at the inode that will be used
497 * if this dentry were to be opened as a file. The inode may be on the upper
498 * dentry or it may be on a lower dentry pinned by the upper.
499 *
500 * Normal filesystems should not use this to access their own inodes.
501 */
502static inline struct inode *d_backing_inode(const struct dentry *upper)
503{
504 struct inode *inode = upper->d_inode;
505
506 return inode;
507}
508
509/**
510 * d_backing_dentry - Get upper or lower dentry we should be using
511 * @upper: The upper layer
512 *
513 * This is the helper that should be used to get the dentry of the inode that
514 * will be used if this dentry were opened as a file. It may be the upper
515 * dentry or it may be a lower dentry pinned by the upper.
516 *
517 * Normal filesystems should not use this to access their own dentries.
518 */
519static inline struct dentry *d_backing_dentry(struct dentry *upper)
520{
521 return upper;
522}
523
467#endif /* __LINUX_DCACHE_H */ 524#endif /* __LINUX_DCACHE_H */