file.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2017 Red Hat, Inc.
  4. */
  5. #include <linux/cred.h>
  6. #include <linux/file.h>
  7. #include <linux/mount.h>
  8. #include <linux/xattr.h>
  9. #include <linux/uio.h>
  10. #include <linux/uaccess.h>
  11. #include <linux/splice.h>
  12. #include <linux/security.h>
  13. #include <linux/mm.h>
  14. #include <linux/fs.h>
  15. #include "overlayfs.h"
  16. #define OVL_IOCB_MASK (IOCB_DSYNC | IOCB_HIPRI | IOCB_NOWAIT | IOCB_SYNC)
  17. struct ovl_aio_req {
  18. struct kiocb iocb;
  19. refcount_t ref;
  20. struct kiocb *orig_iocb;
  21. };
  22. static struct kmem_cache *ovl_aio_request_cachep;
  23. static char ovl_whatisit(struct inode *inode, struct inode *realinode)
  24. {
  25. if (realinode != ovl_inode_upper(inode))
  26. return 'l';
  27. if (ovl_has_upperdata(inode))
  28. return 'u';
  29. else
  30. return 'm';
  31. }
  32. /* No atime modificaton nor notify on underlying */
  33. #define OVL_OPEN_FLAGS (O_NOATIME | FMODE_NONOTIFY)
  34. static struct file *ovl_open_realfile(const struct file *file,
  35. const struct path *realpath)
  36. {
  37. struct inode *realinode = d_inode(realpath->dentry);
  38. struct inode *inode = file_inode(file);
  39. struct user_namespace *real_mnt_userns;
  40. struct file *realfile;
  41. const struct cred *old_cred;
  42. int flags = file->f_flags | OVL_OPEN_FLAGS;
  43. int acc_mode = ACC_MODE(flags);
  44. int err;
  45. if (flags & O_APPEND)
  46. acc_mode |= MAY_APPEND;
  47. old_cred = ovl_override_creds(inode->i_sb);
  48. real_mnt_userns = mnt_user_ns(realpath->mnt);
  49. err = inode_permission(real_mnt_userns, realinode, MAY_OPEN | acc_mode);
  50. if (err) {
  51. realfile = ERR_PTR(err);
  52. } else {
  53. if (old_cred && !inode_owner_or_capable(real_mnt_userns,
  54. realinode))
  55. flags &= ~O_NOATIME;
  56. realfile = open_with_fake_path(&file->f_path, flags, realinode,
  57. current_cred());
  58. }
  59. ovl_revert_creds(inode->i_sb, old_cred);
  60. pr_debug("open(%p[%pD2/%c], 0%o) -> (%p, 0%o)\n",
  61. file, file, ovl_whatisit(inode, realinode), file->f_flags,
  62. realfile, IS_ERR(realfile) ? 0 : realfile->f_flags);
  63. return realfile;
  64. }
  65. #define OVL_SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | O_DIRECT)
  66. static int ovl_change_flags(struct file *file, unsigned int flags)
  67. {
  68. struct inode *inode = file_inode(file);
  69. int err;
  70. flags &= OVL_SETFL_MASK;
  71. if (((flags ^ file->f_flags) & O_APPEND) && IS_APPEND(inode))
  72. return -EPERM;
  73. if ((flags & O_DIRECT) && !(file->f_mode & FMODE_CAN_ODIRECT))
  74. return -EINVAL;
  75. if (file->f_op->check_flags) {
  76. err = file->f_op->check_flags(flags);
  77. if (err)
  78. return err;
  79. }
  80. spin_lock(&file->f_lock);
  81. file->f_flags = (file->f_flags & ~OVL_SETFL_MASK) | flags;
  82. file->f_iocb_flags = iocb_flags(file);
  83. spin_unlock(&file->f_lock);
  84. return 0;
  85. }
  86. static int ovl_real_fdget_meta(const struct file *file, struct fd *real,
  87. bool allow_meta)
  88. {
  89. struct dentry *dentry = file_dentry(file);
  90. struct path realpath;
  91. real->flags = 0;
  92. real->file = file->private_data;
  93. if (allow_meta)
  94. ovl_path_real(dentry, &realpath);
  95. else
  96. ovl_path_realdata(dentry, &realpath);
  97. /* Has it been copied up since we'd opened it? */
  98. if (unlikely(file_inode(real->file) != d_inode(realpath.dentry))) {
  99. real->flags = FDPUT_FPUT;
  100. real->file = ovl_open_realfile(file, &realpath);
  101. return PTR_ERR_OR_ZERO(real->file);
  102. }
  103. /* Did the flags change since open? */
  104. if (unlikely((file->f_flags ^ real->file->f_flags) & ~OVL_OPEN_FLAGS))
  105. return ovl_change_flags(real->file, file->f_flags);
  106. return 0;
  107. }
  108. static int ovl_real_fdget(const struct file *file, struct fd *real)
  109. {
  110. if (d_is_dir(file_dentry(file))) {
  111. real->flags = 0;
  112. real->file = ovl_dir_real_file(file, false);
  113. return PTR_ERR_OR_ZERO(real->file);
  114. }
  115. return ovl_real_fdget_meta(file, real, false);
  116. }
  117. static int ovl_open(struct inode *inode, struct file *file)
  118. {
  119. struct dentry *dentry = file_dentry(file);
  120. struct file *realfile;
  121. struct path realpath;
  122. int err;
  123. err = ovl_maybe_copy_up(dentry, file->f_flags);
  124. if (err)
  125. return err;
  126. /* No longer need these flags, so don't pass them on to underlying fs */
  127. file->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
  128. ovl_path_realdata(dentry, &realpath);
  129. realfile = ovl_open_realfile(file, &realpath);
  130. if (IS_ERR(realfile))
  131. return PTR_ERR(realfile);
  132. file->private_data = realfile;
  133. return 0;
  134. }
  135. static int ovl_release(struct inode *inode, struct file *file)
  136. {
  137. fput(file->private_data);
  138. return 0;
  139. }
  140. static loff_t ovl_llseek(struct file *file, loff_t offset, int whence)
  141. {
  142. struct inode *inode = file_inode(file);
  143. struct fd real;
  144. const struct cred *old_cred;
  145. loff_t ret;
  146. /*
  147. * The two special cases below do not need to involve real fs,
  148. * so we can optimizing concurrent callers.
  149. */
  150. if (offset == 0) {
  151. if (whence == SEEK_CUR)
  152. return file->f_pos;
  153. if (whence == SEEK_SET)
  154. return vfs_setpos(file, 0, 0);
  155. }
  156. ret = ovl_real_fdget(file, &real);
  157. if (ret)
  158. return ret;
  159. /*
  160. * Overlay file f_pos is the master copy that is preserved
  161. * through copy up and modified on read/write, but only real
  162. * fs knows how to SEEK_HOLE/SEEK_DATA and real fs may impose
  163. * limitations that are more strict than ->s_maxbytes for specific
  164. * files, so we use the real file to perform seeks.
  165. */
  166. ovl_inode_lock(inode);
  167. real.file->f_pos = file->f_pos;
  168. old_cred = ovl_override_creds(inode->i_sb);
  169. ret = vfs_llseek(real.file, offset, whence);
  170. ovl_revert_creds(inode->i_sb, old_cred);
  171. file->f_pos = real.file->f_pos;
  172. ovl_inode_unlock(inode);
  173. fdput(real);
  174. return ret;
  175. }
  176. static void ovl_file_accessed(struct file *file)
  177. {
  178. struct inode *inode, *upperinode;
  179. if (file->f_flags & O_NOATIME)
  180. return;
  181. inode = file_inode(file);
  182. upperinode = ovl_inode_upper(inode);
  183. if (!upperinode)
  184. return;
  185. if ((!timespec64_equal(&inode->i_mtime, &upperinode->i_mtime) ||
  186. !timespec64_equal(&inode->i_ctime, &upperinode->i_ctime))) {
  187. inode->i_mtime = upperinode->i_mtime;
  188. inode->i_ctime = upperinode->i_ctime;
  189. }
  190. touch_atime(&file->f_path);
  191. }
  192. static inline void ovl_aio_put(struct ovl_aio_req *aio_req)
  193. {
  194. if (refcount_dec_and_test(&aio_req->ref)) {
  195. fput(aio_req->iocb.ki_filp);
  196. kmem_cache_free(ovl_aio_request_cachep, aio_req);
  197. }
  198. }
  199. static void ovl_aio_cleanup_handler(struct ovl_aio_req *aio_req)
  200. {
  201. struct kiocb *iocb = &aio_req->iocb;
  202. struct kiocb *orig_iocb = aio_req->orig_iocb;
  203. if (iocb->ki_flags & IOCB_WRITE) {
  204. struct inode *inode = file_inode(orig_iocb->ki_filp);
  205. /* Actually acquired in ovl_write_iter() */
  206. __sb_writers_acquired(file_inode(iocb->ki_filp)->i_sb,
  207. SB_FREEZE_WRITE);
  208. file_end_write(iocb->ki_filp);
  209. ovl_copyattr(inode);
  210. }
  211. orig_iocb->ki_pos = iocb->ki_pos;
  212. ovl_aio_put(aio_req);
  213. }
  214. static void ovl_aio_rw_complete(struct kiocb *iocb, long res)
  215. {
  216. struct ovl_aio_req *aio_req = container_of(iocb,
  217. struct ovl_aio_req, iocb);
  218. struct kiocb *orig_iocb = aio_req->orig_iocb;
  219. ovl_aio_cleanup_handler(aio_req);
  220. orig_iocb->ki_complete(orig_iocb, res);
  221. }
  222. static ssize_t ovl_read_iter(struct kiocb *iocb, struct iov_iter *iter)
  223. {
  224. struct file *file = iocb->ki_filp;
  225. struct fd real;
  226. const struct cred *old_cred;
  227. ssize_t ret;
  228. if (!iov_iter_count(iter))
  229. return 0;
  230. ret = ovl_real_fdget(file, &real);
  231. if (ret)
  232. return ret;
  233. ret = -EINVAL;
  234. if (iocb->ki_flags & IOCB_DIRECT &&
  235. !(real.file->f_mode & FMODE_CAN_ODIRECT))
  236. goto out_fdput;
  237. old_cred = ovl_override_creds(file_inode(file)->i_sb);
  238. if (is_sync_kiocb(iocb)) {
  239. ret = vfs_iter_read(real.file, iter, &iocb->ki_pos,
  240. iocb_to_rw_flags(iocb->ki_flags,
  241. OVL_IOCB_MASK));
  242. } else {
  243. struct ovl_aio_req *aio_req;
  244. ret = -ENOMEM;
  245. aio_req = kmem_cache_zalloc(ovl_aio_request_cachep, GFP_KERNEL);
  246. if (!aio_req)
  247. goto out;
  248. real.flags = 0;
  249. aio_req->orig_iocb = iocb;
  250. kiocb_clone(&aio_req->iocb, iocb, get_file(real.file));
  251. aio_req->iocb.ki_complete = ovl_aio_rw_complete;
  252. refcount_set(&aio_req->ref, 2);
  253. ret = vfs_iocb_iter_read(real.file, &aio_req->iocb, iter);
  254. ovl_aio_put(aio_req);
  255. if (ret != -EIOCBQUEUED)
  256. ovl_aio_cleanup_handler(aio_req);
  257. }
  258. out:
  259. ovl_revert_creds(file_inode(file)->i_sb, old_cred);
  260. ovl_file_accessed(file);
  261. out_fdput:
  262. fdput(real);
  263. return ret;
  264. }
  265. static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter)
  266. {
  267. struct file *file = iocb->ki_filp;
  268. struct inode *inode = file_inode(file);
  269. struct fd real;
  270. const struct cred *old_cred;
  271. ssize_t ret;
  272. int ifl = iocb->ki_flags;
  273. if (!iov_iter_count(iter))
  274. return 0;
  275. inode_lock(inode);
  276. /* Update mode */
  277. ovl_copyattr(inode);
  278. ret = file_remove_privs(file);
  279. if (ret)
  280. goto out_unlock;
  281. ret = ovl_real_fdget(file, &real);
  282. if (ret)
  283. goto out_unlock;
  284. ret = -EINVAL;
  285. if (iocb->ki_flags & IOCB_DIRECT &&
  286. !(real.file->f_mode & FMODE_CAN_ODIRECT))
  287. goto out_fdput;
  288. if (!ovl_should_sync(OVL_FS(inode->i_sb)))
  289. ifl &= ~(IOCB_DSYNC | IOCB_SYNC);
  290. old_cred = ovl_override_creds(file_inode(file)->i_sb);
  291. if (is_sync_kiocb(iocb)) {
  292. file_start_write(real.file);
  293. ret = vfs_iter_write(real.file, iter, &iocb->ki_pos,
  294. iocb_to_rw_flags(ifl, OVL_IOCB_MASK));
  295. file_end_write(real.file);
  296. /* Update size */
  297. ovl_copyattr(inode);
  298. } else {
  299. struct ovl_aio_req *aio_req;
  300. ret = -ENOMEM;
  301. aio_req = kmem_cache_zalloc(ovl_aio_request_cachep, GFP_KERNEL);
  302. if (!aio_req)
  303. goto out;
  304. file_start_write(real.file);
  305. /* Pacify lockdep, same trick as done in aio_write() */
  306. __sb_writers_release(file_inode(real.file)->i_sb,
  307. SB_FREEZE_WRITE);
  308. real.flags = 0;
  309. aio_req->orig_iocb = iocb;
  310. kiocb_clone(&aio_req->iocb, iocb, get_file(real.file));
  311. aio_req->iocb.ki_flags = ifl;
  312. aio_req->iocb.ki_complete = ovl_aio_rw_complete;
  313. refcount_set(&aio_req->ref, 2);
  314. ret = vfs_iocb_iter_write(real.file, &aio_req->iocb, iter);
  315. ovl_aio_put(aio_req);
  316. if (ret != -EIOCBQUEUED)
  317. ovl_aio_cleanup_handler(aio_req);
  318. }
  319. out:
  320. ovl_revert_creds(file_inode(file)->i_sb, old_cred);
  321. out_fdput:
  322. fdput(real);
  323. out_unlock:
  324. inode_unlock(inode);
  325. return ret;
  326. }
  327. /*
  328. * Calling iter_file_splice_write() directly from overlay's f_op may deadlock
  329. * due to lock order inversion between pipe->mutex in iter_file_splice_write()
  330. * and file_start_write(real.file) in ovl_write_iter().
  331. *
  332. * So do everything ovl_write_iter() does and call iter_file_splice_write() on
  333. * the real file.
  334. */
  335. static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out,
  336. loff_t *ppos, size_t len, unsigned int flags)
  337. {
  338. struct fd real;
  339. const struct cred *old_cred;
  340. struct inode *inode = file_inode(out);
  341. ssize_t ret;
  342. inode_lock(inode);
  343. /* Update mode */
  344. ovl_copyattr(inode);
  345. ret = file_remove_privs(out);
  346. if (ret)
  347. goto out_unlock;
  348. ret = ovl_real_fdget(out, &real);
  349. if (ret)
  350. goto out_unlock;
  351. old_cred = ovl_override_creds(inode->i_sb);
  352. file_start_write(real.file);
  353. ret = iter_file_splice_write(pipe, real.file, ppos, len, flags);
  354. file_end_write(real.file);
  355. /* Update size */
  356. ovl_copyattr(inode);
  357. ovl_revert_creds(inode->i_sb, old_cred);
  358. fdput(real);
  359. out_unlock:
  360. inode_unlock(inode);
  361. return ret;
  362. }
  363. static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  364. {
  365. struct fd real;
  366. const struct cred *old_cred;
  367. int ret;
  368. ret = ovl_sync_status(OVL_FS(file_inode(file)->i_sb));
  369. if (ret <= 0)
  370. return ret;
  371. ret = ovl_real_fdget_meta(file, &real, !datasync);
  372. if (ret)
  373. return ret;
  374. /* Don't sync lower file for fear of receiving EROFS error */
  375. if (file_inode(real.file) == ovl_inode_upper(file_inode(file))) {
  376. old_cred = ovl_override_creds(file_inode(file)->i_sb);
  377. ret = vfs_fsync_range(real.file, start, end, datasync);
  378. ovl_revert_creds(file_inode(file)->i_sb, old_cred);
  379. }
  380. fdput(real);
  381. return ret;
  382. }
  383. static int ovl_mmap(struct file *file, struct vm_area_struct *vma)
  384. {
  385. struct file *realfile = file->private_data;
  386. const struct cred *old_cred;
  387. int ret;
  388. if (!realfile->f_op->mmap)
  389. return -ENODEV;
  390. if (WARN_ON(file != vma->vm_file))
  391. return -EIO;
  392. vma_set_file(vma, realfile);
  393. old_cred = ovl_override_creds(file_inode(file)->i_sb);
  394. ret = call_mmap(vma->vm_file, vma);
  395. ovl_revert_creds(file_inode(file)->i_sb, old_cred);
  396. ovl_file_accessed(file);
  397. return ret;
  398. }
  399. static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
  400. {
  401. struct inode *inode = file_inode(file);
  402. struct fd real;
  403. const struct cred *old_cred;
  404. int ret;
  405. inode_lock(inode);
  406. /* Update mode */
  407. ovl_copyattr(inode);
  408. ret = file_remove_privs(file);
  409. if (ret)
  410. goto out_unlock;
  411. ret = ovl_real_fdget(file, &real);
  412. if (ret)
  413. goto out_unlock;
  414. old_cred = ovl_override_creds(file_inode(file)->i_sb);
  415. ret = vfs_fallocate(real.file, mode, offset, len);
  416. ovl_revert_creds(file_inode(file)->i_sb, old_cred);
  417. /* Update size */
  418. ovl_copyattr(inode);
  419. fdput(real);
  420. out_unlock:
  421. inode_unlock(inode);
  422. return ret;
  423. }
  424. static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice)
  425. {
  426. struct fd real;
  427. const struct cred *old_cred;
  428. int ret;
  429. ret = ovl_real_fdget(file, &real);
  430. if (ret)
  431. return ret;
  432. old_cred = ovl_override_creds(file_inode(file)->i_sb);
  433. ret = vfs_fadvise(real.file, offset, len, advice);
  434. ovl_revert_creds(file_inode(file)->i_sb, old_cred);
  435. fdput(real);
  436. return ret;
  437. }
  438. enum ovl_copyop {
  439. OVL_COPY,
  440. OVL_CLONE,
  441. OVL_DEDUPE,
  442. };
  443. static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in,
  444. struct file *file_out, loff_t pos_out,
  445. loff_t len, unsigned int flags, enum ovl_copyop op)
  446. {
  447. struct inode *inode_out = file_inode(file_out);
  448. struct fd real_in, real_out;
  449. const struct cred *old_cred;
  450. loff_t ret;
  451. inode_lock(inode_out);
  452. if (op != OVL_DEDUPE) {
  453. /* Update mode */
  454. ovl_copyattr(inode_out);
  455. ret = file_remove_privs(file_out);
  456. if (ret)
  457. goto out_unlock;
  458. }
  459. ret = ovl_real_fdget(file_out, &real_out);
  460. if (ret)
  461. goto out_unlock;
  462. ret = ovl_real_fdget(file_in, &real_in);
  463. if (ret) {
  464. fdput(real_out);
  465. goto out_unlock;
  466. }
  467. old_cred = ovl_override_creds(file_inode(file_out)->i_sb);
  468. switch (op) {
  469. case OVL_COPY:
  470. ret = vfs_copy_file_range(real_in.file, pos_in,
  471. real_out.file, pos_out, len, flags);
  472. break;
  473. case OVL_CLONE:
  474. ret = vfs_clone_file_range(real_in.file, pos_in,
  475. real_out.file, pos_out, len, flags);
  476. break;
  477. case OVL_DEDUPE:
  478. ret = vfs_dedupe_file_range_one(real_in.file, pos_in,
  479. real_out.file, pos_out, len,
  480. flags);
  481. break;
  482. }
  483. ovl_revert_creds(file_inode(file_out)->i_sb, old_cred);
  484. /* Update size */
  485. ovl_copyattr(inode_out);
  486. fdput(real_in);
  487. fdput(real_out);
  488. out_unlock:
  489. inode_unlock(inode_out);
  490. return ret;
  491. }
  492. static ssize_t ovl_copy_file_range(struct file *file_in, loff_t pos_in,
  493. struct file *file_out, loff_t pos_out,
  494. size_t len, unsigned int flags)
  495. {
  496. return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, flags,
  497. OVL_COPY);
  498. }
  499. static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in,
  500. struct file *file_out, loff_t pos_out,
  501. loff_t len, unsigned int remap_flags)
  502. {
  503. enum ovl_copyop op;
  504. if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
  505. return -EINVAL;
  506. if (remap_flags & REMAP_FILE_DEDUP)
  507. op = OVL_DEDUPE;
  508. else
  509. op = OVL_CLONE;
  510. /*
  511. * Don't copy up because of a dedupe request, this wouldn't make sense
  512. * most of the time (data would be duplicated instead of deduplicated).
  513. */
  514. if (op == OVL_DEDUPE &&
  515. (!ovl_inode_upper(file_inode(file_in)) ||
  516. !ovl_inode_upper(file_inode(file_out))))
  517. return -EPERM;
  518. return ovl_copyfile(file_in, pos_in, file_out, pos_out, len,
  519. remap_flags, op);
  520. }
  521. static int ovl_flush(struct file *file, fl_owner_t id)
  522. {
  523. struct fd real;
  524. const struct cred *old_cred;
  525. int err;
  526. err = ovl_real_fdget(file, &real);
  527. if (err)
  528. return err;
  529. if (real.file->f_op->flush) {
  530. old_cred = ovl_override_creds(file_inode(file)->i_sb);
  531. err = real.file->f_op->flush(real.file, id);
  532. ovl_revert_creds(file_inode(file)->i_sb, old_cred);
  533. }
  534. fdput(real);
  535. return err;
  536. }
  537. const struct file_operations ovl_file_operations = {
  538. .open = ovl_open,
  539. .release = ovl_release,
  540. .llseek = ovl_llseek,
  541. .read_iter = ovl_read_iter,
  542. .write_iter = ovl_write_iter,
  543. .fsync = ovl_fsync,
  544. .mmap = ovl_mmap,
  545. .fallocate = ovl_fallocate,
  546. .fadvise = ovl_fadvise,
  547. .flush = ovl_flush,
  548. .splice_read = generic_file_splice_read,
  549. .splice_write = ovl_splice_write,
  550. .copy_file_range = ovl_copy_file_range,
  551. .remap_file_range = ovl_remap_file_range,
  552. };
  553. int __init ovl_aio_request_cache_init(void)
  554. {
  555. ovl_aio_request_cachep = kmem_cache_create("ovl_aio_req",
  556. sizeof(struct ovl_aio_req),
  557. 0, SLAB_HWCACHE_ALIGN, NULL);
  558. if (!ovl_aio_request_cachep)
  559. return -ENOMEM;
  560. return 0;
  561. }
  562. void ovl_aio_request_cache_destroy(void)
  563. {
  564. kmem_cache_destroy(ovl_aio_request_cachep);
  565. }