Whamcloud - gitweb
LU-17705 ptlrpc: replace synchronize_rcu() with rcu_barrier()
[fs/lustre-release.git] / libcfs / include / libcfs / linux / linux-fs.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2012, 2016, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  *
31  * libcfs/include/libcfs/linux/linux-fs.h
32  *
33  * Basic library routines.
34  */
35
36 #ifndef __LIBCFS_LINUX_CFS_FS_H__
37 #define __LIBCFS_LINUX_CFS_FS_H__
38
39 #include <linux/fs.h>
40 #include <linux/stat.h>
41 #include <linux/mount.h>
42 #include <linux/backing-dev.h>
43 #include <linux/pagemap.h>
44
45 #ifndef HAVE_FILE_DENTRY
46 static inline struct dentry *file_dentry(const struct file *file)
47 {
48         return file->f_path.dentry;
49 }
50 #endif
51
52 #ifndef S_DT_SHIFT
53 #define S_DT_SHIFT              12
54 #endif
55
56 #ifndef S_DT
57 #define S_DT(type)              (((type) & S_IFMT) >> S_DT_SHIFT)
58 #endif
59 #ifndef DTTOIF
60 #define DTTOIF(dirtype)         ((dirtype) << S_DT_SHIFT)
61 #endif
62
63 #ifdef HAVE_PROC_OPS
64 #define PROC_OWNER(_fn)
65 #else
66 #define proc_ops file_operations
67 #define PROC_OWNER(_owner)              .owner = (_owner),
68 #define proc_open                       open
69 #define proc_read                       read
70 #define proc_write                      write
71 #define proc_lseek                      llseek
72 #define proc_release                    release
73 #define proc_poll                       poll
74 #define proc_ioctl                      unlocked_ioctl
75 #define proc_compat_ioctl               compat_ioctl
76 #define proc_mmap                       mmap
77 #define proc_get_unmapped_area          get_unmapped_area
78 #endif
79
80 static inline void mapping_clear_exiting(struct address_space *mapping)
81 {
82 #ifdef HAVE_MAPPING_AS_EXITING_FLAG
83         clear_bit(AS_EXITING, &mapping->flags);
84 #endif
85 }
86
87 #endif /* __LIBCFS_LINUX_CFS_FS_H__ */