Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: filesystems: caching/backend-api.txt: convert it to ReST

- Add a SPDX header;
- Adjust document and section titles;
- Some whitespace fixes and new line breaks;
- Mark literal blocks as such;
- Add table markups;
- Add it to filesystems/caching/index.rst.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/5d0a61abaa87bfe913b9e2f321e74ef7af0f3dfc.1588021877.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
0e822145 d74802ad

+92 -90
+83 -82
Documentation/filesystems/caching/backend-api.txt Documentation/filesystems/caching/backend-api.rst
··· 1 - ========================== 2 - FS-CACHE CACHE BACKEND API 3 - ========================== 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + ========================== 4 + FS-Cache Cache backend API 5 + ========================== 4 6 5 7 The FS-Cache system provides an API by which actual caches can be supplied to 6 8 FS-Cache for it to then serve out to network filesystems and other interested ··· 11 9 This API is declared in <linux/fscache-cache.h>. 12 10 13 11 14 - ==================================== 15 - INITIALISING AND REGISTERING A CACHE 12 + Initialising and Registering a Cache 16 13 ==================================== 17 14 18 15 To start off, a cache definition must be initialised and registered for each 19 16 cache the backend wants to make available. For instance, CacheFS does this in 20 17 the fill_super() operation on mounting. 21 18 22 - The cache definition (struct fscache_cache) should be initialised by calling: 19 + The cache definition (struct fscache_cache) should be initialised by calling:: 23 20 24 21 void fscache_init_cache(struct fscache_cache *cache, 25 22 struct fscache_cache_ops *ops, ··· 27 26 28 27 Where: 29 28 30 - (*) "cache" is a pointer to the cache definition; 29 + * "cache" is a pointer to the cache definition; 31 30 32 - (*) "ops" is a pointer to the table of operations that the backend supports on 31 + * "ops" is a pointer to the table of operations that the backend supports on 33 32 this cache; and 34 33 35 - (*) "idfmt" is a format and printf-style arguments for constructing a label 34 + * "idfmt" is a format and printf-style arguments for constructing a label 36 35 for the cache. 37 36 38 37 39 38 The cache should then be registered with FS-Cache by passing a pointer to the 40 - previously initialised cache definition to: 39 + previously initialised cache definition to:: 41 40 42 41 int fscache_add_cache(struct fscache_cache *cache, 43 42 struct fscache_object *fsdef, ··· 45 44 46 45 Two extra arguments should also be supplied: 47 46 48 - (*) "fsdef" which should point to the object representation for the FS-Cache 47 + * "fsdef" which should point to the object representation for the FS-Cache 49 48 master index in this cache. Netfs primary index entries will be created 50 49 here. FS-Cache keeps the caller's reference to the index object if 51 50 successful and will release it upon withdrawal of the cache. 52 51 53 - (*) "tagname" which, if given, should be a text string naming this cache. If 52 + * "tagname" which, if given, should be a text string naming this cache. If 54 53 this is NULL, the identifier will be used instead. For CacheFS, the 55 54 identifier is set to name the underlying block device and the tag can be 56 55 supplied by mount. ··· 59 58 is already in use. 0 will be returned on success. 60 59 61 60 62 - ===================== 63 - UNREGISTERING A CACHE 61 + Unregistering a Cache 64 62 ===================== 65 63 66 64 A cache can be withdrawn from the system by calling this function with a 67 - pointer to the cache definition: 65 + pointer to the cache definition:: 68 66 69 67 void fscache_withdraw_cache(struct fscache_cache *cache); 70 68 71 69 In CacheFS's case, this is called by put_super(). 72 70 73 71 74 - ======== 75 - SECURITY 72 + Security 76 73 ======== 77 74 78 75 The cache methods are executed one of two contexts: ··· 88 89 This is left to the cache to handle; FS-Cache makes no effort in this regard. 89 90 90 91 91 - =================================== 92 - CONTROL AND STATISTICS PRESENTATION 92 + Control and Statistics Presentation 93 93 =================================== 94 94 95 95 The cache may present data to the outside world through FS-Cache's interfaces ··· 99 101 and is for use by the cache as it sees fit. 100 102 101 103 102 - ======================== 103 - RELEVANT DATA STRUCTURES 104 + Relevant Data Structures 104 105 ======================== 105 106 106 - (*) Index/Data file FS-Cache representation cookie: 107 + * Index/Data file FS-Cache representation cookie:: 107 108 108 109 struct fscache_cookie { 109 110 struct fscache_object_def *def; ··· 118 121 cache operations. 119 122 120 123 121 - (*) In-cache object representation: 124 + * In-cache object representation:: 122 125 123 126 struct fscache_object { 124 127 int debug_id; ··· 147 150 initialised by calling fscache_object_init(object). 148 151 149 152 150 - (*) FS-Cache operation record: 153 + * FS-Cache operation record:: 151 154 152 155 struct fscache_operation { 153 156 atomic_t usage; ··· 170 173 an operation needs more processing time, it should be enqueued again. 171 174 172 175 173 - (*) FS-Cache retrieval operation record: 176 + * FS-Cache retrieval operation record:: 174 177 175 178 struct fscache_retrieval { 176 179 struct fscache_operation op; ··· 195 198 it sees fit. 196 199 197 200 198 - (*) FS-Cache storage operation record: 201 + * FS-Cache storage operation record:: 199 202 200 203 struct fscache_storage { 201 204 struct fscache_operation op; ··· 209 212 storage. 210 213 211 214 212 - ================ 213 - CACHE OPERATIONS 215 + Cache Operations 214 216 ================ 215 217 216 218 The cache backend provides FS-Cache with a table of operations that can be 217 219 performed on the denizens of the cache. These are held in a structure of type: 218 220 219 - struct fscache_cache_ops 221 + :: 220 222 221 - (*) Name of cache provider [mandatory]: 223 + struct fscache_cache_ops 224 + 225 + * Name of cache provider [mandatory]:: 222 226 223 227 const char *name 224 228 ··· 227 229 the backend. 228 230 229 231 230 - (*) Allocate a new object [mandatory]: 232 + * Allocate a new object [mandatory]:: 231 233 232 234 struct fscache_object *(*alloc_object)(struct fscache_cache *cache, 233 235 struct fscache_cookie *cookie) ··· 242 244 form once lookup is complete or aborted. 243 245 244 246 245 - (*) Look up and create object [mandatory]: 247 + * Look up and create object [mandatory]:: 246 248 247 249 void (*lookup_object)(struct fscache_object *object) 248 250 ··· 261 263 to abort the lookup of that object. 262 264 263 265 264 - (*) Release lookup data [mandatory]: 266 + * Release lookup data [mandatory]:: 265 267 266 268 void (*lookup_complete)(struct fscache_object *object) 267 269 ··· 269 271 using to perform a lookup. 270 272 271 273 272 - (*) Increment object refcount [mandatory]: 274 + * Increment object refcount [mandatory]:: 273 275 274 276 struct fscache_object *(*grab_object)(struct fscache_object *object) 275 277 ··· 278 280 It should return the object pointer if successful. 279 281 280 282 281 - (*) Lock/Unlock object [mandatory]: 283 + * Lock/Unlock object [mandatory]:: 282 284 283 285 void (*lock_object)(struct fscache_object *object) 284 286 void (*unlock_object)(struct fscache_object *object) ··· 287 289 to schedule with the lock held, so a spinlock isn't sufficient. 288 290 289 291 290 - (*) Pin/Unpin object [optional]: 292 + * Pin/Unpin object [optional]:: 291 293 292 294 int (*pin_object)(struct fscache_object *object) 293 295 void (*unpin_object)(struct fscache_object *object) ··· 297 299 enough space in the cache to permit this. 298 300 299 301 300 - (*) Check coherency state of an object [mandatory]: 302 + * Check coherency state of an object [mandatory]:: 301 303 302 304 int (*check_consistency)(struct fscache_object *object) 303 305 ··· 306 308 if they're consistent and -ESTALE otherwise. -ENOMEM and -ERESTARTSYS 307 309 may also be returned. 308 310 309 - (*) Update object [mandatory]: 311 + * Update object [mandatory]:: 310 312 311 313 int (*update_object)(struct fscache_object *object) 312 314 ··· 315 317 obtained by calling object->cookie->def->get_aux()/get_attr(). 316 318 317 319 318 - (*) Invalidate data object [mandatory]: 320 + * Invalidate data object [mandatory]:: 319 321 320 322 int (*invalidate_object)(struct fscache_operation *op) 321 323 ··· 327 329 fscache_op_complete() must be called on op before returning. 328 330 329 331 330 - (*) Discard object [mandatory]: 332 + * Discard object [mandatory]:: 331 333 332 334 void (*drop_object)(struct fscache_object *object) 333 335 ··· 339 341 caller. The caller will invoke the put_object() method as appropriate. 340 342 341 343 342 - (*) Release object reference [mandatory]: 344 + * Release object reference [mandatory]:: 343 345 344 346 void (*put_object)(struct fscache_object *object) 345 347 ··· 347 349 be freed when all the references to it are released. 348 350 349 351 350 - (*) Synchronise a cache [mandatory]: 352 + * Synchronise a cache [mandatory]:: 351 353 352 354 void (*sync)(struct fscache_cache *cache) 353 355 ··· 355 357 device. 356 358 357 359 358 - (*) Dissociate a cache [mandatory]: 360 + * Dissociate a cache [mandatory]:: 359 361 360 362 void (*dissociate_pages)(struct fscache_cache *cache) 361 363 ··· 363 365 cache withdrawal. 364 366 365 367 366 - (*) Notification that the attributes on a netfs file changed [mandatory]: 368 + * Notification that the attributes on a netfs file changed [mandatory]:: 367 369 368 370 int (*attr_changed)(struct fscache_object *object); 369 371 ··· 384 386 execution of this operation. 385 387 386 388 387 - (*) Reserve cache space for an object's data [optional]: 389 + * Reserve cache space for an object's data [optional]:: 388 390 389 391 int (*reserve_space)(struct fscache_object *object, loff_t size); 390 392 ··· 402 404 size if larger than that already. 403 405 404 406 405 - (*) Request page be read from cache [mandatory]: 407 + * Request page be read from cache [mandatory]:: 406 408 407 409 int (*read_or_alloc_page)(struct fscache_retrieval *op, 408 410 struct page *page, ··· 444 446 with. This will complete the operation when all pages are dealt with. 445 447 446 448 447 - (*) Request pages be read from cache [mandatory]: 449 + * Request pages be read from cache [mandatory]:: 448 450 449 451 int (*read_or_alloc_pages)(struct fscache_retrieval *op, 450 452 struct list_head *pages, ··· 455 457 of pages instead of one page. Any pages on which a read operation is 456 458 started must be added to the page cache for the specified mapping and also 457 459 to the LRU. Such pages must also be removed from the pages list and 458 - *nr_pages decremented per page. 460 + ``*nr_pages`` decremented per page. 459 461 460 462 If there was an error such as -ENOMEM, then that should be returned; else 461 463 if one or more pages couldn't be read or allocated, then -ENOBUFS should ··· 464 466 returned. 465 467 466 468 467 - (*) Request page be allocated in the cache [mandatory]: 469 + * Request page be allocated in the cache [mandatory]:: 468 470 469 471 int (*allocate_page)(struct fscache_retrieval *op, 470 472 struct page *page, ··· 480 482 allocated, then the netfs page should be marked and 0 returned. 481 483 482 484 483 - (*) Request pages be allocated in the cache [mandatory]: 485 + * Request pages be allocated in the cache [mandatory]:: 484 486 485 487 int (*allocate_pages)(struct fscache_retrieval *op, 486 488 struct list_head *pages, ··· 491 493 nr_pages should be treated as for the read_or_alloc_pages() method. 492 494 493 495 494 - (*) Request page be written to cache [mandatory]: 496 + * Request page be written to cache [mandatory]:: 495 497 496 498 int (*write_page)(struct fscache_storage *op, 497 499 struct page *page); ··· 512 514 appropriately. 513 515 514 516 515 - (*) Discard retained per-page metadata [mandatory]: 517 + * Discard retained per-page metadata [mandatory]:: 516 518 517 519 void (*uncache_page)(struct fscache_object *object, struct page *page) 518 520 ··· 521 523 maintains for this page. 522 524 523 525 524 - ================== 525 - FS-CACHE UTILITIES 526 + FS-Cache Utilities 526 527 ================== 527 528 528 529 FS-Cache provides some utilities that a cache backend may make use of: 529 530 530 - (*) Note occurrence of an I/O error in a cache: 531 + * Note occurrence of an I/O error in a cache:: 531 532 532 533 void fscache_io_error(struct fscache_cache *cache) 533 534 ··· 538 541 This does not actually withdraw the cache. That must be done separately. 539 542 540 543 541 - (*) Invoke the retrieval I/O completion function: 544 + * Invoke the retrieval I/O completion function:: 542 545 543 546 void fscache_end_io(struct fscache_retrieval *op, struct page *page, 544 547 int error); ··· 547 550 error value should be 0 if successful and an error otherwise. 548 551 549 552 550 - (*) Record that one or more pages being retrieved or allocated have been dealt 551 - with: 553 + * Record that one or more pages being retrieved or allocated have been dealt 554 + with:: 552 555 553 556 void fscache_retrieval_complete(struct fscache_retrieval *op, 554 557 int n_pages); ··· 559 562 completed. 560 563 561 564 562 - (*) Record operation completion: 565 + * Record operation completion:: 563 566 564 567 void fscache_op_complete(struct fscache_operation *op); 565 568 ··· 568 571 one or more pending operations to start running. 569 572 570 573 571 - (*) Set highest store limit: 574 + * Set highest store limit:: 572 575 573 576 void fscache_set_store_limit(struct fscache_object *object, 574 577 loff_t i_size); ··· 578 581 rejected by fscache_read_alloc_page() and co with -ENOBUFS. 579 582 580 583 581 - (*) Mark pages as being cached: 584 + * Mark pages as being cached:: 582 585 583 586 void fscache_mark_pages_cached(struct fscache_retrieval *op, 584 587 struct pagevec *pagevec); ··· 587 590 the netfs must call fscache_uncache_page() to unmark the pages. 588 591 589 592 590 - (*) Perform coherency check on an object: 593 + * Perform coherency check on an object:: 591 594 592 595 enum fscache_checkaux fscache_check_aux(struct fscache_object *object, 593 596 const void *data, ··· 600 603 601 604 One of three values will be returned: 602 605 603 - (*) FSCACHE_CHECKAUX_OKAY 604 - 606 + FSCACHE_CHECKAUX_OKAY 605 607 The coherency data indicates the object is valid as is. 606 608 607 - (*) FSCACHE_CHECKAUX_NEEDS_UPDATE 608 - 609 + FSCACHE_CHECKAUX_NEEDS_UPDATE 609 610 The coherency data needs updating, but otherwise the object is 610 611 valid. 611 612 612 - (*) FSCACHE_CHECKAUX_OBSOLETE 613 - 613 + FSCACHE_CHECKAUX_OBSOLETE 614 614 The coherency data indicates that the object is obsolete and should 615 615 be discarded. 616 616 617 617 618 - (*) Initialise a freshly allocated object: 618 + * Initialise a freshly allocated object:: 619 619 620 620 void fscache_object_init(struct fscache_object *object); 621 621 622 622 This initialises all the fields in an object representation. 623 623 624 624 625 - (*) Indicate the destruction of an object: 625 + * Indicate the destruction of an object:: 626 626 627 627 void fscache_object_destroyed(struct fscache_cache *cache); 628 628 ··· 629 635 all the objects. 630 636 631 637 632 - (*) Indicate negative lookup on an object: 638 + * Indicate negative lookup on an object:: 633 639 634 640 void fscache_object_lookup_negative(struct fscache_object *object); 635 641 ··· 644 650 significant - all subsequent calls are ignored. 645 651 646 652 647 - (*) Indicate an object has been obtained: 653 + * Indicate an object has been obtained:: 648 654 649 655 void fscache_obtained_object(struct fscache_object *object); 650 656 ··· 661 667 (2) that writes may now proceed against this object. 662 668 663 669 664 - (*) Indicate that object lookup failed: 670 + * Indicate that object lookup failed:: 665 671 666 672 void fscache_object_lookup_error(struct fscache_object *object); 667 673 ··· 670 676 as possible. 671 677 672 678 673 - (*) Indicate that a stale object was found and discarded: 679 + * Indicate that a stale object was found and discarded:: 674 680 675 681 void fscache_object_retrying_stale(struct fscache_object *object); 676 682 ··· 679 685 discarded from the cache and the lookup will be performed again. 680 686 681 687 682 - (*) Indicate that the caching backend killed an object: 688 + * Indicate that the caching backend killed an object:: 683 689 684 690 void fscache_object_mark_killed(struct fscache_object *object, 685 691 enum fscache_why_object_killed why); ··· 687 693 This is called to indicate that the cache backend preemptively killed an 688 694 object. The why parameter should be set to indicate the reason: 689 695 690 - FSCACHE_OBJECT_IS_STALE - the object was stale and needs discarding. 691 - FSCACHE_OBJECT_NO_SPACE - there was insufficient cache space 692 - FSCACHE_OBJECT_WAS_RETIRED - the object was retired when relinquished. 693 - FSCACHE_OBJECT_WAS_CULLED - the object was culled to make space. 696 + FSCACHE_OBJECT_IS_STALE 697 + - the object was stale and needs discarding. 698 + 699 + FSCACHE_OBJECT_NO_SPACE 700 + - there was insufficient cache space 701 + 702 + FSCACHE_OBJECT_WAS_RETIRED 703 + - the object was retired when relinquished. 704 + 705 + FSCACHE_OBJECT_WAS_CULLED 706 + - the object was culled to make space. 694 707 695 708 696 - (*) Get and release references on a retrieval record: 709 + * Get and release references on a retrieval record:: 697 710 698 711 void fscache_get_retrieval(struct fscache_retrieval *op); 699 712 void fscache_put_retrieval(struct fscache_retrieval *op); ··· 709 708 asynchronous data retrieval and block allocation. 710 709 711 710 712 - (*) Enqueue a retrieval record for processing. 711 + * Enqueue a retrieval record for processing:: 713 712 714 713 void fscache_enqueue_retrieval(struct fscache_retrieval *op); 715 714 ··· 719 718 within the callback function. 720 719 721 720 722 - (*) List of object state names: 721 + * List of object state names:: 723 722 724 723 const char *fscache_object_states[]; 725 724
+1 -1
Documentation/filesystems/caching/fscache.rst
··· 187 187 188 188 The cache backend API to FS-Cache can be found in: 189 189 190 - Documentation/filesystems/caching/backend-api.txt 190 + Documentation/filesystems/caching/backend-api.rst 191 191 192 192 A description of the internal representations and object state machine can be 193 193 found in:
+1
Documentation/filesystems/caching/index.rst
··· 8 8 9 9 fscache 10 10 object 11 + backend-api 11 12 cachefiles 12 13 netfs-api 13 14 operations
+4 -4
fs/fscache/cache.c
··· 172 172 * 173 173 * Initialise a record of a cache and fill in the name. 174 174 * 175 - * See Documentation/filesystems/caching/backend-api.txt for a complete 175 + * See Documentation/filesystems/caching/backend-api.rst for a complete 176 176 * description. 177 177 */ 178 178 void fscache_init_cache(struct fscache_cache *cache, ··· 207 207 * 208 208 * Add a cache to the system, making it available for netfs's to use. 209 209 * 210 - * See Documentation/filesystems/caching/backend-api.txt for a complete 210 + * See Documentation/filesystems/caching/backend-api.rst for a complete 211 211 * description. 212 212 */ 213 213 int fscache_add_cache(struct fscache_cache *cache, ··· 307 307 * Note that an I/O error occurred in a cache and that it should no longer be 308 308 * used for anything. This also reports the error into the kernel log. 309 309 * 310 - * See Documentation/filesystems/caching/backend-api.txt for a complete 310 + * See Documentation/filesystems/caching/backend-api.rst for a complete 311 311 * description. 312 312 */ 313 313 void fscache_io_error(struct fscache_cache *cache) ··· 355 355 * Withdraw a cache from service, unbinding all its cache objects from the 356 356 * netfs cookies they're currently representing. 357 357 * 358 - * See Documentation/filesystems/caching/backend-api.txt for a complete 358 + * See Documentation/filesystems/caching/backend-api.rst for a complete 359 359 * description. 360 360 */ 361 361 void fscache_withdraw_cache(struct fscache_cache *cache)
+1 -1
fs/fscache/object.c
··· 295 295 * 296 296 * Initialise a cache object description to its basic values. 297 297 * 298 - * See Documentation/filesystems/caching/backend-api.txt for a complete 298 + * See Documentation/filesystems/caching/backend-api.rst for a complete 299 299 * description. 300 300 */ 301 301 void fscache_object_init(struct fscache_object *object,
+2 -2
include/linux/fscache-cache.h
··· 6 6 * 7 7 * NOTE!!! See: 8 8 * 9 - * Documentation/filesystems/caching/backend-api.txt 9 + * Documentation/filesystems/caching/backend-api.rst 10 10 * 11 11 * for a description of the cache backend interface declared here. 12 12 */ ··· 454 454 * Set the maximum size an object is permitted to reach, implying the highest 455 455 * byte that may be written. Intended to be called by the attr_changed() op. 456 456 * 457 - * See Documentation/filesystems/caching/backend-api.txt for a complete 457 + * See Documentation/filesystems/caching/backend-api.rst for a complete 458 458 * description. 459 459 */ 460 460 static inline