ops_file.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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/pagemap.h>
  14. #include <linux/uio.h>
  15. #include <linux/blkdev.h>
  16. #include <linux/mm.h>
  17. #include <linux/fs.h>
  18. #include <linux/gfs2_ondisk.h>
  19. #include <linux/ext2_fs.h>
  20. #include <linux/crc32.h>
  21. #include <linux/lm_interface.h>
  22. #include <linux/writeback.h>
  23. #include <asm/uaccess.h>
  24. #include "gfs2.h"
  25. #include "incore.h"
  26. #include "bmap.h"
  27. #include "dir.h"
  28. #include "glock.h"
  29. #include "glops.h"
  30. #include "inode.h"
  31. #include "lm.h"
  32. #include "log.h"
  33. #include "meta_io.h"
  34. #include "ops_file.h"
  35. #include "ops_vm.h"
  36. #include "quota.h"
  37. #include "rgrp.h"
  38. #include "trans.h"
  39. #include "util.h"
  40. #include "eaops.h"
  41. /*
  42. * Most fields left uninitialised to catch anybody who tries to
  43. * use them. f_flags set to prevent file_accessed() from touching
  44. * any other part of this. Its use is purely as a flag so that we
  45. * know (in readpage()) whether or not do to locking.
  46. */
  47. struct file gfs2_internal_file_sentinel = {
  48. .f_flags = O_NOATIME|O_RDONLY,
  49. };
  50. static int gfs2_read_actor(read_descriptor_t *desc, struct page *page,
  51. unsigned long offset, unsigned long size)
  52. {
  53. char *kaddr;
  54. unsigned long count = desc->count;
  55. if (size > count)
  56. size = count;
  57. kaddr = kmap(page);
  58. memcpy(desc->arg.data, kaddr + offset, size);
  59. kunmap(page);
  60. desc->count = count - size;
  61. desc->written += size;
  62. desc->arg.buf += size;
  63. return size;
  64. }
  65. int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state,
  66. char *buf, loff_t *pos, unsigned size)
  67. {
  68. struct inode *inode = &ip->i_inode;
  69. read_descriptor_t desc;
  70. desc.written = 0;
  71. desc.arg.data = buf;
  72. desc.count = size;
  73. desc.error = 0;
  74. do_generic_mapping_read(inode->i_mapping, ra_state,
  75. &gfs2_internal_file_sentinel, pos, &desc,
  76. gfs2_read_actor);
  77. return desc.written ? desc.written : desc.error;
  78. }
  79. /**
  80. * gfs2_llseek - seek to a location in a file
  81. * @file: the file
  82. * @offset: the offset
  83. * @origin: Where to seek from (SEEK_SET, SEEK_CUR, or SEEK_END)
  84. *
  85. * SEEK_END requires the glock for the file because it references the
  86. * file's size.
  87. *
  88. * Returns: The new offset, or errno
  89. */
  90. static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin)
  91. {
  92. struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
  93. struct gfs2_holder i_gh;
  94. loff_t error;
  95. if (origin == 2) {
  96. error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
  97. &i_gh);
  98. if (!error) {
  99. error = remote_llseek(file, offset, origin);
  100. gfs2_glock_dq_uninit(&i_gh);
  101. }
  102. } else
  103. error = remote_llseek(file, offset, origin);
  104. return error;
  105. }
  106. /**
  107. * gfs2_readdir - Read directory entries from a directory
  108. * @file: The directory to read from
  109. * @dirent: Buffer for dirents
  110. * @filldir: Function used to do the copying
  111. *
  112. * Returns: errno
  113. */
  114. static int gfs2_readdir(struct file *file, void *dirent, filldir_t filldir)
  115. {
  116. struct inode *dir = file->f_mapping->host;
  117. struct gfs2_inode *dip = GFS2_I(dir);
  118. struct gfs2_holder d_gh;
  119. u64 offset = file->f_pos;
  120. int error;
  121. gfs2_holder_init(dip->i_gl, LM_ST_SHARED, GL_ATIME, &d_gh);
  122. error = gfs2_glock_nq_atime(&d_gh);
  123. if (error) {
  124. gfs2_holder_uninit(&d_gh);
  125. return error;
  126. }
  127. error = gfs2_dir_read(dir, &offset, dirent, filldir);
  128. gfs2_glock_dq_uninit(&d_gh);
  129. file->f_pos = offset;
  130. return error;
  131. }
  132. /**
  133. * fsflags_cvt
  134. * @table: A table of 32 u32 flags
  135. * @val: a 32 bit value to convert
  136. *
  137. * This function can be used to convert between fsflags values and
  138. * GFS2's own flags values.
  139. *
  140. * Returns: the converted flags
  141. */
  142. static u32 fsflags_cvt(const u32 *table, u32 val)
  143. {
  144. u32 res = 0;
  145. while(val) {
  146. if (val & 1)
  147. res |= *table;
  148. table++;
  149. val >>= 1;
  150. }
  151. return res;
  152. }
  153. static const u32 fsflags_to_gfs2[32] = {
  154. [3] = GFS2_DIF_SYNC,
  155. [4] = GFS2_DIF_IMMUTABLE,
  156. [5] = GFS2_DIF_APPENDONLY,
  157. [7] = GFS2_DIF_NOATIME,
  158. [12] = GFS2_DIF_EXHASH,
  159. [14] = GFS2_DIF_JDATA,
  160. [20] = GFS2_DIF_DIRECTIO,
  161. };
  162. static const u32 gfs2_to_fsflags[32] = {
  163. [gfs2fl_Sync] = FS_SYNC_FL,
  164. [gfs2fl_Immutable] = FS_IMMUTABLE_FL,
  165. [gfs2fl_AppendOnly] = FS_APPEND_FL,
  166. [gfs2fl_NoAtime] = FS_NOATIME_FL,
  167. [gfs2fl_ExHash] = FS_INDEX_FL,
  168. [gfs2fl_Jdata] = FS_JOURNAL_DATA_FL,
  169. [gfs2fl_Directio] = FS_DIRECTIO_FL,
  170. [gfs2fl_InheritDirectio] = FS_DIRECTIO_FL,
  171. [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
  172. };
  173. static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
  174. {
  175. struct inode *inode = filp->f_path.dentry->d_inode;
  176. struct gfs2_inode *ip = GFS2_I(inode);
  177. struct gfs2_holder gh;
  178. int error;
  179. u32 fsflags;
  180. gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
  181. error = gfs2_glock_nq_atime(&gh);
  182. if (error)
  183. return error;
  184. fsflags = fsflags_cvt(gfs2_to_fsflags, ip->i_di.di_flags);
  185. if (put_user(fsflags, ptr))
  186. error = -EFAULT;
  187. gfs2_glock_dq_m(1, &gh);
  188. gfs2_holder_uninit(&gh);
  189. return error;
  190. }
  191. void gfs2_set_inode_flags(struct inode *inode)
  192. {
  193. struct gfs2_inode *ip = GFS2_I(inode);
  194. struct gfs2_dinode_host *di = &ip->i_di;
  195. unsigned int flags = inode->i_flags;
  196. flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
  197. if (di->di_flags & GFS2_DIF_IMMUTABLE)
  198. flags |= S_IMMUTABLE;
  199. if (di->di_flags & GFS2_DIF_APPENDONLY)
  200. flags |= S_APPEND;
  201. if (di->di_flags & GFS2_DIF_NOATIME)
  202. flags |= S_NOATIME;
  203. if (di->di_flags & GFS2_DIF_SYNC)
  204. flags |= S_SYNC;
  205. inode->i_flags = flags;
  206. }
  207. /* Flags that can be set by user space */
  208. #define GFS2_FLAGS_USER_SET (GFS2_DIF_JDATA| \
  209. GFS2_DIF_DIRECTIO| \
  210. GFS2_DIF_IMMUTABLE| \
  211. GFS2_DIF_APPENDONLY| \
  212. GFS2_DIF_NOATIME| \
  213. GFS2_DIF_SYNC| \
  214. GFS2_DIF_SYSTEM| \
  215. GFS2_DIF_INHERIT_DIRECTIO| \
  216. GFS2_DIF_INHERIT_JDATA)
  217. /**
  218. * gfs2_set_flags - set flags on an inode
  219. * @inode: The inode
  220. * @flags: The flags to set
  221. * @mask: Indicates which flags are valid
  222. *
  223. */
  224. static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
  225. {
  226. struct inode *inode = filp->f_path.dentry->d_inode;
  227. struct gfs2_inode *ip = GFS2_I(inode);
  228. struct gfs2_sbd *sdp = GFS2_SB(inode);
  229. struct buffer_head *bh;
  230. struct gfs2_holder gh;
  231. int error;
  232. u32 new_flags, flags;
  233. error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
  234. if (error)
  235. return error;
  236. flags = ip->i_di.di_flags;
  237. new_flags = (flags & ~mask) | (reqflags & mask);
  238. if ((new_flags ^ flags) == 0)
  239. goto out;
  240. if (S_ISDIR(inode->i_mode)) {
  241. if ((new_flags ^ flags) & GFS2_DIF_JDATA)
  242. new_flags ^= (GFS2_DIF_JDATA|GFS2_DIF_INHERIT_JDATA);
  243. if ((new_flags ^ flags) & GFS2_DIF_DIRECTIO)
  244. new_flags ^= (GFS2_DIF_DIRECTIO|GFS2_DIF_INHERIT_DIRECTIO);
  245. }
  246. error = -EINVAL;
  247. if ((new_flags ^ flags) & ~GFS2_FLAGS_USER_SET)
  248. goto out;
  249. error = -EPERM;
  250. if (IS_IMMUTABLE(inode) && (new_flags & GFS2_DIF_IMMUTABLE))
  251. goto out;
  252. if (IS_APPEND(inode) && (new_flags & GFS2_DIF_APPENDONLY))
  253. goto out;
  254. if (((new_flags ^ flags) & GFS2_DIF_IMMUTABLE) &&
  255. !capable(CAP_LINUX_IMMUTABLE))
  256. goto out;
  257. if (!IS_IMMUTABLE(inode)) {
  258. error = permission(inode, MAY_WRITE, NULL);
  259. if (error)
  260. goto out;
  261. }
  262. error = gfs2_trans_begin(sdp, RES_DINODE, 0);
  263. if (error)
  264. goto out;
  265. error = gfs2_meta_inode_buffer(ip, &bh);
  266. if (error)
  267. goto out_trans_end;
  268. gfs2_trans_add_bh(ip->i_gl, bh, 1);
  269. ip->i_di.di_flags = new_flags;
  270. gfs2_dinode_out(ip, bh->b_data);
  271. brelse(bh);
  272. gfs2_set_inode_flags(inode);
  273. out_trans_end:
  274. gfs2_trans_end(sdp);
  275. out:
  276. gfs2_glock_dq_uninit(&gh);
  277. return error;
  278. }
  279. static int gfs2_set_flags(struct file *filp, u32 __user *ptr)
  280. {
  281. u32 fsflags, gfsflags;
  282. if (get_user(fsflags, ptr))
  283. return -EFAULT;
  284. gfsflags = fsflags_cvt(fsflags_to_gfs2, fsflags);
  285. return do_gfs2_set_flags(filp, gfsflags, ~0);
  286. }
  287. static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
  288. {
  289. switch(cmd) {
  290. case FS_IOC_GETFLAGS:
  291. return gfs2_get_flags(filp, (u32 __user *)arg);
  292. case FS_IOC_SETFLAGS:
  293. return gfs2_set_flags(filp, (u32 __user *)arg);
  294. }
  295. return -ENOTTY;
  296. }
  297. /**
  298. * gfs2_mmap -
  299. * @file: The file to map
  300. * @vma: The VMA which described the mapping
  301. *
  302. * Returns: 0 or error code
  303. */
  304. static int gfs2_mmap(struct file *file, struct vm_area_struct *vma)
  305. {
  306. struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
  307. struct gfs2_holder i_gh;
  308. int error;
  309. gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &i_gh);
  310. error = gfs2_glock_nq_atime(&i_gh);
  311. if (error) {
  312. gfs2_holder_uninit(&i_gh);
  313. return error;
  314. }
  315. /* This is VM_MAYWRITE instead of VM_WRITE because a call
  316. to mprotect() can turn on VM_WRITE later. */
  317. if ((vma->vm_flags & (VM_MAYSHARE | VM_MAYWRITE)) ==
  318. (VM_MAYSHARE | VM_MAYWRITE))
  319. vma->vm_ops = &gfs2_vm_ops_sharewrite;
  320. else
  321. vma->vm_ops = &gfs2_vm_ops_private;
  322. gfs2_glock_dq_uninit(&i_gh);
  323. return error;
  324. }
  325. /**
  326. * gfs2_open - open a file
  327. * @inode: the inode to open
  328. * @file: the struct file for this opening
  329. *
  330. * Returns: errno
  331. */
  332. static int gfs2_open(struct inode *inode, struct file *file)
  333. {
  334. struct gfs2_inode *ip = GFS2_I(inode);
  335. struct gfs2_holder i_gh;
  336. struct gfs2_file *fp;
  337. int error;
  338. fp = kzalloc(sizeof(struct gfs2_file), GFP_KERNEL);
  339. if (!fp)
  340. return -ENOMEM;
  341. mutex_init(&fp->f_fl_mutex);
  342. gfs2_assert_warn(GFS2_SB(inode), !file->private_data);
  343. file->private_data = fp;
  344. if (S_ISREG(ip->i_inode.i_mode)) {
  345. error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
  346. &i_gh);
  347. if (error)
  348. goto fail;
  349. if (!(file->f_flags & O_LARGEFILE) &&
  350. ip->i_di.di_size > MAX_NON_LFS) {
  351. error = -EFBIG;
  352. goto fail_gunlock;
  353. }
  354. /* Listen to the Direct I/O flag */
  355. if (ip->i_di.di_flags & GFS2_DIF_DIRECTIO)
  356. file->f_flags |= O_DIRECT;
  357. gfs2_glock_dq_uninit(&i_gh);
  358. }
  359. return 0;
  360. fail_gunlock:
  361. gfs2_glock_dq_uninit(&i_gh);
  362. fail:
  363. file->private_data = NULL;
  364. kfree(fp);
  365. return error;
  366. }
  367. /**
  368. * gfs2_close - called to close a struct file
  369. * @inode: the inode the struct file belongs to
  370. * @file: the struct file being closed
  371. *
  372. * Returns: errno
  373. */
  374. static int gfs2_close(struct inode *inode, struct file *file)
  375. {
  376. struct gfs2_sbd *sdp = inode->i_sb->s_fs_info;
  377. struct gfs2_file *fp;
  378. fp = file->private_data;
  379. file->private_data = NULL;
  380. if (gfs2_assert_warn(sdp, fp))
  381. return -EIO;
  382. kfree(fp);
  383. return 0;
  384. }
  385. /**
  386. * gfs2_fsync - sync the dirty data for a file (across the cluster)
  387. * @file: the file that points to the dentry (we ignore this)
  388. * @dentry: the dentry that points to the inode to sync
  389. *
  390. * The VFS will flush "normal" data for us. We only need to worry
  391. * about metadata here. For journaled data, we just do a log flush
  392. * as we can't avoid it. Otherwise we can just bale out if datasync
  393. * is set. For stuffed inodes we must flush the log in order to
  394. * ensure that all data is on disk.
  395. *
  396. * The call to write_inode_now() is there to write back metadata and
  397. * the inode itself. It does also try and write the data, but thats
  398. * (hopefully) a no-op due to the VFS having already called filemap_fdatawrite()
  399. * for us.
  400. *
  401. * Returns: errno
  402. */
  403. static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync)
  404. {
  405. struct inode *inode = dentry->d_inode;
  406. int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC);
  407. int ret = 0;
  408. if (gfs2_is_jdata(GFS2_I(inode))) {
  409. gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);
  410. return 0;
  411. }
  412. if (sync_state != 0) {
  413. if (!datasync)
  414. ret = write_inode_now(inode, 0);
  415. if (gfs2_is_stuffed(GFS2_I(inode)))
  416. gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);
  417. }
  418. return ret;
  419. }
  420. /**
  421. * gfs2_lock - acquire/release a posix lock on a file
  422. * @file: the file pointer
  423. * @cmd: either modify or retrieve lock state, possibly wait
  424. * @fl: type and range of lock
  425. *
  426. * Returns: errno
  427. */
  428. static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
  429. {
  430. struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
  431. struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host);
  432. struct lm_lockname name =
  433. { .ln_number = ip->i_num.no_addr,
  434. .ln_type = LM_TYPE_PLOCK };
  435. if (!(fl->fl_flags & FL_POSIX))
  436. return -ENOLCK;
  437. if ((ip->i_inode.i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
  438. return -ENOLCK;
  439. if (sdp->sd_args.ar_localflocks) {
  440. if (IS_GETLK(cmd)) {
  441. posix_test_lock(file, fl);
  442. return 0;
  443. } else {
  444. return posix_lock_file_wait(file, fl);
  445. }
  446. }
  447. if (cmd == F_CANCELLK) {
  448. /* Hack: */
  449. cmd = F_SETLK;
  450. fl->fl_type = F_UNLCK;
  451. }
  452. if (IS_GETLK(cmd))
  453. return gfs2_lm_plock_get(sdp, &name, file, fl);
  454. else if (fl->fl_type == F_UNLCK)
  455. return gfs2_lm_punlock(sdp, &name, file, fl);
  456. else
  457. return gfs2_lm_plock(sdp, &name, file, cmd, fl);
  458. }
  459. static int do_flock(struct file *file, int cmd, struct file_lock *fl)
  460. {
  461. struct gfs2_file *fp = file->private_data;
  462. struct gfs2_holder *fl_gh = &fp->f_fl_gh;
  463. struct gfs2_inode *ip = GFS2_I(file->f_path.dentry->d_inode);
  464. struct gfs2_glock *gl;
  465. unsigned int state;
  466. int flags;
  467. int error = 0;
  468. state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED;
  469. flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE;
  470. mutex_lock(&fp->f_fl_mutex);
  471. gl = fl_gh->gh_gl;
  472. if (gl) {
  473. if (fl_gh->gh_state == state)
  474. goto out;
  475. gfs2_glock_hold(gl);
  476. flock_lock_file_wait(file,
  477. &(struct file_lock){.fl_type = F_UNLCK});
  478. gfs2_glock_dq_uninit(fl_gh);
  479. } else {
  480. error = gfs2_glock_get(GFS2_SB(&ip->i_inode),
  481. ip->i_num.no_addr, &gfs2_flock_glops,
  482. CREATE, &gl);
  483. if (error)
  484. goto out;
  485. }
  486. gfs2_holder_init(gl, state, flags, fl_gh);
  487. gfs2_glock_put(gl);
  488. error = gfs2_glock_nq(fl_gh);
  489. if (error) {
  490. gfs2_holder_uninit(fl_gh);
  491. if (error == GLR_TRYFAILED)
  492. error = -EAGAIN;
  493. } else {
  494. error = flock_lock_file_wait(file, fl);
  495. gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error);
  496. }
  497. out:
  498. mutex_unlock(&fp->f_fl_mutex);
  499. return error;
  500. }
  501. static void do_unflock(struct file *file, struct file_lock *fl)
  502. {
  503. struct gfs2_file *fp = file->private_data;
  504. struct gfs2_holder *fl_gh = &fp->f_fl_gh;
  505. mutex_lock(&fp->f_fl_mutex);
  506. flock_lock_file_wait(file, fl);
  507. if (fl_gh->gh_gl)
  508. gfs2_glock_dq_uninit(fl_gh);
  509. mutex_unlock(&fp->f_fl_mutex);
  510. }
  511. /**
  512. * gfs2_flock - acquire/release a flock lock on a file
  513. * @file: the file pointer
  514. * @cmd: either modify or retrieve lock state, possibly wait
  515. * @fl: type and range of lock
  516. *
  517. * Returns: errno
  518. */
  519. static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl)
  520. {
  521. struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
  522. struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host);
  523. if (!(fl->fl_flags & FL_FLOCK))
  524. return -ENOLCK;
  525. if ((ip->i_inode.i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
  526. return -ENOLCK;
  527. if (sdp->sd_args.ar_localflocks)
  528. return flock_lock_file_wait(file, fl);
  529. if (fl->fl_type == F_UNLCK) {
  530. do_unflock(file, fl);
  531. return 0;
  532. } else {
  533. return do_flock(file, cmd, fl);
  534. }
  535. }
  536. const struct file_operations gfs2_file_fops = {
  537. .llseek = gfs2_llseek,
  538. .read = do_sync_read,
  539. .aio_read = generic_file_aio_read,
  540. .write = do_sync_write,
  541. .aio_write = generic_file_aio_write,
  542. .unlocked_ioctl = gfs2_ioctl,
  543. .mmap = gfs2_mmap,
  544. .open = gfs2_open,
  545. .release = gfs2_close,
  546. .fsync = gfs2_fsync,
  547. .lock = gfs2_lock,
  548. .sendfile = generic_file_sendfile,
  549. .flock = gfs2_flock,
  550. .splice_read = generic_file_splice_read,
  551. .splice_write = generic_file_splice_write,
  552. };
  553. const struct file_operations gfs2_dir_fops = {
  554. .readdir = gfs2_readdir,
  555. .unlocked_ioctl = gfs2_ioctl,
  556. .open = gfs2_open,
  557. .release = gfs2_close,
  558. .fsync = gfs2_fsync,
  559. .lock = gfs2_lock,
  560. .flock = gfs2_flock,
  561. };