Commit c69bf479 authored by David Howells's avatar David Howells
parent f015cf1d
...@@ -241,6 +241,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key) ...@@ -241,6 +241,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
refcount_set(&req->usage, 1); refcount_set(&req->usage, 1);
req->key = key_get(key);
req->nr_pages = nr_pages; req->nr_pages = nr_pages;
req->actual_len = i_size; /* May change */ req->actual_len = i_size; /* May change */
req->len = nr_pages * PAGE_SIZE; /* We can ask for more than there is */ req->len = nr_pages * PAGE_SIZE; /* We can ask for more than there is */
...@@ -305,7 +306,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key) ...@@ -305,7 +306,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)
if (!test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) { if (!test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) {
trace_afs_reload_dir(dvnode); trace_afs_reload_dir(dvnode);
ret = afs_fetch_data(dvnode, key, req); ret = afs_fetch_data(dvnode, req);
if (ret < 0) if (ret < 0)
goto error_unlock; goto error_unlock;
......
...@@ -198,6 +198,7 @@ void afs_put_read(struct afs_read *req) ...@@ -198,6 +198,7 @@ void afs_put_read(struct afs_read *req)
if (req->pages != req->array) if (req->pages != req->array)
kfree(req->pages); kfree(req->pages);
} }
key_put(req->key);
kfree(req); kfree(req);
} }
} }
...@@ -228,7 +229,7 @@ static const struct afs_operation_ops afs_fetch_data_operation = { ...@@ -228,7 +229,7 @@ static const struct afs_operation_ops afs_fetch_data_operation = {
/* /*
* Fetch file data from the volume. * Fetch file data from the volume.
*/ */
int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *req) int afs_fetch_data(struct afs_vnode *vnode, struct afs_read *req)
{ {
struct afs_operation *op; struct afs_operation *op;
...@@ -237,9 +238,9 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *re ...@@ -237,9 +238,9 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *re
vnode->fid.vid, vnode->fid.vid,
vnode->fid.vnode, vnode->fid.vnode,
vnode->fid.unique, vnode->fid.unique,
key_serial(key)); key_serial(req->key));
op = afs_alloc_operation(key, vnode->volume); op = afs_alloc_operation(req->key, vnode->volume);
if (IS_ERR(op)) if (IS_ERR(op))
return PTR_ERR(op); return PTR_ERR(op);
...@@ -278,6 +279,7 @@ int afs_page_filler(void *data, struct page *page) ...@@ -278,6 +279,7 @@ int afs_page_filler(void *data, struct page *page)
* unmarshalling code will clear the unfilled space. * unmarshalling code will clear the unfilled space.
*/ */
refcount_set(&req->usage, 1); refcount_set(&req->usage, 1);
req->key = key_get(key);
req->pos = (loff_t)page->index << PAGE_SHIFT; req->pos = (loff_t)page->index << PAGE_SHIFT;
req->len = PAGE_SIZE; req->len = PAGE_SIZE;
req->nr_pages = 1; req->nr_pages = 1;
...@@ -287,7 +289,7 @@ int afs_page_filler(void *data, struct page *page) ...@@ -287,7 +289,7 @@ int afs_page_filler(void *data, struct page *page)
/* read the contents of the file from the server into the /* read the contents of the file from the server into the
* page */ * page */
ret = afs_fetch_data(vnode, key, req); ret = afs_fetch_data(vnode, req);
afs_put_read(req); afs_put_read(req);
if (ret < 0) { if (ret < 0) {
...@@ -372,7 +374,6 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping, ...@@ -372,7 +374,6 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
struct afs_read *req; struct afs_read *req;
struct list_head *p; struct list_head *p;
struct page *first, *page; struct page *first, *page;
struct key *key = afs_file_key(file);
pgoff_t index; pgoff_t index;
int ret, n, i; int ret, n, i;
...@@ -396,6 +397,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping, ...@@ -396,6 +397,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
refcount_set(&req->usage, 1); refcount_set(&req->usage, 1);
req->vnode = vnode; req->vnode = vnode;
req->key = key_get(afs_file_key(file));
req->page_done = afs_readpages_page_done; req->page_done = afs_readpages_page_done;
req->pos = first->index; req->pos = first->index;
req->pos <<= PAGE_SHIFT; req->pos <<= PAGE_SHIFT;
...@@ -425,11 +427,11 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping, ...@@ -425,11 +427,11 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
} while (req->nr_pages < n); } while (req->nr_pages < n);
if (req->nr_pages == 0) { if (req->nr_pages == 0) {
kfree(req); afs_put_read(req);
return 0; return 0;
} }
ret = afs_fetch_data(vnode, key, req); ret = afs_fetch_data(vnode, req);
if (ret < 0) if (ret < 0)
goto error; goto error;
......
...@@ -204,6 +204,7 @@ struct afs_read { ...@@ -204,6 +204,7 @@ struct afs_read {
loff_t actual_len; /* How much we're actually getting */ loff_t actual_len; /* How much we're actually getting */
loff_t remain; /* Amount remaining */ loff_t remain; /* Amount remaining */
loff_t file_size; /* File size returned by server */ loff_t file_size; /* File size returned by server */
struct key *key; /* The key to use to reissue the read */
afs_dataversion_t data_version; /* Version number returned by server */ afs_dataversion_t data_version; /* Version number returned by server */
refcount_t usage; refcount_t usage;
unsigned int index; /* Which page we're reading into */ unsigned int index; /* Which page we're reading into */
...@@ -1045,7 +1046,7 @@ extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *); ...@@ -1045,7 +1046,7 @@ extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *);
extern void afs_put_wb_key(struct afs_wb_key *); extern void afs_put_wb_key(struct afs_wb_key *);
extern int afs_open(struct inode *, struct file *); extern int afs_open(struct inode *, struct file *);
extern int afs_release(struct inode *, struct file *); extern int afs_release(struct inode *, struct file *);
extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *); extern int afs_fetch_data(struct afs_vnode *, struct afs_read *);
extern int afs_page_filler(void *, struct page *); extern int afs_page_filler(void *, struct page *);
extern void afs_put_read(struct afs_read *); extern void afs_put_read(struct afs_read *);
......
...@@ -25,9 +25,10 @@ int afs_set_page_dirty(struct page *page) ...@@ -25,9 +25,10 @@ int afs_set_page_dirty(struct page *page)
/* /*
* partly or wholly fill a page that's under preparation for writing * partly or wholly fill a page that's under preparation for writing
*/ */
static int afs_fill_page(struct afs_vnode *vnode, struct key *key, static int afs_fill_page(struct file *file,
loff_t pos, unsigned int len, struct page *page) loff_t pos, unsigned int len, struct page *page)
{ {
struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
struct afs_read *req; struct afs_read *req;
size_t p; size_t p;
void *data; void *data;
...@@ -49,6 +50,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key, ...@@ -49,6 +50,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
return -ENOMEM; return -ENOMEM;
refcount_set(&req->usage, 1); refcount_set(&req->usage, 1);
req->key = key_get(afs_file_key(file));
req->pos = pos; req->pos = pos;
req->len = len; req->len = len;
req->nr_pages = 1; req->nr_pages = 1;
...@@ -56,7 +58,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key, ...@@ -56,7 +58,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
req->pages[0] = page; req->pages[0] = page;
get_page(page); get_page(page);
ret = afs_fetch_data(vnode, key, req); ret = afs_fetch_data(vnode, req);
afs_put_read(req); afs_put_read(req);
if (ret < 0) { if (ret < 0) {
if (ret == -ENOENT) { if (ret == -ENOENT) {
...@@ -80,7 +82,6 @@ int afs_write_begin(struct file *file, struct address_space *mapping, ...@@ -80,7 +82,6 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
{ {
struct afs_vnode *vnode = AFS_FS_I(file_inode(file)); struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
struct page *page; struct page *page;
struct key *key = afs_file_key(file);
unsigned long priv; unsigned long priv;
unsigned f, from = pos & (PAGE_SIZE - 1); unsigned f, from = pos & (PAGE_SIZE - 1);
unsigned t, to = from + len; unsigned t, to = from + len;
...@@ -95,7 +96,7 @@ int afs_write_begin(struct file *file, struct address_space *mapping, ...@@ -95,7 +96,7 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
return -ENOMEM; return -ENOMEM;
if (!PageUptodate(page) && len != PAGE_SIZE) { if (!PageUptodate(page) && len != PAGE_SIZE) {
ret = afs_fill_page(vnode, key, pos & PAGE_MASK, PAGE_SIZE, page); ret = afs_fill_page(file, pos & PAGE_MASK, PAGE_SIZE, page);
if (ret < 0) { if (ret < 0) {
unlock_page(page); unlock_page(page);
put_page(page); put_page(page);
...@@ -163,7 +164,6 @@ int afs_write_end(struct file *file, struct address_space *mapping, ...@@ -163,7 +164,6 @@ int afs_write_end(struct file *file, struct address_space *mapping,
struct page *page, void *fsdata) struct page *page, void *fsdata)
{ {
struct afs_vnode *vnode = AFS_FS_I(file_inode(file)); struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
struct key *key = afs_file_key(file);
unsigned long priv; unsigned long priv;
unsigned int f, from = pos & (PAGE_SIZE - 1); unsigned int f, from = pos & (PAGE_SIZE - 1);
unsigned int t, to = from + copied; unsigned int t, to = from + copied;
...@@ -193,7 +193,7 @@ int afs_write_end(struct file *file, struct address_space *mapping, ...@@ -193,7 +193,7 @@ int afs_write_end(struct file *file, struct address_space *mapping,
* unmarshalling routine will take care of clearing any * unmarshalling routine will take care of clearing any
* bits that are beyond the EOF. * bits that are beyond the EOF.
*/ */
ret = afs_fill_page(vnode, key, pos + copied, ret = afs_fill_page(file, pos + copied,
len - copied, page); len - copied, page);
if (ret < 0) if (ret < 0)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment