Skip to content

Commit 03ffae9

Browse files
committed
1 parent 26aaeff commit 03ffae9

3 files changed

Lines changed: 36 additions & 175 deletions

File tree

fs/afs/file.c

Lines changed: 35 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,6 @@ void afs_put_read(struct afs_read *req)
202202
}
203203
}
204204

205-
#ifdef CONFIG_AFS_FSCACHE
206-
/*
207-
* deal with notification that a page was read from the cache
208-
*/
209-
static void afs_file_readpage_read_complete(struct page *page,
210-
void *data,
211-
int error)
212-
{
213-
_enter("%p,%p,%d", page, data, error);
214-
215-
/* if the read completes with an error, we just unlock the page and let
216-
* the VM reissue the readpage */
217-
if (!error)
218-
SetPageUptodate(page);
219-
unlock_page(page);
220-
}
221-
#endif
222-
223205
static void afs_fetch_data_success(struct afs_operation *op)
224206
{
225207
struct afs_vnode *vnode = op->file[0].vnode;
@@ -287,89 +269,46 @@ int afs_page_filler(void *data, struct page *page)
287269
if (test_bit(AFS_VNODE_DELETED, &vnode->flags))
288270
goto error;
289271

290-
/* is it cached? */
291-
#ifdef CONFIG_AFS_FSCACHE
292-
ret = fscache_read_or_alloc_page(vnode->cache,
293-
page,
294-
afs_file_readpage_read_complete,
295-
NULL,
296-
GFP_KERNEL);
297-
#else
298-
ret = -ENOBUFS;
299-
#endif
300-
switch (ret) {
301-
/* read BIO submitted (page in cache) */
302-
case 0:
303-
break;
304-
305-
/* page not yet cached */
306-
case -ENODATA:
307-
_debug("cache said ENODATA");
308-
goto go_on;
309-
310-
/* page will not be cached */
311-
case -ENOBUFS:
312-
_debug("cache said ENOBUFS");
313-
314-
fallthrough;
315-
default:
316-
go_on:
317-
req = kzalloc(struct_size(req, array, 1), GFP_KERNEL);
318-
if (!req)
319-
goto enomem;
320-
321-
/* We request a full page. If the page is a partial one at the
322-
* end of the file, the server will return a short read and the
323-
* unmarshalling code will clear the unfilled space.
324-
*/
325-
refcount_set(&req->usage, 1);
326-
req->pos = (loff_t)page->index << PAGE_SHIFT;
327-
req->len = PAGE_SIZE;
328-
req->nr_pages = 1;
329-
req->pages = req->array;
330-
req->pages[0] = page;
331-
get_page(page);
332-
333-
/* read the contents of the file from the server into the
334-
* page */
335-
ret = afs_fetch_data(vnode, key, req);
336-
afs_put_read(req);
337-
338-
if (ret < 0) {
339-
if (ret == -ENOENT) {
340-
_debug("got NOENT from server"
341-
" - marking file deleted and stale");
342-
set_bit(AFS_VNODE_DELETED, &vnode->flags);
343-
ret = -ESTALE;
344-
}
345-
346-
#ifdef CONFIG_AFS_FSCACHE
347-
fscache_uncache_page(vnode->cache, page);
348-
#endif
349-
BUG_ON(PageFsCache(page));
350-
351-
if (ret == -EINTR ||
352-
ret == -ENOMEM ||
353-
ret == -ERESTARTSYS ||
354-
ret == -EAGAIN)
355-
goto error;
356-
goto io_error;
357-
}
272+
req = kzalloc(struct_size(req, array, 1), GFP_KERNEL);
273+
if (!req)
274+
goto enomem;
358275

359-
SetPageUptodate(page);
276+
/* We request a full page. If the page is a partial one at the
277+
* end of the file, the server will return a short read and the
278+
* unmarshalling code will clear the unfilled space.
279+
*/
280+
refcount_set(&req->usage, 1);
281+
req->pos = (loff_t)page->index << PAGE_SHIFT;
282+
req->len = PAGE_SIZE;
283+
req->nr_pages = 1;
284+
req->pages = req->array;
285+
req->pages[0] = page;
286+
get_page(page);
287+
288+
/* read the contents of the file from the server into the
289+
* page */
290+
ret = afs_fetch_data(vnode, key, req);
291+
afs_put_read(req);
360292

361-
/* send the page to the cache */
362-
#ifdef CONFIG_AFS_FSCACHE
363-
if (PageFsCache(page) &&
364-
fscache_write_page(vnode->cache, page, vnode->status.size,
365-
GFP_KERNEL) != 0) {
366-
fscache_uncache_page(vnode->cache, page);
367-
BUG_ON(PageFsCache(page));
293+
if (ret < 0) {
294+
if (ret == -ENOENT) {
295+
_debug("got NOENT from server"
296+
" - marking file deleted and stale");
297+
set_bit(AFS_VNODE_DELETED, &vnode->flags);
298+
ret = -ESTALE;
368299
}
369-
#endif
370-
unlock_page(page);
300+
301+
if (ret == -EINTR ||
302+
ret == -ENOMEM ||
303+
ret == -ERESTARTSYS ||
304+
ret == -EAGAIN)
305+
goto error;
306+
goto io_error;
371307
}
372308

309+
SetPageUptodate(page);
310+
unlock_page(page);
311+
373312
_leave(" = 0");
374313
return 0;
375314

@@ -415,23 +354,10 @@ static int afs_readpage(struct file *file, struct page *page)
415354
*/
416355
static void afs_readpages_page_done(struct afs_read *req)
417356
{
418-
#ifdef CONFIG_AFS_FSCACHE
419-
struct afs_vnode *vnode = req->vnode;
420-
#endif
421357
struct page *page = req->pages[req->index];
422358

423359
req->pages[req->index] = NULL;
424360
SetPageUptodate(page);
425-
426-
/* send the page to the cache */
427-
#ifdef CONFIG_AFS_FSCACHE
428-
if (PageFsCache(page) &&
429-
fscache_write_page(vnode->cache, page, vnode->status.size,
430-
GFP_KERNEL) != 0) {
431-
fscache_uncache_page(vnode->cache, page);
432-
BUG_ON(PageFsCache(page));
433-
}
434-
#endif
435361
unlock_page(page);
436362
put_page(page);
437363
}
@@ -490,9 +416,6 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
490416
index = page->index;
491417
if (add_to_page_cache_lru(page, mapping, index,
492418
readahead_gfp_mask(mapping))) {
493-
#ifdef CONFIG_AFS_FSCACHE
494-
fscache_uncache_page(vnode->cache, page);
495-
#endif
496419
put_page(page);
497420
break;
498421
}
@@ -525,9 +448,6 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
525448
for (i = 0; i < req->nr_pages; i++) {
526449
page = req->pages[i];
527450
if (page) {
528-
#ifdef CONFIG_AFS_FSCACHE
529-
fscache_uncache_page(vnode->cache, page);
530-
#endif
531451
SetPageError(page);
532452
unlock_page(page);
533453
}
@@ -559,37 +479,6 @@ static int afs_readpages(struct file *file, struct address_space *mapping,
559479
}
560480

561481
/* attempt to read as many of the pages as possible */
562-
#ifdef CONFIG_AFS_FSCACHE
563-
ret = fscache_read_or_alloc_pages(vnode->cache,
564-
mapping,
565-
pages,
566-
&nr_pages,
567-
afs_file_readpage_read_complete,
568-
NULL,
569-
mapping_gfp_mask(mapping));
570-
#else
571-
ret = -ENOBUFS;
572-
#endif
573-
574-
switch (ret) {
575-
/* all pages are being read from the cache */
576-
case 0:
577-
BUG_ON(!list_empty(pages));
578-
BUG_ON(nr_pages != 0);
579-
_leave(" = 0 [reading all]");
580-
return 0;
581-
582-
/* there were pages that couldn't be read from the cache */
583-
case -ENODATA:
584-
case -ENOBUFS:
585-
break;
586-
587-
/* other error */
588-
default:
589-
_leave(" = %d", ret);
590-
return ret;
591-
}
592-
593482
while (!list_empty(pages)) {
594483
ret = afs_readpages_one(file, mapping, pages);
595484
if (ret < 0)
@@ -669,17 +558,6 @@ static void afs_invalidatepage(struct page *page, unsigned int offset,
669558

670559
BUG_ON(!PageLocked(page));
671560

672-
#ifdef CONFIG_AFS_FSCACHE
673-
/* we clean up only if the entire page is being invalidated */
674-
if (offset == 0 && length == PAGE_SIZE) {
675-
if (PageFsCache(page)) {
676-
struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
677-
fscache_wait_on_page_write(vnode->cache, page);
678-
fscache_uncache_page(vnode->cache, page);
679-
}
680-
}
681-
#endif
682-
683561
if (PagePrivate(page))
684562
afs_invalidate_dirty(page, offset, length);
685563

@@ -701,13 +579,6 @@ static int afs_releasepage(struct page *page, gfp_t gfp_flags)
701579

702580
/* deny if page is being written to the cache and the caller hasn't
703581
* elected to wait */
704-
#ifdef CONFIG_AFS_FSCACHE
705-
if (!fscache_maybe_release_page(vnode->cache, page, gfp_flags)) {
706-
_leave(" = F [cache busy]");
707-
return 0;
708-
}
709-
#endif
710-
711582
if (PagePrivate(page)) {
712583
priv = (unsigned long)detach_page_private(page);
713584
trace_afs_page_dirty(vnode, tracepoint_string("rel"),

fs/afs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ static void afs_get_inode_cache(struct afs_vnode *vnode)
427427
} __packed key;
428428
struct afs_vnode_cache_aux aux;
429429

430-
if (vnode->status.type == AFS_FTYPE_DIR) {
430+
if (vnode->status.type != AFS_FTYPE_FILE) {
431431
vnode->cache = NULL;
432432
return;
433433
}

fs/afs/write.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,6 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
847847
/* Wait for the page to be written to the cache before we allow it to
848848
* be modified. We then assume the entire page will need writing back.
849849
*/
850-
#ifdef CONFIG_AFS_FSCACHE
851-
fscache_wait_on_page_write(vnode->cache, vmf->page);
852-
#endif
853850

854851
if (wait_on_page_writeback_killable(vmf->page))
855852
return VM_FAULT_RETRY;
@@ -935,12 +932,5 @@ int afs_launder_page(struct page *page)
935932
priv = (unsigned long)detach_page_private(page);
936933
trace_afs_page_dirty(vnode, tracepoint_string("laundered"),
937934
page->index, priv);
938-
939-
#ifdef CONFIG_AFS_FSCACHE
940-
if (PageFsCache(page)) {
941-
fscache_wait_on_page_write(vnode->cache, page);
942-
fscache_uncache_page(vnode->cache, page);
943-
}
944-
#endif
945935
return ret;
946936
}

0 commit comments

Comments
 (0)