xref: /freebsd/sys/contrib/openzfs/module/os/linux/zfs/zpl_inode.c (revision 6132212808e8dccedc9e5d85fea4390c2f38059a)
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 http://www.opensolaris.org/os/licensing.
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  * Copyright (c) 2015 by Chunwei Chen. All rights reserved.
24  */
25 
26 
27 #include <sys/zfs_ctldir.h>
28 #include <sys/zfs_vfsops.h>
29 #include <sys/zfs_vnops.h>
30 #include <sys/zfs_znode.h>
31 #include <sys/dmu_objset.h>
32 #include <sys/vfs.h>
33 #include <sys/zpl.h>
34 #include <sys/file.h>
35 
36 
37 static struct dentry *
38 zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
39 {
40 	cred_t *cr = CRED();
41 	struct inode *ip;
42 	znode_t *zp;
43 	int error;
44 	fstrans_cookie_t cookie;
45 	pathname_t *ppn = NULL;
46 	pathname_t pn;
47 	int zfs_flags = 0;
48 	zfsvfs_t *zfsvfs = dentry->d_sb->s_fs_info;
49 
50 	if (dlen(dentry) >= ZAP_MAXNAMELEN)
51 		return (ERR_PTR(-ENAMETOOLONG));
52 
53 	crhold(cr);
54 	cookie = spl_fstrans_mark();
55 
56 	/* If we are a case insensitive fs, we need the real name */
57 	if (zfsvfs->z_case == ZFS_CASE_INSENSITIVE) {
58 		zfs_flags = FIGNORECASE;
59 		pn_alloc(&pn);
60 		ppn = &pn;
61 	}
62 
63 	error = -zfs_lookup(ITOZ(dir), dname(dentry), &zp,
64 	    zfs_flags, cr, NULL, ppn);
65 	spl_fstrans_unmark(cookie);
66 	ASSERT3S(error, <=, 0);
67 	crfree(cr);
68 
69 	spin_lock(&dentry->d_lock);
70 	dentry->d_time = jiffies;
71 	spin_unlock(&dentry->d_lock);
72 
73 	if (error) {
74 		/*
75 		 * If we have a case sensitive fs, we do not want to
76 		 * insert negative entries, so return NULL for ENOENT.
77 		 * Fall through if the error is not ENOENT. Also free memory.
78 		 */
79 		if (ppn) {
80 			pn_free(ppn);
81 			if (error == -ENOENT)
82 				return (NULL);
83 		}
84 
85 		if (error == -ENOENT)
86 			return (d_splice_alias(NULL, dentry));
87 		else
88 			return (ERR_PTR(error));
89 	}
90 	ip = ZTOI(zp);
91 
92 	/*
93 	 * If we are case insensitive, call the correct function
94 	 * to install the name.
95 	 */
96 	if (ppn) {
97 		struct dentry *new_dentry;
98 		struct qstr ci_name;
99 
100 		if (strcmp(dname(dentry), pn.pn_buf) == 0) {
101 			new_dentry = d_splice_alias(ip,  dentry);
102 		} else {
103 			ci_name.name = pn.pn_buf;
104 			ci_name.len = strlen(pn.pn_buf);
105 			new_dentry = d_add_ci(dentry, ip, &ci_name);
106 		}
107 		pn_free(ppn);
108 		return (new_dentry);
109 	} else {
110 		return (d_splice_alias(ip, dentry));
111 	}
112 }
113 
114 void
115 zpl_vap_init(vattr_t *vap, struct inode *dir, umode_t mode, cred_t *cr)
116 {
117 	vap->va_mask = ATTR_MODE;
118 	vap->va_mode = mode;
119 	vap->va_uid = crgetfsuid(cr);
120 
121 	if (dir && dir->i_mode & S_ISGID) {
122 		vap->va_gid = KGID_TO_SGID(dir->i_gid);
123 		if (S_ISDIR(mode))
124 			vap->va_mode |= S_ISGID;
125 	} else {
126 		vap->va_gid = crgetfsgid(cr);
127 	}
128 }
129 
130 static int
131 zpl_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool flag)
132 {
133 	cred_t *cr = CRED();
134 	znode_t *zp;
135 	vattr_t *vap;
136 	int error;
137 	fstrans_cookie_t cookie;
138 
139 	crhold(cr);
140 	vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
141 	zpl_vap_init(vap, dir, mode, cr);
142 
143 	cookie = spl_fstrans_mark();
144 	error = -zfs_create(ITOZ(dir), dname(dentry), vap, 0,
145 	    mode, &zp, cr, 0, NULL);
146 	if (error == 0) {
147 		d_instantiate(dentry, ZTOI(zp));
148 
149 		error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
150 		if (error == 0)
151 			error = zpl_init_acl(ZTOI(zp), dir);
152 
153 		if (error)
154 			(void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
155 	}
156 
157 	spl_fstrans_unmark(cookie);
158 	kmem_free(vap, sizeof (vattr_t));
159 	crfree(cr);
160 	ASSERT3S(error, <=, 0);
161 
162 	return (error);
163 }
164 
165 static int
166 zpl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
167     dev_t rdev)
168 {
169 	cred_t *cr = CRED();
170 	znode_t *zp;
171 	vattr_t *vap;
172 	int error;
173 	fstrans_cookie_t cookie;
174 
175 	/*
176 	 * We currently expect Linux to supply rdev=0 for all sockets
177 	 * and fifos, but we want to know if this behavior ever changes.
178 	 */
179 	if (S_ISSOCK(mode) || S_ISFIFO(mode))
180 		ASSERT(rdev == 0);
181 
182 	crhold(cr);
183 	vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
184 	zpl_vap_init(vap, dir, mode, cr);
185 	vap->va_rdev = rdev;
186 
187 	cookie = spl_fstrans_mark();
188 	error = -zfs_create(ITOZ(dir), dname(dentry), vap, 0,
189 	    mode, &zp, cr, 0, NULL);
190 	if (error == 0) {
191 		d_instantiate(dentry, ZTOI(zp));
192 
193 		error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
194 		if (error == 0)
195 			error = zpl_init_acl(ZTOI(zp), dir);
196 
197 		if (error)
198 			(void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
199 	}
200 
201 	spl_fstrans_unmark(cookie);
202 	kmem_free(vap, sizeof (vattr_t));
203 	crfree(cr);
204 	ASSERT3S(error, <=, 0);
205 
206 	return (error);
207 }
208 
209 #ifdef HAVE_TMPFILE
210 static int
211 zpl_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
212 {
213 	cred_t *cr = CRED();
214 	struct inode *ip;
215 	vattr_t *vap;
216 	int error;
217 	fstrans_cookie_t cookie;
218 
219 	crhold(cr);
220 	vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
221 	/*
222 	 * The VFS does not apply the umask, therefore it is applied here
223 	 * when POSIX ACLs are not enabled.
224 	 */
225 	if (!IS_POSIXACL(dir))
226 		mode &= ~current_umask();
227 	zpl_vap_init(vap, dir, mode, cr);
228 
229 	cookie = spl_fstrans_mark();
230 	error = -zfs_tmpfile(dir, vap, 0, mode, &ip, cr, 0, NULL);
231 	if (error == 0) {
232 		/* d_tmpfile will do drop_nlink, so we should set it first */
233 		set_nlink(ip, 1);
234 		d_tmpfile(dentry, ip);
235 
236 		error = zpl_xattr_security_init(ip, dir, &dentry->d_name);
237 		if (error == 0)
238 			error = zpl_init_acl(ip, dir);
239 		/*
240 		 * don't need to handle error here, file is already in
241 		 * unlinked set.
242 		 */
243 	}
244 
245 	spl_fstrans_unmark(cookie);
246 	kmem_free(vap, sizeof (vattr_t));
247 	crfree(cr);
248 	ASSERT3S(error, <=, 0);
249 
250 	return (error);
251 }
252 #endif
253 
254 static int
255 zpl_unlink(struct inode *dir, struct dentry *dentry)
256 {
257 	cred_t *cr = CRED();
258 	int error;
259 	fstrans_cookie_t cookie;
260 	zfsvfs_t *zfsvfs = dentry->d_sb->s_fs_info;
261 
262 	crhold(cr);
263 	cookie = spl_fstrans_mark();
264 	error = -zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
265 
266 	/*
267 	 * For a CI FS we must invalidate the dentry to prevent the
268 	 * creation of negative entries.
269 	 */
270 	if (error == 0 && zfsvfs->z_case == ZFS_CASE_INSENSITIVE)
271 		d_invalidate(dentry);
272 
273 	spl_fstrans_unmark(cookie);
274 	crfree(cr);
275 	ASSERT3S(error, <=, 0);
276 
277 	return (error);
278 }
279 
280 static int
281 zpl_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
282 {
283 	cred_t *cr = CRED();
284 	vattr_t *vap;
285 	znode_t *zp;
286 	int error;
287 	fstrans_cookie_t cookie;
288 
289 	crhold(cr);
290 	vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
291 	zpl_vap_init(vap, dir, mode | S_IFDIR, cr);
292 
293 	cookie = spl_fstrans_mark();
294 	error = -zfs_mkdir(ITOZ(dir), dname(dentry), vap, &zp, cr, 0, NULL);
295 	if (error == 0) {
296 		d_instantiate(dentry, ZTOI(zp));
297 
298 		error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
299 		if (error == 0)
300 			error = zpl_init_acl(ZTOI(zp), dir);
301 
302 		if (error)
303 			(void) zfs_rmdir(ITOZ(dir), dname(dentry), NULL, cr, 0);
304 	}
305 
306 	spl_fstrans_unmark(cookie);
307 	kmem_free(vap, sizeof (vattr_t));
308 	crfree(cr);
309 	ASSERT3S(error, <=, 0);
310 
311 	return (error);
312 }
313 
314 static int
315 zpl_rmdir(struct inode *dir, struct dentry *dentry)
316 {
317 	cred_t *cr = CRED();
318 	int error;
319 	fstrans_cookie_t cookie;
320 	zfsvfs_t *zfsvfs = dentry->d_sb->s_fs_info;
321 
322 	crhold(cr);
323 	cookie = spl_fstrans_mark();
324 	error = -zfs_rmdir(ITOZ(dir), dname(dentry), NULL, cr, 0);
325 
326 	/*
327 	 * For a CI FS we must invalidate the dentry to prevent the
328 	 * creation of negative entries.
329 	 */
330 	if (error == 0 && zfsvfs->z_case == ZFS_CASE_INSENSITIVE)
331 		d_invalidate(dentry);
332 
333 	spl_fstrans_unmark(cookie);
334 	crfree(cr);
335 	ASSERT3S(error, <=, 0);
336 
337 	return (error);
338 }
339 
340 static int
341 zpl_getattr_impl(const struct path *path, struct kstat *stat, u32 request_mask,
342     unsigned int query_flags)
343 {
344 	int error;
345 	fstrans_cookie_t cookie;
346 
347 	cookie = spl_fstrans_mark();
348 
349 	/*
350 	 * XXX request_mask and query_flags currently ignored.
351 	 */
352 
353 	error = -zfs_getattr_fast(path->dentry->d_inode, stat);
354 	spl_fstrans_unmark(cookie);
355 	ASSERT3S(error, <=, 0);
356 
357 	return (error);
358 }
359 ZPL_GETATTR_WRAPPER(zpl_getattr);
360 
361 static int
362 zpl_setattr(struct dentry *dentry, struct iattr *ia)
363 {
364 	struct inode *ip = dentry->d_inode;
365 	cred_t *cr = CRED();
366 	vattr_t *vap;
367 	int error;
368 	fstrans_cookie_t cookie;
369 
370 	error = setattr_prepare(dentry, ia);
371 	if (error)
372 		return (error);
373 
374 	crhold(cr);
375 	vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
376 	vap->va_mask = ia->ia_valid & ATTR_IATTR_MASK;
377 	vap->va_mode = ia->ia_mode;
378 	vap->va_uid = KUID_TO_SUID(ia->ia_uid);
379 	vap->va_gid = KGID_TO_SGID(ia->ia_gid);
380 	vap->va_size = ia->ia_size;
381 	vap->va_atime = ia->ia_atime;
382 	vap->va_mtime = ia->ia_mtime;
383 	vap->va_ctime = ia->ia_ctime;
384 
385 	if (vap->va_mask & ATTR_ATIME)
386 		ip->i_atime = zpl_inode_timestamp_truncate(ia->ia_atime, ip);
387 
388 	cookie = spl_fstrans_mark();
389 	error = -zfs_setattr(ITOZ(ip), vap, 0, cr);
390 	if (!error && (ia->ia_valid & ATTR_MODE))
391 		error = zpl_chmod_acl(ip);
392 
393 	spl_fstrans_unmark(cookie);
394 	kmem_free(vap, sizeof (vattr_t));
395 	crfree(cr);
396 	ASSERT3S(error, <=, 0);
397 
398 	return (error);
399 }
400 
401 static int
402 zpl_rename2(struct inode *sdip, struct dentry *sdentry,
403     struct inode *tdip, struct dentry *tdentry, unsigned int flags)
404 {
405 	cred_t *cr = CRED();
406 	int error;
407 	fstrans_cookie_t cookie;
408 
409 	/* We don't have renameat2(2) support */
410 	if (flags)
411 		return (-EINVAL);
412 
413 	crhold(cr);
414 	cookie = spl_fstrans_mark();
415 	error = -zfs_rename(ITOZ(sdip), dname(sdentry), ITOZ(tdip),
416 	    dname(tdentry), cr, 0);
417 	spl_fstrans_unmark(cookie);
418 	crfree(cr);
419 	ASSERT3S(error, <=, 0);
420 
421 	return (error);
422 }
423 
424 #ifndef HAVE_RENAME_WANTS_FLAGS
425 static int
426 zpl_rename(struct inode *sdip, struct dentry *sdentry,
427     struct inode *tdip, struct dentry *tdentry)
428 {
429 	return (zpl_rename2(sdip, sdentry, tdip, tdentry, 0));
430 }
431 #endif
432 
433 static int
434 zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
435 {
436 	cred_t *cr = CRED();
437 	vattr_t *vap;
438 	znode_t *zp;
439 	int error;
440 	fstrans_cookie_t cookie;
441 
442 	crhold(cr);
443 	vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
444 	zpl_vap_init(vap, dir, S_IFLNK | S_IRWXUGO, cr);
445 
446 	cookie = spl_fstrans_mark();
447 	error = -zfs_symlink(ITOZ(dir), dname(dentry), vap,
448 	    (char *)name, &zp, cr, 0);
449 	if (error == 0) {
450 		d_instantiate(dentry, ZTOI(zp));
451 
452 		error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
453 		if (error)
454 			(void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
455 	}
456 
457 	spl_fstrans_unmark(cookie);
458 	kmem_free(vap, sizeof (vattr_t));
459 	crfree(cr);
460 	ASSERT3S(error, <=, 0);
461 
462 	return (error);
463 }
464 
465 #if defined(HAVE_PUT_LINK_COOKIE)
466 static void
467 zpl_put_link(struct inode *unused, void *cookie)
468 {
469 	kmem_free(cookie, MAXPATHLEN);
470 }
471 #elif defined(HAVE_PUT_LINK_NAMEIDATA)
472 static void
473 zpl_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
474 {
475 	const char *link = nd_get_link(nd);
476 
477 	if (!IS_ERR(link))
478 		kmem_free(link, MAXPATHLEN);
479 }
480 #elif defined(HAVE_PUT_LINK_DELAYED)
481 static void
482 zpl_put_link(void *ptr)
483 {
484 	kmem_free(ptr, MAXPATHLEN);
485 }
486 #endif
487 
488 static int
489 zpl_get_link_common(struct dentry *dentry, struct inode *ip, char **link)
490 {
491 	fstrans_cookie_t cookie;
492 	cred_t *cr = CRED();
493 	struct iovec iov;
494 	uio_t uio = { { 0 }, 0 };
495 	int error;
496 
497 	crhold(cr);
498 	*link = NULL;
499 	iov.iov_len = MAXPATHLEN;
500 	iov.iov_base = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
501 
502 	uio.uio_iov = &iov;
503 	uio.uio_iovcnt = 1;
504 	uio.uio_segflg = UIO_SYSSPACE;
505 	uio.uio_resid = (MAXPATHLEN - 1);
506 
507 	cookie = spl_fstrans_mark();
508 	error = -zfs_readlink(ip, &uio, cr);
509 	spl_fstrans_unmark(cookie);
510 	crfree(cr);
511 
512 	if (error)
513 		kmem_free(iov.iov_base, MAXPATHLEN);
514 	else
515 		*link = iov.iov_base;
516 
517 	return (error);
518 }
519 
520 #if defined(HAVE_GET_LINK_DELAYED)
521 static const char *
522 zpl_get_link(struct dentry *dentry, struct inode *inode,
523     struct delayed_call *done)
524 {
525 	char *link = NULL;
526 	int error;
527 
528 	if (!dentry)
529 		return (ERR_PTR(-ECHILD));
530 
531 	error = zpl_get_link_common(dentry, inode, &link);
532 	if (error)
533 		return (ERR_PTR(error));
534 
535 	set_delayed_call(done, zpl_put_link, link);
536 
537 	return (link);
538 }
539 #elif defined(HAVE_GET_LINK_COOKIE)
540 static const char *
541 zpl_get_link(struct dentry *dentry, struct inode *inode, void **cookie)
542 {
543 	char *link = NULL;
544 	int error;
545 
546 	if (!dentry)
547 		return (ERR_PTR(-ECHILD));
548 
549 	error = zpl_get_link_common(dentry, inode, &link);
550 	if (error)
551 		return (ERR_PTR(error));
552 
553 	return (*cookie = link);
554 }
555 #elif defined(HAVE_FOLLOW_LINK_COOKIE)
556 static const char *
557 zpl_follow_link(struct dentry *dentry, void **cookie)
558 {
559 	char *link = NULL;
560 	int error;
561 
562 	error = zpl_get_link_common(dentry, dentry->d_inode, &link);
563 	if (error)
564 		return (ERR_PTR(error));
565 
566 	return (*cookie = link);
567 }
568 #elif defined(HAVE_FOLLOW_LINK_NAMEIDATA)
569 static void *
570 zpl_follow_link(struct dentry *dentry, struct nameidata *nd)
571 {
572 	char *link = NULL;
573 	int error;
574 
575 	error = zpl_get_link_common(dentry, dentry->d_inode, &link);
576 	if (error)
577 		nd_set_link(nd, ERR_PTR(error));
578 	else
579 		nd_set_link(nd, link);
580 
581 	return (NULL);
582 }
583 #endif
584 
585 static int
586 zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
587 {
588 	cred_t *cr = CRED();
589 	struct inode *ip = old_dentry->d_inode;
590 	int error;
591 	fstrans_cookie_t cookie;
592 
593 	if (ip->i_nlink >= ZFS_LINK_MAX)
594 		return (-EMLINK);
595 
596 	crhold(cr);
597 	ip->i_ctime = current_time(ip);
598 	igrab(ip); /* Use ihold() if available */
599 
600 	cookie = spl_fstrans_mark();
601 	error = -zfs_link(ITOZ(dir), ITOZ(ip), dname(dentry), cr, 0);
602 	if (error) {
603 		iput(ip);
604 		goto out;
605 	}
606 
607 	d_instantiate(dentry, ip);
608 out:
609 	spl_fstrans_unmark(cookie);
610 	crfree(cr);
611 	ASSERT3S(error, <=, 0);
612 
613 	return (error);
614 }
615 
616 static int
617 #ifdef HAVE_D_REVALIDATE_NAMEIDATA
618 zpl_revalidate(struct dentry *dentry, struct nameidata *nd)
619 {
620 	unsigned int flags = (nd ? nd->flags : 0);
621 #else
622 zpl_revalidate(struct dentry *dentry, unsigned int flags)
623 {
624 #endif /* HAVE_D_REVALIDATE_NAMEIDATA */
625 	/* CSTYLED */
626 	zfsvfs_t *zfsvfs = dentry->d_sb->s_fs_info;
627 	int error;
628 
629 	if (flags & LOOKUP_RCU)
630 		return (-ECHILD);
631 
632 	/*
633 	 * After a rollback negative dentries created before the rollback
634 	 * time must be invalidated.  Otherwise they can obscure files which
635 	 * are only present in the rolled back dataset.
636 	 */
637 	if (dentry->d_inode == NULL) {
638 		spin_lock(&dentry->d_lock);
639 		error = time_before(dentry->d_time, zfsvfs->z_rollback_time);
640 		spin_unlock(&dentry->d_lock);
641 
642 		if (error)
643 			return (0);
644 	}
645 
646 	/*
647 	 * The dentry may reference a stale inode if a mounted file system
648 	 * was rolled back to a point in time where the object didn't exist.
649 	 */
650 	if (dentry->d_inode && ITOZ(dentry->d_inode)->z_is_stale)
651 		return (0);
652 
653 	return (1);
654 }
655 
656 const struct inode_operations zpl_inode_operations = {
657 	.setattr	= zpl_setattr,
658 	.getattr	= zpl_getattr,
659 #ifdef HAVE_GENERIC_SETXATTR
660 	.setxattr	= generic_setxattr,
661 	.getxattr	= generic_getxattr,
662 	.removexattr	= generic_removexattr,
663 #endif
664 	.listxattr	= zpl_xattr_list,
665 #if defined(CONFIG_FS_POSIX_ACL)
666 #if defined(HAVE_SET_ACL)
667 	.set_acl	= zpl_set_acl,
668 #endif /* HAVE_SET_ACL */
669 	.get_acl	= zpl_get_acl,
670 #endif /* CONFIG_FS_POSIX_ACL */
671 };
672 
673 const struct inode_operations zpl_dir_inode_operations = {
674 	.create		= zpl_create,
675 	.lookup		= zpl_lookup,
676 	.link		= zpl_link,
677 	.unlink		= zpl_unlink,
678 	.symlink	= zpl_symlink,
679 	.mkdir		= zpl_mkdir,
680 	.rmdir		= zpl_rmdir,
681 	.mknod		= zpl_mknod,
682 #ifdef HAVE_RENAME_WANTS_FLAGS
683 	.rename		= zpl_rename2,
684 #else
685 	.rename		= zpl_rename,
686 #endif
687 #ifdef HAVE_TMPFILE
688 	.tmpfile	= zpl_tmpfile,
689 #endif
690 	.setattr	= zpl_setattr,
691 	.getattr	= zpl_getattr,
692 #ifdef HAVE_GENERIC_SETXATTR
693 	.setxattr	= generic_setxattr,
694 	.getxattr	= generic_getxattr,
695 	.removexattr	= generic_removexattr,
696 #endif
697 	.listxattr	= zpl_xattr_list,
698 #if defined(CONFIG_FS_POSIX_ACL)
699 #if defined(HAVE_SET_ACL)
700 	.set_acl	= zpl_set_acl,
701 #endif /* HAVE_SET_ACL */
702 	.get_acl	= zpl_get_acl,
703 #endif /* CONFIG_FS_POSIX_ACL */
704 };
705 
706 const struct inode_operations zpl_symlink_inode_operations = {
707 #ifdef HAVE_GENERIC_READLINK
708 	.readlink	= generic_readlink,
709 #endif
710 #if defined(HAVE_GET_LINK_DELAYED) || defined(HAVE_GET_LINK_COOKIE)
711 	.get_link	= zpl_get_link,
712 #elif defined(HAVE_FOLLOW_LINK_COOKIE) || defined(HAVE_FOLLOW_LINK_NAMEIDATA)
713 	.follow_link	= zpl_follow_link,
714 #endif
715 #if defined(HAVE_PUT_LINK_COOKIE) || defined(HAVE_PUT_LINK_NAMEIDATA)
716 	.put_link	= zpl_put_link,
717 #endif
718 	.setattr	= zpl_setattr,
719 	.getattr	= zpl_getattr,
720 #ifdef HAVE_GENERIC_SETXATTR
721 	.setxattr	= generic_setxattr,
722 	.getxattr	= generic_getxattr,
723 	.removexattr	= generic_removexattr,
724 #endif
725 	.listxattr	= zpl_xattr_list,
726 };
727 
728 const struct inode_operations zpl_special_inode_operations = {
729 	.setattr	= zpl_setattr,
730 	.getattr	= zpl_getattr,
731 #ifdef HAVE_GENERIC_SETXATTR
732 	.setxattr	= generic_setxattr,
733 	.getxattr	= generic_getxattr,
734 	.removexattr	= generic_removexattr,
735 #endif
736 	.listxattr	= zpl_xattr_list,
737 #if defined(CONFIG_FS_POSIX_ACL)
738 #if defined(HAVE_SET_ACL)
739 	.set_acl	= zpl_set_acl,
740 #endif /* HAVE_SET_ACL */
741 	.get_acl	= zpl_get_acl,
742 #endif /* CONFIG_FS_POSIX_ACL */
743 };
744 
745 dentry_operations_t zpl_dentry_operations = {
746 	.d_revalidate	= zpl_revalidate,
747 };
748