diff options
Diffstat (limited to 'fs/9p/vfs_super.c')
-rw-r--r-- | fs/9p/vfs_super.c | 91 |
1 files changed, 37 insertions, 54 deletions
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 7bdf8b326841..f6a0519ade8c 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
@@ -37,10 +37,10 @@ | |||
37 | #include <linux/mount.h> | 37 | #include <linux/mount.h> |
38 | #include <linux/idr.h> | 38 | #include <linux/idr.h> |
39 | #include <linux/sched.h> | 39 | #include <linux/sched.h> |
40 | #include <net/9p/9p.h> | ||
41 | #include <net/9p/client.h> | ||
40 | 42 | ||
41 | #include "debug.h" | ||
42 | #include "v9fs.h" | 43 | #include "v9fs.h" |
43 | #include "9p.h" | ||
44 | #include "v9fs_vfs.h" | 44 | #include "v9fs_vfs.h" |
45 | #include "fid.h" | 45 | #include "fid.h" |
46 | 46 | ||
@@ -107,41 +107,48 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags, | |||
107 | struct vfsmount *mnt) | 107 | struct vfsmount *mnt) |
108 | { | 108 | { |
109 | struct super_block *sb = NULL; | 109 | struct super_block *sb = NULL; |
110 | struct v9fs_fcall *fcall = NULL; | ||
111 | struct inode *inode = NULL; | 110 | struct inode *inode = NULL; |
112 | struct dentry *root = NULL; | 111 | struct dentry *root = NULL; |
113 | struct v9fs_session_info *v9ses = NULL; | 112 | struct v9fs_session_info *v9ses = NULL; |
114 | struct v9fs_fid *root_fid = NULL; | 113 | struct p9_stat *st = NULL; |
115 | int mode = S_IRWXUGO | S_ISVTX; | 114 | int mode = S_IRWXUGO | S_ISVTX; |
116 | uid_t uid = current->fsuid; | 115 | uid_t uid = current->fsuid; |
117 | gid_t gid = current->fsgid; | 116 | gid_t gid = current->fsgid; |
118 | int stat_result = 0; | 117 | struct p9_fid *fid; |
119 | int newfid = 0; | ||
120 | int retval = 0; | 118 | int retval = 0; |
121 | 119 | ||
122 | dprintk(DEBUG_VFS, " \n"); | 120 | P9_DPRINTK(P9_DEBUG_VFS, " \n"); |
123 | 121 | ||
124 | v9ses = kzalloc(sizeof(struct v9fs_session_info), GFP_KERNEL); | 122 | v9ses = kzalloc(sizeof(struct v9fs_session_info), GFP_KERNEL); |
125 | if (!v9ses) | 123 | if (!v9ses) |
126 | return -ENOMEM; | 124 | return -ENOMEM; |
127 | 125 | ||
128 | if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) { | 126 | fid = v9fs_session_init(v9ses, dev_name, data); |
129 | dprintk(DEBUG_ERROR, "problem initiating session\n"); | 127 | if (IS_ERR(fid)) { |
130 | retval = newfid; | 128 | retval = PTR_ERR(fid); |
131 | goto out_free_session; | 129 | fid = NULL; |
130 | kfree(v9ses); | ||
131 | v9ses = NULL; | ||
132 | goto error; | ||
133 | } | ||
134 | |||
135 | st = p9_client_stat(fid); | ||
136 | if (IS_ERR(st)) { | ||
137 | retval = PTR_ERR(st); | ||
138 | goto error; | ||
132 | } | 139 | } |
133 | 140 | ||
134 | sb = sget(fs_type, NULL, v9fs_set_super, v9ses); | 141 | sb = sget(fs_type, NULL, v9fs_set_super, v9ses); |
135 | if (IS_ERR(sb)) { | 142 | if (IS_ERR(sb)) { |
136 | retval = PTR_ERR(sb); | 143 | retval = PTR_ERR(sb); |
137 | goto out_close_session; | 144 | goto error; |
138 | } | 145 | } |
139 | v9fs_fill_super(sb, v9ses, flags); | 146 | v9fs_fill_super(sb, v9ses, flags); |
140 | 147 | ||
141 | inode = v9fs_get_inode(sb, S_IFDIR | mode); | 148 | inode = v9fs_get_inode(sb, S_IFDIR | mode); |
142 | if (IS_ERR(inode)) { | 149 | if (IS_ERR(inode)) { |
143 | retval = PTR_ERR(inode); | 150 | retval = PTR_ERR(inode); |
144 | goto put_back_sb; | 151 | goto error; |
145 | } | 152 | } |
146 | 153 | ||
147 | inode->i_uid = uid; | 154 | inode->i_uid = uid; |
@@ -150,54 +157,30 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags, | |||
150 | root = d_alloc_root(inode); | 157 | root = d_alloc_root(inode); |
151 | if (!root) { | 158 | if (!root) { |
152 | retval = -ENOMEM; | 159 | retval = -ENOMEM; |
153 | goto put_back_sb; | 160 | goto error; |
154 | } | 161 | } |
155 | 162 | ||
156 | sb->s_root = root; | 163 | sb->s_root = root; |
164 | root->d_inode->i_ino = v9fs_qid2ino(&st->qid); | ||
165 | v9fs_stat2inode(st, root->d_inode, sb); | ||
166 | v9fs_fid_add(root, fid); | ||
157 | 167 | ||
158 | stat_result = v9fs_t_stat(v9ses, newfid, &fcall); | 168 | return simple_set_mnt(mnt, sb); |
159 | if (stat_result < 0) { | ||
160 | dprintk(DEBUG_ERROR, "stat error\n"); | ||
161 | v9fs_t_clunk(v9ses, newfid); | ||
162 | } else { | ||
163 | /* Setup the Root Inode */ | ||
164 | root_fid = v9fs_fid_create(v9ses, newfid); | ||
165 | if (root_fid == NULL) { | ||
166 | retval = -ENOMEM; | ||
167 | goto put_back_sb; | ||
168 | } | ||
169 | |||
170 | retval = v9fs_fid_insert(root_fid, root); | ||
171 | if (retval < 0) { | ||
172 | kfree(fcall); | ||
173 | goto put_back_sb; | ||
174 | } | ||
175 | |||
176 | root_fid->qid = fcall->params.rstat.stat.qid; | ||
177 | root->d_inode->i_ino = | ||
178 | v9fs_qid2ino(&fcall->params.rstat.stat.qid); | ||
179 | v9fs_stat2inode(&fcall->params.rstat.stat, root->d_inode, sb); | ||
180 | } | ||
181 | 169 | ||
182 | kfree(fcall); | 170 | error: |
171 | if (fid) | ||
172 | p9_client_clunk(fid); | ||
183 | 173 | ||
184 | if (stat_result < 0) { | 174 | if (v9ses) { |
185 | retval = stat_result; | 175 | v9fs_session_close(v9ses); |
186 | goto put_back_sb; | 176 | kfree(v9ses); |
187 | } | 177 | } |
188 | 178 | ||
189 | return simple_set_mnt(mnt, sb); | 179 | if (sb) { |
190 | 180 | up_write(&sb->s_umount); | |
191 | out_close_session: | 181 | deactivate_super(sb); |
192 | v9fs_session_close(v9ses); | 182 | } |
193 | out_free_session: | ||
194 | kfree(v9ses); | ||
195 | return retval; | ||
196 | 183 | ||
197 | put_back_sb: | ||
198 | /* deactivate_super calls v9fs_kill_super which will frees the rest */ | ||
199 | up_write(&sb->s_umount); | ||
200 | deactivate_super(sb); | ||
201 | return retval; | 184 | return retval; |
202 | } | 185 | } |
203 | 186 | ||
@@ -211,7 +194,7 @@ static void v9fs_kill_super(struct super_block *s) | |||
211 | { | 194 | { |
212 | struct v9fs_session_info *v9ses = s->s_fs_info; | 195 | struct v9fs_session_info *v9ses = s->s_fs_info; |
213 | 196 | ||
214 | dprintk(DEBUG_VFS, " %p\n", s); | 197 | P9_DPRINTK(P9_DEBUG_VFS, " %p\n", s); |
215 | 198 | ||
216 | v9fs_dentry_release(s->s_root); /* clunk root */ | 199 | v9fs_dentry_release(s->s_root); /* clunk root */ |
217 | 200 | ||
@@ -219,7 +202,7 @@ static void v9fs_kill_super(struct super_block *s) | |||
219 | 202 | ||
220 | v9fs_session_close(v9ses); | 203 | v9fs_session_close(v9ses); |
221 | kfree(v9ses); | 204 | kfree(v9ses); |
222 | dprintk(DEBUG_VFS, "exiting kill_super\n"); | 205 | P9_DPRINTK(P9_DEBUG_VFS, "exiting kill_super\n"); |
223 | } | 206 | } |
224 | 207 | ||
225 | /** | 208 | /** |