file.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. * linux/fs/nfs/file.c
  3. *
  4. * Copyright (C) 1992 Rick Sladkey
  5. *
  6. * Changes Copyright (C) 1994 by Florian La Roche
  7. * - Do not copy data too often around in the kernel.
  8. * - In nfs_file_read the return value of kmalloc wasn't checked.
  9. * - Put in a better version of read look-ahead buffering. Original idea
  10. * and implementation by Wai S Kok elekokws@ee.nus.sg.
  11. *
  12. * Expire cache on write to a file by Wai S Kok (Oct 1994).
  13. *
  14. * Total rewrite of read side for new NFS buffer cache.. Linus.
  15. *
  16. * nfs regular file handling functions
  17. */
  18. #include <linux/time.h>
  19. #include <linux/kernel.h>
  20. #include <linux/errno.h>
  21. #include <linux/fcntl.h>
  22. #include <linux/stat.h>
  23. #include <linux/nfs_fs.h>
  24. #include <linux/nfs_mount.h>
  25. #include <linux/mm.h>
  26. #include <linux/slab.h>
  27. #include <linux/pagemap.h>
  28. #include <linux/smp_lock.h>
  29. #include <linux/aio.h>
  30. #include <asm/uaccess.h>
  31. #include <asm/system.h>
  32. #include "delegation.h"
  33. #include "internal.h"
  34. #include "iostat.h"
  35. #define NFSDBG_FACILITY NFSDBG_FILE
  36. static int nfs_file_open(struct inode *, struct file *);
  37. static int nfs_file_release(struct inode *, struct file *);
  38. static loff_t nfs_file_llseek(struct file *file, loff_t offset, int origin);
  39. static int nfs_file_mmap(struct file *, struct vm_area_struct *);
  40. static ssize_t nfs_file_splice_read(struct file *filp, loff_t *ppos,
  41. struct pipe_inode_info *pipe,
  42. size_t count, unsigned int flags);
  43. static ssize_t nfs_file_read(struct kiocb *, const struct iovec *iov,
  44. unsigned long nr_segs, loff_t pos);
  45. static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov,
  46. unsigned long nr_segs, loff_t pos);
  47. static int nfs_file_flush(struct file *, fl_owner_t id);
  48. static int nfs_fsync(struct file *, struct dentry *dentry, int datasync);
  49. static int nfs_check_flags(int flags);
  50. static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl);
  51. static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl);
  52. static int nfs_setlease(struct file *file, long arg, struct file_lock **fl);
  53. static struct vm_operations_struct nfs_file_vm_ops;
  54. const struct file_operations nfs_file_operations = {
  55. .llseek = nfs_file_llseek,
  56. .read = do_sync_read,
  57. .write = do_sync_write,
  58. .aio_read = nfs_file_read,
  59. .aio_write = nfs_file_write,
  60. #ifdef CONFIG_MMU
  61. .mmap = nfs_file_mmap,
  62. #else
  63. .mmap = generic_file_mmap,
  64. #endif
  65. .open = nfs_file_open,
  66. .flush = nfs_file_flush,
  67. .release = nfs_file_release,
  68. .fsync = nfs_fsync,
  69. .lock = nfs_lock,
  70. .flock = nfs_flock,
  71. .splice_read = nfs_file_splice_read,
  72. .check_flags = nfs_check_flags,
  73. .setlease = nfs_setlease,
  74. };
  75. const struct inode_operations nfs_file_inode_operations = {
  76. .permission = nfs_permission,
  77. .getattr = nfs_getattr,
  78. .setattr = nfs_setattr,
  79. };
  80. #ifdef CONFIG_NFS_V3
  81. const struct inode_operations nfs3_file_inode_operations = {
  82. .permission = nfs_permission,
  83. .getattr = nfs_getattr,
  84. .setattr = nfs_setattr,
  85. .listxattr = nfs3_listxattr,
  86. .getxattr = nfs3_getxattr,
  87. .setxattr = nfs3_setxattr,
  88. .removexattr = nfs3_removexattr,
  89. };
  90. #endif /* CONFIG_NFS_v3 */
  91. /* Hack for future NFS swap support */
  92. #ifndef IS_SWAPFILE
  93. # define IS_SWAPFILE(inode) (0)
  94. #endif
  95. static int nfs_check_flags(int flags)
  96. {
  97. if ((flags & (O_APPEND | O_DIRECT)) == (O_APPEND | O_DIRECT))
  98. return -EINVAL;
  99. return 0;
  100. }
  101. /*
  102. * Open file
  103. */
  104. static int
  105. nfs_file_open(struct inode *inode, struct file *filp)
  106. {
  107. int res;
  108. res = nfs_check_flags(filp->f_flags);
  109. if (res)
  110. return res;
  111. nfs_inc_stats(inode, NFSIOS_VFSOPEN);
  112. lock_kernel();
  113. res = NFS_PROTO(inode)->file_open(inode, filp);
  114. unlock_kernel();
  115. return res;
  116. }
  117. static int
  118. nfs_file_release(struct inode *inode, struct file *filp)
  119. {
  120. /* Ensure that dirty pages are flushed out with the right creds */
  121. if (filp->f_mode & FMODE_WRITE)
  122. nfs_wb_all(filp->f_path.dentry->d_inode);
  123. nfs_inc_stats(inode, NFSIOS_VFSRELEASE);
  124. return NFS_PROTO(inode)->file_release(inode, filp);
  125. }
  126. /**
  127. * nfs_revalidate_size - Revalidate the file size
  128. * @inode - pointer to inode struct
  129. * @file - pointer to struct file
  130. *
  131. * Revalidates the file length. This is basically a wrapper around
  132. * nfs_revalidate_inode() that takes into account the fact that we may
  133. * have cached writes (in which case we don't care about the server's
  134. * idea of what the file length is), or O_DIRECT (in which case we
  135. * shouldn't trust the cache).
  136. */
  137. static int nfs_revalidate_file_size(struct inode *inode, struct file *filp)
  138. {
  139. struct nfs_server *server = NFS_SERVER(inode);
  140. struct nfs_inode *nfsi = NFS_I(inode);
  141. if (server->flags & NFS_MOUNT_NOAC)
  142. goto force_reval;
  143. if (filp->f_flags & O_DIRECT)
  144. goto force_reval;
  145. if (nfsi->npages != 0)
  146. return 0;
  147. if (!(nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) && !nfs_attribute_timeout(inode))
  148. return 0;
  149. force_reval:
  150. return __nfs_revalidate_inode(server, inode);
  151. }
  152. static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
  153. {
  154. /* origin == SEEK_END => we must revalidate the cached file length */
  155. if (origin == SEEK_END) {
  156. struct inode *inode = filp->f_mapping->host;
  157. int retval = nfs_revalidate_file_size(inode, filp);
  158. if (retval < 0)
  159. return (loff_t)retval;
  160. }
  161. return remote_llseek(filp, offset, origin);
  162. }
  163. /*
  164. * Helper for nfs_file_flush() and nfs_fsync()
  165. *
  166. * Notice that it clears the NFS_CONTEXT_ERROR_WRITE before synching to
  167. * disk, but it retrieves and clears ctx->error after synching, despite
  168. * the two being set at the same time in nfs_context_set_write_error().
  169. * This is because the former is used to notify the _next_ call to
  170. * nfs_file_write() that a write error occured, and hence cause it to
  171. * fall back to doing a synchronous write.
  172. */
  173. static int nfs_do_fsync(struct nfs_open_context *ctx, struct inode *inode)
  174. {
  175. int have_error, status;
  176. int ret = 0;
  177. have_error = test_and_clear_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
  178. status = nfs_wb_all(inode);
  179. have_error |= test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
  180. if (have_error)
  181. ret = xchg(&ctx->error, 0);
  182. if (!ret)
  183. ret = status;
  184. return ret;
  185. }
  186. /*
  187. * Flush all dirty pages, and check for write errors.
  188. *
  189. */
  190. static int
  191. nfs_file_flush(struct file *file, fl_owner_t id)
  192. {
  193. struct nfs_open_context *ctx = nfs_file_open_context(file);
  194. struct inode *inode = file->f_path.dentry->d_inode;
  195. int status;
  196. dfprintk(VFS, "nfs: flush(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino);
  197. if ((file->f_mode & FMODE_WRITE) == 0)
  198. return 0;
  199. nfs_inc_stats(inode, NFSIOS_VFSFLUSH);
  200. /* Ensure that data+attribute caches are up to date after close() */
  201. status = nfs_do_fsync(ctx, inode);
  202. if (!status)
  203. nfs_revalidate_inode(NFS_SERVER(inode), inode);
  204. return status;
  205. }
  206. static ssize_t
  207. nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
  208. unsigned long nr_segs, loff_t pos)
  209. {
  210. struct dentry * dentry = iocb->ki_filp->f_path.dentry;
  211. struct inode * inode = dentry->d_inode;
  212. ssize_t result;
  213. size_t count = iov_length(iov, nr_segs);
  214. if (iocb->ki_filp->f_flags & O_DIRECT)
  215. return nfs_file_direct_read(iocb, iov, nr_segs, pos);
  216. dfprintk(VFS, "nfs: read(%s/%s, %lu@%lu)\n",
  217. dentry->d_parent->d_name.name, dentry->d_name.name,
  218. (unsigned long) count, (unsigned long) pos);
  219. result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping);
  220. nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, count);
  221. if (!result)
  222. result = generic_file_aio_read(iocb, iov, nr_segs, pos);
  223. return result;
  224. }
  225. static ssize_t
  226. nfs_file_splice_read(struct file *filp, loff_t *ppos,
  227. struct pipe_inode_info *pipe, size_t count,
  228. unsigned int flags)
  229. {
  230. struct dentry *dentry = filp->f_path.dentry;
  231. struct inode *inode = dentry->d_inode;
  232. ssize_t res;
  233. dfprintk(VFS, "nfs: splice_read(%s/%s, %lu@%Lu)\n",
  234. dentry->d_parent->d_name.name, dentry->d_name.name,
  235. (unsigned long) count, (unsigned long long) *ppos);
  236. res = nfs_revalidate_mapping(inode, filp->f_mapping);
  237. if (!res)
  238. res = generic_file_splice_read(filp, ppos, pipe, count, flags);
  239. return res;
  240. }
  241. static int
  242. nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
  243. {
  244. struct dentry *dentry = file->f_path.dentry;
  245. struct inode *inode = dentry->d_inode;
  246. int status;
  247. dfprintk(VFS, "nfs: mmap(%s/%s)\n",
  248. dentry->d_parent->d_name.name, dentry->d_name.name);
  249. status = nfs_revalidate_mapping(inode, file->f_mapping);
  250. if (!status) {
  251. vma->vm_ops = &nfs_file_vm_ops;
  252. vma->vm_flags |= VM_CAN_NONLINEAR;
  253. file_accessed(file);
  254. }
  255. return status;
  256. }
  257. /*
  258. * Flush any dirty pages for this process, and check for write errors.
  259. * The return status from this call provides a reliable indication of
  260. * whether any write errors occurred for this process.
  261. */
  262. static int
  263. nfs_fsync(struct file *file, struct dentry *dentry, int datasync)
  264. {
  265. struct nfs_open_context *ctx = nfs_file_open_context(file);
  266. struct inode *inode = dentry->d_inode;
  267. dfprintk(VFS, "nfs: fsync(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino);
  268. nfs_inc_stats(inode, NFSIOS_VFSFSYNC);
  269. return nfs_do_fsync(ctx, inode);
  270. }
  271. /*
  272. * This does the "real" work of the write. We must allocate and lock the
  273. * page to be sent back to the generic routine, which then copies the
  274. * data from user space.
  275. *
  276. * If the writer ends up delaying the write, the writer needs to
  277. * increment the page use counts until he is done with the page.
  278. */
  279. static int nfs_write_begin(struct file *file, struct address_space *mapping,
  280. loff_t pos, unsigned len, unsigned flags,
  281. struct page **pagep, void **fsdata)
  282. {
  283. int ret;
  284. pgoff_t index;
  285. struct page *page;
  286. index = pos >> PAGE_CACHE_SHIFT;
  287. page = __grab_cache_page(mapping, index);
  288. if (!page)
  289. return -ENOMEM;
  290. *pagep = page;
  291. ret = nfs_flush_incompatible(file, page);
  292. if (ret) {
  293. unlock_page(page);
  294. page_cache_release(page);
  295. }
  296. return ret;
  297. }
  298. static int nfs_write_end(struct file *file, struct address_space *mapping,
  299. loff_t pos, unsigned len, unsigned copied,
  300. struct page *page, void *fsdata)
  301. {
  302. unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
  303. int status;
  304. lock_kernel();
  305. status = nfs_updatepage(file, page, offset, copied);
  306. unlock_kernel();
  307. unlock_page(page);
  308. page_cache_release(page);
  309. if (status < 0)
  310. return status;
  311. return copied;
  312. }
  313. static void nfs_invalidate_page(struct page *page, unsigned long offset)
  314. {
  315. if (offset != 0)
  316. return;
  317. /* Cancel any unstarted writes on this page */
  318. nfs_wb_page_cancel(page->mapping->host, page);
  319. }
  320. static int nfs_release_page(struct page *page, gfp_t gfp)
  321. {
  322. /* If PagePrivate() is set, then the page is not freeable */
  323. return 0;
  324. }
  325. static int nfs_launder_page(struct page *page)
  326. {
  327. return nfs_wb_page(page->mapping->host, page);
  328. }
  329. const struct address_space_operations nfs_file_aops = {
  330. .readpage = nfs_readpage,
  331. .readpages = nfs_readpages,
  332. .set_page_dirty = __set_page_dirty_nobuffers,
  333. .writepage = nfs_writepage,
  334. .writepages = nfs_writepages,
  335. .write_begin = nfs_write_begin,
  336. .write_end = nfs_write_end,
  337. .invalidatepage = nfs_invalidate_page,
  338. .releasepage = nfs_release_page,
  339. .direct_IO = nfs_direct_IO,
  340. .launder_page = nfs_launder_page,
  341. };
  342. static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct page *page)
  343. {
  344. struct file *filp = vma->vm_file;
  345. unsigned pagelen;
  346. int ret = -EINVAL;
  347. struct address_space *mapping;
  348. lock_page(page);
  349. mapping = page->mapping;
  350. if (mapping != vma->vm_file->f_path.dentry->d_inode->i_mapping)
  351. goto out_unlock;
  352. ret = 0;
  353. pagelen = nfs_page_length(page);
  354. if (pagelen == 0)
  355. goto out_unlock;
  356. ret = nfs_flush_incompatible(filp, page);
  357. if (ret != 0)
  358. goto out_unlock;
  359. ret = nfs_updatepage(filp, page, 0, pagelen);
  360. if (ret == 0)
  361. ret = pagelen;
  362. out_unlock:
  363. unlock_page(page);
  364. return ret;
  365. }
  366. static struct vm_operations_struct nfs_file_vm_ops = {
  367. .fault = filemap_fault,
  368. .page_mkwrite = nfs_vm_page_mkwrite,
  369. };
  370. static int nfs_need_sync_write(struct file *filp, struct inode *inode)
  371. {
  372. struct nfs_open_context *ctx;
  373. if (IS_SYNC(inode) || (filp->f_flags & O_SYNC))
  374. return 1;
  375. ctx = nfs_file_open_context(filp);
  376. if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags))
  377. return 1;
  378. return 0;
  379. }
  380. static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
  381. unsigned long nr_segs, loff_t pos)
  382. {
  383. struct dentry * dentry = iocb->ki_filp->f_path.dentry;
  384. struct inode * inode = dentry->d_inode;
  385. ssize_t result;
  386. size_t count = iov_length(iov, nr_segs);
  387. if (iocb->ki_filp->f_flags & O_DIRECT)
  388. return nfs_file_direct_write(iocb, iov, nr_segs, pos);
  389. dfprintk(VFS, "nfs: write(%s/%s(%ld), %lu@%Ld)\n",
  390. dentry->d_parent->d_name.name, dentry->d_name.name,
  391. inode->i_ino, (unsigned long) count, (long long) pos);
  392. result = -EBUSY;
  393. if (IS_SWAPFILE(inode))
  394. goto out_swapfile;
  395. /*
  396. * O_APPEND implies that we must revalidate the file length.
  397. */
  398. if (iocb->ki_filp->f_flags & O_APPEND) {
  399. result = nfs_revalidate_file_size(inode, iocb->ki_filp);
  400. if (result)
  401. goto out;
  402. }
  403. result = count;
  404. if (!count)
  405. goto out;
  406. nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count);
  407. result = generic_file_aio_write(iocb, iov, nr_segs, pos);
  408. /* Return error values for O_SYNC and IS_SYNC() */
  409. if (result >= 0 && nfs_need_sync_write(iocb->ki_filp, inode)) {
  410. int err = nfs_do_fsync(nfs_file_open_context(iocb->ki_filp), inode);
  411. if (err < 0)
  412. result = err;
  413. }
  414. out:
  415. return result;
  416. out_swapfile:
  417. printk(KERN_INFO "NFS: attempt to write to active swap file!\n");
  418. goto out;
  419. }
  420. static int do_getlk(struct file *filp, int cmd, struct file_lock *fl)
  421. {
  422. struct inode *inode = filp->f_mapping->host;
  423. int status = 0;
  424. lock_kernel();
  425. /* Try local locking first */
  426. posix_test_lock(filp, fl);
  427. if (fl->fl_type != F_UNLCK) {
  428. /* found a conflict */
  429. goto out;
  430. }
  431. if (nfs_have_delegation(inode, FMODE_READ))
  432. goto out_noconflict;
  433. if (NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM)
  434. goto out_noconflict;
  435. status = NFS_PROTO(inode)->lock(filp, cmd, fl);
  436. out:
  437. unlock_kernel();
  438. return status;
  439. out_noconflict:
  440. fl->fl_type = F_UNLCK;
  441. goto out;
  442. }
  443. static int do_vfs_lock(struct file *file, struct file_lock *fl)
  444. {
  445. int res = 0;
  446. switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) {
  447. case FL_POSIX:
  448. res = posix_lock_file_wait(file, fl);
  449. break;
  450. case FL_FLOCK:
  451. res = flock_lock_file_wait(file, fl);
  452. break;
  453. default:
  454. BUG();
  455. }
  456. if (res < 0)
  457. dprintk(KERN_WARNING "%s: VFS is out of sync with lock manager"
  458. " - error %d!\n",
  459. __FUNCTION__, res);
  460. return res;
  461. }
  462. static int do_unlk(struct file *filp, int cmd, struct file_lock *fl)
  463. {
  464. struct inode *inode = filp->f_mapping->host;
  465. int status;
  466. /*
  467. * Flush all pending writes before doing anything
  468. * with locks..
  469. */
  470. nfs_sync_mapping(filp->f_mapping);
  471. /* NOTE: special case
  472. * If we're signalled while cleaning up locks on process exit, we
  473. * still need to complete the unlock.
  474. */
  475. lock_kernel();
  476. /* Use local locking if mounted with "-onolock" */
  477. if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM))
  478. status = NFS_PROTO(inode)->lock(filp, cmd, fl);
  479. else
  480. status = do_vfs_lock(filp, fl);
  481. unlock_kernel();
  482. return status;
  483. }
  484. static int do_setlk(struct file *filp, int cmd, struct file_lock *fl)
  485. {
  486. struct inode *inode = filp->f_mapping->host;
  487. int status;
  488. /*
  489. * Flush all pending writes before doing anything
  490. * with locks..
  491. */
  492. status = nfs_sync_mapping(filp->f_mapping);
  493. if (status != 0)
  494. goto out;
  495. lock_kernel();
  496. /* Use local locking if mounted with "-onolock" */
  497. if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM))
  498. status = NFS_PROTO(inode)->lock(filp, cmd, fl);
  499. else
  500. status = do_vfs_lock(filp, fl);
  501. unlock_kernel();
  502. if (status < 0)
  503. goto out;
  504. /*
  505. * Make sure we clear the cache whenever we try to get the lock.
  506. * This makes locking act as a cache coherency point.
  507. */
  508. nfs_sync_mapping(filp->f_mapping);
  509. nfs_zap_caches(inode);
  510. out:
  511. return status;
  512. }
  513. /*
  514. * Lock a (portion of) a file
  515. */
  516. static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
  517. {
  518. struct inode * inode = filp->f_mapping->host;
  519. dprintk("NFS: nfs_lock(f=%s/%ld, t=%x, fl=%x, r=%Ld:%Ld)\n",
  520. inode->i_sb->s_id, inode->i_ino,
  521. fl->fl_type, fl->fl_flags,
  522. (long long)fl->fl_start, (long long)fl->fl_end);
  523. nfs_inc_stats(inode, NFSIOS_VFSLOCK);
  524. /* No mandatory locks over NFS */
  525. if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
  526. return -ENOLCK;
  527. if (IS_GETLK(cmd))
  528. return do_getlk(filp, cmd, fl);
  529. if (fl->fl_type == F_UNLCK)
  530. return do_unlk(filp, cmd, fl);
  531. return do_setlk(filp, cmd, fl);
  532. }
  533. /*
  534. * Lock a (portion of) a file
  535. */
  536. static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl)
  537. {
  538. dprintk("NFS: nfs_flock(f=%s/%ld, t=%x, fl=%x)\n",
  539. filp->f_path.dentry->d_inode->i_sb->s_id,
  540. filp->f_path.dentry->d_inode->i_ino,
  541. fl->fl_type, fl->fl_flags);
  542. /*
  543. * No BSD flocks over NFS allowed.
  544. * Note: we could try to fake a POSIX lock request here by
  545. * using ((u32) filp | 0x80000000) or some such as the pid.
  546. * Not sure whether that would be unique, though, or whether
  547. * that would break in other places.
  548. */
  549. if (!(fl->fl_flags & FL_FLOCK))
  550. return -ENOLCK;
  551. /* We're simulating flock() locks using posix locks on the server */
  552. fl->fl_owner = (fl_owner_t)filp;
  553. fl->fl_start = 0;
  554. fl->fl_end = OFFSET_MAX;
  555. if (fl->fl_type == F_UNLCK)
  556. return do_unlk(filp, cmd, fl);
  557. return do_setlk(filp, cmd, fl);
  558. }
  559. static int nfs_setlease(struct file *file, long arg, struct file_lock **fl)
  560. {
  561. /*
  562. * There is no protocol support for leases, so we have no way
  563. * to implement them correctly in the face of opens by other
  564. * clients.
  565. */
  566. return -EINVAL;
  567. }