]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - mm/prfile.c
UBUNTU: ubuntu: vbox -- update to 5.2.6-dfsg-5
[mirror_ubuntu-bionic-kernel.git] / mm / prfile.c
1 /*
2 * SPDX-License-Identifier: GPL-2.0
3 * Mainly for aufs which mmap(2) different file and wants to print different
4 * path in /proc/PID/maps.
5 * Call these functions via macros defined in linux/mm.h.
6 *
7 * See Documentation/filesystems/aufs/design/06mmap.txt
8 *
9 * Copyright (c) 2014-2017 Junjro R. Okajima
10 * Copyright (c) 2014 Ian Campbell
11 */
12
13 #include <linux/mm.h>
14 #include <linux/file.h>
15 #include <linux/fs.h>
16
17 /* #define PRFILE_TRACE */
18 static inline void prfile_trace(struct file *f, struct file *pr,
19 const char func[], int line, const char func2[])
20 {
21 #ifdef PRFILE_TRACE
22 if (pr)
23 pr_info("%s:%d: %s, %pD2\n", func, line, func2, f);
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 */