ops_file.c 15 KB

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