blob: b25ec4c8e56a802b4af7f4143a995cbea15ef6ba [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License v.2.
8 */
9
10#include <linux/sched.h>
11#include <linux/slab.h>
12#include <linux/spinlock.h>
13#include <linux/completion.h>
14#include <linux/buffer_head.h>
15#include <linux/namei.h>
16#include <linux/utsname.h>
17#include <linux/mm.h>
18#include <linux/xattr.h>
19#include <linux/posix_acl.h>
Steven Whitehouse5c676f62006-02-27 17:23:27 -050020#include <linux/gfs2_ondisk.h>
Steven Whitehouse71b86f52006-03-28 14:14:04 -050021#include <linux/crc32.h>
David Teiglandb3b94fa2006-01-16 16:50:04 +000022#include <asm/semaphore.h>
23#include <asm/uaccess.h>
24
25#include "gfs2.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050026#include "lm_interface.h"
27#include "incore.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000028#include "acl.h"
29#include "bmap.h"
30#include "dir.h"
31#include "eaops.h"
32#include "eattr.h"
33#include "glock.h"
34#include "inode.h"
35#include "meta_io.h"
36#include "ops_dentry.h"
37#include "ops_inode.h"
38#include "page.h"
39#include "quota.h"
40#include "rgrp.h"
41#include "trans.h"
42#include "unlinked.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050043#include "util.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000044
45/**
46 * gfs2_create - Create a file
47 * @dir: The directory in which to create the file
48 * @dentry: The dentry of the new file
49 * @mode: The mode of the new file
50 *
51 * Returns: errno
52 */
53
54static int gfs2_create(struct inode *dir, struct dentry *dentry,
55 int mode, struct nameidata *nd)
56{
Steven Whitehouse5c676f62006-02-27 17:23:27 -050057 struct gfs2_inode *dip = dir->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +000058 struct gfs2_sbd *sdp = dip->i_sbd;
59 struct gfs2_holder ghs[2];
60 struct inode *inode;
61 int new = 1;
David Teiglandb3b94fa2006-01-16 16:50:04 +000062
David Teiglandb3b94fa2006-01-16 16:50:04 +000063 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
64
65 for (;;) {
Steven Whitehouse7359a192006-02-13 12:27:43 +000066 inode = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode);
67 if (!IS_ERR(inode)) {
David Teiglandb3b94fa2006-01-16 16:50:04 +000068 gfs2_trans_end(sdp);
69 if (dip->i_alloc.al_rgd)
70 gfs2_inplace_release(dip);
71 gfs2_quota_unlock(dip);
72 gfs2_alloc_put(dip);
73 gfs2_glock_dq_uninit_m(2, ghs);
74 break;
Steven Whitehouse7359a192006-02-13 12:27:43 +000075 } else if (PTR_ERR(inode) != -EEXIST ||
David Teiglandb3b94fa2006-01-16 16:50:04 +000076 (nd->intent.open.flags & O_EXCL)) {
77 gfs2_holder_uninit(ghs);
Steven Whitehouse7359a192006-02-13 12:27:43 +000078 return PTR_ERR(inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +000079 }
80
Steven Whitehousec7526662006-03-20 12:30:04 -050081 inode = gfs2_lookupi(dir, &dentry->d_name, 0, nd);
82 if (inode) {
83 if (!IS_ERR(inode)) {
84 new = 0;
85 gfs2_holder_uninit(ghs);
86 break;
87 } else {
88 gfs2_holder_uninit(ghs);
89 return PTR_ERR(inode);
90 }
David Teiglandb3b94fa2006-01-16 16:50:04 +000091 }
92 }
93
David Teiglandb3b94fa2006-01-16 16:50:04 +000094 d_instantiate(dentry, inode);
95 if (new)
96 mark_inode_dirty(inode);
97
98 return 0;
99}
100
101/**
102 * gfs2_lookup - Look up a filename in a directory and return its inode
103 * @dir: The directory inode
104 * @dentry: The dentry of the new inode
105 * @nd: passed from Linux VFS, ignored by us
106 *
107 * Called by the VFS layer. Lock dir and call gfs2_lookupi()
108 *
109 * Returns: errno
110 */
111
112static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry,
113 struct nameidata *nd)
114{
David Teiglandb3b94fa2006-01-16 16:50:04 +0000115 struct inode *inode = NULL;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000116
Steven Whitehousec7526662006-03-20 12:30:04 -0500117 dentry->d_op = &gfs2_dops;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000118
Steven Whitehousec7526662006-03-20 12:30:04 -0500119 inode = gfs2_lookupi(dir, &dentry->d_name, 0, nd);
120 if (inode && IS_ERR(inode))
121 return ERR_PTR(PTR_ERR(inode));
David Teiglandb3b94fa2006-01-16 16:50:04 +0000122
123 if (inode)
124 return d_splice_alias(inode, dentry);
125 d_add(dentry, inode);
126
127 return NULL;
128}
129
130/**
131 * gfs2_link - Link to a file
132 * @old_dentry: The inode to link
133 * @dir: Add link to this directory
134 * @dentry: The name of the link
135 *
136 * Link the inode in "old_dentry" into the directory "dir" with the
137 * name in "dentry".
138 *
139 * Returns: errno
140 */
141
142static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
143 struct dentry *dentry)
144{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500145 struct gfs2_inode *dip = dir->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000146 struct gfs2_sbd *sdp = dip->i_sbd;
147 struct inode *inode = old_dentry->d_inode;
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500148 struct gfs2_inode *ip = inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000149 struct gfs2_holder ghs[2];
150 int alloc_required;
151 int error;
152
David Teiglandb3b94fa2006-01-16 16:50:04 +0000153 if (S_ISDIR(ip->i_di.di_mode))
154 return -EPERM;
155
156 gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
157 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
158
159 error = gfs2_glock_nq_m(2, ghs);
160 if (error)
161 goto out;
162
163 error = gfs2_repermission(dir, MAY_WRITE | MAY_EXEC, NULL);
164 if (error)
165 goto out_gunlock;
166
Steven Whitehousec7526662006-03-20 12:30:04 -0500167 error = gfs2_dir_search(dir, &dentry->d_name, NULL, NULL);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000168 switch (error) {
169 case -ENOENT:
170 break;
171 case 0:
172 error = -EEXIST;
173 default:
174 goto out_gunlock;
175 }
176
177 error = -EINVAL;
178 if (!dip->i_di.di_nlink)
179 goto out_gunlock;
180 error = -EFBIG;
181 if (dip->i_di.di_entries == (uint32_t)-1)
182 goto out_gunlock;
183 error = -EPERM;
184 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
185 goto out_gunlock;
186 error = -EINVAL;
187 if (!ip->i_di.di_nlink)
188 goto out_gunlock;
189 error = -EMLINK;
190 if (ip->i_di.di_nlink == (uint32_t)-1)
191 goto out_gunlock;
192
Steven Whitehousec7526662006-03-20 12:30:04 -0500193 alloc_required = error = gfs2_diradd_alloc_required(dir, &dentry->d_name);
194 if (error < 0)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000195 goto out_gunlock;
Steven Whitehousec7526662006-03-20 12:30:04 -0500196 error = 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000197
198 if (alloc_required) {
199 struct gfs2_alloc *al = gfs2_alloc_get(dip);
200
201 error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
202 if (error)
203 goto out_alloc;
204
205 error = gfs2_quota_check(dip, dip->i_di.di_uid,
206 dip->i_di.di_gid);
207 if (error)
208 goto out_gunlock_q;
209
210 al->al_requested = sdp->sd_max_dirres;
211
212 error = gfs2_inplace_reserve(dip);
213 if (error)
214 goto out_gunlock_q;
215
Steven Whitehouse1b502592006-05-18 14:10:52 -0400216 error = gfs2_trans_begin(sdp, sdp->sd_max_dirres +
David Teiglandb3b94fa2006-01-16 16:50:04 +0000217 al->al_rgd->rd_ri.ri_length +
218 2 * RES_DINODE + RES_STATFS +
219 RES_QUOTA, 0);
220 if (error)
221 goto out_ipres;
222 } else {
223 error = gfs2_trans_begin(sdp, 2 * RES_DINODE + RES_LEAF, 0);
224 if (error)
225 goto out_ipres;
226 }
227
Steven Whitehousec7526662006-03-20 12:30:04 -0500228 error = gfs2_dir_add(dir, &dentry->d_name, &ip->i_num,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000229 IF2DT(ip->i_di.di_mode));
230 if (error)
231 goto out_end_trans;
232
233 error = gfs2_change_nlink(ip, +1);
234
235 out_end_trans:
236 gfs2_trans_end(sdp);
237
238 out_ipres:
239 if (alloc_required)
240 gfs2_inplace_release(dip);
241
242 out_gunlock_q:
243 if (alloc_required)
244 gfs2_quota_unlock(dip);
245
246 out_alloc:
247 if (alloc_required)
248 gfs2_alloc_put(dip);
249
250 out_gunlock:
251 gfs2_glock_dq_m(2, ghs);
252
253 out:
254 gfs2_holder_uninit(ghs);
255 gfs2_holder_uninit(ghs + 1);
256
257 if (!error) {
258 atomic_inc(&inode->i_count);
259 d_instantiate(dentry, inode);
260 mark_inode_dirty(inode);
261 }
262
263 return error;
264}
265
266/**
267 * gfs2_unlink - Unlink a file
268 * @dir: The inode of the directory containing the file to unlink
269 * @dentry: The file itself
270 *
271 * Unlink a file. Call gfs2_unlinki()
272 *
273 * Returns: errno
274 */
275
276static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
277{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500278 struct gfs2_inode *dip = dir->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000279 struct gfs2_sbd *sdp = dip->i_sbd;
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500280 struct gfs2_inode *ip = dentry->d_inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000281 struct gfs2_unlinked *ul;
282 struct gfs2_holder ghs[2];
283 int error;
284
David Teiglandb3b94fa2006-01-16 16:50:04 +0000285 error = gfs2_unlinked_get(sdp, &ul);
286 if (error)
287 return error;
288
289 gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
290 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
291
292 error = gfs2_glock_nq_m(2, ghs);
293 if (error)
294 goto out;
295
296 error = gfs2_unlink_ok(dip, &dentry->d_name, ip);
297 if (error)
298 goto out_gunlock;
299
300 error = gfs2_trans_begin(sdp, 2 * RES_DINODE + RES_LEAF +
301 RES_UNLINKED, 0);
302 if (error)
303 goto out_gunlock;
304
Steven Whitehouse1b502592006-05-18 14:10:52 -0400305 error = gfs2_unlinki(dip, &dentry->d_name, ip, ul);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000306
307 gfs2_trans_end(sdp);
308
309 out_gunlock:
310 gfs2_glock_dq_m(2, ghs);
311
312 out:
313 gfs2_holder_uninit(ghs);
314 gfs2_holder_uninit(ghs + 1);
315
316 gfs2_unlinked_put(sdp, ul);
317
318 return error;
319}
320
321/**
322 * gfs2_symlink - Create a symlink
323 * @dir: The directory to create the symlink in
324 * @dentry: The dentry to put the symlink in
325 * @symname: The thing which the link points to
326 *
327 * Returns: errno
328 */
329
330static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
331 const char *symname)
332{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500333 struct gfs2_inode *dip = dir->u.generic_ip, *ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000334 struct gfs2_sbd *sdp = dip->i_sbd;
335 struct gfs2_holder ghs[2];
336 struct inode *inode;
337 struct buffer_head *dibh;
338 int size;
339 int error;
340
David Teiglandb3b94fa2006-01-16 16:50:04 +0000341 /* Must be stuffed with a null terminator for gfs2_follow_link() */
342 size = strlen(symname);
343 if (size > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode) - 1)
344 return -ENAMETOOLONG;
345
346 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
347
Steven Whitehouse7359a192006-02-13 12:27:43 +0000348 inode = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO);
349 if (IS_ERR(inode)) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000350 gfs2_holder_uninit(ghs);
Steven Whitehouse7359a192006-02-13 12:27:43 +0000351 return PTR_ERR(inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000352 }
353
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500354 ip = ghs[1].gh_gl->gl_object;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000355
356 ip->i_di.di_size = size;
357
358 error = gfs2_meta_inode_buffer(ip, &dibh);
359
360 if (!gfs2_assert_withdraw(sdp, !error)) {
361 gfs2_dinode_out(&ip->i_di, dibh->b_data);
362 memcpy(dibh->b_data + sizeof(struct gfs2_dinode), symname,
363 size);
364 brelse(dibh);
365 }
366
367 gfs2_trans_end(sdp);
368 if (dip->i_alloc.al_rgd)
369 gfs2_inplace_release(dip);
370 gfs2_quota_unlock(dip);
371 gfs2_alloc_put(dip);
372
373 gfs2_glock_dq_uninit_m(2, ghs);
374
David Teiglandb3b94fa2006-01-16 16:50:04 +0000375 d_instantiate(dentry, inode);
376 mark_inode_dirty(inode);
377
378 return 0;
379}
380
381/**
382 * gfs2_mkdir - Make a directory
383 * @dir: The parent directory of the new one
384 * @dentry: The dentry of the new directory
385 * @mode: The mode of the new directory
386 *
387 * Returns: errno
388 */
389
390static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
391{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500392 struct gfs2_inode *dip = dir->u.generic_ip, *ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000393 struct gfs2_sbd *sdp = dip->i_sbd;
394 struct gfs2_holder ghs[2];
395 struct inode *inode;
396 struct buffer_head *dibh;
397 int error;
398
David Teiglandb3b94fa2006-01-16 16:50:04 +0000399 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
400
Steven Whitehouse7359a192006-02-13 12:27:43 +0000401 inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode);
402 if (IS_ERR(inode)) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000403 gfs2_holder_uninit(ghs);
Steven Whitehouse7359a192006-02-13 12:27:43 +0000404 return PTR_ERR(inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000405 }
406
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500407 ip = ghs[1].gh_gl->gl_object;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000408
409 ip->i_di.di_nlink = 2;
410 ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
411 ip->i_di.di_flags |= GFS2_DIF_JDATA;
412 ip->i_di.di_payload_format = GFS2_FORMAT_DE;
413 ip->i_di.di_entries = 2;
414
415 error = gfs2_meta_inode_buffer(ip, &dibh);
416
417 if (!gfs2_assert_withdraw(sdp, !error)) {
418 struct gfs2_dinode *di = (struct gfs2_dinode *)dibh->b_data;
Steven Whitehousec7526662006-03-20 12:30:04 -0500419 struct gfs2_dirent *dent = (struct gfs2_dirent *)(di+1);
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500420 struct qstr str;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000421
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500422 gfs2_str2qstr(&str, ".");
Steven Whitehousec7526662006-03-20 12:30:04 -0500423 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
424 gfs2_qstr2dirent(&str, GFS2_DIRENT_SIZE(str.len), dent);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000425 dent->de_inum = di->di_num; /* already GFS2 endian */
David Teiglandb3b94fa2006-01-16 16:50:04 +0000426 dent->de_type = DT_DIR;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000427 di->di_entries = cpu_to_be32(1);
428
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500429 gfs2_str2qstr(&str, "..");
Steven Whitehousec7526662006-03-20 12:30:04 -0500430 dent = (struct gfs2_dirent *)((char*)dent + GFS2_DIRENT_SIZE(1));
431 gfs2_qstr2dirent(&str, dibh->b_size - GFS2_DIRENT_SIZE(1) - sizeof(struct gfs2_dinode), dent);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000432
433 gfs2_inum_out(&dip->i_num, (char *) &dent->de_inum);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000434 dent->de_type = DT_DIR;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000435
436 gfs2_dinode_out(&ip->i_di, (char *)di);
437
438 brelse(dibh);
439 }
440
441 error = gfs2_change_nlink(dip, +1);
442 gfs2_assert_withdraw(sdp, !error); /* dip already pinned */
443
444 gfs2_trans_end(sdp);
445 if (dip->i_alloc.al_rgd)
446 gfs2_inplace_release(dip);
447 gfs2_quota_unlock(dip);
448 gfs2_alloc_put(dip);
449
450 gfs2_glock_dq_uninit_m(2, ghs);
451
David Teiglandb3b94fa2006-01-16 16:50:04 +0000452 d_instantiate(dentry, inode);
453 mark_inode_dirty(inode);
454
455 return 0;
456}
457
458/**
459 * gfs2_rmdir - Remove a directory
460 * @dir: The parent directory of the directory to be removed
461 * @dentry: The dentry of the directory to remove
462 *
463 * Remove a directory. Call gfs2_rmdiri()
464 *
465 * Returns: errno
466 */
467
468static int gfs2_rmdir(struct inode *dir, struct dentry *dentry)
469{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500470 struct gfs2_inode *dip = dir->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000471 struct gfs2_sbd *sdp = dip->i_sbd;
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500472 struct gfs2_inode *ip = dentry->d_inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000473 struct gfs2_unlinked *ul;
474 struct gfs2_holder ghs[2];
475 int error;
476
David Teiglandb3b94fa2006-01-16 16:50:04 +0000477 error = gfs2_unlinked_get(sdp, &ul);
478 if (error)
479 return error;
480
481 gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
482 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
483
484 error = gfs2_glock_nq_m(2, ghs);
485 if (error)
486 goto out;
487
488 error = gfs2_unlink_ok(dip, &dentry->d_name, ip);
489 if (error)
490 goto out_gunlock;
491
492 if (ip->i_di.di_entries < 2) {
493 if (gfs2_consist_inode(ip))
494 gfs2_dinode_print(&ip->i_di);
495 error = -EIO;
496 goto out_gunlock;
497 }
498 if (ip->i_di.di_entries > 2) {
499 error = -ENOTEMPTY;
500 goto out_gunlock;
501 }
502
503 error = gfs2_trans_begin(sdp, 2 * RES_DINODE + 3 * RES_LEAF +
504 RES_UNLINKED, 0);
505 if (error)
506 goto out_gunlock;
507
508 error = gfs2_rmdiri(dip, &dentry->d_name, ip, ul);
509
510 gfs2_trans_end(sdp);
511
512 out_gunlock:
513 gfs2_glock_dq_m(2, ghs);
514
515 out:
516 gfs2_holder_uninit(ghs);
517 gfs2_holder_uninit(ghs + 1);
518
519 gfs2_unlinked_put(sdp, ul);
520
521 return error;
522}
523
524/**
525 * gfs2_mknod - Make a special file
526 * @dir: The directory in which the special file will reside
527 * @dentry: The dentry of the special file
528 * @mode: The mode of the special file
529 * @rdev: The device specification of the special file
530 *
531 */
532
533static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode,
534 dev_t dev)
535{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500536 struct gfs2_inode *dip = dir->u.generic_ip, *ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000537 struct gfs2_sbd *sdp = dip->i_sbd;
538 struct gfs2_holder ghs[2];
539 struct inode *inode;
540 struct buffer_head *dibh;
541 uint32_t major = 0, minor = 0;
542 int error;
543
David Teiglandb3b94fa2006-01-16 16:50:04 +0000544 switch (mode & S_IFMT) {
545 case S_IFBLK:
546 case S_IFCHR:
547 major = MAJOR(dev);
548 minor = MINOR(dev);
549 break;
550 case S_IFIFO:
551 case S_IFSOCK:
552 break;
553 default:
554 return -EOPNOTSUPP;
555 };
556
557 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
558
Steven Whitehouse7359a192006-02-13 12:27:43 +0000559 inode = gfs2_createi(ghs, &dentry->d_name, mode);
560 if (IS_ERR(inode)) {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000561 gfs2_holder_uninit(ghs);
Steven Whitehouse7359a192006-02-13 12:27:43 +0000562 return PTR_ERR(inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000563 }
564
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500565 ip = ghs[1].gh_gl->gl_object;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000566
567 ip->i_di.di_major = major;
568 ip->i_di.di_minor = minor;
569
570 error = gfs2_meta_inode_buffer(ip, &dibh);
571
572 if (!gfs2_assert_withdraw(sdp, !error)) {
573 gfs2_dinode_out(&ip->i_di, dibh->b_data);
574 brelse(dibh);
575 }
576
577 gfs2_trans_end(sdp);
578 if (dip->i_alloc.al_rgd)
579 gfs2_inplace_release(dip);
580 gfs2_quota_unlock(dip);
581 gfs2_alloc_put(dip);
582
583 gfs2_glock_dq_uninit_m(2, ghs);
584
David Teiglandb3b94fa2006-01-16 16:50:04 +0000585 d_instantiate(dentry, inode);
586 mark_inode_dirty(inode);
587
588 return 0;
589}
590
591/**
592 * gfs2_rename - Rename a file
593 * @odir: Parent directory of old file name
594 * @odentry: The old dentry of the file
595 * @ndir: Parent directory of new file name
596 * @ndentry: The new dentry of the file
597 *
598 * Returns: errno
599 */
600
601static int gfs2_rename(struct inode *odir, struct dentry *odentry,
602 struct inode *ndir, struct dentry *ndentry)
603{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500604 struct gfs2_inode *odip = odir->u.generic_ip;
605 struct gfs2_inode *ndip = ndir->u.generic_ip;
606 struct gfs2_inode *ip = odentry->d_inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000607 struct gfs2_inode *nip = NULL;
608 struct gfs2_sbd *sdp = odip->i_sbd;
609 struct gfs2_unlinked *ul;
610 struct gfs2_holder ghs[4], r_gh;
611 unsigned int num_gh;
612 int dir_rename = 0;
613 int alloc_required;
614 unsigned int x;
615 int error;
616
David Teiglandb3b94fa2006-01-16 16:50:04 +0000617 if (ndentry->d_inode) {
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500618 nip = ndentry->d_inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000619 if (ip == nip)
620 return 0;
621 }
622
623 error = gfs2_unlinked_get(sdp, &ul);
624 if (error)
625 return error;
626
627 /* Make sure we aren't trying to move a dirctory into it's subdir */
628
629 if (S_ISDIR(ip->i_di.di_mode) && odip != ndip) {
630 dir_rename = 1;
631
632 error = gfs2_glock_nq_init(sdp->sd_rename_gl,
633 LM_ST_EXCLUSIVE, 0,
634 &r_gh);
635 if (error)
636 goto out;
637
638 error = gfs2_ok_to_move(ip, ndip);
639 if (error)
640 goto out_gunlock_r;
641 }
642
643 gfs2_holder_init(odip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
644 gfs2_holder_init(ndip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
645 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 2);
646 num_gh = 3;
647
648 if (nip)
649 gfs2_holder_init(nip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh++);
650
651 error = gfs2_glock_nq_m(num_gh, ghs);
652 if (error)
653 goto out_uninit;
654
655 /* Check out the old directory */
656
657 error = gfs2_unlink_ok(odip, &odentry->d_name, ip);
658 if (error)
659 goto out_gunlock;
660
661 /* Check out the new directory */
662
663 if (nip) {
664 error = gfs2_unlink_ok(ndip, &ndentry->d_name, nip);
665 if (error)
666 goto out_gunlock;
667
668 if (S_ISDIR(nip->i_di.di_mode)) {
669 if (nip->i_di.di_entries < 2) {
670 if (gfs2_consist_inode(nip))
671 gfs2_dinode_print(&nip->i_di);
672 error = -EIO;
673 goto out_gunlock;
674 }
675 if (nip->i_di.di_entries > 2) {
676 error = -ENOTEMPTY;
677 goto out_gunlock;
678 }
679 }
680 } else {
681 error = gfs2_repermission(ndir, MAY_WRITE | MAY_EXEC, NULL);
682 if (error)
683 goto out_gunlock;
684
Steven Whitehousec7526662006-03-20 12:30:04 -0500685 error = gfs2_dir_search(ndir, &ndentry->d_name, NULL, NULL);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000686 switch (error) {
687 case -ENOENT:
688 error = 0;
689 break;
690 case 0:
691 error = -EEXIST;
692 default:
693 goto out_gunlock;
694 };
695
696 if (odip != ndip) {
697 if (!ndip->i_di.di_nlink) {
698 error = -EINVAL;
699 goto out_gunlock;
700 }
701 if (ndip->i_di.di_entries == (uint32_t)-1) {
702 error = -EFBIG;
703 goto out_gunlock;
704 }
705 if (S_ISDIR(ip->i_di.di_mode) &&
706 ndip->i_di.di_nlink == (uint32_t)-1) {
707 error = -EMLINK;
708 goto out_gunlock;
709 }
710 }
711 }
712
713 /* Check out the dir to be renamed */
714
715 if (dir_rename) {
716 error = gfs2_repermission(odentry->d_inode, MAY_WRITE, NULL);
717 if (error)
718 goto out_gunlock;
719 }
720
Steven Whitehousec7526662006-03-20 12:30:04 -0500721 alloc_required = error = gfs2_diradd_alloc_required(ndir, &ndentry->d_name);
722 if (error < 0)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000723 goto out_gunlock;
Steven Whitehousec7526662006-03-20 12:30:04 -0500724 error = 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000725
726 if (alloc_required) {
727 struct gfs2_alloc *al = gfs2_alloc_get(ndip);
728
729 error = gfs2_quota_lock(ndip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
730 if (error)
731 goto out_alloc;
732
733 error = gfs2_quota_check(ndip, ndip->i_di.di_uid,
734 ndip->i_di.di_gid);
735 if (error)
736 goto out_gunlock_q;
737
738 al->al_requested = sdp->sd_max_dirres;
739
740 error = gfs2_inplace_reserve(ndip);
741 if (error)
742 goto out_gunlock_q;
743
Steven Whitehousefe1bded2006-04-18 10:09:15 -0400744 error = gfs2_trans_begin(sdp, sdp->sd_max_dirres +
David Teiglandb3b94fa2006-01-16 16:50:04 +0000745 al->al_rgd->rd_ri.ri_length +
746 4 * RES_DINODE + 4 * RES_LEAF +
747 RES_UNLINKED + RES_STATFS +
748 RES_QUOTA, 0);
749 if (error)
750 goto out_ipreserv;
751 } else {
752 error = gfs2_trans_begin(sdp, 4 * RES_DINODE +
753 5 * RES_LEAF +
754 RES_UNLINKED, 0);
755 if (error)
756 goto out_gunlock;
757 }
758
759 /* Remove the target file, if it exists */
760
761 if (nip) {
762 if (S_ISDIR(nip->i_di.di_mode))
763 error = gfs2_rmdiri(ndip, &ndentry->d_name, nip, ul);
764 else
765 error = gfs2_unlinki(ndip, &ndentry->d_name, nip, ul);
766 if (error)
767 goto out_end_trans;
768 }
769
770 if (dir_rename) {
771 struct qstr name;
Steven Whitehouse71b86f52006-03-28 14:14:04 -0500772 gfs2_str2qstr(&name, "..");
David Teiglandb3b94fa2006-01-16 16:50:04 +0000773
774 error = gfs2_change_nlink(ndip, +1);
775 if (error)
776 goto out_end_trans;
777 error = gfs2_change_nlink(odip, -1);
778 if (error)
779 goto out_end_trans;
780
781 error = gfs2_dir_mvino(ip, &name, &ndip->i_num, DT_DIR);
782 if (error)
783 goto out_end_trans;
784 } else {
785 struct buffer_head *dibh;
786 error = gfs2_meta_inode_buffer(ip, &dibh);
787 if (error)
788 goto out_end_trans;
789 ip->i_di.di_ctime = get_seconds();
Steven Whitehoused4e9c4c2006-01-18 11:19:28 +0000790 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000791 gfs2_dinode_out(&ip->i_di, dibh->b_data);
792 brelse(dibh);
793 }
794
795 error = gfs2_dir_del(odip, &odentry->d_name);
796 if (error)
797 goto out_end_trans;
798
Steven Whitehousec7526662006-03-20 12:30:04 -0500799 error = gfs2_dir_add(ndir, &ndentry->d_name, &ip->i_num,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000800 IF2DT(ip->i_di.di_mode));
801 if (error)
802 goto out_end_trans;
803
804 out_end_trans:
805 gfs2_trans_end(sdp);
806
807 out_ipreserv:
808 if (alloc_required)
809 gfs2_inplace_release(ndip);
810
811 out_gunlock_q:
812 if (alloc_required)
813 gfs2_quota_unlock(ndip);
814
815 out_alloc:
816 if (alloc_required)
817 gfs2_alloc_put(ndip);
818
819 out_gunlock:
820 gfs2_glock_dq_m(num_gh, ghs);
821
822 out_uninit:
823 for (x = 0; x < num_gh; x++)
824 gfs2_holder_uninit(ghs + x);
825
826 out_gunlock_r:
827 if (dir_rename)
828 gfs2_glock_dq_uninit(&r_gh);
829
830 out:
831 gfs2_unlinked_put(sdp, ul);
832
833 return error;
834}
835
836/**
837 * gfs2_readlink - Read the value of a symlink
838 * @dentry: the symlink
839 * @buf: the buffer to read the symlink data into
840 * @size: the size of the buffer
841 *
842 * Returns: errno
843 */
844
845static int gfs2_readlink(struct dentry *dentry, char __user *user_buf,
846 int user_size)
847{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500848 struct gfs2_inode *ip = dentry->d_inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000849 char array[GFS2_FAST_NAME_SIZE], *buf = array;
850 unsigned int len = GFS2_FAST_NAME_SIZE;
851 int error;
852
David Teiglandb3b94fa2006-01-16 16:50:04 +0000853 error = gfs2_readlinki(ip, &buf, &len);
854 if (error)
855 return error;
856
857 if (user_size > len - 1)
858 user_size = len - 1;
859
860 if (copy_to_user(user_buf, buf, user_size))
861 error = -EFAULT;
862 else
863 error = user_size;
864
865 if (buf != array)
866 kfree(buf);
867
868 return error;
869}
870
871/**
872 * gfs2_follow_link - Follow a symbolic link
873 * @dentry: The dentry of the link
874 * @nd: Data that we pass to vfs_follow_link()
875 *
876 * This can handle symlinks of any size. It is optimised for symlinks
877 * under GFS2_FAST_NAME_SIZE.
878 *
879 * Returns: 0 on success or error code
880 */
881
882static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
883{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500884 struct gfs2_inode *ip = dentry->d_inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000885 char array[GFS2_FAST_NAME_SIZE], *buf = array;
886 unsigned int len = GFS2_FAST_NAME_SIZE;
887 int error;
888
David Teiglandb3b94fa2006-01-16 16:50:04 +0000889 error = gfs2_readlinki(ip, &buf, &len);
890 if (!error) {
891 error = vfs_follow_link(nd, buf);
892 if (buf != array)
893 kfree(buf);
894 }
895
896 return ERR_PTR(error);
897}
898
899/**
900 * gfs2_permission -
901 * @inode:
902 * @mask:
903 * @nd: passed from Linux VFS, ignored by us
904 *
905 * Returns: errno
906 */
907
908static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd)
909{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500910 struct gfs2_inode *ip = inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000911 struct gfs2_holder i_gh;
912 int error;
913
David Teiglandb3b94fa2006-01-16 16:50:04 +0000914 if (ip->i_vn == ip->i_gl->gl_vn)
915 return generic_permission(inode, mask, gfs2_check_acl);
916
917 error = gfs2_glock_nq_init(ip->i_gl,
918 LM_ST_SHARED, LM_FLAG_ANY,
919 &i_gh);
920 if (!error) {
921 error = generic_permission(inode, mask, gfs2_check_acl_locked);
922 gfs2_glock_dq_uninit(&i_gh);
923 }
924
925 return error;
926}
927
928static int setattr_size(struct inode *inode, struct iattr *attr)
929{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500930 struct gfs2_inode *ip = inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000931 int error;
932
933 if (attr->ia_size != ip->i_di.di_size) {
934 error = vmtruncate(inode, attr->ia_size);
935 if (error)
936 return error;
937 }
938
Steven Whitehouseaa6a85a2006-01-24 10:37:06 +0000939 error = gfs2_truncatei(ip, attr->ia_size);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000940 if (error)
941 return error;
942
943 return error;
944}
945
946static int setattr_chown(struct inode *inode, struct iattr *attr)
947{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500948 struct gfs2_inode *ip = inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000949 struct gfs2_sbd *sdp = ip->i_sbd;
950 struct buffer_head *dibh;
951 uint32_t ouid, ogid, nuid, ngid;
952 int error;
953
954 ouid = ip->i_di.di_uid;
955 ogid = ip->i_di.di_gid;
956 nuid = attr->ia_uid;
957 ngid = attr->ia_gid;
958
959 if (!(attr->ia_valid & ATTR_UID) || ouid == nuid)
960 ouid = nuid = NO_QUOTA_CHANGE;
961 if (!(attr->ia_valid & ATTR_GID) || ogid == ngid)
962 ogid = ngid = NO_QUOTA_CHANGE;
963
964 gfs2_alloc_get(ip);
965
966 error = gfs2_quota_lock(ip, nuid, ngid);
967 if (error)
968 goto out_alloc;
969
970 if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) {
971 error = gfs2_quota_check(ip, nuid, ngid);
972 if (error)
973 goto out_gunlock_q;
974 }
975
976 error = gfs2_trans_begin(sdp, RES_DINODE + 2 * RES_QUOTA, 0);
977 if (error)
978 goto out_gunlock_q;
979
980 error = gfs2_meta_inode_buffer(ip, &dibh);
981 if (error)
982 goto out_end_trans;
983
984 error = inode_setattr(inode, attr);
985 gfs2_assert_warn(sdp, !error);
986 gfs2_inode_attr_out(ip);
987
Steven Whitehoused4e9c4c2006-01-18 11:19:28 +0000988 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000989 gfs2_dinode_out(&ip->i_di, dibh->b_data);
990 brelse(dibh);
991
992 if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) {
993 gfs2_quota_change(ip, -ip->i_di.di_blocks,
994 ouid, ogid);
995 gfs2_quota_change(ip, ip->i_di.di_blocks,
996 nuid, ngid);
997 }
998
999 out_end_trans:
1000 gfs2_trans_end(sdp);
1001
1002 out_gunlock_q:
1003 gfs2_quota_unlock(ip);
1004
1005 out_alloc:
1006 gfs2_alloc_put(ip);
1007
1008 return error;
1009}
1010
1011/**
1012 * gfs2_setattr - Change attributes on an inode
1013 * @dentry: The dentry which is changing
1014 * @attr: The structure describing the change
1015 *
1016 * The VFS layer wants to change one or more of an inodes attributes. Write
1017 * that change out to disk.
1018 *
1019 * Returns: errno
1020 */
1021
1022static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
1023{
1024 struct inode *inode = dentry->d_inode;
Steven Whitehouse5c676f62006-02-27 17:23:27 -05001025 struct gfs2_inode *ip = inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +00001026 struct gfs2_holder i_gh;
1027 int error;
1028
David Teiglandb3b94fa2006-01-16 16:50:04 +00001029 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh);
1030 if (error)
1031 return error;
1032
1033 error = -EPERM;
1034 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1035 goto out;
1036
1037 error = inode_change_ok(inode, attr);
1038 if (error)
1039 goto out;
1040
1041 if (attr->ia_valid & ATTR_SIZE)
1042 error = setattr_size(inode, attr);
1043 else if (attr->ia_valid & (ATTR_UID | ATTR_GID))
1044 error = setattr_chown(inode, attr);
1045 else if ((attr->ia_valid & ATTR_MODE) && IS_POSIXACL(inode))
1046 error = gfs2_acl_chmod(ip, attr);
1047 else
1048 error = gfs2_setattr_simple(ip, attr);
1049
1050 out:
1051 gfs2_glock_dq_uninit(&i_gh);
1052
1053 if (!error)
1054 mark_inode_dirty(inode);
1055
1056 return error;
1057}
1058
1059/**
1060 * gfs2_getattr - Read out an inode's attributes
1061 * @mnt: ?
1062 * @dentry: The dentry to stat
1063 * @stat: The inode's stats
1064 *
1065 * Returns: errno
1066 */
1067
1068static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
1069 struct kstat *stat)
1070{
1071 struct inode *inode = dentry->d_inode;
Steven Whitehouse5c676f62006-02-27 17:23:27 -05001072 struct gfs2_inode *ip = inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +00001073 struct gfs2_holder gh;
1074 int error;
1075
David Teiglandb3b94fa2006-01-16 16:50:04 +00001076 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
1077 if (!error) {
1078 generic_fillattr(inode, stat);
1079 gfs2_glock_dq_uninit(&gh);
1080 }
1081
1082 return error;
1083}
1084
1085static int gfs2_setxattr(struct dentry *dentry, const char *name,
1086 const void *data, size_t size, int flags)
1087{
Steven Whitehouse5c676f62006-02-27 17:23:27 -05001088 struct gfs2_inode *ip = dentry->d_inode->u.generic_ip;
David Teiglandb3b94fa2006-01-16 16:50:04 +00001089 struct gfs2_ea_request er;
1090
David Teiglandb3b94fa2006-01-16 16:50:04 +00001091 memset(&er, 0, sizeof(struct gfs2_ea_request));
1092 er.er_type = gfs2_ea_name2type(name, &er.er_name);
1093 if (er.er_type == GFS2_EATYPE_UNUSED)
1094 return -EOPNOTSUPP;
1095 er.er_data = (char *)data;
1096 er.er_name_len = strlen(er.er_name);
1097 er.er_data_len = size;
1098 er.er_flags = flags;
1099
1100 gfs2_assert_warn(ip->i_sbd, !(er.er_flags & GFS2_ERF_MODE));
1101
1102 return gfs2_ea_set(ip, &er);
1103}
1104
1105static ssize_t gfs2_getxattr(struct dentry *dentry, const char *name,
1106 void *data, size_t size)
1107{
1108 struct gfs2_ea_request er;
1109
David Teiglandb3b94fa2006-01-16 16:50:04 +00001110 memset(&er, 0, sizeof(struct gfs2_ea_request));
1111 er.er_type = gfs2_ea_name2type(name, &er.er_name);
1112 if (er.er_type == GFS2_EATYPE_UNUSED)
1113 return -EOPNOTSUPP;
1114 er.er_data = data;
1115 er.er_name_len = strlen(er.er_name);
1116 er.er_data_len = size;
1117
Steven Whitehouse5c676f62006-02-27 17:23:27 -05001118 return gfs2_ea_get(dentry->d_inode->u.generic_ip, &er);
David Teiglandb3b94fa2006-01-16 16:50:04 +00001119}
1120
1121static ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size)
1122{
1123 struct gfs2_ea_request er;
1124
David Teiglandb3b94fa2006-01-16 16:50:04 +00001125 memset(&er, 0, sizeof(struct gfs2_ea_request));
1126 er.er_data = (size) ? buffer : NULL;
1127 er.er_data_len = size;
1128
Steven Whitehouse5c676f62006-02-27 17:23:27 -05001129 return gfs2_ea_list(dentry->d_inode->u.generic_ip, &er);
David Teiglandb3b94fa2006-01-16 16:50:04 +00001130}
1131
1132static int gfs2_removexattr(struct dentry *dentry, const char *name)
1133{
1134 struct gfs2_ea_request er;
1135
David Teiglandb3b94fa2006-01-16 16:50:04 +00001136 memset(&er, 0, sizeof(struct gfs2_ea_request));
1137 er.er_type = gfs2_ea_name2type(name, &er.er_name);
1138 if (er.er_type == GFS2_EATYPE_UNUSED)
1139 return -EOPNOTSUPP;
1140 er.er_name_len = strlen(er.er_name);
1141
Steven Whitehouse5c676f62006-02-27 17:23:27 -05001142 return gfs2_ea_remove(dentry->d_inode->u.generic_ip, &er);
David Teiglandb3b94fa2006-01-16 16:50:04 +00001143}
1144
1145struct inode_operations gfs2_file_iops = {
1146 .permission = gfs2_permission,
1147 .setattr = gfs2_setattr,
1148 .getattr = gfs2_getattr,
1149 .setxattr = gfs2_setxattr,
1150 .getxattr = gfs2_getxattr,
1151 .listxattr = gfs2_listxattr,
1152 .removexattr = gfs2_removexattr,
1153};
1154
1155struct inode_operations gfs2_dev_iops = {
1156 .permission = gfs2_permission,
1157 .setattr = gfs2_setattr,
1158 .getattr = gfs2_getattr,
1159 .setxattr = gfs2_setxattr,
1160 .getxattr = gfs2_getxattr,
1161 .listxattr = gfs2_listxattr,
1162 .removexattr = gfs2_removexattr,
1163};
1164
1165struct inode_operations gfs2_dir_iops = {
1166 .create = gfs2_create,
1167 .lookup = gfs2_lookup,
1168 .link = gfs2_link,
1169 .unlink = gfs2_unlink,
1170 .symlink = gfs2_symlink,
1171 .mkdir = gfs2_mkdir,
1172 .rmdir = gfs2_rmdir,
1173 .mknod = gfs2_mknod,
1174 .rename = gfs2_rename,
1175 .permission = gfs2_permission,
1176 .setattr = gfs2_setattr,
1177 .getattr = gfs2_getattr,
1178 .setxattr = gfs2_setxattr,
1179 .getxattr = gfs2_getxattr,
1180 .listxattr = gfs2_listxattr,
1181 .removexattr = gfs2_removexattr,
1182};
1183
1184struct inode_operations gfs2_symlink_iops = {
1185 .readlink = gfs2_readlink,
1186 .follow_link = gfs2_follow_link,
1187 .permission = gfs2_permission,
1188 .setattr = gfs2_setattr,
1189 .getattr = gfs2_getattr,
1190 .setxattr = gfs2_setxattr,
1191 .getxattr = gfs2_getxattr,
1192 .listxattr = gfs2_listxattr,
1193 .removexattr = gfs2_removexattr,
1194};
1195