1 /* Storage object read/write
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
12 #include <linux/mount.h>
13 #include <linux/file.h>
17 * detect wake up events generated by the unlocking of pages in which we're
19 * - we use this to detect read completion of backing pages
20 * - the caller holds the waitqueue lock
22 static int cachefiles_read_waiter(wait_queue_t
*wait
, unsigned mode
,
25 struct cachefiles_one_read
*monitor
=
26 container_of(wait
, struct cachefiles_one_read
, monitor
);
27 struct cachefiles_object
*object
;
28 struct wait_bit_key
*key
= _key
;
29 struct page
*page
= wait
->private;
33 _enter("{%lu},%u,%d,{%p,%u}",
34 monitor
->netfs_page
->index
, mode
, sync
,
35 key
->flags
, key
->bit_nr
);
37 if (key
->flags
!= &page
->flags
||
38 key
->bit_nr
!= PG_locked
)
41 _debug("--- monitor %p %lx ---", page
, page
->flags
);
43 if (!PageUptodate(page
) && !PageError(page
)) {
44 /* unlocked, not uptodate and not erronous? */
45 _debug("page probably truncated");
48 /* remove from the waitqueue */
49 list_del(&wait
->task_list
);
51 /* move onto the action list and queue for FS-Cache thread pool */
54 object
= container_of(monitor
->op
->op
.object
,
55 struct cachefiles_object
, fscache
);
57 spin_lock(&object
->work_lock
);
58 list_add_tail(&monitor
->op_link
, &monitor
->op
->to_do
);
59 spin_unlock(&object
->work_lock
);
61 fscache_enqueue_retrieval(monitor
->op
);
66 * handle a probably truncated page
67 * - check to see if the page is still relevant and reissue the read if
69 * - return -EIO on error, -ENODATA if the page is gone, -EINPROGRESS if we
70 * must wait again and 0 if successful
72 static int cachefiles_read_reissue(struct cachefiles_object
*object
,
73 struct cachefiles_one_read
*monitor
)
75 struct address_space
*bmapping
= object
->backer
->d_inode
->i_mapping
;
76 struct page
*backpage
= monitor
->back_page
, *backpage2
;
79 kenter("{ino=%lx},{%lx,%lx}",
80 object
->backer
->d_inode
->i_ino
,
81 backpage
->index
, backpage
->flags
);
83 /* skip if the page was truncated away completely */
84 if (backpage
->mapping
!= bmapping
) {
85 kleave(" = -ENODATA [mapping]");
89 backpage2
= find_get_page(bmapping
, backpage
->index
);
91 kleave(" = -ENODATA [gone]");
95 if (backpage
!= backpage2
) {
97 kleave(" = -ENODATA [different]");
101 /* the page is still there and we already have a ref on it, so we don't
105 INIT_LIST_HEAD(&monitor
->op_link
);
106 add_page_wait_queue(backpage
, &monitor
->monitor
);
108 if (trylock_page(backpage
)) {
110 if (PageError(backpage
))
113 if (PageUptodate(backpage
))
116 kdebug("reissue read");
117 ret
= bmapping
->a_ops
->readpage(NULL
, backpage
);
122 /* but the page may have been read before the monitor was installed, so
123 * the monitor may miss the event - so we have to ensure that we do get
124 * one in such a case */
125 if (trylock_page(backpage
)) {
126 _debug("jumpstart %p {%lx}", backpage
, backpage
->flags
);
127 unlock_page(backpage
);
130 /* it'll reappear on the todo list */
131 kleave(" = -EINPROGRESS");
135 unlock_page(backpage
);
136 spin_lock_irq(&object
->work_lock
);
137 list_del(&monitor
->op_link
);
138 spin_unlock_irq(&object
->work_lock
);
139 kleave(" = %d", ret
);
144 * copy data from backing pages to netfs pages to complete a read operation
145 * - driven by FS-Cache's thread pool
147 static void cachefiles_read_copier(struct fscache_operation
*_op
)
149 struct cachefiles_one_read
*monitor
;
150 struct cachefiles_object
*object
;
151 struct fscache_retrieval
*op
;
152 struct pagevec pagevec
;
155 op
= container_of(_op
, struct fscache_retrieval
, op
);
156 object
= container_of(op
->op
.object
,
157 struct cachefiles_object
, fscache
);
159 _enter("{ino=%lu}", object
->backer
->d_inode
->i_ino
);
161 pagevec_init(&pagevec
, 0);
164 spin_lock_irq(&object
->work_lock
);
166 while (!list_empty(&op
->to_do
)) {
167 monitor
= list_entry(op
->to_do
.next
,
168 struct cachefiles_one_read
, op_link
);
169 list_del(&monitor
->op_link
);
171 spin_unlock_irq(&object
->work_lock
);
173 _debug("- copy {%lu}", monitor
->back_page
->index
);
176 if (PageUptodate(monitor
->back_page
)) {
177 copy_highpage(monitor
->netfs_page
, monitor
->back_page
);
179 pagevec_add(&pagevec
, monitor
->netfs_page
);
180 fscache_mark_pages_cached(monitor
->op
, &pagevec
);
182 } else if (!PageError(monitor
->back_page
)) {
183 /* the page has probably been truncated */
184 error
= cachefiles_read_reissue(object
, monitor
);
185 if (error
== -EINPROGRESS
)
189 cachefiles_io_error_obj(
191 "Readpage failed on backing file %lx",
192 (unsigned long) monitor
->back_page
->flags
);
196 page_cache_release(monitor
->back_page
);
198 fscache_end_io(op
, monitor
->netfs_page
, error
);
199 page_cache_release(monitor
->netfs_page
);
200 fscache_put_retrieval(op
);
204 /* let the thread pool have some air occasionally */
206 if (max
< 0 || need_resched()) {
207 if (!list_empty(&op
->to_do
))
208 fscache_enqueue_retrieval(op
);
209 _leave(" [maxed out]");
213 spin_lock_irq(&object
->work_lock
);
216 spin_unlock_irq(&object
->work_lock
);
221 * read the corresponding page to the given set from the backing file
222 * - an uncertain page is simply discarded, to be tried again another time
224 static int cachefiles_read_backing_file_one(struct cachefiles_object
*object
,
225 struct fscache_retrieval
*op
,
226 struct page
*netpage
,
227 struct pagevec
*pagevec
)
229 struct cachefiles_one_read
*monitor
;
230 struct address_space
*bmapping
;
231 struct page
*newpage
, *backpage
;
236 pagevec_reinit(pagevec
);
238 _debug("read back %p{%lu,%d}",
239 netpage
, netpage
->index
, page_count(netpage
));
241 monitor
= kzalloc(sizeof(*monitor
), GFP_KERNEL
);
245 monitor
->netfs_page
= netpage
;
246 monitor
->op
= fscache_get_retrieval(op
);
248 init_waitqueue_func_entry(&monitor
->monitor
, cachefiles_read_waiter
);
250 /* attempt to get hold of the backing page */
251 bmapping
= object
->backer
->d_inode
->i_mapping
;
255 backpage
= find_get_page(bmapping
, netpage
->index
);
257 goto backing_page_already_present
;
260 newpage
= page_cache_alloc_cold(bmapping
);
265 ret
= add_to_page_cache(newpage
, bmapping
,
266 netpage
->index
, GFP_KERNEL
);
268 goto installed_new_backing_page
;
273 /* we've installed a new backing page, so now we need to add it
274 * to the LRU list and start it reading */
275 installed_new_backing_page
:
276 _debug("- new %p", newpage
);
281 page_cache_get(backpage
);
282 pagevec_add(pagevec
, backpage
);
283 __pagevec_lru_add_file(pagevec
);
286 ret
= bmapping
->a_ops
->readpage(NULL
, backpage
);
290 /* set the monitor to transfer the data across */
291 monitor_backing_page
:
292 _debug("- monitor add");
294 /* install the monitor */
295 page_cache_get(monitor
->netfs_page
);
296 page_cache_get(backpage
);
297 monitor
->back_page
= backpage
;
298 monitor
->monitor
.private = backpage
;
299 add_page_wait_queue(backpage
, &monitor
->monitor
);
302 /* but the page may have been read before the monitor was installed, so
303 * the monitor may miss the event - so we have to ensure that we do get
304 * one in such a case */
305 if (trylock_page(backpage
)) {
306 _debug("jumpstart %p {%lx}", backpage
, backpage
->flags
);
307 unlock_page(backpage
);
311 /* if the backing page is already present, it can be in one of
312 * three states: read in progress, read failed or read okay */
313 backing_page_already_present
:
317 page_cache_release(newpage
);
321 if (PageError(backpage
))
324 if (PageUptodate(backpage
))
325 goto backing_page_already_uptodate
;
327 if (!trylock_page(backpage
))
328 goto monitor_backing_page
;
329 _debug("read %p {%lx}", backpage
, backpage
->flags
);
330 goto read_backing_page
;
332 /* the backing page is already up to date, attach the netfs
333 * page to the pagecache and LRU and copy the data across */
334 backing_page_already_uptodate
:
335 _debug("- uptodate");
337 pagevec_add(pagevec
, netpage
);
338 fscache_mark_pages_cached(op
, pagevec
);
340 copy_highpage(netpage
, backpage
);
341 fscache_end_io(op
, netpage
, 0);
349 page_cache_release(backpage
);
351 fscache_put_retrieval(monitor
->op
);
354 _leave(" = %d", ret
);
358 _debug("read error %d", ret
);
362 cachefiles_io_error_obj(object
, "Page read error on backing file");
367 page_cache_release(newpage
);
369 fscache_put_retrieval(monitor
->op
);
372 _leave(" = -ENOMEM");
377 * read a page from the cache or allocate a block in which to store it
378 * - cache withdrawal is prevented by the caller
379 * - returns -EINTR if interrupted
380 * - returns -ENOMEM if ran out of memory
381 * - returns -ENOBUFS if no buffers can be made available
382 * - returns -ENOBUFS if page is beyond EOF
383 * - if the page is backed by a block in the cache:
384 * - a read will be started which will call the callback on completion
385 * - 0 will be returned
386 * - else if the page is unbacked:
387 * - the metadata will be retained
388 * - -ENODATA will be returned
390 int cachefiles_read_or_alloc_page(struct fscache_retrieval
*op
,
394 struct cachefiles_object
*object
;
395 struct cachefiles_cache
*cache
;
396 struct pagevec pagevec
;
398 sector_t block0
, block
;
402 object
= container_of(op
->op
.object
,
403 struct cachefiles_object
, fscache
);
404 cache
= container_of(object
->fscache
.cache
,
405 struct cachefiles_cache
, cache
);
407 _enter("{%p},{%lx},,,", object
, page
->index
);
412 inode
= object
->backer
->d_inode
;
413 ASSERT(S_ISREG(inode
->i_mode
));
414 ASSERT(inode
->i_mapping
->a_ops
->bmap
);
415 ASSERT(inode
->i_mapping
->a_ops
->readpages
);
417 /* calculate the shift required to use bmap */
418 if (inode
->i_sb
->s_blocksize
> PAGE_SIZE
)
421 shift
= PAGE_SHIFT
- inode
->i_sb
->s_blocksize_bits
;
423 op
->op
.flags
&= FSCACHE_OP_KEEP_FLAGS
;
424 op
->op
.flags
|= FSCACHE_OP_FAST
;
425 op
->op
.processor
= cachefiles_read_copier
;
427 pagevec_init(&pagevec
, 0);
429 /* we assume the absence or presence of the first block is a good
430 * enough indication for the page as a whole
431 * - TODO: don't use bmap() for this as it is _not_ actually good
432 * enough for this as it doesn't indicate errors, but it's all we've
435 block0
= page
->index
;
438 block
= inode
->i_mapping
->a_ops
->bmap(inode
->i_mapping
, block0
);
439 _debug("%llx -> %llx",
440 (unsigned long long) block0
,
441 (unsigned long long) block
);
444 /* submit the apparently valid page to the backing fs to be
446 ret
= cachefiles_read_backing_file_one(object
, op
, page
,
448 } else if (cachefiles_has_space(cache
, 0, 1) == 0) {
449 /* there's space in the cache we can use */
450 pagevec_add(&pagevec
, page
);
451 fscache_mark_pages_cached(op
, &pagevec
);
457 _leave(" = %d", ret
);
462 * read the corresponding pages to the given set from the backing file
463 * - any uncertain pages are simply discarded, to be tried again another time
465 static int cachefiles_read_backing_file(struct cachefiles_object
*object
,
466 struct fscache_retrieval
*op
,
467 struct list_head
*list
,
468 struct pagevec
*mark_pvec
)
470 struct cachefiles_one_read
*monitor
= NULL
;
471 struct address_space
*bmapping
= object
->backer
->d_inode
->i_mapping
;
472 struct pagevec lru_pvec
;
473 struct page
*newpage
= NULL
, *netpage
, *_n
, *backpage
= NULL
;
478 pagevec_init(&lru_pvec
, 0);
480 list_for_each_entry_safe(netpage
, _n
, list
, lru
) {
481 list_del(&netpage
->lru
);
483 _debug("read back %p{%lu,%d}",
484 netpage
, netpage
->index
, page_count(netpage
));
487 monitor
= kzalloc(sizeof(*monitor
), GFP_KERNEL
);
491 monitor
->op
= fscache_get_retrieval(op
);
492 init_waitqueue_func_entry(&monitor
->monitor
,
493 cachefiles_read_waiter
);
497 backpage
= find_get_page(bmapping
, netpage
->index
);
499 goto backing_page_already_present
;
502 newpage
= page_cache_alloc_cold(bmapping
);
507 ret
= add_to_page_cache(newpage
, bmapping
,
508 netpage
->index
, GFP_KERNEL
);
510 goto installed_new_backing_page
;
515 /* we've installed a new backing page, so now we need to add it
516 * to the LRU list and start it reading */
517 installed_new_backing_page
:
518 _debug("- new %p", newpage
);
523 page_cache_get(backpage
);
524 if (!pagevec_add(&lru_pvec
, backpage
))
525 __pagevec_lru_add_file(&lru_pvec
);
528 ret
= bmapping
->a_ops
->readpage(NULL
, backpage
);
532 /* add the netfs page to the pagecache and LRU, and set the
533 * monitor to transfer the data across */
534 monitor_backing_page
:
535 _debug("- monitor add");
537 ret
= add_to_page_cache(netpage
, op
->mapping
, netpage
->index
,
540 if (ret
== -EEXIST
) {
541 page_cache_release(netpage
);
547 page_cache_get(netpage
);
548 if (!pagevec_add(&lru_pvec
, netpage
))
549 __pagevec_lru_add_file(&lru_pvec
);
551 /* install a monitor */
552 page_cache_get(netpage
);
553 monitor
->netfs_page
= netpage
;
555 page_cache_get(backpage
);
556 monitor
->back_page
= backpage
;
557 monitor
->monitor
.private = backpage
;
558 add_page_wait_queue(backpage
, &monitor
->monitor
);
561 /* but the page may have been read before the monitor was
562 * installed, so the monitor may miss the event - so we have to
563 * ensure that we do get one in such a case */
564 if (trylock_page(backpage
)) {
565 _debug("2unlock %p {%lx}", backpage
, backpage
->flags
);
566 unlock_page(backpage
);
569 page_cache_release(backpage
);
572 page_cache_release(netpage
);
576 /* if the backing page is already present, it can be in one of
577 * three states: read in progress, read failed or read okay */
578 backing_page_already_present
:
579 _debug("- present %p", backpage
);
581 if (PageError(backpage
))
584 if (PageUptodate(backpage
))
585 goto backing_page_already_uptodate
;
587 _debug("- not ready %p{%lx}", backpage
, backpage
->flags
);
589 if (!trylock_page(backpage
))
590 goto monitor_backing_page
;
592 if (PageError(backpage
)) {
593 _debug("error %lx", backpage
->flags
);
594 unlock_page(backpage
);
598 if (PageUptodate(backpage
))
599 goto backing_page_already_uptodate_unlock
;
601 /* we've locked a page that's neither up to date nor erroneous,
602 * so we need to attempt to read it again */
603 goto reread_backing_page
;
605 /* the backing page is already up to date, attach the netfs
606 * page to the pagecache and LRU and copy the data across */
607 backing_page_already_uptodate_unlock
:
608 _debug("uptodate %lx", backpage
->flags
);
609 unlock_page(backpage
);
610 backing_page_already_uptodate
:
611 _debug("- uptodate");
613 ret
= add_to_page_cache(netpage
, op
->mapping
, netpage
->index
,
616 if (ret
== -EEXIST
) {
617 page_cache_release(netpage
);
623 copy_highpage(netpage
, backpage
);
625 page_cache_release(backpage
);
628 if (!pagevec_add(mark_pvec
, netpage
))
629 fscache_mark_pages_cached(op
, mark_pvec
);
631 page_cache_get(netpage
);
632 if (!pagevec_add(&lru_pvec
, netpage
))
633 __pagevec_lru_add_file(&lru_pvec
);
635 fscache_end_io(op
, netpage
, 0);
636 page_cache_release(netpage
);
647 pagevec_lru_add_file(&lru_pvec
);
650 page_cache_release(newpage
);
652 page_cache_release(netpage
);
654 page_cache_release(backpage
);
656 fscache_put_retrieval(op
);
660 list_for_each_entry_safe(netpage
, _n
, list
, lru
) {
661 list_del(&netpage
->lru
);
662 page_cache_release(netpage
);
665 _leave(" = %d", ret
);
674 _debug("read error %d", ret
);
678 cachefiles_io_error_obj(object
, "Page read error on backing file");
684 * read a list of pages from the cache or allocate blocks in which to store
687 int cachefiles_read_or_alloc_pages(struct fscache_retrieval
*op
,
688 struct list_head
*pages
,
692 struct cachefiles_object
*object
;
693 struct cachefiles_cache
*cache
;
694 struct list_head backpages
;
695 struct pagevec pagevec
;
697 struct page
*page
, *_n
;
698 unsigned shift
, nrbackpages
;
699 int ret
, ret2
, space
;
701 object
= container_of(op
->op
.object
,
702 struct cachefiles_object
, fscache
);
703 cache
= container_of(object
->fscache
.cache
,
704 struct cachefiles_cache
, cache
);
706 _enter("{OBJ%x,%d},,%d,,",
707 object
->fscache
.debug_id
, atomic_read(&op
->op
.usage
),
714 if (cachefiles_has_space(cache
, 0, *nr_pages
) < 0)
717 inode
= object
->backer
->d_inode
;
718 ASSERT(S_ISREG(inode
->i_mode
));
719 ASSERT(inode
->i_mapping
->a_ops
->bmap
);
720 ASSERT(inode
->i_mapping
->a_ops
->readpages
);
722 /* calculate the shift required to use bmap */
723 if (inode
->i_sb
->s_blocksize
> PAGE_SIZE
)
726 shift
= PAGE_SHIFT
- inode
->i_sb
->s_blocksize_bits
;
728 pagevec_init(&pagevec
, 0);
730 op
->op
.flags
&= FSCACHE_OP_KEEP_FLAGS
;
731 op
->op
.flags
|= FSCACHE_OP_FAST
;
732 op
->op
.processor
= cachefiles_read_copier
;
734 INIT_LIST_HEAD(&backpages
);
737 ret
= space
? -ENODATA
: -ENOBUFS
;
738 list_for_each_entry_safe(page
, _n
, pages
, lru
) {
739 sector_t block0
, block
;
741 /* we assume the absence or presence of the first block is a
742 * good enough indication for the page as a whole
743 * - TODO: don't use bmap() for this as it is _not_ actually
744 * good enough for this as it doesn't indicate errors, but
745 * it's all we've got for the moment
747 block0
= page
->index
;
750 block
= inode
->i_mapping
->a_ops
->bmap(inode
->i_mapping
,
752 _debug("%llx -> %llx",
753 (unsigned long long) block0
,
754 (unsigned long long) block
);
757 /* we have data - add it to the list to give to the
759 list_move(&page
->lru
, &backpages
);
762 } else if (space
&& pagevec_add(&pagevec
, page
) == 0) {
763 fscache_mark_pages_cached(op
, &pagevec
);
768 if (pagevec_count(&pagevec
) > 0)
769 fscache_mark_pages_cached(op
, &pagevec
);
771 if (list_empty(pages
))
774 /* submit the apparently valid pages to the backing fs to be read from
776 if (nrbackpages
> 0) {
777 ret2
= cachefiles_read_backing_file(object
, op
, &backpages
,
779 if (ret2
== -ENOMEM
|| ret2
== -EINTR
)
783 if (pagevec_count(&pagevec
) > 0)
784 fscache_mark_pages_cached(op
, &pagevec
);
786 _leave(" = %d [nr=%u%s]",
787 ret
, *nr_pages
, list_empty(pages
) ? " empty" : "");
792 * allocate a block in the cache in which to store a page
793 * - cache withdrawal is prevented by the caller
794 * - returns -EINTR if interrupted
795 * - returns -ENOMEM if ran out of memory
796 * - returns -ENOBUFS if no buffers can be made available
797 * - returns -ENOBUFS if page is beyond EOF
799 * - the metadata will be retained
800 * - 0 will be returned
802 int cachefiles_allocate_page(struct fscache_retrieval
*op
,
806 struct cachefiles_object
*object
;
807 struct cachefiles_cache
*cache
;
808 struct pagevec pagevec
;
811 object
= container_of(op
->op
.object
,
812 struct cachefiles_object
, fscache
);
813 cache
= container_of(object
->fscache
.cache
,
814 struct cachefiles_cache
, cache
);
816 _enter("%p,{%lx},", object
, page
->index
);
818 ret
= cachefiles_has_space(cache
, 0, 1);
820 pagevec_init(&pagevec
, 0);
821 pagevec_add(&pagevec
, page
);
822 fscache_mark_pages_cached(op
, &pagevec
);
827 _leave(" = %d", ret
);
832 * allocate blocks in the cache in which to store a set of pages
833 * - cache withdrawal is prevented by the caller
834 * - returns -EINTR if interrupted
835 * - returns -ENOMEM if ran out of memory
836 * - returns -ENOBUFS if some buffers couldn't be made available
837 * - returns -ENOBUFS if some pages are beyond EOF
839 * - -ENODATA will be returned
840 * - metadata will be retained for any page marked
842 int cachefiles_allocate_pages(struct fscache_retrieval
*op
,
843 struct list_head
*pages
,
847 struct cachefiles_object
*object
;
848 struct cachefiles_cache
*cache
;
849 struct pagevec pagevec
;
853 object
= container_of(op
->op
.object
,
854 struct cachefiles_object
, fscache
);
855 cache
= container_of(object
->fscache
.cache
,
856 struct cachefiles_cache
, cache
);
858 _enter("%p,,,%d,", object
, *nr_pages
);
860 ret
= cachefiles_has_space(cache
, 0, *nr_pages
);
862 pagevec_init(&pagevec
, 0);
864 list_for_each_entry(page
, pages
, lru
) {
865 if (pagevec_add(&pagevec
, page
) == 0)
866 fscache_mark_pages_cached(op
, &pagevec
);
869 if (pagevec_count(&pagevec
) > 0)
870 fscache_mark_pages_cached(op
, &pagevec
);
876 _leave(" = %d", ret
);
881 * request a page be stored in the cache
882 * - cache withdrawal is prevented by the caller
883 * - this request may be ignored if there's no cache block available, in which
884 * case -ENOBUFS will be returned
885 * - if the op is in progress, 0 will be returned
887 int cachefiles_write_page(struct fscache_storage
*op
, struct page
*page
)
889 struct cachefiles_object
*object
;
890 struct cachefiles_cache
*cache
;
899 ASSERT(page
!= NULL
);
901 object
= container_of(op
->op
.object
,
902 struct cachefiles_object
, fscache
);
904 _enter("%p,%p{%lx},,,", object
, page
, page
->index
);
906 if (!object
->backer
) {
907 _leave(" = -ENOBUFS");
911 ASSERT(S_ISREG(object
->backer
->d_inode
->i_mode
));
913 cache
= container_of(object
->fscache
.cache
,
914 struct cachefiles_cache
, cache
);
916 /* write the page to the backing filesystem and let it store it in its
918 dget(object
->backer
);
920 file
= dentry_open(object
->backer
, cache
->mnt
, O_RDWR
,
926 if (file
->f_op
->write
) {
927 pos
= (loff_t
) page
->index
<< PAGE_SHIFT
;
929 /* we mustn't write more data than we have, so we have
930 * to beware of a partial page at EOF */
931 eof
= object
->fscache
.store_limit_l
;
933 if (eof
& ~PAGE_MASK
) {
934 ASSERTCMP(pos
, <, eof
);
935 if (eof
- pos
< PAGE_SIZE
) {
936 _debug("cut short %llx to %llx",
939 ASSERTCMP(pos
+ len
, ==, eof
);
946 ret
= file
->f_op
->write(
947 file
, (const void __user
*) data
, len
, &pos
);
958 cachefiles_io_error_obj(
959 object
, "Write page to backing file failed");
963 _leave(" = %d", ret
);
968 * detach a backing block from a page
969 * - cache withdrawal is prevented by the caller
971 void cachefiles_uncache_page(struct fscache_object
*_object
, struct page
*page
)
973 struct cachefiles_object
*object
;
974 struct cachefiles_cache
*cache
;
976 object
= container_of(_object
, struct cachefiles_object
, fscache
);
977 cache
= container_of(object
->fscache
.cache
,
978 struct cachefiles_cache
, cache
);
980 _enter("%p,{%lu}", object
, page
->index
);
982 spin_unlock(&object
->fscache
.cookie
->lock
);