]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - fs/overlayfs/ovl_entry.h
ovl: use ovl_inode mutex to synchronize concurrent copy up
[mirror_ubuntu-artful-kernel.git] / fs / overlayfs / ovl_entry.h
1 /*
2 *
3 * Copyright (C) 2011 Novell Inc.
4 * Copyright (C) 2016 Red Hat, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
9 */
10
11 struct ovl_config {
12 char *lowerdir;
13 char *upperdir;
14 char *workdir;
15 bool default_permissions;
16 bool redirect_dir;
17 };
18
19 /* private information held for overlayfs's superblock */
20 struct ovl_fs {
21 struct vfsmount *upper_mnt;
22 unsigned numlower;
23 struct vfsmount **lower_mnt;
24 struct dentry *workdir;
25 long namelen;
26 /* pathnames of lower and upper dirs, for show_options */
27 struct ovl_config config;
28 /* creds of process who forced instantiation of super block */
29 const struct cred *creator_cred;
30 bool tmpfile;
31 bool noxattr;
32 /* sb common to all layers */
33 struct super_block *same_sb;
34 };
35
36 /* private information held for every overlayfs dentry */
37 struct ovl_entry {
38 struct ovl_dir_cache *cache;
39 union {
40 struct {
41 u64 version;
42 bool opaque;
43 };
44 struct rcu_head rcu;
45 };
46 unsigned numlower;
47 struct path lowerstack[];
48 };
49
50 struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
51
52 struct ovl_inode {
53 const char *redirect;
54 unsigned long flags;
55 struct inode vfs_inode;
56 struct dentry *__upperdentry;
57 struct inode *lower;
58
59 /* synchronize copy up and more */
60 struct mutex lock;
61 };
62
63 static inline struct ovl_inode *OVL_I(struct inode *inode)
64 {
65 return container_of(inode, struct ovl_inode, vfs_inode);
66 }
67
68 static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
69 {
70 return lockless_dereference(oi->__upperdentry);
71 }