1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or https://opensource.org/licenses/CDDL-1.0. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 2011, Lawrence Livermore National Security, LLC. 23 */ 24 25 #ifndef _SYS_ZPL_H 26 #define _SYS_ZPL_H 27 28 #include <sys/mntent.h> 29 #include <sys/vfs.h> 30 #include <linux/aio.h> 31 #include <linux/dcache_compat.h> 32 #include <linux/exportfs.h> 33 #include <linux/falloc.h> 34 #include <linux/parser.h> 35 #include <linux/vfs_compat.h> 36 #include <linux/writeback.h> 37 #include <linux/xattr_compat.h> 38 39 /* zpl_inode.c */ 40 extern void zpl_vap_init(vattr_t *vap, struct inode *dir, 41 umode_t mode, cred_t *cr, zidmap_t *mnt_ns); 42 43 extern const struct inode_operations zpl_inode_operations; 44 extern const struct inode_operations zpl_dir_inode_operations; 45 extern const struct inode_operations zpl_symlink_inode_operations; 46 extern const struct inode_operations zpl_special_inode_operations; 47 48 /* zpl_file.c */ 49 extern const struct address_space_operations zpl_address_space_operations; 50 extern const struct file_operations zpl_file_operations; 51 extern const struct file_operations zpl_dir_file_operations; 52 53 /* zpl_super.c */ 54 extern void zpl_prune_sb(uint64_t nr_to_scan, void *arg); 55 56 extern const struct super_operations zpl_super_operations; 57 extern const struct export_operations zpl_export_operations; 58 extern struct file_system_type zpl_fs_type; 59 60 /* zpl_xattr.c */ 61 extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size); 62 extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip, 63 const struct qstr *qstr); 64 65 #if defined(CONFIG_FS_POSIX_ACL) 66 67 #if defined(HAVE_SET_ACL_IDMAP_DENTRY) 68 extern int zpl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, 69 struct posix_acl *acl, int type); 70 #elif defined(HAVE_SET_ACL_USERNS) 71 extern int zpl_set_acl(struct user_namespace *userns, struct inode *ip, 72 struct posix_acl *acl, int type); 73 #elif defined(HAVE_SET_ACL_USERNS_DENTRY_ARG2) 74 extern int zpl_set_acl(struct user_namespace *userns, struct dentry *dentry, 75 struct posix_acl *acl, int type); 76 #else 77 extern int zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type); 78 #endif /* HAVE_SET_ACL_USERNS */ 79 80 #if defined(HAVE_GET_ACL_RCU) || defined(HAVE_GET_INODE_ACL) 81 extern struct posix_acl *zpl_get_acl(struct inode *ip, int type, bool rcu); 82 #elif defined(HAVE_GET_ACL) 83 extern struct posix_acl *zpl_get_acl(struct inode *ip, int type); 84 #endif 85 extern int zpl_init_acl(struct inode *ip, struct inode *dir); 86 extern int zpl_chmod_acl(struct inode *ip); 87 #else 88 static inline int 89 zpl_init_acl(struct inode *ip, struct inode *dir) 90 { 91 return (0); 92 } 93 94 static inline int 95 zpl_chmod_acl(struct inode *ip) 96 { 97 return (0); 98 } 99 #endif /* CONFIG_FS_POSIX_ACL */ 100 101 extern xattr_handler_t *zpl_xattr_handlers[]; 102 103 /* zpl_ctldir.c */ 104 extern const struct file_operations zpl_fops_root; 105 extern const struct inode_operations zpl_ops_root; 106 107 extern const struct file_operations zpl_fops_snapdir; 108 extern const struct inode_operations zpl_ops_snapdir; 109 110 extern const struct file_operations zpl_fops_shares; 111 extern const struct inode_operations zpl_ops_shares; 112 113 /* zpl_file_range.c */ 114 115 /* handlers for file_operations of the same name */ 116 extern ssize_t zpl_copy_file_range(struct file *src_file, loff_t src_off, 117 struct file *dst_file, loff_t dst_off, size_t len, unsigned int flags); 118 extern loff_t zpl_remap_file_range(struct file *src_file, loff_t src_off, 119 struct file *dst_file, loff_t dst_off, loff_t len, unsigned int flags); 120 extern int zpl_clone_file_range(struct file *src_file, loff_t src_off, 121 struct file *dst_file, loff_t dst_off, uint64_t len); 122 extern int zpl_dedupe_file_range(struct file *src_file, loff_t src_off, 123 struct file *dst_file, loff_t dst_off, uint64_t len); 124 125 /* compat for FICLONE/FICLONERANGE/FIDEDUPERANGE ioctls */ 126 typedef struct { 127 int64_t fcr_src_fd; 128 uint64_t fcr_src_offset; 129 uint64_t fcr_src_length; 130 uint64_t fcr_dest_offset; 131 } zfs_ioc_compat_file_clone_range_t; 132 133 typedef struct { 134 int64_t fdri_dest_fd; 135 uint64_t fdri_dest_offset; 136 uint64_t fdri_bytes_deduped; 137 int32_t fdri_status; 138 uint32_t fdri_reserved; 139 } zfs_ioc_compat_dedupe_range_info_t; 140 141 typedef struct { 142 uint64_t fdr_src_offset; 143 uint64_t fdr_src_length; 144 uint16_t fdr_dest_count; 145 uint16_t fdr_reserved1; 146 uint32_t fdr_reserved2; 147 zfs_ioc_compat_dedupe_range_info_t fdr_info[]; 148 } zfs_ioc_compat_dedupe_range_t; 149 150 #define ZFS_IOC_COMPAT_FICLONE _IOW(0x94, 9, int) 151 #define ZFS_IOC_COMPAT_FICLONERANGE \ 152 _IOW(0x94, 13, zfs_ioc_compat_file_clone_range_t) 153 #define ZFS_IOC_COMPAT_FIDEDUPERANGE \ 154 _IOWR(0x94, 54, zfs_ioc_compat_dedupe_range_t) 155 156 extern long zpl_ioctl_ficlone(struct file *filp, void *arg); 157 extern long zpl_ioctl_ficlonerange(struct file *filp, void *arg); 158 extern long zpl_ioctl_fideduperange(struct file *filp, void *arg); 159 160 161 #if defined(HAVE_INODE_TIMESTAMP_TRUNCATE) 162 #define zpl_inode_timestamp_truncate(ts, ip) timestamp_truncate(ts, ip) 163 #else 164 #define zpl_inode_timestamp_truncate(ts, ip) \ 165 timespec64_trunc(ts, (ip)->i_sb->s_time_gran) 166 #endif 167 168 #if defined(HAVE_INODE_OWNER_OR_CAPABLE) 169 #define zpl_inode_owner_or_capable(ns, ip) inode_owner_or_capable(ip) 170 #elif defined(HAVE_INODE_OWNER_OR_CAPABLE_USERNS) 171 #define zpl_inode_owner_or_capable(ns, ip) inode_owner_or_capable(ns, ip) 172 #elif defined(HAVE_INODE_OWNER_OR_CAPABLE_IDMAP) 173 #define zpl_inode_owner_or_capable(idmap, ip) inode_owner_or_capable(idmap, ip) 174 #else 175 #error "Unsupported kernel" 176 #endif 177 178 #if defined(HAVE_SETATTR_PREPARE_USERNS) || defined(HAVE_SETATTR_PREPARE_IDMAP) 179 #define zpl_setattr_prepare(ns, dentry, ia) setattr_prepare(ns, dentry, ia) 180 #else 181 /* 182 * Use kernel-provided version, or our own from 183 * linux/vfs_compat.h 184 */ 185 #define zpl_setattr_prepare(ns, dentry, ia) setattr_prepare(dentry, ia) 186 #endif 187 188 #ifdef HAVE_INODE_GET_CTIME 189 #define zpl_inode_get_ctime(ip) inode_get_ctime(ip) 190 #else 191 #define zpl_inode_get_ctime(ip) (ip->i_ctime) 192 #endif 193 #ifdef HAVE_INODE_SET_CTIME_TO_TS 194 #define zpl_inode_set_ctime_to_ts(ip, ts) inode_set_ctime_to_ts(ip, ts) 195 #else 196 #define zpl_inode_set_ctime_to_ts(ip, ts) (ip->i_ctime = ts) 197 #endif 198 #ifdef HAVE_INODE_GET_ATIME 199 #define zpl_inode_get_atime(ip) inode_get_atime(ip) 200 #else 201 #define zpl_inode_get_atime(ip) (ip->i_atime) 202 #endif 203 #ifdef HAVE_INODE_SET_ATIME_TO_TS 204 #define zpl_inode_set_atime_to_ts(ip, ts) inode_set_atime_to_ts(ip, ts) 205 #else 206 #define zpl_inode_set_atime_to_ts(ip, ts) (ip->i_atime = ts) 207 #endif 208 #ifdef HAVE_INODE_GET_MTIME 209 #define zpl_inode_get_mtime(ip) inode_get_mtime(ip) 210 #else 211 #define zpl_inode_get_mtime(ip) (ip->i_mtime) 212 #endif 213 #ifdef HAVE_INODE_SET_MTIME_TO_TS 214 #define zpl_inode_set_mtime_to_ts(ip, ts) inode_set_mtime_to_ts(ip, ts) 215 #else 216 #define zpl_inode_set_mtime_to_ts(ip, ts) (ip->i_mtime = ts) 217 #endif 218 219 #endif /* _SYS_ZPL_H */ 220