]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - mm/prfile.c
UBUNTU: Ubuntu-4.10.0-37.41
[mirror_ubuntu-zesty-kernel.git] / mm / prfile.c
1 /*
2 * Mainly for aufs which mmap(2) diffrent file and wants to print different path
3 * in /proc/PID/maps.
4 * Call these functions via macros defined in linux/mm.h.
5 *
6 * See Documentation/filesystems/aufs/design/06mmap.txt
7 *
8 * Copyright (c) 2014 Junjro R. Okajima
9 * Copyright (c) 2014 Ian Campbell
10 */
11
12 #include <linux/mm.h>
13 #include <linux/file.h>
14 #include <linux/fs.h>
15
16 /* #define PRFILE_TRACE */
17 static inline void prfile_trace(struct file *f, struct file *pr,
18 const char func[], int line, const char func2[])
19 {
20 #ifdef PRFILE_TRACE
21 if (pr)
22 pr_info("%s:%d: %s, %s\n", func, line, func2,
23 f ? (char *)f->f_path.dentry->d_name.name : "(null)");
24 #endif
25 }
26
27 void vma_do_file_update_time(struct vm_area_struct *vma, const char func[],
28 int line)
29 {
30 struct file *f = vma->vm_file, *pr = vma->vm_prfile;
31
32 prfile_trace(f, pr, func, line, __func__);
33 file_update_time(f);
34 if (f && pr)
35 file_update_time(pr);
36 }
37
38 struct file *vma_do_pr_or_file(struct vm_area_struct *vma, const char func[],
39 int line)
40 {
41 struct file *f = vma->vm_file, *pr = vma->vm_prfile;
42
43 prfile_trace(f, pr, func, line, __func__);
44 return (f && pr) ? pr : f;
45 }
46
47 void vma_do_get_file(struct vm_area_struct *vma, const char func[], int line)
48 {
49 struct file *f = vma->vm_file, *pr = vma->vm_prfile;
50
51 prfile_trace(f, pr, func, line, __func__);
52 get_file(f);
53 if (f && pr)
54 get_file(pr);
55 }
56
57 void vma_do_fput(struct vm_area_struct *vma, const char func[], int line)
58 {
59 struct file *f = vma->vm_file, *pr = vma->vm_prfile;
60
61 prfile_trace(f, pr, func, line, __func__);
62 fput(f);
63 if (f && pr)
64 fput(pr);
65 }
66
67 #ifndef CONFIG_MMU
68 struct file *vmr_do_pr_or_file(struct vm_region *region, const char func[],
69 int line)
70 {
71 struct file *f = region->vm_file, *pr = region->vm_prfile;
72
73 prfile_trace(f, pr, func, line, __func__);
74 return (f && pr) ? pr : f;
75 }
76
77 void vmr_do_fput(struct vm_region *region, const char func[], int line)
78 {
79 struct file *f = region->vm_file, *pr = region->vm_prfile;
80
81 prfile_trace(f, pr, func, line, __func__);
82 fput(f);
83 if (f && pr)
84 fput(pr);
85 }
86 #endif /* !CONFIG_MMU */