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.
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.
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]
22 * Copyright (c) 2011, Lawrence Livermore National Security, LLC.
26 #include <sys/zfs_vfsops.h>
27 #include <sys/zfs_vnops.h>
28 #include <sys/zfs_znode.h>
33 zpl_inode_alloc(struct super_block *sb)
37 VERIFY3S(zfs_inode_alloc(sb, &ip), ==, 0);
44 zpl_inode_destroy(struct inode *ip)
46 ASSERT(atomic_read(&ip->i_count) == 0);
47 zfs_inode_destroy(ip);
51 * When ->drop_inode() is called its return value indicates if the
52 * inode should be evicted from the inode cache. If the inode is
53 * unhashed and has no links the default policy is to evict it
56 * Prior to 2.6.36 this eviction was accomplished by the vfs calling
57 * ->delete_inode(). It was ->delete_inode()'s responsibility to
58 * truncate the inode pages and call clear_inode(). The call to
59 * clear_inode() synchronously invalidates all the buffers and
60 * calls ->clear_inode(). It was ->clear_inode()'s responsibility
61 * to cleanup and filesystem specific data before freeing the inode.
63 * This elaborate mechanism was replaced by ->evict_inode() which
64 * does the job of both ->delete_inode() and ->clear_inode(). It
65 * will be called exactly once, and when it returns the inode must
66 * be in a state where it can simply be freed. The ->evict_inode()
67 * callback must minimally truncate the inode pages, and call
68 * end_writeback() to complete all outstanding writeback for the
69 * inode. After this is complete evict inode can cleanup any
70 * remaining filesystem specific data.
72 #ifdef HAVE_EVICT_INODE
74 zpl_evict_inode(struct inode *ip)
76 truncate_inode_pages(&ip->i_data, 0);
84 zpl_clear_inode(struct inode *ip)
90 zpl_inode_delete(struct inode *ip)
92 truncate_inode_pages(&ip->i_data, 0);
96 #endif /* HAVE_EVICT_INODE */
99 zpl_put_super(struct super_block *sb)
103 error = -zfs_umount(sb);
104 ASSERT3S(error, <=, 0);
108 zpl_sync_fs(struct super_block *sb, int wait)
113 cr = (cred_t *)get_current_cred();
114 error = -zfs_sync(sb, wait, cr);
116 ASSERT3S(error, <=, 0);
122 zpl_statfs(struct dentry *dentry, struct kstatfs *statp)
126 error = -zfs_statvfs(dentry, statp);
127 ASSERT3S(error, <=, 0);
133 zpl_remount_fs(struct super_block *sb, int *flags, char *data)
136 error = -zfs_remount(sb, flags, data);
137 ASSERT3S(error, <=, 0);
143 zpl_show_options(struct seq_file *seq, struct vfsmount *vfsp)
145 struct super_block *sb = vfsp->mnt_sb;
146 zfs_sb_t *zsb = sb->s_fs_info;
149 * The Linux VFS automatically handles the following flags:
150 * MNT_NOSUID, MNT_NODEV, MNT_NOEXEC, MNT_NOATIME, MNT_READONLY
153 if (zsb->z_flags & ZSB_XATTR_USER)
154 seq_printf(seq, ",%s", "xattr");
160 zpl_fill_super(struct super_block *sb, void *data, int silent)
164 error = -zfs_domount(sb, data, silent);
165 ASSERT3S(error, <=, 0);
171 zpl_get_sb(struct file_system_type *fs_type, int flags,
172 const char *osname, void *data, struct vfsmount *mnt)
174 zpl_mount_data_t zmd = { osname, data, mnt };
176 return get_sb_nodev(fs_type, flags, &zmd, zpl_fill_super, mnt);
180 zpl_kill_sb(struct super_block *sb)
183 zfs_sb_t *zsb = sb->s_fs_info;
185 if (zsb && dmu_objset_is_snapshot(zsb->z_os))
186 zfs_snap_destroy(zsb);
187 #endif /* HAVE_SNAPSHOT */
192 const struct super_operations zpl_super_operations = {
193 .alloc_inode = zpl_inode_alloc,
194 .destroy_inode = zpl_inode_destroy,
198 #ifdef HAVE_EVICT_INODE
199 .evict_inode = zpl_evict_inode,
201 .clear_inode = zpl_clear_inode,
202 .delete_inode = zpl_inode_delete,
203 #endif /* HAVE_EVICT_INODE */
204 .put_super = zpl_put_super,
206 .sync_fs = zpl_sync_fs,
207 .statfs = zpl_statfs,
208 .remount_fs = zpl_remount_fs,
209 .show_options = zpl_show_options,
214 const struct export_operations zpl_export_operations = {
215 .fh_to_dentry = NULL,
216 .fh_to_parent = NULL,
221 struct file_system_type zpl_fs_type = {
222 .owner = THIS_MODULE,
224 .get_sb = zpl_get_sb,
225 .kill_sb = zpl_kill_sb,