Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347820
b: refs/heads/master
c: 9f10523
h: refs/heads/master
v: v3
  • Loading branch information
David Howells committed Dec 20, 2012
1 parent 43948b5 commit 10cc89e
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 51 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ef46ed888efb1e8da33be5d33c9b54476289a43b
refs/heads/master: 9f10523f891928330b7529da54c1a3cc65180b1a
26 changes: 25 additions & 1 deletion trunk/Documentation/filesystems/caching/backend-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@ performed on the denizens of the cache. These are held in a structure of type:

If an I/O error occurs, fscache_io_error() should be called and -ENOBUFS
returned if possible or fscache_end_io() called with a suitable error
code..
code.

fscache_put_retrieval() should be called after a page or pages are dealt
with. This will complete the operation when all pages are dealt with.


(*) Request pages be read from cache [mandatory]:
Expand Down Expand Up @@ -526,6 +529,27 @@ FS-Cache provides some utilities that a cache backend may make use of:
error value should be 0 if successful and an error otherwise.


(*) Record that one or more pages being retrieved or allocated have been dealt
with:

void fscache_retrieval_complete(struct fscache_retrieval *op,
int n_pages);

This is called to record the fact that one or more pages have been dealt
with and are no longer the concern of this operation. When the number of
pages remaining in the operation reaches 0, the operation will be
completed.


(*) Record operation completion:

void fscache_op_complete(struct fscache_operation *op);

This is called to record the completion of an operation. This deducts
this operation from the parent object's run state, potentially permitting
one or more pending operations to start running.


(*) Set highest store limit:

void fscache_set_store_limit(struct fscache_object *object,
Expand Down
2 changes: 1 addition & 1 deletion trunk/Documentation/filesystems/caching/operations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Operations are used through the following procedure:
necessary (the object might have died whilst the thread was waiting).

When it has finished doing its processing, it should call
fscache_put_operation() on it.
fscache_op_complete() and fscache_put_operation() on it.

(4) The operation holds an effective lock upon the object, preventing other
exclusive ops conflicting until it is released. The operation can be
Expand Down
31 changes: 26 additions & 5 deletions trunk/fs/cachefiles/rdwr.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ static void cachefiles_read_copier(struct fscache_operation *_op)

fscache_end_io(op, monitor->netfs_page, error);
page_cache_release(monitor->netfs_page);
fscache_retrieval_complete(op, 1);
fscache_put_retrieval(op);
kfree(monitor);

Expand Down Expand Up @@ -339,6 +340,7 @@ static int cachefiles_read_backing_file_one(struct cachefiles_object *object,

copy_highpage(netpage, backpage);
fscache_end_io(op, netpage, 0);
fscache_retrieval_complete(op, 1);

success:
_debug("success");
Expand All @@ -360,6 +362,7 @@ static int cachefiles_read_backing_file_one(struct cachefiles_object *object,
goto out;
io_error:
cachefiles_io_error_obj(object, "Page read error on backing file");
fscache_retrieval_complete(op, 1);
ret = -ENOBUFS;
goto out;

Expand All @@ -369,6 +372,7 @@ static int cachefiles_read_backing_file_one(struct cachefiles_object *object,
fscache_put_retrieval(monitor->op);
kfree(monitor);
nomem:
fscache_retrieval_complete(op, 1);
_leave(" = -ENOMEM");
return -ENOMEM;
}
Expand Down Expand Up @@ -407,7 +411,7 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
_enter("{%p},{%lx},,,", object, page->index);

if (!object->backer)
return -ENOBUFS;
goto enobufs;

inode = object->backer->d_inode;
ASSERT(S_ISREG(inode->i_mode));
Expand All @@ -416,7 +420,7 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,

/* calculate the shift required to use bmap */
if (inode->i_sb->s_blocksize > PAGE_SIZE)
return -ENOBUFS;
goto enobufs;

shift = PAGE_SHIFT - inode->i_sb->s_blocksize_bits;

Expand Down Expand Up @@ -448,13 +452,19 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
} else if (cachefiles_has_space(cache, 0, 1) == 0) {
/* there's space in the cache we can use */
fscache_mark_page_cached(op, page);
fscache_retrieval_complete(op, 1);
ret = -ENODATA;
} else {
ret = -ENOBUFS;
goto enobufs;
}

_leave(" = %d", ret);
return ret;

enobufs:
fscache_retrieval_complete(op, 1);
_leave(" = -ENOBUFS");
return -ENOBUFS;
}

/*
Expand Down Expand Up @@ -632,6 +642,7 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object,

/* the netpage is unlocked and marked up to date here */
fscache_end_io(op, netpage, 0);
fscache_retrieval_complete(op, 1);
page_cache_release(netpage);
netpage = NULL;
continue;
Expand Down Expand Up @@ -659,6 +670,7 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object,
list_for_each_entry_safe(netpage, _n, list, lru) {
list_del(&netpage->lru);
page_cache_release(netpage);
fscache_retrieval_complete(op, 1);
}

_leave(" = %d", ret);
Expand Down Expand Up @@ -707,7 +719,7 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,
*nr_pages);

if (!object->backer)
return -ENOBUFS;
goto all_enobufs;

space = 1;
if (cachefiles_has_space(cache, 0, *nr_pages) < 0)
Expand All @@ -720,7 +732,7 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,

/* calculate the shift required to use bmap */
if (inode->i_sb->s_blocksize > PAGE_SIZE)
return -ENOBUFS;
goto all_enobufs;

shift = PAGE_SHIFT - inode->i_sb->s_blocksize_bits;

Expand Down Expand Up @@ -760,7 +772,10 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,
nrbackpages++;
} else if (space && pagevec_add(&pagevec, page) == 0) {
fscache_mark_pages_cached(op, &pagevec);
fscache_retrieval_complete(op, 1);
ret = -ENODATA;
} else {
fscache_retrieval_complete(op, 1);
}
}

Expand All @@ -781,6 +796,10 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,
_leave(" = %d [nr=%u%s]",
ret, *nr_pages, list_empty(pages) ? " empty" : "");
return ret;

all_enobufs:
fscache_retrieval_complete(op, *nr_pages);
return -ENOBUFS;
}

/*
Expand Down Expand Up @@ -815,6 +834,7 @@ int cachefiles_allocate_page(struct fscache_retrieval *op,
else
ret = -ENOBUFS;

fscache_retrieval_complete(op, 1);
_leave(" = %d", ret);
return ret;
}
Expand Down Expand Up @@ -864,6 +884,7 @@ int cachefiles_allocate_pages(struct fscache_retrieval *op,
ret = -ENOBUFS;
}

fscache_retrieval_complete(op, *nr_pages);
_leave(" = %d", ret);
return ret;
}
Expand Down
2 changes: 0 additions & 2 deletions trunk/fs/fscache/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,6 @@ static void fscache_object_available(struct fscache_object *object)
if (object->n_in_progress == 0) {
if (object->n_ops > 0) {
ASSERTCMP(object->n_ops, >=, object->n_obj_ops);
ASSERTIF(object->n_ops > object->n_obj_ops,
!list_empty(&object->pending_ops));
fscache_start_operations(object);
} else {
ASSERT(list_empty(&object->pending_ops));
Expand Down
Loading

0 comments on commit 10cc89e

Please sign in to comment.