PageRenderTime 58ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/linux-2.6.33/kernel/linux-2.6.33/fs/gfs2/ops_inode.c

https://bitbucket.org/microcreat/cortexm_uclinux
C | 1440 lines | 1020 code | 226 blank | 194 comment | 224 complexity | daa58cc525de02510eef5d1538a0919d MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /*
  2. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  3. * Copyright (C) 2004-2006 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 version 2.
  8. */
  9. #include <linux/slab.h>
  10. #include <linux/spinlock.h>
  11. #include <linux/completion.h>
  12. #include <linux/buffer_head.h>
  13. #include <linux/namei.h>
  14. #include <linux/mm.h>
  15. #include <linux/xattr.h>
  16. #include <linux/posix_acl.h>
  17. #include <linux/gfs2_ondisk.h>
  18. #include <linux/crc32.h>
  19. #include <linux/fiemap.h>
  20. #include <asm/uaccess.h>
  21. #include "gfs2.h"
  22. #include "incore.h"
  23. #include "acl.h"
  24. #include "bmap.h"
  25. #include "dir.h"
  26. #include "xattr.h"
  27. #include "glock.h"
  28. #include "inode.h"
  29. #include "meta_io.h"
  30. #include "quota.h"
  31. #include "rgrp.h"
  32. #include "trans.h"
  33. #include "util.h"
  34. #include "super.h"
  35. /**
  36. * gfs2_create - Create a file
  37. * @dir: The directory in which to create the file
  38. * @dentry: The dentry of the new file
  39. * @mode: The mode of the new file
  40. *
  41. * Returns: errno
  42. */
  43. static int gfs2_create(struct inode *dir, struct dentry *dentry,
  44. int mode, struct nameidata *nd)
  45. {
  46. struct gfs2_inode *dip = GFS2_I(dir);
  47. struct gfs2_sbd *sdp = GFS2_SB(dir);
  48. struct gfs2_holder ghs[2];
  49. struct inode *inode;
  50. gfs2_holder_init(dip->i_gl, 0, 0, ghs);
  51. for (;;) {
  52. inode = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode, 0);
  53. if (!IS_ERR(inode)) {
  54. gfs2_trans_end(sdp);
  55. if (dip->i_alloc->al_rgd)
  56. gfs2_inplace_release(dip);
  57. gfs2_quota_unlock(dip);
  58. gfs2_alloc_put(dip);
  59. gfs2_glock_dq_uninit_m(2, ghs);
  60. mark_inode_dirty(inode);
  61. break;
  62. } else if (PTR_ERR(inode) != -EEXIST ||
  63. (nd && nd->flags & LOOKUP_EXCL)) {
  64. gfs2_holder_uninit(ghs);
  65. return PTR_ERR(inode);
  66. }
  67. inode = gfs2_lookupi(dir, &dentry->d_name, 0);
  68. if (inode) {
  69. if (!IS_ERR(inode)) {
  70. gfs2_holder_uninit(ghs);
  71. break;
  72. } else {
  73. gfs2_holder_uninit(ghs);
  74. return PTR_ERR(inode);
  75. }
  76. }
  77. }
  78. d_instantiate(dentry, inode);
  79. return 0;
  80. }
  81. /**
  82. * gfs2_lookup - Look up a filename in a directory and return its inode
  83. * @dir: The directory inode
  84. * @dentry: The dentry of the new inode
  85. * @nd: passed from Linux VFS, ignored by us
  86. *
  87. * Called by the VFS layer. Lock dir and call gfs2_lookupi()
  88. *
  89. * Returns: errno
  90. */
  91. static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry,
  92. struct nameidata *nd)
  93. {
  94. struct inode *inode = NULL;
  95. dentry->d_op = &gfs2_dops;
  96. inode = gfs2_lookupi(dir, &dentry->d_name, 0);
  97. if (inode && IS_ERR(inode))
  98. return ERR_CAST(inode);
  99. if (inode) {
  100. struct gfs2_glock *gl = GFS2_I(inode)->i_gl;
  101. struct gfs2_holder gh;
  102. int error;
  103. error = gfs2_glock_nq_init(gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
  104. if (error) {
  105. iput(inode);
  106. return ERR_PTR(error);
  107. }
  108. gfs2_glock_dq_uninit(&gh);
  109. return d_splice_alias(inode, dentry);
  110. }
  111. d_add(dentry, inode);
  112. return NULL;
  113. }
  114. /**
  115. * gfs2_link - Link to a file
  116. * @old_dentry: The inode to link
  117. * @dir: Add link to this directory
  118. * @dentry: The name of the link
  119. *
  120. * Link the inode in "old_dentry" into the directory "dir" with the
  121. * name in "dentry".
  122. *
  123. * Returns: errno
  124. */
  125. static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
  126. struct dentry *dentry)
  127. {
  128. struct gfs2_inode *dip = GFS2_I(dir);
  129. struct gfs2_sbd *sdp = GFS2_SB(dir);
  130. struct inode *inode = old_dentry->d_inode;
  131. struct gfs2_inode *ip = GFS2_I(inode);
  132. struct gfs2_holder ghs[2];
  133. int alloc_required;
  134. int error;
  135. if (S_ISDIR(inode->i_mode))
  136. return -EPERM;
  137. gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
  138. gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
  139. error = gfs2_glock_nq(ghs); /* parent */
  140. if (error)
  141. goto out_parent;
  142. error = gfs2_glock_nq(ghs + 1); /* child */
  143. if (error)
  144. goto out_child;
  145. error = gfs2_permission(dir, MAY_WRITE | MAY_EXEC);
  146. if (error)
  147. goto out_gunlock;
  148. error = gfs2_dir_check(dir, &dentry->d_name, NULL);
  149. switch (error) {
  150. case -ENOENT:
  151. break;
  152. case 0:
  153. error = -EEXIST;
  154. default:
  155. goto out_gunlock;
  156. }
  157. error = -EINVAL;
  158. if (!dip->i_inode.i_nlink)
  159. goto out_gunlock;
  160. error = -EFBIG;
  161. if (dip->i_entries == (u32)-1)
  162. goto out_gunlock;
  163. error = -EPERM;
  164. if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
  165. goto out_gunlock;
  166. error = -EINVAL;
  167. if (!ip->i_inode.i_nlink)
  168. goto out_gunlock;
  169. error = -EMLINK;
  170. if (ip->i_inode.i_nlink == (u32)-1)
  171. goto out_gunlock;
  172. alloc_required = error = gfs2_diradd_alloc_required(dir, &dentry->d_name);
  173. if (error < 0)
  174. goto out_gunlock;
  175. error = 0;
  176. if (alloc_required) {
  177. struct gfs2_alloc *al = gfs2_alloc_get(dip);
  178. if (!al) {
  179. error = -ENOMEM;
  180. goto out_gunlock;
  181. }
  182. error = gfs2_quota_lock_check(dip);
  183. if (error)
  184. goto out_alloc;
  185. al->al_requested = sdp->sd_max_dirres;
  186. error = gfs2_inplace_reserve(dip);
  187. if (error)
  188. goto out_gunlock_q;
  189. error = gfs2_trans_begin(sdp, sdp->sd_max_dirres +
  190. al->al_rgd->rd_length +
  191. 2 * RES_DINODE + RES_STATFS +
  192. RES_QUOTA, 0);
  193. if (error)
  194. goto out_ipres;
  195. } else {
  196. error = gfs2_trans_begin(sdp, 2 * RES_DINODE + RES_LEAF, 0);
  197. if (error)
  198. goto out_ipres;
  199. }
  200. error = gfs2_dir_add(dir, &dentry->d_name, ip, IF2DT(inode->i_mode));
  201. if (error)
  202. goto out_end_trans;
  203. error = gfs2_change_nlink(ip, +1);
  204. out_end_trans:
  205. gfs2_trans_end(sdp);
  206. out_ipres:
  207. if (alloc_required)
  208. gfs2_inplace_release(dip);
  209. out_gunlock_q:
  210. if (alloc_required)
  211. gfs2_quota_unlock(dip);
  212. out_alloc:
  213. if (alloc_required)
  214. gfs2_alloc_put(dip);
  215. out_gunlock:
  216. gfs2_glock_dq(ghs + 1);
  217. out_child:
  218. gfs2_glock_dq(ghs);
  219. out_parent:
  220. gfs2_holder_uninit(ghs);
  221. gfs2_holder_uninit(ghs + 1);
  222. if (!error) {
  223. atomic_inc(&inode->i_count);
  224. d_instantiate(dentry, inode);
  225. mark_inode_dirty(inode);
  226. }
  227. return error;
  228. }
  229. /*
  230. * gfs2_unlink_ok - check to see that a inode is still in a directory
  231. * @dip: the directory
  232. * @name: the name of the file
  233. * @ip: the inode
  234. *
  235. * Assumes that the lock on (at least) @dip is held.
  236. *
  237. * Returns: 0 if the parent/child relationship is correct, errno if it isn't
  238. */
  239. static int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
  240. const struct gfs2_inode *ip)
  241. {
  242. int error;
  243. if (IS_IMMUTABLE(&ip->i_inode) || IS_APPEND(&ip->i_inode))
  244. return -EPERM;
  245. if ((dip->i_inode.i_mode & S_ISVTX) &&
  246. dip->i_inode.i_uid != current_fsuid() &&
  247. ip->i_inode.i_uid != current_fsuid() && !capable(CAP_FOWNER))
  248. return -EPERM;
  249. if (IS_APPEND(&dip->i_inode))
  250. return -EPERM;
  251. error = gfs2_permission(&dip->i_inode, MAY_WRITE | MAY_EXEC);
  252. if (error)
  253. return error;
  254. error = gfs2_dir_check(&dip->i_inode, name, ip);
  255. if (error)
  256. return error;
  257. return 0;
  258. }
  259. /**
  260. * gfs2_unlink - Unlink a file
  261. * @dir: The inode of the directory containing the file to unlink
  262. * @dentry: The file itself
  263. *
  264. * Unlink a file. Call gfs2_unlinki()
  265. *
  266. * Returns: errno
  267. */
  268. static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
  269. {
  270. struct gfs2_inode *dip = GFS2_I(dir);
  271. struct gfs2_sbd *sdp = GFS2_SB(dir);
  272. struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
  273. struct gfs2_holder ghs[3];
  274. struct gfs2_rgrpd *rgd;
  275. struct gfs2_holder ri_gh;
  276. int error;
  277. error = gfs2_rindex_hold(sdp, &ri_gh);
  278. if (error)
  279. return error;
  280. gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
  281. gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
  282. rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr);
  283. gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, ghs + 2);
  284. error = gfs2_glock_nq(ghs); /* parent */
  285. if (error)
  286. goto out_parent;
  287. error = gfs2_glock_nq(ghs + 1); /* child */
  288. if (error)
  289. goto out_child;
  290. error = gfs2_glock_nq(ghs + 2); /* rgrp */
  291. if (error)
  292. goto out_rgrp;
  293. error = gfs2_unlink_ok(dip, &dentry->d_name, ip);
  294. if (error)
  295. goto out_gunlock;
  296. error = gfs2_trans_begin(sdp, 2*RES_DINODE + RES_LEAF + RES_RG_BIT, 0);
  297. if (error)
  298. goto out_gunlock;
  299. error = gfs2_dir_del(dip, &dentry->d_name);
  300. if (error)
  301. goto out_end_trans;
  302. error = gfs2_change_nlink(ip, -1);
  303. out_end_trans:
  304. gfs2_trans_end(sdp);
  305. out_gunlock:
  306. gfs2_glock_dq(ghs + 2);
  307. out_rgrp:
  308. gfs2_holder_uninit(ghs + 2);
  309. gfs2_glock_dq(ghs + 1);
  310. out_child:
  311. gfs2_holder_uninit(ghs + 1);
  312. gfs2_glock_dq(ghs);
  313. out_parent:
  314. gfs2_holder_uninit(ghs);
  315. gfs2_glock_dq_uninit(&ri_gh);
  316. return error;
  317. }
  318. /**
  319. * gfs2_symlink - Create a symlink
  320. * @dir: The directory to create the symlink in
  321. * @dentry: The dentry to put the symlink in
  322. * @symname: The thing which the link points to
  323. *
  324. * Returns: errno
  325. */
  326. static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
  327. const char *symname)
  328. {
  329. struct gfs2_inode *dip = GFS2_I(dir), *ip;
  330. struct gfs2_sbd *sdp = GFS2_SB(dir);
  331. struct gfs2_holder ghs[2];
  332. struct inode *inode;
  333. struct buffer_head *dibh;
  334. int size;
  335. int error;
  336. /* Must be stuffed with a null terminator for gfs2_follow_link() */
  337. size = strlen(symname);
  338. if (size > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode) - 1)
  339. return -ENAMETOOLONG;
  340. gfs2_holder_init(dip->i_gl, 0, 0, ghs);
  341. inode = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO, 0);
  342. if (IS_ERR(inode)) {
  343. gfs2_holder_uninit(ghs);
  344. return PTR_ERR(inode);
  345. }
  346. ip = ghs[1].gh_gl->gl_object;
  347. ip->i_disksize = size;
  348. i_size_write(inode, size);
  349. error = gfs2_meta_inode_buffer(ip, &dibh);
  350. if (!gfs2_assert_withdraw(sdp, !error)) {
  351. gfs2_dinode_out(ip, dibh->b_data);
  352. memcpy(dibh->b_data + sizeof(struct gfs2_dinode), symname,
  353. size);
  354. brelse(dibh);
  355. }
  356. gfs2_trans_end(sdp);
  357. if (dip->i_alloc->al_rgd)
  358. gfs2_inplace_release(dip);
  359. gfs2_quota_unlock(dip);
  360. gfs2_alloc_put(dip);
  361. gfs2_glock_dq_uninit_m(2, ghs);
  362. d_instantiate(dentry, inode);
  363. mark_inode_dirty(inode);
  364. return 0;
  365. }
  366. /**
  367. * gfs2_mkdir - Make a directory
  368. * @dir: The parent directory of the new one
  369. * @dentry: The dentry of the new directory
  370. * @mode: The mode of the new directory
  371. *
  372. * Returns: errno
  373. */
  374. static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
  375. {
  376. struct gfs2_inode *dip = GFS2_I(dir), *ip;
  377. struct gfs2_sbd *sdp = GFS2_SB(dir);
  378. struct gfs2_holder ghs[2];
  379. struct inode *inode;
  380. struct buffer_head *dibh;
  381. int error;
  382. gfs2_holder_init(dip->i_gl, 0, 0, ghs);
  383. inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode, 0);
  384. if (IS_ERR(inode)) {
  385. gfs2_holder_uninit(ghs);
  386. return PTR_ERR(inode);
  387. }
  388. ip = ghs[1].gh_gl->gl_object;
  389. ip->i_inode.i_nlink = 2;
  390. ip->i_disksize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
  391. ip->i_diskflags |= GFS2_DIF_JDATA;
  392. ip->i_entries = 2;
  393. error = gfs2_meta_inode_buffer(ip, &dibh);
  394. if (!gfs2_assert_withdraw(sdp, !error)) {
  395. struct gfs2_dinode *di = (struct gfs2_dinode *)dibh->b_data;
  396. struct gfs2_dirent *dent = (struct gfs2_dirent *)(di+1);
  397. struct qstr str;
  398. gfs2_str2qstr(&str, ".");
  399. gfs2_trans_add_bh(ip->i_gl, dibh, 1);
  400. gfs2_qstr2dirent(&str, GFS2_DIRENT_SIZE(str.len), dent);
  401. dent->de_inum = di->di_num; /* already GFS2 endian */
  402. dent->de_type = cpu_to_be16(DT_DIR);
  403. di->di_entries = cpu_to_be32(1);
  404. gfs2_str2qstr(&str, "..");
  405. dent = (struct gfs2_dirent *)((char*)dent + GFS2_DIRENT_SIZE(1));
  406. gfs2_qstr2dirent(&str, dibh->b_size - GFS2_DIRENT_SIZE(1) - sizeof(struct gfs2_dinode), dent);
  407. gfs2_inum_out(dip, dent);
  408. dent->de_type = cpu_to_be16(DT_DIR);
  409. gfs2_dinode_out(ip, di);
  410. brelse(dibh);
  411. }
  412. error = gfs2_change_nlink(dip, +1);
  413. gfs2_assert_withdraw(sdp, !error); /* dip already pinned */
  414. gfs2_trans_end(sdp);
  415. if (dip->i_alloc->al_rgd)
  416. gfs2_inplace_release(dip);
  417. gfs2_quota_unlock(dip);
  418. gfs2_alloc_put(dip);
  419. gfs2_glock_dq_uninit_m(2, ghs);
  420. d_instantiate(dentry, inode);
  421. mark_inode_dirty(inode);
  422. return 0;
  423. }
  424. /**
  425. * gfs2_rmdiri - Remove a directory
  426. * @dip: The parent directory of the directory to be removed
  427. * @name: The name of the directory to be removed
  428. * @ip: The GFS2 inode of the directory to be removed
  429. *
  430. * Assumes Glocks on dip and ip are held
  431. *
  432. * Returns: errno
  433. */
  434. static int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
  435. struct gfs2_inode *ip)
  436. {
  437. struct qstr dotname;
  438. int error;
  439. if (ip->i_entries != 2) {
  440. if (gfs2_consist_inode(ip))
  441. gfs2_dinode_print(ip);
  442. return -EIO;
  443. }
  444. error = gfs2_dir_del(dip, name);
  445. if (error)
  446. return error;
  447. error = gfs2_change_nlink(dip, -1);
  448. if (error)
  449. return error;
  450. gfs2_str2qstr(&dotname, ".");
  451. error = gfs2_dir_del(ip, &dotname);
  452. if (error)
  453. return error;
  454. gfs2_str2qstr(&dotname, "..");
  455. error = gfs2_dir_del(ip, &dotname);
  456. if (error)
  457. return error;
  458. /* It looks odd, but it really should be done twice */
  459. error = gfs2_change_nlink(ip, -1);
  460. if (error)
  461. return error;
  462. error = gfs2_change_nlink(ip, -1);
  463. if (error)
  464. return error;
  465. return error;
  466. }
  467. /**
  468. * gfs2_rmdir - Remove a directory
  469. * @dir: The parent directory of the directory to be removed
  470. * @dentry: The dentry of the directory to remove
  471. *
  472. * Remove a directory. Call gfs2_rmdiri()
  473. *
  474. * Returns: errno
  475. */
  476. static int gfs2_rmdir(struct inode *dir, struct dentry *dentry)
  477. {
  478. struct gfs2_inode *dip = GFS2_I(dir);
  479. struct gfs2_sbd *sdp = GFS2_SB(dir);
  480. struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
  481. struct gfs2_holder ghs[3];
  482. struct gfs2_rgrpd *rgd;
  483. struct gfs2_holder ri_gh;
  484. int error;
  485. error = gfs2_rindex_hold(sdp, &ri_gh);
  486. if (error)
  487. return error;
  488. gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
  489. gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
  490. rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr);
  491. gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, ghs + 2);
  492. error = gfs2_glock_nq(ghs); /* parent */
  493. if (error)
  494. goto out_parent;
  495. error = gfs2_glock_nq(ghs + 1); /* child */
  496. if (error)
  497. goto out_child;
  498. error = gfs2_glock_nq(ghs + 2); /* rgrp */
  499. if (error)
  500. goto out_rgrp;
  501. error = gfs2_unlink_ok(dip, &dentry->d_name, ip);
  502. if (error)
  503. goto out_gunlock;
  504. if (ip->i_entries < 2) {
  505. if (gfs2_consist_inode(ip))
  506. gfs2_dinode_print(ip);
  507. error = -EIO;
  508. goto out_gunlock;
  509. }
  510. if (ip->i_entries > 2) {
  511. error = -ENOTEMPTY;
  512. goto out_gunlock;
  513. }
  514. error = gfs2_trans_begin(sdp, 2 * RES_DINODE + 3 * RES_LEAF + RES_RG_BIT, 0);
  515. if (error)
  516. goto out_gunlock;
  517. error = gfs2_rmdiri(dip, &dentry->d_name, ip);
  518. gfs2_trans_end(sdp);
  519. out_gunlock:
  520. gfs2_glock_dq(ghs + 2);
  521. out_rgrp:
  522. gfs2_holder_uninit(ghs + 2);
  523. gfs2_glock_dq(ghs + 1);
  524. out_child:
  525. gfs2_holder_uninit(ghs + 1);
  526. gfs2_glock_dq(ghs);
  527. out_parent:
  528. gfs2_holder_uninit(ghs);
  529. gfs2_glock_dq_uninit(&ri_gh);
  530. return error;
  531. }
  532. /**
  533. * gfs2_mknod - Make a special file
  534. * @dir: The directory in which the special file will reside
  535. * @dentry: The dentry of the special file
  536. * @mode: The mode of the special file
  537. * @rdev: The device specification of the special file
  538. *
  539. */
  540. static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode,
  541. dev_t dev)
  542. {
  543. struct gfs2_inode *dip = GFS2_I(dir);
  544. struct gfs2_sbd *sdp = GFS2_SB(dir);
  545. struct gfs2_holder ghs[2];
  546. struct inode *inode;
  547. gfs2_holder_init(dip->i_gl, 0, 0, ghs);
  548. inode = gfs2_createi(ghs, &dentry->d_name, mode, dev);
  549. if (IS_ERR(inode)) {
  550. gfs2_holder_uninit(ghs);
  551. return PTR_ERR(inode);
  552. }
  553. gfs2_trans_end(sdp);
  554. if (dip->i_alloc->al_rgd)
  555. gfs2_inplace_release(dip);
  556. gfs2_quota_unlock(dip);
  557. gfs2_alloc_put(dip);
  558. gfs2_glock_dq_uninit_m(2, ghs);
  559. d_instantiate(dentry, inode);
  560. mark_inode_dirty(inode);
  561. return 0;
  562. }
  563. /*
  564. * gfs2_ok_to_move - check if it's ok to move a directory to another directory
  565. * @this: move this
  566. * @to: to here
  567. *
  568. * Follow @to back to the root and make sure we don't encounter @this
  569. * Assumes we already hold the rename lock.
  570. *
  571. * Returns: errno
  572. */
  573. static int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
  574. {
  575. struct inode *dir = &to->i_inode;
  576. struct super_block *sb = dir->i_sb;
  577. struct inode *tmp;
  578. struct qstr dotdot;
  579. int error = 0;
  580. gfs2_str2qstr(&dotdot, "..");
  581. igrab(dir);
  582. for (;;) {
  583. if (dir == &this->i_inode) {
  584. error = -EINVAL;
  585. break;
  586. }
  587. if (dir == sb->s_root->d_inode) {
  588. error = 0;
  589. break;
  590. }
  591. tmp = gfs2_lookupi(dir, &dotdot, 1);
  592. if (IS_ERR(tmp)) {
  593. error = PTR_ERR(tmp);
  594. break;
  595. }
  596. iput(dir);
  597. dir = tmp;
  598. }
  599. iput(dir);
  600. return error;
  601. }
  602. /**
  603. * gfs2_rename - Rename a file
  604. * @odir: Parent directory of old file name
  605. * @odentry: The old dentry of the file
  606. * @ndir: Parent directory of new file name
  607. * @ndentry: The new dentry of the file
  608. *
  609. * Returns: errno
  610. */
  611. static int gfs2_rename(struct inode *odir, struct dentry *odentry,
  612. struct inode *ndir, struct dentry *ndentry)
  613. {
  614. struct gfs2_inode *odip = GFS2_I(odir);
  615. struct gfs2_inode *ndip = GFS2_I(ndir);
  616. struct gfs2_inode *ip = GFS2_I(odentry->d_inode);
  617. struct gfs2_inode *nip = NULL;
  618. struct gfs2_sbd *sdp = GFS2_SB(odir);
  619. struct gfs2_holder ghs[5], r_gh = { .gh_gl = NULL, };
  620. struct gfs2_rgrpd *nrgd;
  621. unsigned int num_gh;
  622. int dir_rename = 0;
  623. int alloc_required = 0;
  624. unsigned int x;
  625. int error;
  626. if (ndentry->d_inode) {
  627. nip = GFS2_I(ndentry->d_inode);
  628. if (ip == nip)
  629. return 0;
  630. }
  631. if (odip != ndip) {
  632. error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE,
  633. 0, &r_gh);
  634. if (error)
  635. goto out;
  636. if (S_ISDIR(ip->i_inode.i_mode)) {
  637. dir_rename = 1;
  638. /* don't move a dirctory into it's subdir */
  639. error = gfs2_ok_to_move(ip, ndip);
  640. if (error)
  641. goto out_gunlock_r;
  642. }
  643. }
  644. num_gh = 1;
  645. gfs2_holder_init(odip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
  646. if (odip != ndip) {
  647. gfs2_holder_init(ndip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh);
  648. num_gh++;
  649. }
  650. gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh);
  651. num_gh++;
  652. if (nip) {
  653. gfs2_holder_init(nip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh);
  654. num_gh++;
  655. /* grab the resource lock for unlink flag twiddling
  656. * this is the case of the target file already existing
  657. * so we unlink before doing the rename
  658. */
  659. nrgd = gfs2_blk2rgrpd(sdp, nip->i_no_addr);
  660. if (nrgd)
  661. gfs2_holder_init(nrgd->rd_gl, LM_ST_EXCLUSIVE, 0, ghs + num_gh++);
  662. }
  663. for (x = 0; x < num_gh; x++) {
  664. error = gfs2_glock_nq(ghs + x);
  665. if (error)
  666. goto out_gunlock;
  667. }
  668. /* Check out the old directory */
  669. error = gfs2_unlink_ok(odip, &odentry->d_name, ip);
  670. if (error)
  671. goto out_gunlock;
  672. /* Check out the new directory */
  673. if (nip) {
  674. error = gfs2_unlink_ok(ndip, &ndentry->d_name, nip);
  675. if (error)
  676. goto out_gunlock;
  677. if (S_ISDIR(nip->i_inode.i_mode)) {
  678. if (nip->i_entries < 2) {
  679. if (gfs2_consist_inode(nip))
  680. gfs2_dinode_print(nip);
  681. error = -EIO;
  682. goto out_gunlock;
  683. }
  684. if (nip->i_entries > 2) {
  685. error = -ENOTEMPTY;
  686. goto out_gunlock;
  687. }
  688. }
  689. } else {
  690. error = gfs2_permission(ndir, MAY_WRITE | MAY_EXEC);
  691. if (error)
  692. goto out_gunlock;
  693. error = gfs2_dir_check(ndir, &ndentry->d_name, NULL);
  694. switch (error) {
  695. case -ENOENT:
  696. error = 0;
  697. break;
  698. case 0:
  699. error = -EEXIST;
  700. default:
  701. goto out_gunlock;
  702. };
  703. if (odip != ndip) {
  704. if (!ndip->i_inode.i_nlink) {
  705. error = -EINVAL;
  706. goto out_gunlock;
  707. }
  708. if (ndip->i_entries == (u32)-1) {
  709. error = -EFBIG;
  710. goto out_gunlock;
  711. }
  712. if (S_ISDIR(ip->i_inode.i_mode) &&
  713. ndip->i_inode.i_nlink == (u32)-1) {
  714. error = -EMLINK;
  715. goto out_gunlock;
  716. }
  717. }
  718. }
  719. /* Check out the dir to be renamed */
  720. if (dir_rename) {
  721. error = gfs2_permission(odentry->d_inode, MAY_WRITE);
  722. if (error)
  723. goto out_gunlock;
  724. }
  725. if (nip == NULL)
  726. alloc_required = gfs2_diradd_alloc_required(ndir, &ndentry->d_name);
  727. error = alloc_required;
  728. if (error < 0)
  729. goto out_gunlock;
  730. error = 0;
  731. if (alloc_required) {
  732. struct gfs2_alloc *al = gfs2_alloc_get(ndip);
  733. if (!al) {
  734. error = -ENOMEM;
  735. goto out_gunlock;
  736. }
  737. error = gfs2_quota_lock_check(ndip);
  738. if (error)
  739. goto out_alloc;
  740. al->al_requested = sdp->sd_max_dirres;
  741. error = gfs2_inplace_reserve(ndip);
  742. if (error)
  743. goto out_gunlock_q;
  744. error = gfs2_trans_begin(sdp, sdp->sd_max_dirres +
  745. al->al_rgd->rd_length +
  746. 4 * RES_DINODE + 4 * RES_LEAF +
  747. RES_STATFS + RES_QUOTA + 4, 0);
  748. if (error)
  749. goto out_ipreserv;
  750. } else {
  751. error = gfs2_trans_begin(sdp, 4 * RES_DINODE +
  752. 5 * RES_LEAF + 4, 0);
  753. if (error)
  754. goto out_gunlock;
  755. }
  756. /* Remove the target file, if it exists */
  757. if (nip) {
  758. if (S_ISDIR(nip->i_inode.i_mode))
  759. error = gfs2_rmdiri(ndip, &ndentry->d_name, nip);
  760. else {
  761. error = gfs2_dir_del(ndip, &ndentry->d_name);
  762. if (error)
  763. goto out_end_trans;
  764. error = gfs2_change_nlink(nip, -1);
  765. }
  766. if (error)
  767. goto out_end_trans;
  768. }
  769. if (dir_rename) {
  770. struct qstr name;
  771. gfs2_str2qstr(&name, "..");
  772. error = gfs2_change_nlink(ndip, +1);
  773. if (error)
  774. goto out_end_trans;
  775. error = gfs2_change_nlink(odip, -1);
  776. if (error)
  777. goto out_end_trans;
  778. error = gfs2_dir_mvino(ip, &name, ndip, DT_DIR);
  779. if (error)
  780. goto out_end_trans;
  781. } else {
  782. struct buffer_head *dibh;
  783. error = gfs2_meta_inode_buffer(ip, &dibh);
  784. if (error)
  785. goto out_end_trans;
  786. ip->i_inode.i_ctime = CURRENT_TIME;
  787. gfs2_trans_add_bh(ip->i_gl, dibh, 1);
  788. gfs2_dinode_out(ip, dibh->b_data);
  789. brelse(dibh);
  790. }
  791. error = gfs2_dir_del(odip, &odentry->d_name);
  792. if (error)
  793. goto out_end_trans;
  794. error = gfs2_dir_add(ndir, &ndentry->d_name, ip, IF2DT(ip->i_inode.i_mode));
  795. if (error)
  796. goto out_end_trans;
  797. out_end_trans:
  798. gfs2_trans_end(sdp);
  799. out_ipreserv:
  800. if (alloc_required)
  801. gfs2_inplace_release(ndip);
  802. out_gunlock_q:
  803. if (alloc_required)
  804. gfs2_quota_unlock(ndip);
  805. out_alloc:
  806. if (alloc_required)
  807. gfs2_alloc_put(ndip);
  808. out_gunlock:
  809. while (x--) {
  810. gfs2_glock_dq(ghs + x);
  811. gfs2_holder_uninit(ghs + x);
  812. }
  813. out_gunlock_r:
  814. if (r_gh.gh_gl)
  815. gfs2_glock_dq_uninit(&r_gh);
  816. out:
  817. return error;
  818. }
  819. /**
  820. * gfs2_readlinki - return the contents of a symlink
  821. * @ip: the symlink's inode
  822. * @buf: a pointer to the buffer to be filled
  823. * @len: a pointer to the length of @buf
  824. *
  825. * If @buf is too small, a piece of memory is kmalloc()ed and needs
  826. * to be freed by the caller.
  827. *
  828. * Returns: errno
  829. */
  830. static int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len)
  831. {
  832. struct gfs2_holder i_gh;
  833. struct buffer_head *dibh;
  834. unsigned int x;
  835. int error;
  836. gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh);
  837. error = gfs2_glock_nq(&i_gh);
  838. if (error) {
  839. gfs2_holder_uninit(&i_gh);
  840. return error;
  841. }
  842. if (!ip->i_disksize) {
  843. gfs2_consist_inode(ip);
  844. error = -EIO;
  845. goto out;
  846. }
  847. error = gfs2_meta_inode_buffer(ip, &dibh);
  848. if (error)
  849. goto out;
  850. x = ip->i_disksize + 1;
  851. if (x > *len) {
  852. *buf = kmalloc(x, GFP_NOFS);
  853. if (!*buf) {
  854. error = -ENOMEM;
  855. goto out_brelse;
  856. }
  857. }
  858. memcpy(*buf, dibh->b_data + sizeof(struct gfs2_dinode), x);
  859. *len = x;
  860. out_brelse:
  861. brelse(dibh);
  862. out:
  863. gfs2_glock_dq_uninit(&i_gh);
  864. return error;
  865. }
  866. /**
  867. * gfs2_readlink - Read the value of a symlink
  868. * @dentry: the symlink
  869. * @buf: the buffer to read the symlink data into
  870. * @size: the size of the buffer
  871. *
  872. * Returns: errno
  873. */
  874. static int gfs2_readlink(struct dentry *dentry, char __user *user_buf,
  875. int user_size)
  876. {
  877. struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
  878. char array[GFS2_FAST_NAME_SIZE], *buf = array;
  879. unsigned int len = GFS2_FAST_NAME_SIZE;
  880. int error;
  881. error = gfs2_readlinki(ip, &buf, &len);
  882. if (error)
  883. return error;
  884. if (user_size > len - 1)
  885. user_size = len - 1;
  886. if (copy_to_user(user_buf, buf, user_size))
  887. error = -EFAULT;
  888. else
  889. error = user_size;
  890. if (buf != array)
  891. kfree(buf);
  892. return error;
  893. }
  894. /**
  895. * gfs2_follow_link - Follow a symbolic link
  896. * @dentry: The dentry of the link
  897. * @nd: Data that we pass to vfs_follow_link()
  898. *
  899. * This can handle symlinks of any size. It is optimised for symlinks
  900. * under GFS2_FAST_NAME_SIZE.
  901. *
  902. * Returns: 0 on success or error code
  903. */
  904. static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
  905. {
  906. struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
  907. char array[GFS2_FAST_NAME_SIZE], *buf = array;
  908. unsigned int len = GFS2_FAST_NAME_SIZE;
  909. int error;
  910. error = gfs2_readlinki(ip, &buf, &len);
  911. if (!error) {
  912. error = vfs_follow_link(nd, buf);
  913. if (buf != array)
  914. kfree(buf);
  915. } else
  916. path_put(&nd->path);
  917. return ERR_PTR(error);
  918. }
  919. /**
  920. * gfs2_permission -
  921. * @inode:
  922. * @mask:
  923. * @nd: passed from Linux VFS, ignored by us
  924. *
  925. * This may be called from the VFS directly, or from within GFS2 with the
  926. * inode locked, so we look to see if the glock is already locked and only
  927. * lock the glock if its not already been done.
  928. *
  929. * Returns: errno
  930. */
  931. int gfs2_permission(struct inode *inode, int mask)
  932. {
  933. struct gfs2_inode *ip = GFS2_I(inode);
  934. struct gfs2_holder i_gh;
  935. int error;
  936. int unlock = 0;
  937. if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) {
  938. error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
  939. if (error)
  940. return error;
  941. unlock = 1;
  942. }
  943. if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
  944. error = -EACCES;
  945. else
  946. error = generic_permission(inode, mask, gfs2_check_acl);
  947. if (unlock)
  948. gfs2_glock_dq_uninit(&i_gh);
  949. return error;
  950. }
  951. static int setattr_size(struct inode *inode, struct iattr *attr)
  952. {
  953. struct gfs2_inode *ip = GFS2_I(inode);
  954. struct gfs2_sbd *sdp = GFS2_SB(inode);
  955. int error;
  956. if (attr->ia_size != ip->i_disksize) {
  957. error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
  958. if (error)
  959. return error;
  960. error = vmtruncate(inode, attr->ia_size);
  961. gfs2_trans_end(sdp);
  962. if (error)
  963. return error;
  964. }
  965. error = gfs2_truncatei(ip, attr->ia_size);
  966. if (error && (inode->i_size != ip->i_disksize))
  967. i_size_write(inode, ip->i_disksize);
  968. return error;
  969. }
  970. static int setattr_chown(struct inode *inode, struct iattr *attr)
  971. {
  972. struct gfs2_inode *ip = GFS2_I(inode);
  973. struct gfs2_sbd *sdp = GFS2_SB(inode);
  974. struct buffer_head *dibh;
  975. u32 ouid, ogid, nuid, ngid;
  976. int error;
  977. ouid = inode->i_uid;
  978. ogid = inode->i_gid;
  979. nuid = attr->ia_uid;
  980. ngid = attr->ia_gid;
  981. if (!(attr->ia_valid & ATTR_UID) || ouid == nuid)
  982. ouid = nuid = NO_QUOTA_CHANGE;
  983. if (!(attr->ia_valid & ATTR_GID) || ogid == ngid)
  984. ogid = ngid = NO_QUOTA_CHANGE;
  985. if (!gfs2_alloc_get(ip))
  986. return -ENOMEM;
  987. error = gfs2_quota_lock(ip, nuid, ngid);
  988. if (error)
  989. goto out_alloc;
  990. if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) {
  991. error = gfs2_quota_check(ip, nuid, ngid);
  992. if (error)
  993. goto out_gunlock_q;
  994. }
  995. error = gfs2_trans_begin(sdp, RES_DINODE + 2 * RES_QUOTA, 0);
  996. if (error)
  997. goto out_gunlock_q;
  998. error = gfs2_meta_inode_buffer(ip, &dibh);
  999. if (error)
  1000. goto out_end_trans;
  1001. error = inode_setattr(inode, attr);
  1002. gfs2_assert_warn(sdp, !error);
  1003. gfs2_trans_add_bh(ip->i_gl, dibh, 1);
  1004. gfs2_dinode_out(ip, dibh->b_data);
  1005. brelse(dibh);
  1006. if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) {
  1007. u64 blocks = gfs2_get_inode_blocks(&ip->i_inode);
  1008. gfs2_quota_change(ip, -blocks, ouid, ogid);
  1009. gfs2_quota_change(ip, blocks, nuid, ngid);
  1010. }
  1011. out_end_trans:
  1012. gfs2_trans_end(sdp);
  1013. out_gunlock_q:
  1014. gfs2_quota_unlock(ip);
  1015. out_alloc:
  1016. gfs2_alloc_put(ip);
  1017. return error;
  1018. }
  1019. /**
  1020. * gfs2_setattr - Change attributes on an inode
  1021. * @dentry: The dentry which is changing
  1022. * @attr: The structure describing the change
  1023. *
  1024. * The VFS layer wants to change one or more of an inodes attributes. Write
  1025. * that change out to disk.
  1026. *
  1027. * Returns: errno
  1028. */
  1029. static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
  1030. {
  1031. struct inode *inode = dentry->d_inode;
  1032. struct gfs2_inode *ip = GFS2_I(inode);
  1033. struct gfs2_holder i_gh;
  1034. int error;
  1035. error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh);
  1036. if (error)
  1037. return error;
  1038. error = -EPERM;
  1039. if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
  1040. goto out;
  1041. error = inode_change_ok(inode, attr);
  1042. if (error)
  1043. goto out;
  1044. if (attr->ia_valid & ATTR_SIZE)
  1045. error = setattr_size(inode, attr);
  1046. else if (attr->ia_valid & (ATTR_UID | ATTR_GID))
  1047. error = setattr_chown(inode, attr);
  1048. else if ((attr->ia_valid & ATTR_MODE) && IS_POSIXACL(inode))
  1049. error = gfs2_acl_chmod(ip, attr);
  1050. else
  1051. error = gfs2_setattr_simple(ip, attr);
  1052. out:
  1053. gfs2_glock_dq_uninit(&i_gh);
  1054. if (!error)
  1055. mark_inode_dirty(inode);
  1056. return error;
  1057. }
  1058. /**
  1059. * gfs2_getattr - Read out an inode's attributes
  1060. * @mnt: The vfsmount the inode is being accessed from
  1061. * @dentry: The dentry to stat
  1062. * @stat: The inode's stats
  1063. *
  1064. * This may be called from the VFS directly, or from within GFS2 with the
  1065. * inode locked, so we look to see if the glock is already locked and only
  1066. * lock the glock if its not already been done. Note that its the NFS
  1067. * readdirplus operation which causes this to be called (from filldir)
  1068. * with the glock already held.
  1069. *
  1070. * Returns: errno
  1071. */
  1072. static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
  1073. struct kstat *stat)
  1074. {
  1075. struct inode *inode = dentry->d_inode;
  1076. struct gfs2_inode *ip = GFS2_I(inode);
  1077. struct gfs2_holder gh;
  1078. int error;
  1079. int unlock = 0;
  1080. if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) {
  1081. error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
  1082. if (error)
  1083. return error;
  1084. unlock = 1;
  1085. }
  1086. generic_fillattr(inode, stat);
  1087. if (unlock)
  1088. gfs2_glock_dq_uninit(&gh);
  1089. return 0;
  1090. }
  1091. static int gfs2_setxattr(struct dentry *dentry, const char *name,
  1092. const void *data, size_t size, int flags)
  1093. {
  1094. struct inode *inode = dentry->d_inode;
  1095. struct gfs2_inode *ip = GFS2_I(inode);
  1096. struct gfs2_holder gh;
  1097. int ret;
  1098. gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
  1099. ret = gfs2_glock_nq(&gh);
  1100. if (ret == 0) {
  1101. ret = generic_setxattr(dentry, name, data, size, flags);
  1102. gfs2_glock_dq(&gh);
  1103. }
  1104. gfs2_holder_uninit(&gh);
  1105. return ret;
  1106. }
  1107. static ssize_t gfs2_getxattr(struct dentry *dentry, const char *name,
  1108. void *data, size_t size)
  1109. {
  1110. struct inode *inode = dentry->d_inode;
  1111. struct gfs2_inode *ip = GFS2_I(inode);
  1112. struct gfs2_holder gh;
  1113. int ret;
  1114. gfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
  1115. ret = gfs2_glock_nq(&gh);
  1116. if (ret == 0) {
  1117. ret = generic_getxattr(dentry, name, data, size);
  1118. gfs2_glock_dq(&gh);
  1119. }
  1120. gfs2_holder_uninit(&gh);
  1121. return ret;
  1122. }
  1123. static int gfs2_removexattr(struct dentry *dentry, const char *name)
  1124. {
  1125. struct inode *inode = dentry->d_inode;
  1126. struct gfs2_inode *ip = GFS2_I(inode);
  1127. struct gfs2_holder gh;
  1128. int ret;
  1129. gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
  1130. ret = gfs2_glock_nq(&gh);
  1131. if (ret == 0) {
  1132. ret = generic_removexattr(dentry, name);
  1133. gfs2_glock_dq(&gh);
  1134. }
  1135. gfs2_holder_uninit(&gh);
  1136. return ret;
  1137. }
  1138. static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
  1139. u64 start, u64 len)
  1140. {
  1141. struct gfs2_inode *ip = GFS2_I(inode);
  1142. struct gfs2_holder gh;
  1143. int ret;
  1144. ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC);
  1145. if (ret)
  1146. return ret;
  1147. mutex_lock(&inode->i_mutex);
  1148. ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
  1149. if (ret)
  1150. goto out;
  1151. if (gfs2_is_stuffed(ip)) {
  1152. u64 phys = ip->i_no_addr << inode->i_blkbits;
  1153. u64 size = i_size_read(inode);
  1154. u32 flags = FIEMAP_EXTENT_LAST|FIEMAP_EXTENT_NOT_ALIGNED|
  1155. FIEMAP_EXTENT_DATA_INLINE;
  1156. phys += sizeof(struct gfs2_dinode);
  1157. phys += start;
  1158. if (start + len > size)
  1159. len = size - start;
  1160. if (start < size)
  1161. ret = fiemap_fill_next_extent(fieinfo, start, phys,
  1162. len, flags);
  1163. if (ret == 1)
  1164. ret = 0;
  1165. } else {
  1166. ret = __generic_block_fiemap(inode, fieinfo, start, len,
  1167. gfs2_block_map);
  1168. }
  1169. gfs2_glock_dq_uninit(&gh);
  1170. out:
  1171. mutex_unlock(&inode->i_mutex);
  1172. return ret;
  1173. }
  1174. const struct inode_operations gfs2_file_iops = {
  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. .fiemap = gfs2_fiemap,
  1183. };
  1184. const struct inode_operations gfs2_dir_iops = {
  1185. .create = gfs2_create,
  1186. .lookup = gfs2_lookup,
  1187. .link = gfs2_link,
  1188. .unlink = gfs2_unlink,
  1189. .symlink = gfs2_symlink,
  1190. .mkdir = gfs2_mkdir,
  1191. .rmdir = gfs2_rmdir,
  1192. .mknod = gfs2_mknod,
  1193. .rename = gfs2_rename,
  1194. .permission = gfs2_permission,
  1195. .setattr = gfs2_setattr,
  1196. .getattr = gfs2_getattr,
  1197. .setxattr = gfs2_setxattr,
  1198. .getxattr = gfs2_getxattr,
  1199. .listxattr = gfs2_listxattr,
  1200. .removexattr = gfs2_removexattr,
  1201. .fiemap = gfs2_fiemap,
  1202. };
  1203. const struct inode_operations gfs2_symlink_iops = {
  1204. .readlink = gfs2_readlink,
  1205. .follow_link = gfs2_follow_link,
  1206. .permission = gfs2_permission,
  1207. .setattr = gfs2_setattr,
  1208. .getattr = gfs2_getattr,
  1209. .setxattr = gfs2_setxattr,
  1210. .getxattr = gfs2_getxattr,
  1211. .listxattr = gfs2_listxattr,
  1212. .removexattr = gfs2_removexattr,
  1213. .fiemap = gfs2_fiemap,
  1214. };