1 /*****************************************************************************\
2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
8 * This file is part of the SPL, Solaris Porting Layer.
9 * For details, see <http://zfsonlinux.org/>.
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * You should have received a copy of the GNU General Public License along
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
23 *****************************************************************************
24 * Solaris Porting Layer (SPL) Vnode Implementation.
25 \*****************************************************************************/
27 #include <sys/vnode.h>
28 #include <linux/falloc.h>
29 #include <spl-debug.h>
31 #ifdef SS_DEBUG_SUBSYS
32 #undef SS_DEBUG_SUBSYS
35 #define SS_DEBUG_SUBSYS SS_VNODE
37 vnode_t
*rootdir
= (vnode_t
*)0xabcd1234;
38 EXPORT_SYMBOL(rootdir
);
40 static spl_kmem_cache_t
*vn_cache
;
41 static spl_kmem_cache_t
*vn_file_cache
;
43 static DEFINE_SPINLOCK(vn_file_lock
);
44 static LIST_HEAD(vn_file_list
);
46 #ifdef HAVE_KERN_PATH_PARENT_HEADER
47 #ifndef HAVE_KERN_PATH_PARENT_SYMBOL
48 kern_path_parent_t kern_path_parent_fn
= SYMBOL_POISON
;
49 EXPORT_SYMBOL(kern_path_parent_fn
);
50 #endif /* HAVE_KERN_PATH_PARENT_SYMBOL */
51 #endif /* HAVE_KERN_PATH_PARENT_HEADER */
53 #ifdef HAVE_KERN_PATH_LOCKED
54 kern_path_locked_t kern_path_locked_fn
= SYMBOL_POISON
;
55 #endif /* HAVE_KERN_PATH_LOCKED */
58 vn_mode_to_vtype(mode_t mode
)
85 } /* vn_mode_to_vtype() */
86 EXPORT_SYMBOL(vn_mode_to_vtype
);
89 vn_vtype_to_mode(vtype_t vtype
)
113 } /* vn_vtype_to_mode() */
114 EXPORT_SYMBOL(vn_vtype_to_mode
);
122 vp
= kmem_cache_alloc(vn_cache
, flag
);
130 EXPORT_SYMBOL(vn_alloc
);
136 kmem_cache_free(vn_cache
, vp
);
139 EXPORT_SYMBOL(vn_free
);
142 vn_open(const char *path
, uio_seg_t seg
, int flags
, int mode
,
143 vnode_t
**vpp
, int x1
, void *x2
)
147 int rc
, saved_umask
= 0;
152 ASSERT(flags
& (FWRITE
| FREAD
));
153 ASSERT(seg
== UIO_SYSSPACE
);
157 if (!(flags
& FCREAT
) && (flags
& FWRITE
))
160 /* Note for filp_open() the two low bits must be remapped to mean:
161 * 01 - read-only -> 00 read-only
162 * 10 - write-only -> 01 write-only
163 * 11 - read-write -> 10 read-write
168 saved_umask
= xchg(¤t
->fs
->umask
, 0);
170 fp
= filp_open(path
, flags
, mode
);
173 (void)xchg(¤t
->fs
->umask
, saved_umask
);
176 SRETURN(-PTR_ERR(fp
));
178 #ifdef HAVE_2ARGS_VFS_GETATTR
179 rc
= vfs_getattr(&fp
->f_path
, &stat
);
181 rc
= vfs_getattr(fp
->f_path
.mnt
, fp
->f_dentry
, &stat
);
188 vp
= vn_alloc(KM_SLEEP
);
194 saved_gfp
= mapping_gfp_mask(fp
->f_mapping
);
195 mapping_set_gfp_mask(fp
->f_mapping
, saved_gfp
& ~(__GFP_IO
|__GFP_FS
));
197 mutex_enter(&vp
->v_lock
);
198 vp
->v_type
= vn_mode_to_vtype(stat
.mode
);
200 vp
->v_gfp_mask
= saved_gfp
;
202 mutex_exit(&vp
->v_lock
);
206 EXPORT_SYMBOL(vn_open
);
209 vn_openat(const char *path
, uio_seg_t seg
, int flags
, int mode
,
210 vnode_t
**vpp
, int x1
, void *x2
, vnode_t
*vp
, int fd
)
216 ASSERT(vp
== rootdir
);
218 len
= strlen(path
) + 2;
219 realpath
= kmalloc(len
, GFP_KERNEL
);
223 (void)snprintf(realpath
, len
, "/%s", path
);
224 rc
= vn_open(realpath
, seg
, flags
, mode
, vpp
, x1
, x2
);
229 EXPORT_SYMBOL(vn_openat
);
232 vn_rdwr(uio_rw_t uio
, vnode_t
*vp
, void *addr
, ssize_t len
, offset_t off
,
233 uio_seg_t seg
, int ioflag
, rlim64_t x2
, void *x3
, ssize_t
*residp
)
236 mm_segment_t saved_fs
;
241 ASSERT(uio
== UIO_WRITE
|| uio
== UIO_READ
);
244 ASSERT(seg
== UIO_SYSSPACE
);
245 ASSERT((ioflag
& ~FAPPEND
) == 0);
246 ASSERT(x2
== RLIM64_INFINITY
);
251 if (ioflag
& FAPPEND
)
254 /* Writable user data segment must be briefly increased for this
255 * process so we can use the user space read call paths to write
256 * in to memory allocated by the kernel. */
261 rc
= vfs_write(fp
, addr
, len
, &offset
);
263 rc
= vfs_read(fp
, addr
, len
, &offset
);
280 EXPORT_SYMBOL(vn_rdwr
);
283 vn_close(vnode_t
*vp
, int flags
, int x1
, int x2
, void *x3
, void *x4
)
291 mapping_set_gfp_mask(vp
->v_file
->f_mapping
, vp
->v_gfp_mask
);
292 rc
= filp_close(vp
->v_file
, 0);
297 EXPORT_SYMBOL(vn_close
);
299 /* vn_seek() does not actually seek it only performs bounds checking on the
300 * proposed seek. We perform minimal checking and allow vn_rdwr() to catch
301 * anything more serious. */
303 vn_seek(vnode_t
*vp
, offset_t ooff
, offset_t
*noffp
, void *ct
)
305 return ((*noffp
< 0 || *noffp
> MAXOFFSET_T
) ? EINVAL
: 0);
307 EXPORT_SYMBOL(vn_seek
);
309 #ifdef HAVE_KERN_PATH_LOCKED
310 /* Based on do_unlinkat() from linux/fs/namei.c */
312 vn_remove(const char *path
, uio_seg_t seg
, int flags
)
314 struct dentry
*dentry
;
316 struct inode
*inode
= NULL
;
320 ASSERT(seg
== UIO_SYSSPACE
);
321 ASSERT(flags
== RMFILE
);
323 dentry
= spl_kern_path_locked(path
, &parent
);
324 rc
= PTR_ERR(dentry
);
325 if (!IS_ERR(dentry
)) {
326 if (parent
.dentry
->d_name
.name
[parent
.dentry
->d_name
.len
])
327 SGOTO(slashes
, rc
= 0);
329 inode
= dentry
->d_inode
;
331 SGOTO(slashes
, rc
= 0);
336 rc
= vfs_unlink(parent
.dentry
->d_inode
, dentry
);
343 spl_inode_unlock(parent
.dentry
->d_inode
);
345 iput(inode
); /* truncate the inode here */
351 rc
= !dentry
->d_inode
? -ENOENT
:
352 S_ISDIR(dentry
->d_inode
->i_mode
) ? -EISDIR
: -ENOTDIR
;
355 EXPORT_SYMBOL(vn_remove
);
357 /* Based on do_rename() from linux/fs/namei.c */
359 vn_rename(const char *oldname
, const char *newname
, int x1
)
361 struct dentry
*old_dir
, *new_dir
;
362 struct dentry
*old_dentry
, *new_dentry
;
364 struct path old_parent
, new_parent
;
368 old_dentry
= spl_kern_path_locked(oldname
, &old_parent
);
369 if (IS_ERR(old_dentry
))
370 SGOTO(exit
, rc
= PTR_ERR(old_dentry
));
372 spl_inode_unlock(old_parent
.dentry
->d_inode
);
374 new_dentry
= spl_kern_path_locked(newname
, &new_parent
);
375 if (IS_ERR(new_dentry
))
376 SGOTO(exit2
, rc
= PTR_ERR(new_dentry
));
378 spl_inode_unlock(new_parent
.dentry
->d_inode
);
381 if (old_parent
.mnt
!= new_parent
.mnt
)
384 old_dir
= old_parent
.dentry
;
385 new_dir
= new_parent
.dentry
;
386 trap
= lock_rename(new_dir
, old_dir
);
388 /* source should not be ancestor of target */
390 if (old_dentry
== trap
)
393 /* target should not be an ancestor of source */
395 if (new_dentry
== trap
)
398 /* source must exist */
400 if (!old_dentry
->d_inode
)
403 /* unless the source is a directory trailing slashes give -ENOTDIR */
404 if (!S_ISDIR(old_dentry
->d_inode
->i_mode
)) {
406 if (old_dentry
->d_name
.name
[old_dentry
->d_name
.len
])
408 if (new_dentry
->d_name
.name
[new_dentry
->d_name
.len
])
412 #ifdef HAVE_4ARGS_VFS_RENAME
413 rc
= vfs_rename(old_dir
->d_inode
, old_dentry
,
414 new_dir
->d_inode
, new_dentry
);
416 rc
= vfs_rename(old_dir
->d_inode
, old_dentry
, oldnd
.nd_mnt
,
417 new_dir
->d_inode
, new_dentry
, newnd
.nd_mnt
);
418 #endif /* HAVE_4ARGS_VFS_RENAME */
420 unlock_rename(new_dir
, old_dir
);
423 path_put(&new_parent
);
426 path_put(&old_parent
);
430 EXPORT_SYMBOL(vn_rename
);
433 static struct dentry
*
434 vn_lookup_hash(struct nameidata
*nd
)
436 return lookup_one_len((const char *)nd
->last
.name
,
437 nd
->nd_dentry
, nd
->last
.len
);
438 } /* lookup_hash() */
441 vn_path_release(struct nameidata
*nd
)
447 /* Modified do_unlinkat() from linux/fs/namei.c, only uses exported symbols */
449 vn_remove(const char *path
, uio_seg_t seg
, int flags
)
451 struct dentry
*dentry
;
453 struct inode
*inode
= NULL
;
457 ASSERT(seg
== UIO_SYSSPACE
);
458 ASSERT(flags
== RMFILE
);
460 rc
= spl_kern_path_parent(path
, &nd
);
465 if (nd
.last_type
!= LAST_NORM
)
468 spl_inode_lock_nested(nd
.nd_dentry
->d_inode
, I_MUTEX_PARENT
);
469 dentry
= vn_lookup_hash(&nd
);
470 rc
= PTR_ERR(dentry
);
471 if (!IS_ERR(dentry
)) {
472 /* Why not before? Because we want correct rc value */
473 if (nd
.last
.name
[nd
.last
.len
])
476 inode
= dentry
->d_inode
;
478 atomic_inc(&inode
->i_count
);
479 #ifdef HAVE_2ARGS_VFS_UNLINK
480 rc
= vfs_unlink(nd
.nd_dentry
->d_inode
, dentry
);
482 rc
= vfs_unlink(nd
.nd_dentry
->d_inode
, dentry
, nd
.nd_mnt
);
483 #endif /* HAVE_2ARGS_VFS_UNLINK */
488 spl_inode_unlock(nd
.nd_dentry
->d_inode
);
490 iput(inode
); /* truncate the inode here */
492 vn_path_release(&nd
);
497 rc
= !dentry
->d_inode
? -ENOENT
:
498 S_ISDIR(dentry
->d_inode
->i_mode
) ? -EISDIR
: -ENOTDIR
;
501 EXPORT_SYMBOL(vn_remove
);
503 /* Modified do_rename() from linux/fs/namei.c, only uses exported symbols */
505 vn_rename(const char *oldname
, const char *newname
, int x1
)
507 struct dentry
*old_dir
, *new_dir
;
508 struct dentry
*old_dentry
, *new_dentry
;
510 struct nameidata oldnd
, newnd
;
514 rc
= spl_kern_path_parent(oldname
, &oldnd
);
518 rc
= spl_kern_path_parent(newname
, &newnd
);
523 if (oldnd
.nd_mnt
!= newnd
.nd_mnt
)
526 old_dir
= oldnd
.nd_dentry
;
528 if (oldnd
.last_type
!= LAST_NORM
)
531 new_dir
= newnd
.nd_dentry
;
532 if (newnd
.last_type
!= LAST_NORM
)
535 trap
= lock_rename(new_dir
, old_dir
);
537 old_dentry
= vn_lookup_hash(&oldnd
);
539 rc
= PTR_ERR(old_dentry
);
540 if (IS_ERR(old_dentry
))
543 /* source must exist */
545 if (!old_dentry
->d_inode
)
548 /* unless the source is a directory trailing slashes give -ENOTDIR */
549 if (!S_ISDIR(old_dentry
->d_inode
->i_mode
)) {
551 if (oldnd
.last
.name
[oldnd
.last
.len
])
553 if (newnd
.last
.name
[newnd
.last
.len
])
557 /* source should not be ancestor of target */
559 if (old_dentry
== trap
)
562 new_dentry
= vn_lookup_hash(&newnd
);
563 rc
= PTR_ERR(new_dentry
);
564 if (IS_ERR(new_dentry
))
567 /* target should not be an ancestor of source */
569 if (new_dentry
== trap
)
572 #ifdef HAVE_4ARGS_VFS_RENAME
573 rc
= vfs_rename(old_dir
->d_inode
, old_dentry
,
574 new_dir
->d_inode
, new_dentry
);
576 rc
= vfs_rename(old_dir
->d_inode
, old_dentry
, oldnd
.nd_mnt
,
577 new_dir
->d_inode
, new_dentry
, newnd
.nd_mnt
);
578 #endif /* HAVE_4ARGS_VFS_RENAME */
584 unlock_rename(new_dir
, old_dir
);
586 vn_path_release(&newnd
);
588 vn_path_release(&oldnd
);
592 EXPORT_SYMBOL(vn_rename
);
593 #endif /* HAVE_KERN_PATH_LOCKED */
596 vn_getattr(vnode_t
*vp
, vattr_t
*vap
, int flags
, void *x3
, void *x4
)
609 #ifdef HAVE_2ARGS_VFS_GETATTR
610 rc
= vfs_getattr(&fp
->f_path
, &stat
);
612 rc
= vfs_getattr(fp
->f_path
.mnt
, fp
->f_dentry
, &stat
);
617 vap
->va_type
= vn_mode_to_vtype(stat
.mode
);
618 vap
->va_mode
= stat
.mode
;
619 vap
->va_uid
= stat
.uid
;
620 vap
->va_gid
= stat
.gid
;
622 vap
->va_nodeid
= stat
.ino
;
623 vap
->va_nlink
= stat
.nlink
;
624 vap
->va_size
= stat
.size
;
625 vap
->va_blksize
= stat
.blksize
;
626 vap
->va_atime
= stat
.atime
;
627 vap
->va_mtime
= stat
.mtime
;
628 vap
->va_ctime
= stat
.ctime
;
629 vap
->va_rdev
= stat
.rdev
;
630 vap
->va_nblocks
= stat
.blocks
;
634 EXPORT_SYMBOL(vn_getattr
);
636 int vn_fsync(vnode_t
*vp
, int flags
, void *x3
, void *x4
)
647 SRETURN(-spl_filp_fsync(vp
->v_file
, datasync
));
649 EXPORT_SYMBOL(vn_fsync
);
651 int vn_space(vnode_t
*vp
, int cmd
, struct flock
*bfp
, int flag
,
652 offset_t offset
, void *x6
, void *x7
)
654 int error
= EOPNOTSUPP
;
657 if (cmd
!= F_FREESP
|| bfp
->l_whence
!= 0)
662 ASSERT(bfp
->l_start
>= 0 && bfp
->l_len
> 0);
664 #ifdef FALLOC_FL_PUNCH_HOLE
666 * When supported by the underlying file system preferentially
667 * use the fallocate() callback to preallocate the space.
669 error
= -spl_filp_fallocate(vp
->v_file
,
670 FALLOC_FL_KEEP_SIZE
| FALLOC_FL_PUNCH_HOLE
,
671 bfp
->l_start
, bfp
->l_len
);
676 #ifdef HAVE_INODE_TRUNCATE_RANGE
677 if (vp
->v_file
->f_dentry
&& vp
->v_file
->f_dentry
->d_inode
&&
678 vp
->v_file
->f_dentry
->d_inode
->i_op
&&
679 vp
->v_file
->f_dentry
->d_inode
->i_op
->truncate_range
) {
680 off_t end
= bfp
->l_start
+ bfp
->l_len
;
682 * Judging from the code in shmem_truncate_range(),
683 * it seems the kernel expects the end offset to be
684 * inclusive and aligned to the end of a page.
686 if (end
% PAGE_SIZE
!= 0) {
687 end
&= ~(off_t
)(PAGE_SIZE
- 1);
688 if (end
<= bfp
->l_start
)
693 vp
->v_file
->f_dentry
->d_inode
->i_op
->truncate_range(
694 vp
->v_file
->f_dentry
->d_inode
,
703 EXPORT_SYMBOL(vn_space
);
705 /* Function must be called while holding the vn_file_lock */
711 ASSERT(spin_is_locked(&vn_file_lock
));
713 list_for_each_entry(fp
, &vn_file_list
, f_list
) {
714 if (fd
== fp
->f_fd
&& fp
->f_task
== current
) {
715 ASSERT(atomic_read(&fp
->f_ref
) != 0);
733 /* Already open just take an extra reference */
734 spin_lock(&vn_file_lock
);
738 atomic_inc(&fp
->f_ref
);
739 spin_unlock(&vn_file_lock
);
743 spin_unlock(&vn_file_lock
);
745 /* File was not yet opened create the object and setup */
746 fp
= kmem_cache_alloc(vn_file_cache
, KM_SLEEP
);
750 mutex_enter(&fp
->f_lock
);
753 fp
->f_task
= current
;
755 atomic_inc(&fp
->f_ref
);
759 SGOTO(out_mutex
, rc
);
761 vp
= vn_alloc(KM_SLEEP
);
765 #ifdef HAVE_2ARGS_VFS_GETATTR
766 rc
= vfs_getattr(&lfp
->f_path
, &stat
);
768 rc
= vfs_getattr(lfp
->f_path
.mnt
, lfp
->f_dentry
, &stat
);
771 SGOTO(out_vnode
, rc
);
773 mutex_enter(&vp
->v_lock
);
774 vp
->v_type
= vn_mode_to_vtype(stat
.mode
);
776 mutex_exit(&vp
->v_lock
);
781 /* Put it on the tracking list */
782 spin_lock(&vn_file_lock
);
783 list_add(&fp
->f_list
, &vn_file_list
);
784 spin_unlock(&vn_file_lock
);
786 mutex_exit(&fp
->f_lock
);
794 mutex_exit(&fp
->f_lock
);
795 kmem_cache_free(vn_file_cache
, fp
);
801 static void releasef_locked(file_t
*fp
)
806 /* Unlinked from list, no refs, safe to free outside mutex */
808 vn_free(fp
->f_vnode
);
810 kmem_cache_free(vn_file_cache
, fp
);
819 spin_lock(&vn_file_lock
);
822 atomic_dec(&fp
->f_ref
);
823 if (atomic_read(&fp
->f_ref
) > 0) {
824 spin_unlock(&vn_file_lock
);
829 list_del(&fp
->f_list
);
832 spin_unlock(&vn_file_lock
);
837 EXPORT_SYMBOL(releasef
);
839 #ifndef HAVE_SET_FS_PWD
840 # ifdef HAVE_2ARGS_SET_FS_PWD
841 /* Used from 2.6.25 - 2.6.31+ */
843 # ifdef HAVE_SET_FS_PWD_WITH_CONST
844 set_fs_pwd(struct fs_struct
*fs
, const struct path
*path
)
846 set_fs_pwd(struct fs_struct
*fs
, struct path
*path
)
851 # ifdef HAVE_FS_STRUCT_SPINLOCK
852 spin_lock(&fs
->lock
);
856 spin_unlock(&fs
->lock
);
858 write_lock(&fs
->lock
);
862 write_unlock(&fs
->lock
);
863 # endif /* HAVE_FS_STRUCT_SPINLOCK */
869 /* Used from 2.6.11 - 2.6.24 */
871 set_fs_pwd(struct fs_struct
*fs
, struct vfsmount
*mnt
, struct dentry
*dentry
)
873 struct dentry
*old_pwd
;
874 struct vfsmount
*old_pwdmnt
;
876 write_lock(&fs
->lock
);
878 old_pwdmnt
= fs
->pwdmnt
;
879 fs
->pwdmnt
= mntget(mnt
);
880 fs
->pwd
= dget(dentry
);
881 write_unlock(&fs
->lock
);
888 # endif /* HAVE_2ARGS_SET_FS_PWD */
889 #endif /* HAVE_SET_FS_PWD */
892 vn_set_pwd(const char *filename
)
894 #if defined(HAVE_2ARGS_SET_FS_PWD) && defined(HAVE_USER_PATH_DIR)
898 #endif /* HAVE_2ARGS_SET_FS_PWD */
899 mm_segment_t saved_fs
;
904 * user_path_dir() and __user_walk() both expect 'filename' to be
905 * a user space address so we must briefly increase the data segment
906 * size to ensure strncpy_from_user() does not fail with -EFAULT.
911 #ifdef HAVE_2ARGS_SET_FS_PWD
912 # ifdef HAVE_USER_PATH_DIR
913 rc
= user_path_dir(filename
, &path
);
917 rc
= inode_permission(path
.dentry
->d_inode
, MAY_EXEC
| MAY_ACCESS
);
919 SGOTO(dput_and_out
, rc
);
921 set_fs_pwd(current
->fs
, &path
);
926 rc
= __user_walk(filename
,
927 LOOKUP_FOLLOW
|LOOKUP_DIRECTORY
|LOOKUP_CHDIR
, &nd
);
931 rc
= vfs_permission(&nd
, MAY_EXEC
);
933 SGOTO(dput_and_out
, rc
);
935 set_fs_pwd(current
->fs
, &nd
.path
);
939 # endif /* HAVE_USER_PATH_DIR */
941 rc
= __user_walk(filename
,
942 LOOKUP_FOLLOW
|LOOKUP_DIRECTORY
|LOOKUP_CHDIR
, &nd
);
946 rc
= vfs_permission(&nd
, MAY_EXEC
);
948 SGOTO(dput_and_out
, rc
);
950 set_fs_pwd(current
->fs
, nd
.nd_mnt
, nd
.nd_dentry
);
953 vn_path_release(&nd
);
954 #endif /* HAVE_2ARGS_SET_FS_PWD */
960 EXPORT_SYMBOL(vn_set_pwd
);
963 vn_cache_constructor(void *buf
, void *cdrarg
, int kmflags
)
965 struct vnode
*vp
= buf
;
967 mutex_init(&vp
->v_lock
, NULL
, MUTEX_DEFAULT
, NULL
);
970 } /* vn_cache_constructor() */
973 vn_cache_destructor(void *buf
, void *cdrarg
)
975 struct vnode
*vp
= buf
;
977 mutex_destroy(&vp
->v_lock
);
978 } /* vn_cache_destructor() */
981 vn_file_cache_constructor(void *buf
, void *cdrarg
, int kmflags
)
985 atomic_set(&fp
->f_ref
, 0);
986 mutex_init(&fp
->f_lock
, NULL
, MUTEX_DEFAULT
, NULL
);
987 INIT_LIST_HEAD(&fp
->f_list
);
990 } /* file_cache_constructor() */
993 vn_file_cache_destructor(void *buf
, void *cdrarg
)
997 mutex_destroy(&fp
->f_lock
);
998 } /* vn_file_cache_destructor() */
1000 int spl_vn_init_kallsyms_lookup(void)
1002 #ifdef HAVE_KERN_PATH_PARENT_HEADER
1003 #ifndef HAVE_KERN_PATH_PARENT_SYMBOL
1004 kern_path_parent_fn
= (kern_path_parent_t
)
1005 spl_kallsyms_lookup_name("kern_path_parent");
1006 if (!kern_path_parent_fn
) {
1007 printk(KERN_ERR
"Error: Unknown symbol kern_path_parent\n");
1010 #endif /* HAVE_KERN_PATH_PARENT_SYMBOL */
1011 #endif /* HAVE_KERN_PATH_PARENT_HEADER */
1013 #ifdef HAVE_KERN_PATH_LOCKED
1014 kern_path_locked_fn
= (kern_path_locked_t
)
1015 spl_kallsyms_lookup_name("kern_path_locked");
1016 if (!kern_path_locked_fn
) {
1017 printk(KERN_ERR
"Error: Unknown symbol kern_path_locked\n");
1029 vn_cache
= kmem_cache_create("spl_vn_cache",
1030 sizeof(struct vnode
), 64,
1031 vn_cache_constructor
,
1032 vn_cache_destructor
,
1033 NULL
, NULL
, NULL
, KMC_KMEM
);
1035 vn_file_cache
= kmem_cache_create("spl_vn_file_cache",
1037 vn_file_cache_constructor
,
1038 vn_file_cache_destructor
,
1039 NULL
, NULL
, NULL
, KMC_KMEM
);
1046 file_t
*fp
, *next_fp
;
1050 spin_lock(&vn_file_lock
);
1052 list_for_each_entry_safe(fp
, next_fp
, &vn_file_list
, f_list
) {
1053 list_del(&fp
->f_list
);
1054 releasef_locked(fp
);
1058 spin_unlock(&vn_file_lock
);
1061 SWARN("Warning %d files leaked\n", leaked
);
1063 kmem_cache_destroy(vn_file_cache
);
1064 kmem_cache_destroy(vn_cache
);