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 \*****************************************************************************/
28 #include <sys/vnode.h>
29 #include <linux/falloc.h>
30 #include <spl-debug.h>
32 #ifdef SS_DEBUG_SUBSYS
33 #undef SS_DEBUG_SUBSYS
36 #define SS_DEBUG_SUBSYS SS_VNODE
38 vnode_t
*rootdir
= (vnode_t
*)0xabcd1234;
39 EXPORT_SYMBOL(rootdir
);
41 static spl_kmem_cache_t
*vn_cache
;
42 static spl_kmem_cache_t
*vn_file_cache
;
44 static DEFINE_SPINLOCK(vn_file_lock
);
45 static LIST_HEAD(vn_file_list
);
47 #ifdef HAVE_KERN_PATH_PARENT_HEADER
48 #ifndef HAVE_KERN_PATH_PARENT_SYMBOL
49 kern_path_parent_t kern_path_parent_fn
= SYMBOL_POISON
;
50 EXPORT_SYMBOL(kern_path_parent_fn
);
51 #endif /* HAVE_KERN_PATH_PARENT_SYMBOL */
52 #endif /* HAVE_KERN_PATH_PARENT_HEADER */
54 #ifdef HAVE_KERN_PATH_LOCKED
55 kern_path_locked_t kern_path_locked_fn
= SYMBOL_POISON
;
56 #endif /* HAVE_KERN_PATH_LOCKED */
59 vn_mode_to_vtype(mode_t mode
)
86 } /* vn_mode_to_vtype() */
87 EXPORT_SYMBOL(vn_mode_to_vtype
);
90 vn_vtype_to_mode(vtype_t vtype
)
114 } /* vn_vtype_to_mode() */
115 EXPORT_SYMBOL(vn_vtype_to_mode
);
123 vp
= kmem_cache_alloc(vn_cache
, flag
);
131 EXPORT_SYMBOL(vn_alloc
);
137 kmem_cache_free(vn_cache
, vp
);
140 EXPORT_SYMBOL(vn_free
);
143 vn_open(const char *path
, uio_seg_t seg
, int flags
, int mode
,
144 vnode_t
**vpp
, int x1
, void *x2
)
148 int rc
, saved_umask
= 0;
153 ASSERT(flags
& (FWRITE
| FREAD
));
154 ASSERT(seg
== UIO_SYSSPACE
);
158 if (!(flags
& FCREAT
) && (flags
& FWRITE
))
161 /* Note for filp_open() the two low bits must be remapped to mean:
162 * 01 - read-only -> 00 read-only
163 * 10 - write-only -> 01 write-only
164 * 11 - read-write -> 10 read-write
169 saved_umask
= xchg(¤t
->fs
->umask
, 0);
171 fp
= filp_open(path
, flags
, mode
);
174 (void)xchg(¤t
->fs
->umask
, saved_umask
);
177 SRETURN(-PTR_ERR(fp
));
179 #ifdef HAVE_2ARGS_VFS_GETATTR
180 rc
= vfs_getattr(&fp
->f_path
, &stat
);
182 rc
= vfs_getattr(fp
->f_path
.mnt
, fp
->f_dentry
, &stat
);
189 vp
= vn_alloc(KM_SLEEP
);
195 saved_gfp
= mapping_gfp_mask(fp
->f_mapping
);
196 mapping_set_gfp_mask(fp
->f_mapping
, saved_gfp
& ~(__GFP_IO
|__GFP_FS
));
198 mutex_enter(&vp
->v_lock
);
199 vp
->v_type
= vn_mode_to_vtype(stat
.mode
);
201 vp
->v_gfp_mask
= saved_gfp
;
203 mutex_exit(&vp
->v_lock
);
207 EXPORT_SYMBOL(vn_open
);
210 vn_openat(const char *path
, uio_seg_t seg
, int flags
, int mode
,
211 vnode_t
**vpp
, int x1
, void *x2
, vnode_t
*vp
, int fd
)
217 ASSERT(vp
== rootdir
);
219 len
= strlen(path
) + 2;
220 realpath
= kmalloc(len
, GFP_KERNEL
);
224 (void)snprintf(realpath
, len
, "/%s", path
);
225 rc
= vn_open(realpath
, seg
, flags
, mode
, vpp
, x1
, x2
);
230 EXPORT_SYMBOL(vn_openat
);
233 vn_rdwr(uio_rw_t uio
, vnode_t
*vp
, void *addr
, ssize_t len
, offset_t off
,
234 uio_seg_t seg
, int ioflag
, rlim64_t x2
, void *x3
, ssize_t
*residp
)
237 mm_segment_t saved_fs
;
242 ASSERT(uio
== UIO_WRITE
|| uio
== UIO_READ
);
245 ASSERT(seg
== UIO_SYSSPACE
);
246 ASSERT((ioflag
& ~FAPPEND
) == 0);
247 ASSERT(x2
== RLIM64_INFINITY
);
252 if (ioflag
& FAPPEND
)
255 /* Writable user data segment must be briefly increased for this
256 * process so we can use the user space read call paths to write
257 * in to memory allocated by the kernel. */
262 rc
= vfs_write(fp
, addr
, len
, &offset
);
264 rc
= vfs_read(fp
, addr
, len
, &offset
);
281 EXPORT_SYMBOL(vn_rdwr
);
284 vn_close(vnode_t
*vp
, int flags
, int x1
, int x2
, void *x3
, void *x4
)
292 mapping_set_gfp_mask(vp
->v_file
->f_mapping
, vp
->v_gfp_mask
);
293 rc
= filp_close(vp
->v_file
, 0);
298 EXPORT_SYMBOL(vn_close
);
300 /* vn_seek() does not actually seek it only performs bounds checking on the
301 * proposed seek. We perform minimal checking and allow vn_rdwr() to catch
302 * anything more serious. */
304 vn_seek(vnode_t
*vp
, offset_t ooff
, offset_t
*noffp
, void *ct
)
306 return ((*noffp
< 0 || *noffp
> MAXOFFSET_T
) ? EINVAL
: 0);
308 EXPORT_SYMBOL(vn_seek
);
310 #ifdef HAVE_KERN_PATH_LOCKED
311 /* Based on do_unlinkat() from linux/fs/namei.c */
313 vn_remove(const char *path
, uio_seg_t seg
, int flags
)
315 struct dentry
*dentry
;
317 struct inode
*inode
= NULL
;
321 ASSERT(seg
== UIO_SYSSPACE
);
322 ASSERT(flags
== RMFILE
);
324 dentry
= spl_kern_path_locked(path
, &parent
);
325 rc
= PTR_ERR(dentry
);
326 if (!IS_ERR(dentry
)) {
327 if (parent
.dentry
->d_name
.name
[parent
.dentry
->d_name
.len
])
328 SGOTO(slashes
, rc
= 0);
330 inode
= dentry
->d_inode
;
332 SGOTO(slashes
, rc
= 0);
337 #ifdef HAVE_2ARGS_VFS_UNLINK
338 rc
= vfs_unlink(parent
.dentry
->d_inode
, dentry
);
340 rc
= vfs_unlink(parent
.dentry
->d_inode
, dentry
, NULL
);
341 #endif /* HAVE_2ARGS_VFS_UNLINK */
348 spl_inode_unlock(parent
.dentry
->d_inode
);
350 iput(inode
); /* truncate the inode here */
356 rc
= !dentry
->d_inode
? -ENOENT
:
357 S_ISDIR(dentry
->d_inode
->i_mode
) ? -EISDIR
: -ENOTDIR
;
360 EXPORT_SYMBOL(vn_remove
);
362 /* Based on do_rename() from linux/fs/namei.c */
364 vn_rename(const char *oldname
, const char *newname
, int x1
)
366 struct dentry
*old_dir
, *new_dir
;
367 struct dentry
*old_dentry
, *new_dentry
;
369 struct path old_parent
, new_parent
;
373 old_dentry
= spl_kern_path_locked(oldname
, &old_parent
);
374 if (IS_ERR(old_dentry
))
375 SGOTO(exit
, rc
= PTR_ERR(old_dentry
));
377 spl_inode_unlock(old_parent
.dentry
->d_inode
);
379 new_dentry
= spl_kern_path_locked(newname
, &new_parent
);
380 if (IS_ERR(new_dentry
))
381 SGOTO(exit2
, rc
= PTR_ERR(new_dentry
));
383 spl_inode_unlock(new_parent
.dentry
->d_inode
);
386 if (old_parent
.mnt
!= new_parent
.mnt
)
389 old_dir
= old_parent
.dentry
;
390 new_dir
= new_parent
.dentry
;
391 trap
= lock_rename(new_dir
, old_dir
);
393 /* source should not be ancestor of target */
395 if (old_dentry
== trap
)
398 /* target should not be an ancestor of source */
400 if (new_dentry
== trap
)
403 /* source must exist */
405 if (!old_dentry
->d_inode
)
408 /* unless the source is a directory trailing slashes give -ENOTDIR */
409 if (!S_ISDIR(old_dentry
->d_inode
->i_mode
)) {
411 if (old_dentry
->d_name
.name
[old_dentry
->d_name
.len
])
413 if (new_dentry
->d_name
.name
[new_dentry
->d_name
.len
])
417 #if defined(HAVE_4ARGS_VFS_RENAME)
418 rc
= vfs_rename(old_dir
->d_inode
, old_dentry
,
419 new_dir
->d_inode
, new_dentry
);
420 #elif defined(HAVE_5ARGS_VFS_RENAME)
421 rc
= vfs_rename(old_dir
->d_inode
, old_dentry
,
422 new_dir
->d_inode
, new_dentry
, NULL
);
424 rc
= vfs_rename(old_dir
->d_inode
, old_dentry
,
425 new_dir
->d_inode
, new_dentry
, NULL
, 0);
428 unlock_rename(new_dir
, old_dir
);
431 path_put(&new_parent
);
434 path_put(&old_parent
);
438 EXPORT_SYMBOL(vn_rename
);
441 static struct dentry
*
442 vn_lookup_hash(struct nameidata
*nd
)
444 return lookup_one_len((const char *)nd
->last
.name
,
445 nd
->nd_dentry
, nd
->last
.len
);
446 } /* lookup_hash() */
449 vn_path_release(struct nameidata
*nd
)
455 /* Modified do_unlinkat() from linux/fs/namei.c, only uses exported symbols */
457 vn_remove(const char *path
, uio_seg_t seg
, int flags
)
459 struct dentry
*dentry
;
461 struct inode
*inode
= NULL
;
465 ASSERT(seg
== UIO_SYSSPACE
);
466 ASSERT(flags
== RMFILE
);
468 rc
= spl_kern_path_parent(path
, &nd
);
473 if (nd
.last_type
!= LAST_NORM
)
476 spl_inode_lock_nested(nd
.nd_dentry
->d_inode
, I_MUTEX_PARENT
);
477 dentry
= vn_lookup_hash(&nd
);
478 rc
= PTR_ERR(dentry
);
479 if (!IS_ERR(dentry
)) {
480 /* Why not before? Because we want correct rc value */
481 if (nd
.last
.name
[nd
.last
.len
])
484 inode
= dentry
->d_inode
;
486 atomic_inc(&inode
->i_count
);
487 #ifdef HAVE_2ARGS_VFS_UNLINK
488 rc
= vfs_unlink(nd
.nd_dentry
->d_inode
, dentry
);
490 rc
= vfs_unlink(nd
.nd_dentry
->d_inode
, dentry
, NULL
);
491 #endif /* HAVE_2ARGS_VFS_UNLINK */
496 spl_inode_unlock(nd
.nd_dentry
->d_inode
);
498 iput(inode
); /* truncate the inode here */
500 vn_path_release(&nd
);
505 rc
= !dentry
->d_inode
? -ENOENT
:
506 S_ISDIR(dentry
->d_inode
->i_mode
) ? -EISDIR
: -ENOTDIR
;
509 EXPORT_SYMBOL(vn_remove
);
511 /* Modified do_rename() from linux/fs/namei.c, only uses exported symbols */
513 vn_rename(const char *oldname
, const char *newname
, int x1
)
515 struct dentry
*old_dir
, *new_dir
;
516 struct dentry
*old_dentry
, *new_dentry
;
518 struct nameidata oldnd
, newnd
;
522 rc
= spl_kern_path_parent(oldname
, &oldnd
);
526 rc
= spl_kern_path_parent(newname
, &newnd
);
531 if (oldnd
.nd_mnt
!= newnd
.nd_mnt
)
534 old_dir
= oldnd
.nd_dentry
;
536 if (oldnd
.last_type
!= LAST_NORM
)
539 new_dir
= newnd
.nd_dentry
;
540 if (newnd
.last_type
!= LAST_NORM
)
543 trap
= lock_rename(new_dir
, old_dir
);
545 old_dentry
= vn_lookup_hash(&oldnd
);
547 rc
= PTR_ERR(old_dentry
);
548 if (IS_ERR(old_dentry
))
551 /* source must exist */
553 if (!old_dentry
->d_inode
)
556 /* unless the source is a directory trailing slashes give -ENOTDIR */
557 if (!S_ISDIR(old_dentry
->d_inode
->i_mode
)) {
559 if (oldnd
.last
.name
[oldnd
.last
.len
])
561 if (newnd
.last
.name
[newnd
.last
.len
])
565 /* source should not be ancestor of target */
567 if (old_dentry
== trap
)
570 new_dentry
= vn_lookup_hash(&newnd
);
571 rc
= PTR_ERR(new_dentry
);
572 if (IS_ERR(new_dentry
))
575 /* target should not be an ancestor of source */
577 if (new_dentry
== trap
)
580 #if defined(HAVE_4ARGS_VFS_RENAME)
581 rc
= vfs_rename(old_dir
->d_inode
, old_dentry
,
582 new_dir
->d_inode
, new_dentry
);
583 #elif defined(HAVE_5ARGS_VFS_RENAME)
584 rc
= vfs_rename(old_dir
->d_inode
, old_dentry
,
585 new_dir
->d_inode
, new_dentry
, NULL
);
587 rc
= vfs_rename(old_dir
->d_inode
, old_dentry
,
588 new_dir
->d_inode
, new_dentry
, NULL
, 0);
595 unlock_rename(new_dir
, old_dir
);
597 vn_path_release(&newnd
);
599 vn_path_release(&oldnd
);
603 EXPORT_SYMBOL(vn_rename
);
604 #endif /* HAVE_KERN_PATH_LOCKED */
607 vn_getattr(vnode_t
*vp
, vattr_t
*vap
, int flags
, void *x3
, void *x4
)
620 #ifdef HAVE_2ARGS_VFS_GETATTR
621 rc
= vfs_getattr(&fp
->f_path
, &stat
);
623 rc
= vfs_getattr(fp
->f_path
.mnt
, fp
->f_dentry
, &stat
);
628 vap
->va_type
= vn_mode_to_vtype(stat
.mode
);
629 vap
->va_mode
= stat
.mode
;
630 vap
->va_uid
= KUID_TO_SUID(stat
.uid
);
631 vap
->va_gid
= KGID_TO_SGID(stat
.gid
);
633 vap
->va_nodeid
= stat
.ino
;
634 vap
->va_nlink
= stat
.nlink
;
635 vap
->va_size
= stat
.size
;
636 vap
->va_blksize
= stat
.blksize
;
637 vap
->va_atime
= stat
.atime
;
638 vap
->va_mtime
= stat
.mtime
;
639 vap
->va_ctime
= stat
.ctime
;
640 vap
->va_rdev
= stat
.rdev
;
641 vap
->va_nblocks
= stat
.blocks
;
645 EXPORT_SYMBOL(vn_getattr
);
647 int vn_fsync(vnode_t
*vp
, int flags
, void *x3
, void *x4
)
658 SRETURN(-spl_filp_fsync(vp
->v_file
, datasync
));
660 EXPORT_SYMBOL(vn_fsync
);
662 int vn_space(vnode_t
*vp
, int cmd
, struct flock
*bfp
, int flag
,
663 offset_t offset
, void *x6
, void *x7
)
665 int error
= EOPNOTSUPP
;
668 if (cmd
!= F_FREESP
|| bfp
->l_whence
!= 0)
673 ASSERT(bfp
->l_start
>= 0 && bfp
->l_len
> 0);
675 #ifdef FALLOC_FL_PUNCH_HOLE
677 * When supported by the underlying file system preferentially
678 * use the fallocate() callback to preallocate the space.
680 error
= -spl_filp_fallocate(vp
->v_file
,
681 FALLOC_FL_KEEP_SIZE
| FALLOC_FL_PUNCH_HOLE
,
682 bfp
->l_start
, bfp
->l_len
);
687 #ifdef HAVE_INODE_TRUNCATE_RANGE
688 if (vp
->v_file
->f_dentry
&& vp
->v_file
->f_dentry
->d_inode
&&
689 vp
->v_file
->f_dentry
->d_inode
->i_op
&&
690 vp
->v_file
->f_dentry
->d_inode
->i_op
->truncate_range
) {
691 off_t end
= bfp
->l_start
+ bfp
->l_len
;
693 * Judging from the code in shmem_truncate_range(),
694 * it seems the kernel expects the end offset to be
695 * inclusive and aligned to the end of a page.
697 if (end
% PAGE_SIZE
!= 0) {
698 end
&= ~(off_t
)(PAGE_SIZE
- 1);
699 if (end
<= bfp
->l_start
)
704 vp
->v_file
->f_dentry
->d_inode
->i_op
->truncate_range(
705 vp
->v_file
->f_dentry
->d_inode
,
714 EXPORT_SYMBOL(vn_space
);
716 /* Function must be called while holding the vn_file_lock */
722 ASSERT(spin_is_locked(&vn_file_lock
));
724 list_for_each_entry(fp
, &vn_file_list
, f_list
) {
725 if (fd
== fp
->f_fd
&& fp
->f_task
== current
) {
726 ASSERT(atomic_read(&fp
->f_ref
) != 0);
744 /* Already open just take an extra reference */
745 spin_lock(&vn_file_lock
);
749 atomic_inc(&fp
->f_ref
);
750 spin_unlock(&vn_file_lock
);
754 spin_unlock(&vn_file_lock
);
756 /* File was not yet opened create the object and setup */
757 fp
= kmem_cache_alloc(vn_file_cache
, KM_SLEEP
);
761 mutex_enter(&fp
->f_lock
);
764 fp
->f_task
= current
;
766 atomic_inc(&fp
->f_ref
);
770 SGOTO(out_mutex
, rc
);
772 vp
= vn_alloc(KM_SLEEP
);
776 #ifdef HAVE_2ARGS_VFS_GETATTR
777 rc
= vfs_getattr(&lfp
->f_path
, &stat
);
779 rc
= vfs_getattr(lfp
->f_path
.mnt
, lfp
->f_dentry
, &stat
);
782 SGOTO(out_vnode
, rc
);
784 mutex_enter(&vp
->v_lock
);
785 vp
->v_type
= vn_mode_to_vtype(stat
.mode
);
787 mutex_exit(&vp
->v_lock
);
792 /* Put it on the tracking list */
793 spin_lock(&vn_file_lock
);
794 list_add(&fp
->f_list
, &vn_file_list
);
795 spin_unlock(&vn_file_lock
);
797 mutex_exit(&fp
->f_lock
);
805 mutex_exit(&fp
->f_lock
);
806 kmem_cache_free(vn_file_cache
, fp
);
812 static void releasef_locked(file_t
*fp
)
817 /* Unlinked from list, no refs, safe to free outside mutex */
819 vn_free(fp
->f_vnode
);
821 kmem_cache_free(vn_file_cache
, fp
);
830 spin_lock(&vn_file_lock
);
833 atomic_dec(&fp
->f_ref
);
834 if (atomic_read(&fp
->f_ref
) > 0) {
835 spin_unlock(&vn_file_lock
);
840 list_del(&fp
->f_list
);
843 spin_unlock(&vn_file_lock
);
848 EXPORT_SYMBOL(releasef
);
850 #ifndef HAVE_SET_FS_PWD
852 # ifdef HAVE_SET_FS_PWD_WITH_CONST
853 set_fs_pwd(struct fs_struct
*fs
, const struct path
*path
)
855 set_fs_pwd(struct fs_struct
*fs
, struct path
*path
)
860 # ifdef HAVE_FS_STRUCT_SPINLOCK
861 spin_lock(&fs
->lock
);
865 spin_unlock(&fs
->lock
);
867 write_lock(&fs
->lock
);
871 write_unlock(&fs
->lock
);
872 # endif /* HAVE_FS_STRUCT_SPINLOCK */
877 #endif /* HAVE_SET_FS_PWD */
880 vn_set_pwd(const char *filename
)
882 #ifdef HAVE_USER_PATH_DIR
886 #endif /* HAVE_USER_PATH_DIR */
887 mm_segment_t saved_fs
;
892 * user_path_dir() and __user_walk() both expect 'filename' to be
893 * a user space address so we must briefly increase the data segment
894 * size to ensure strncpy_from_user() does not fail with -EFAULT.
899 # ifdef HAVE_USER_PATH_DIR
900 rc
= user_path_dir(filename
, &path
);
904 rc
= inode_permission(path
.dentry
->d_inode
, MAY_EXEC
| MAY_ACCESS
);
906 SGOTO(dput_and_out
, rc
);
908 set_fs_pwd(current
->fs
, &path
);
913 rc
= __user_walk(filename
,
914 LOOKUP_FOLLOW
|LOOKUP_DIRECTORY
|LOOKUP_CHDIR
, &nd
);
918 rc
= vfs_permission(&nd
, MAY_EXEC
);
920 SGOTO(dput_and_out
, rc
);
922 set_fs_pwd(current
->fs
, &nd
.path
);
926 # endif /* HAVE_USER_PATH_DIR */
932 EXPORT_SYMBOL(vn_set_pwd
);
935 vn_cache_constructor(void *buf
, void *cdrarg
, int kmflags
)
937 struct vnode
*vp
= buf
;
939 mutex_init(&vp
->v_lock
, NULL
, MUTEX_DEFAULT
, NULL
);
942 } /* vn_cache_constructor() */
945 vn_cache_destructor(void *buf
, void *cdrarg
)
947 struct vnode
*vp
= buf
;
949 mutex_destroy(&vp
->v_lock
);
950 } /* vn_cache_destructor() */
953 vn_file_cache_constructor(void *buf
, void *cdrarg
, int kmflags
)
957 atomic_set(&fp
->f_ref
, 0);
958 mutex_init(&fp
->f_lock
, NULL
, MUTEX_DEFAULT
, NULL
);
959 INIT_LIST_HEAD(&fp
->f_list
);
962 } /* file_cache_constructor() */
965 vn_file_cache_destructor(void *buf
, void *cdrarg
)
969 mutex_destroy(&fp
->f_lock
);
970 } /* vn_file_cache_destructor() */
972 int spl_vn_init_kallsyms_lookup(void)
974 #ifdef HAVE_KERN_PATH_PARENT_HEADER
975 #ifndef HAVE_KERN_PATH_PARENT_SYMBOL
976 kern_path_parent_fn
= (kern_path_parent_t
)
977 spl_kallsyms_lookup_name("kern_path_parent");
978 if (!kern_path_parent_fn
) {
979 printk(KERN_ERR
"Error: Unknown symbol kern_path_parent\n");
982 #endif /* HAVE_KERN_PATH_PARENT_SYMBOL */
983 #endif /* HAVE_KERN_PATH_PARENT_HEADER */
985 #ifdef HAVE_KERN_PATH_LOCKED
986 kern_path_locked_fn
= (kern_path_locked_t
)
987 spl_kallsyms_lookup_name("kern_path_locked");
988 if (!kern_path_locked_fn
) {
989 printk(KERN_ERR
"Error: Unknown symbol kern_path_locked\n");
1001 vn_cache
= kmem_cache_create("spl_vn_cache",
1002 sizeof(struct vnode
), 64,
1003 vn_cache_constructor
,
1004 vn_cache_destructor
,
1005 NULL
, NULL
, NULL
, KMC_KMEM
);
1007 vn_file_cache
= kmem_cache_create("spl_vn_file_cache",
1009 vn_file_cache_constructor
,
1010 vn_file_cache_destructor
,
1011 NULL
, NULL
, NULL
, KMC_KMEM
);
1018 file_t
*fp
, *next_fp
;
1022 spin_lock(&vn_file_lock
);
1024 list_for_each_entry_safe(fp
, next_fp
, &vn_file_list
, f_list
) {
1025 list_del(&fp
->f_list
);
1026 releasef_locked(fp
);
1030 spin_unlock(&vn_file_lock
);
1033 SWARN("Warning %d files leaked\n", leaked
);
1035 kmem_cache_destroy(vn_file_cache
);
1036 kmem_cache_destroy(vn_cache
);