ops_file.c 15 KB

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