ops_file.c 15 KB

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