fscache.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /* General filesystem caching interface
  2. *
  3. * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. *
  11. * NOTE!!! See:
  12. *
  13. * Documentation/filesystems/caching/netfs-api.txt
  14. *
  15. * for a description of the network filesystem interface declared here.
  16. */
  17. #ifndef _LINUX_FSCACHE_H
  18. #define _LINUX_FSCACHE_H
  19. #include <linux/fs.h>
  20. #include <linux/list.h>
  21. #include <linux/pagemap.h>
  22. #include <linux/pagevec.h>
  23. #if defined(CONFIG_FSCACHE) || defined(CONFIG_FSCACHE_MODULE)
  24. #define fscache_available() (1)
  25. #define fscache_cookie_valid(cookie) (cookie)
  26. #else
  27. #define fscache_available() (0)
  28. #define fscache_cookie_valid(cookie) (0)
  29. #endif
  30. /*
  31. * overload PG_private_2 to give us PG_fscache - this is used to indicate that
  32. * a page is currently backed by a local disk cache
  33. */
  34. #define PageFsCache(page) PagePrivate2((page))
  35. #define SetPageFsCache(page) SetPagePrivate2((page))
  36. #define ClearPageFsCache(page) ClearPagePrivate2((page))
  37. #define TestSetPageFsCache(page) TestSetPagePrivate2((page))
  38. #define TestClearPageFsCache(page) TestClearPagePrivate2((page))
  39. /* pattern used to fill dead space in an index entry */
  40. #define FSCACHE_INDEX_DEADFILL_PATTERN 0x79
  41. struct pagevec;
  42. struct fscache_cache_tag;
  43. struct fscache_cookie;
  44. struct fscache_netfs;
  45. typedef void (*fscache_rw_complete_t)(struct page *page,
  46. void *context,
  47. int error);
  48. /* result of index entry consultation */
  49. enum fscache_checkaux {
  50. FSCACHE_CHECKAUX_OKAY, /* entry okay as is */
  51. FSCACHE_CHECKAUX_NEEDS_UPDATE, /* entry requires update */
  52. FSCACHE_CHECKAUX_OBSOLETE, /* entry requires deletion */
  53. };
  54. /*
  55. * fscache cookie definition
  56. */
  57. struct fscache_cookie_def {
  58. /* name of cookie type */
  59. char name[16];
  60. /* cookie type */
  61. uint8_t type;
  62. #define FSCACHE_COOKIE_TYPE_INDEX 0
  63. #define FSCACHE_COOKIE_TYPE_DATAFILE 1
  64. /* select the cache into which to insert an entry in this index
  65. * - optional
  66. * - should return a cache identifier or NULL to cause the cache to be
  67. * inherited from the parent if possible or the first cache picked
  68. * for a non-index file if not
  69. */
  70. struct fscache_cache_tag *(*select_cache)(
  71. const void *parent_netfs_data,
  72. const void *cookie_netfs_data);
  73. /* get an index key
  74. * - should store the key data in the buffer
  75. * - should return the amount of data stored
  76. * - not permitted to return an error
  77. * - the netfs data from the cookie being used as the source is
  78. * presented
  79. */
  80. uint16_t (*get_key)(const void *cookie_netfs_data,
  81. void *buffer,
  82. uint16_t bufmax);
  83. /* get certain file attributes from the netfs data
  84. * - this function can be absent for an index
  85. * - not permitted to return an error
  86. * - the netfs data from the cookie being used as the source is
  87. * presented
  88. */
  89. void (*get_attr)(const void *cookie_netfs_data, uint64_t *size);
  90. /* get the auxiliary data from netfs data
  91. * - this function can be absent if the index carries no state data
  92. * - should store the auxiliary data in the buffer
  93. * - should return the amount of amount stored
  94. * - not permitted to return an error
  95. * - the netfs data from the cookie being used as the source is
  96. * presented
  97. */
  98. uint16_t (*get_aux)(const void *cookie_netfs_data,
  99. void *buffer,
  100. uint16_t bufmax);
  101. /* consult the netfs about the state of an object
  102. * - this function can be absent if the index carries no state data
  103. * - the netfs data from the cookie being used as the target is
  104. * presented, as is the auxiliary data
  105. */
  106. enum fscache_checkaux (*check_aux)(void *cookie_netfs_data,
  107. const void *data,
  108. uint16_t datalen);
  109. /* get an extra reference on a read context
  110. * - this function can be absent if the completion function doesn't
  111. * require a context
  112. */
  113. void (*get_context)(void *cookie_netfs_data, void *context);
  114. /* release an extra reference on a read context
  115. * - this function can be absent if the completion function doesn't
  116. * require a context
  117. */
  118. void (*put_context)(void *cookie_netfs_data, void *context);
  119. /* indicate pages that now have cache metadata retained
  120. * - this function should mark the specified pages as now being cached
  121. * - the pages will have been marked with PG_fscache before this is
  122. * called, so this is optional
  123. */
  124. void (*mark_pages_cached)(void *cookie_netfs_data,
  125. struct address_space *mapping,
  126. struct pagevec *cached_pvec);
  127. /* indicate the cookie is no longer cached
  128. * - this function is called when the backing store currently caching
  129. * a cookie is removed
  130. * - the netfs should use this to clean up any markers indicating
  131. * cached pages
  132. * - this is mandatory for any object that may have data
  133. */
  134. void (*now_uncached)(void *cookie_netfs_data);
  135. };
  136. /*
  137. * fscache cached network filesystem type
  138. * - name, version and ops must be filled in before registration
  139. * - all other fields will be set during registration
  140. */
  141. struct fscache_netfs {
  142. uint32_t version; /* indexing version */
  143. const char *name; /* filesystem name */
  144. struct fscache_cookie *primary_index;
  145. struct list_head link; /* internal link */
  146. };
  147. /*
  148. * slow-path functions for when there is actually caching available, and the
  149. * netfs does actually have a valid token
  150. * - these are not to be called directly
  151. * - these are undefined symbols when FS-Cache is not configured and the
  152. * optimiser takes care of not using them
  153. */
  154. extern int __fscache_register_netfs(struct fscache_netfs *);
  155. extern void __fscache_unregister_netfs(struct fscache_netfs *);
  156. extern struct fscache_cache_tag *__fscache_lookup_cache_tag(const char *);
  157. extern void __fscache_release_cache_tag(struct fscache_cache_tag *);
  158. extern struct fscache_cookie *__fscache_acquire_cookie(
  159. struct fscache_cookie *,
  160. const struct fscache_cookie_def *,
  161. void *);
  162. extern void __fscache_relinquish_cookie(struct fscache_cookie *, int);
  163. extern void __fscache_update_cookie(struct fscache_cookie *);
  164. extern int __fscache_attr_changed(struct fscache_cookie *);
  165. extern int __fscache_read_or_alloc_page(struct fscache_cookie *,
  166. struct page *,
  167. fscache_rw_complete_t,
  168. void *,
  169. gfp_t);
  170. extern int __fscache_read_or_alloc_pages(struct fscache_cookie *,
  171. struct address_space *,
  172. struct list_head *,
  173. unsigned *,
  174. fscache_rw_complete_t,
  175. void *,
  176. gfp_t);
  177. extern int __fscache_alloc_page(struct fscache_cookie *, struct page *, gfp_t);
  178. extern int __fscache_write_page(struct fscache_cookie *, struct page *, gfp_t);
  179. extern void __fscache_uncache_page(struct fscache_cookie *, struct page *);
  180. extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *);
  181. extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *);
  182. extern bool __fscache_maybe_release_page(struct fscache_cookie *, struct page *,
  183. gfp_t);
  184. extern void __fscache_uncache_all_inode_pages(struct fscache_cookie *,
  185. struct inode *);
  186. /**
  187. * fscache_register_netfs - Register a filesystem as desiring caching services
  188. * @netfs: The description of the filesystem
  189. *
  190. * Register a filesystem as desiring caching services if they're available.
  191. *
  192. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  193. * description.
  194. */
  195. static inline
  196. int fscache_register_netfs(struct fscache_netfs *netfs)
  197. {
  198. if (fscache_available())
  199. return __fscache_register_netfs(netfs);
  200. else
  201. return 0;
  202. }
  203. /**
  204. * fscache_unregister_netfs - Indicate that a filesystem no longer desires
  205. * caching services
  206. * @netfs: The description of the filesystem
  207. *
  208. * Indicate that a filesystem no longer desires caching services for the
  209. * moment.
  210. *
  211. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  212. * description.
  213. */
  214. static inline
  215. void fscache_unregister_netfs(struct fscache_netfs *netfs)
  216. {
  217. if (fscache_available())
  218. __fscache_unregister_netfs(netfs);
  219. }
  220. /**
  221. * fscache_lookup_cache_tag - Look up a cache tag
  222. * @name: The name of the tag to search for
  223. *
  224. * Acquire a specific cache referral tag that can be used to select a specific
  225. * cache in which to cache an index.
  226. *
  227. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  228. * description.
  229. */
  230. static inline
  231. struct fscache_cache_tag *fscache_lookup_cache_tag(const char *name)
  232. {
  233. if (fscache_available())
  234. return __fscache_lookup_cache_tag(name);
  235. else
  236. return NULL;
  237. }
  238. /**
  239. * fscache_release_cache_tag - Release a cache tag
  240. * @tag: The tag to release
  241. *
  242. * Release a reference to a cache referral tag previously looked up.
  243. *
  244. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  245. * description.
  246. */
  247. static inline
  248. void fscache_release_cache_tag(struct fscache_cache_tag *tag)
  249. {
  250. if (fscache_available())
  251. __fscache_release_cache_tag(tag);
  252. }
  253. /**
  254. * fscache_acquire_cookie - Acquire a cookie to represent a cache object
  255. * @parent: The cookie that's to be the parent of this one
  256. * @def: A description of the cache object, including callback operations
  257. * @netfs_data: An arbitrary piece of data to be kept in the cookie to
  258. * represent the cache object to the netfs
  259. *
  260. * This function is used to inform FS-Cache about part of an index hierarchy
  261. * that can be used to locate files. This is done by requesting a cookie for
  262. * each index in the path to the file.
  263. *
  264. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  265. * description.
  266. */
  267. static inline
  268. struct fscache_cookie *fscache_acquire_cookie(
  269. struct fscache_cookie *parent,
  270. const struct fscache_cookie_def *def,
  271. void *netfs_data)
  272. {
  273. if (fscache_cookie_valid(parent))
  274. return __fscache_acquire_cookie(parent, def, netfs_data);
  275. else
  276. return NULL;
  277. }
  278. /**
  279. * fscache_relinquish_cookie - Return the cookie to the cache, maybe discarding
  280. * it
  281. * @cookie: The cookie being returned
  282. * @retire: True if the cache object the cookie represents is to be discarded
  283. *
  284. * This function returns a cookie to the cache, forcibly discarding the
  285. * associated cache object if retire is set to true.
  286. *
  287. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  288. * description.
  289. */
  290. static inline
  291. void fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
  292. {
  293. if (fscache_cookie_valid(cookie))
  294. __fscache_relinquish_cookie(cookie, retire);
  295. }
  296. /**
  297. * fscache_update_cookie - Request that a cache object be updated
  298. * @cookie: The cookie representing the cache object
  299. *
  300. * Request an update of the index data for the cache object associated with the
  301. * cookie.
  302. *
  303. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  304. * description.
  305. */
  306. static inline
  307. void fscache_update_cookie(struct fscache_cookie *cookie)
  308. {
  309. if (fscache_cookie_valid(cookie))
  310. __fscache_update_cookie(cookie);
  311. }
  312. /**
  313. * fscache_pin_cookie - Pin a data-storage cache object in its cache
  314. * @cookie: The cookie representing the cache object
  315. *
  316. * Permit data-storage cache objects to be pinned in the cache.
  317. *
  318. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  319. * description.
  320. */
  321. static inline
  322. int fscache_pin_cookie(struct fscache_cookie *cookie)
  323. {
  324. return -ENOBUFS;
  325. }
  326. /**
  327. * fscache_pin_cookie - Unpin a data-storage cache object in its cache
  328. * @cookie: The cookie representing the cache object
  329. *
  330. * Permit data-storage cache objects to be unpinned from the cache.
  331. *
  332. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  333. * description.
  334. */
  335. static inline
  336. void fscache_unpin_cookie(struct fscache_cookie *cookie)
  337. {
  338. }
  339. /**
  340. * fscache_attr_changed - Notify cache that an object's attributes changed
  341. * @cookie: The cookie representing the cache object
  342. *
  343. * Send a notification to the cache indicating that an object's attributes have
  344. * changed. This includes the data size. These attributes will be obtained
  345. * through the get_attr() cookie definition op.
  346. *
  347. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  348. * description.
  349. */
  350. static inline
  351. int fscache_attr_changed(struct fscache_cookie *cookie)
  352. {
  353. if (fscache_cookie_valid(cookie))
  354. return __fscache_attr_changed(cookie);
  355. else
  356. return -ENOBUFS;
  357. }
  358. /**
  359. * fscache_reserve_space - Reserve data space for a cached object
  360. * @cookie: The cookie representing the cache object
  361. * @i_size: The amount of space to be reserved
  362. *
  363. * Reserve an amount of space in the cache for the cache object attached to a
  364. * cookie so that a write to that object within the space can always be
  365. * honoured.
  366. *
  367. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  368. * description.
  369. */
  370. static inline
  371. int fscache_reserve_space(struct fscache_cookie *cookie, loff_t size)
  372. {
  373. return -ENOBUFS;
  374. }
  375. /**
  376. * fscache_read_or_alloc_page - Read a page from the cache or allocate a block
  377. * in which to store it
  378. * @cookie: The cookie representing the cache object
  379. * @page: The netfs page to fill if possible
  380. * @end_io_func: The callback to invoke when and if the page is filled
  381. * @context: An arbitrary piece of data to pass on to end_io_func()
  382. * @gfp: The conditions under which memory allocation should be made
  383. *
  384. * Read a page from the cache, or if that's not possible make a potential
  385. * one-block reservation in the cache into which the page may be stored once
  386. * fetched from the server.
  387. *
  388. * If the page is not backed by the cache object, or if it there's some reason
  389. * it can't be, -ENOBUFS will be returned and nothing more will be done for
  390. * that page.
  391. *
  392. * Else, if that page is backed by the cache, a read will be initiated directly
  393. * to the netfs's page and 0 will be returned by this function. The
  394. * end_io_func() callback will be invoked when the operation terminates on a
  395. * completion or failure. Note that the callback may be invoked before the
  396. * return.
  397. *
  398. * Else, if the page is unbacked, -ENODATA is returned and a block may have
  399. * been allocated in the cache.
  400. *
  401. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  402. * description.
  403. */
  404. static inline
  405. int fscache_read_or_alloc_page(struct fscache_cookie *cookie,
  406. struct page *page,
  407. fscache_rw_complete_t end_io_func,
  408. void *context,
  409. gfp_t gfp)
  410. {
  411. if (fscache_cookie_valid(cookie))
  412. return __fscache_read_or_alloc_page(cookie, page, end_io_func,
  413. context, gfp);
  414. else
  415. return -ENOBUFS;
  416. }
  417. /**
  418. * fscache_read_or_alloc_pages - Read pages from the cache and/or allocate
  419. * blocks in which to store them
  420. * @cookie: The cookie representing the cache object
  421. * @mapping: The netfs inode mapping to which the pages will be attached
  422. * @pages: A list of potential netfs pages to be filled
  423. * @nr_pages: Number of pages to be read and/or allocated
  424. * @end_io_func: The callback to invoke when and if each page is filled
  425. * @context: An arbitrary piece of data to pass on to end_io_func()
  426. * @gfp: The conditions under which memory allocation should be made
  427. *
  428. * Read a set of pages from the cache, or if that's not possible, attempt to
  429. * make a potential one-block reservation for each page in the cache into which
  430. * that page may be stored once fetched from the server.
  431. *
  432. * If some pages are not backed by the cache object, or if it there's some
  433. * reason they can't be, -ENOBUFS will be returned and nothing more will be
  434. * done for that pages.
  435. *
  436. * Else, if some of the pages are backed by the cache, a read will be initiated
  437. * directly to the netfs's page and 0 will be returned by this function. The
  438. * end_io_func() callback will be invoked when the operation terminates on a
  439. * completion or failure. Note that the callback may be invoked before the
  440. * return.
  441. *
  442. * Else, if a page is unbacked, -ENODATA is returned and a block may have
  443. * been allocated in the cache.
  444. *
  445. * Because the function may want to return all of -ENOBUFS, -ENODATA and 0 in
  446. * regard to different pages, the return values are prioritised in that order.
  447. * Any pages submitted for reading are removed from the pages list.
  448. *
  449. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  450. * description.
  451. */
  452. static inline
  453. int fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
  454. struct address_space *mapping,
  455. struct list_head *pages,
  456. unsigned *nr_pages,
  457. fscache_rw_complete_t end_io_func,
  458. void *context,
  459. gfp_t gfp)
  460. {
  461. if (fscache_cookie_valid(cookie))
  462. return __fscache_read_or_alloc_pages(cookie, mapping, pages,
  463. nr_pages, end_io_func,
  464. context, gfp);
  465. else
  466. return -ENOBUFS;
  467. }
  468. /**
  469. * fscache_alloc_page - Allocate a block in which to store a page
  470. * @cookie: The cookie representing the cache object
  471. * @page: The netfs page to allocate a page for
  472. * @gfp: The conditions under which memory allocation should be made
  473. *
  474. * Request Allocation a block in the cache in which to store a netfs page
  475. * without retrieving any contents from the cache.
  476. *
  477. * If the page is not backed by a file then -ENOBUFS will be returned and
  478. * nothing more will be done, and no reservation will be made.
  479. *
  480. * Else, a block will be allocated if one wasn't already, and 0 will be
  481. * returned
  482. *
  483. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  484. * description.
  485. */
  486. static inline
  487. int fscache_alloc_page(struct fscache_cookie *cookie,
  488. struct page *page,
  489. gfp_t gfp)
  490. {
  491. if (fscache_cookie_valid(cookie))
  492. return __fscache_alloc_page(cookie, page, gfp);
  493. else
  494. return -ENOBUFS;
  495. }
  496. /**
  497. * fscache_write_page - Request storage of a page in the cache
  498. * @cookie: The cookie representing the cache object
  499. * @page: The netfs page to store
  500. * @gfp: The conditions under which memory allocation should be made
  501. *
  502. * Request the contents of the netfs page be written into the cache. This
  503. * request may be ignored if no cache block is currently allocated, in which
  504. * case it will return -ENOBUFS.
  505. *
  506. * If a cache block was already allocated, a write will be initiated and 0 will
  507. * be returned. The PG_fscache_write page bit is set immediately and will then
  508. * be cleared at the completion of the write to indicate the success or failure
  509. * of the operation. Note that the completion may happen before the return.
  510. *
  511. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  512. * description.
  513. */
  514. static inline
  515. int fscache_write_page(struct fscache_cookie *cookie,
  516. struct page *page,
  517. gfp_t gfp)
  518. {
  519. if (fscache_cookie_valid(cookie))
  520. return __fscache_write_page(cookie, page, gfp);
  521. else
  522. return -ENOBUFS;
  523. }
  524. /**
  525. * fscache_uncache_page - Indicate that caching is no longer required on a page
  526. * @cookie: The cookie representing the cache object
  527. * @page: The netfs page that was being cached.
  528. *
  529. * Tell the cache that we no longer want a page to be cached and that it should
  530. * remove any knowledge of the netfs page it may have.
  531. *
  532. * Note that this cannot cancel any outstanding I/O operations between this
  533. * page and the cache.
  534. *
  535. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  536. * description.
  537. */
  538. static inline
  539. void fscache_uncache_page(struct fscache_cookie *cookie,
  540. struct page *page)
  541. {
  542. if (fscache_cookie_valid(cookie))
  543. __fscache_uncache_page(cookie, page);
  544. }
  545. /**
  546. * fscache_check_page_write - Ask if a page is being writing to the cache
  547. * @cookie: The cookie representing the cache object
  548. * @page: The netfs page that is being cached.
  549. *
  550. * Ask the cache if a page is being written to the cache.
  551. *
  552. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  553. * description.
  554. */
  555. static inline
  556. bool fscache_check_page_write(struct fscache_cookie *cookie,
  557. struct page *page)
  558. {
  559. if (fscache_cookie_valid(cookie))
  560. return __fscache_check_page_write(cookie, page);
  561. return false;
  562. }
  563. /**
  564. * fscache_wait_on_page_write - Wait for a page to complete writing to the cache
  565. * @cookie: The cookie representing the cache object
  566. * @page: The netfs page that is being cached.
  567. *
  568. * Ask the cache to wake us up when a page is no longer being written to the
  569. * cache.
  570. *
  571. * See Documentation/filesystems/caching/netfs-api.txt for a complete
  572. * description.
  573. */
  574. static inline
  575. void fscache_wait_on_page_write(struct fscache_cookie *cookie,
  576. struct page *page)
  577. {
  578. if (fscache_cookie_valid(cookie))
  579. __fscache_wait_on_page_write(cookie, page);
  580. }
  581. /**
  582. * fscache_maybe_release_page - Consider releasing a page, cancelling a store
  583. * @cookie: The cookie representing the cache object
  584. * @page: The netfs page that is being cached.
  585. * @gfp: The gfp flags passed to releasepage()
  586. *
  587. * Consider releasing a page for the vmscan algorithm, on behalf of the netfs's
  588. * releasepage() call. A storage request on the page may cancelled if it is
  589. * not currently being processed.
  590. *
  591. * The function returns true if the page no longer has a storage request on it,
  592. * and false if a storage request is left in place. If true is returned, the
  593. * page will have been passed to fscache_uncache_page(). If false is returned
  594. * the page cannot be freed yet.
  595. */
  596. static inline
  597. bool fscache_maybe_release_page(struct fscache_cookie *cookie,
  598. struct page *page,
  599. gfp_t gfp)
  600. {
  601. if (fscache_cookie_valid(cookie) && PageFsCache(page))
  602. return __fscache_maybe_release_page(cookie, page, gfp);
  603. return false;
  604. }
  605. /**
  606. * fscache_uncache_all_inode_pages - Uncache all an inode's pages
  607. * @cookie: The cookie representing the inode's cache object.
  608. * @inode: The inode to uncache pages from.
  609. *
  610. * Uncache all the pages in an inode that are marked PG_fscache, assuming them
  611. * to be associated with the given cookie.
  612. *
  613. * This function may sleep. It will wait for pages that are being written out
  614. * and will wait whilst the PG_fscache mark is removed by the cache.
  615. */
  616. static inline
  617. void fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
  618. struct inode *inode)
  619. {
  620. if (fscache_cookie_valid(cookie))
  621. __fscache_uncache_all_inode_pages(cookie, inode);
  622. }
  623. #endif /* _LINUX_FSCACHE_H */