]> git.proxmox.com Git - mirror_zfs.git/blame - module/zfs/zpl_super.c
Linux 2.6.33 compat, get/set xattr callbacks
[mirror_zfs.git] / module / zfs / zpl_super.c
CommitLineData
51f0bbe4
BB
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 */
24
25
26#include <sys/zfs_vfsops.h>
27#include <sys/zfs_vnops.h>
28#include <sys/zfs_znode.h>
29#include <sys/zpl.h>
30
31
32static struct inode *
33zpl_inode_alloc(struct super_block *sb)
34{
35 struct inode *ip;
36
37 VERIFY3S(zfs_inode_alloc(sb, &ip), ==, 0);
38 ip->i_version = 1;
39
40 return (ip);
41}
42
43static void
44zpl_inode_destroy(struct inode *ip)
45{
46 ASSERT(atomic_read(&ip->i_count) == 0);
47 zfs_inode_destroy(ip);
48}
49
50static void
51zpl_inode_delete(struct inode *ip)
52{
53 loff_t oldsize = i_size_read(ip);
54
55 i_size_write(ip, 0);
56 truncate_pagecache(ip, oldsize, 0);
57 clear_inode(ip);
58}
59
60static void
61zpl_evict_inode(struct inode *ip)
62{
63 zfs_inactive(ip);
64}
65
66static void
67zpl_put_super(struct super_block *sb)
68{
69 int error;
70
71 error = -zfs_umount(sb);
72 ASSERT3S(error, <=, 0);
73}
74
75static int
76zpl_statfs(struct dentry *dentry, struct kstatfs *statp)
77{
78 int error;
79
80 error = -zfs_statvfs(dentry, statp);
81 ASSERT3S(error, <=, 0);
82
83 return (error);
84}
85
86static int
87zpl_show_options(struct seq_file *seq, struct vfsmount *vfsp)
88{
89 struct super_block *sb = vfsp->mnt_sb;
90 zfs_sb_t *zsb = sb->s_fs_info;
91
92 /*
93 * The Linux VFS automatically handles the following flags:
94 * MNT_NOSUID, MNT_NODEV, MNT_NOEXEC, MNT_NOATIME, MNT_READONLY
95 */
96
97 if (zsb->z_flags & ZSB_XATTR_USER)
98 seq_printf(seq, ",%s", "xattr");
99
100 return (0);
101}
102
103static int
104zpl_fill_super(struct super_block *sb, void *data, int silent)
105{
106 int error;
107
108 error = -zfs_domount(sb, data, silent);
109 ASSERT3S(error, <=, 0);
110
111 return (error);
112}
113
114static int
115zpl_get_sb(struct file_system_type *fs_type, int flags,
116 const char *osname, void *data, struct vfsmount *mnt)
117{
118 zpl_mount_data_t zmd = { osname, data, mnt };
119
120 return get_sb_nodev(fs_type, flags, &zmd, zpl_fill_super, mnt);
121}
122
123static void
124zpl_kill_sb(struct super_block *sb)
125{
126#ifdef HAVE_SNAPSHOT
127 zfs_sb_t *zsb = sb->s_fs_info;
128
129 if (zsb && dmu_objset_is_snapshot(zsb->z_os))
130 zfs_snap_destroy(zsb);
131#endif /* HAVE_SNAPSHOT */
132
133 kill_anon_super(sb);
134}
135
136const struct super_operations zpl_super_operations = {
137 .alloc_inode = zpl_inode_alloc,
138 .destroy_inode = zpl_inode_destroy,
139 .delete_inode = zpl_inode_delete,
140 .dirty_inode = NULL,
141 .write_inode = NULL,
142 .drop_inode = NULL,
143 .clear_inode = zpl_evict_inode,
144 .put_super = zpl_put_super,
145 .write_super = NULL,
146 .sync_fs = NULL,
147 .freeze_fs = NULL,
148 .unfreeze_fs = NULL,
149 .statfs = zpl_statfs,
150 .remount_fs = NULL,
151 .show_options = zpl_show_options,
152 .show_stats = NULL,
153};
154
155#if 0
156const struct export_operations zpl_export_operations = {
157 .fh_to_dentry = NULL,
158 .fh_to_parent = NULL,
159 .get_parent = NULL,
160};
161#endif
162
163struct file_system_type zpl_fs_type = {
164 .owner = THIS_MODULE,
165 .name = ZFS_DRIVER,
166 .get_sb = zpl_get_sb,
167 .kill_sb = zpl_kill_sb,
168};