Skip to content

Commit c69bf47

Browse files
committed
1 parent f015cf1 commit c69bf47

4 files changed

Lines changed: 19 additions & 15 deletions

File tree

fs/afs/dir.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)
241241
return ERR_PTR(-ENOMEM);
242242

243243
refcount_set(&req->usage, 1);
244+
req->key = key_get(key);
244245
req->nr_pages = nr_pages;
245246
req->actual_len = i_size; /* May change */
246247
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)
305306

306307
if (!test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) {
307308
trace_afs_reload_dir(dvnode);
308-
ret = afs_fetch_data(dvnode, key, req);
309+
ret = afs_fetch_data(dvnode, req);
309310
if (ret < 0)
310311
goto error_unlock;
311312

fs/afs/file.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ void afs_put_read(struct afs_read *req)
198198
if (req->pages != req->array)
199199
kfree(req->pages);
200200
}
201+
key_put(req->key);
201202
kfree(req);
202203
}
203204
}
@@ -228,7 +229,7 @@ static const struct afs_operation_ops afs_fetch_data_operation = {
228229
/*
229230
* Fetch file data from the volume.
230231
*/
231-
int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *req)
232+
int afs_fetch_data(struct afs_vnode *vnode, struct afs_read *req)
232233
{
233234
struct afs_operation *op;
234235

@@ -237,9 +238,9 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *re
237238
vnode->fid.vid,
238239
vnode->fid.vnode,
239240
vnode->fid.unique,
240-
key_serial(key));
241+
key_serial(req->key));
241242

242-
op = afs_alloc_operation(key, vnode->volume);
243+
op = afs_alloc_operation(req->key, vnode->volume);
243244
if (IS_ERR(op))
244245
return PTR_ERR(op);
245246

@@ -278,6 +279,7 @@ int afs_page_filler(void *data, struct page *page)
278279
* unmarshalling code will clear the unfilled space.
279280
*/
280281
refcount_set(&req->usage, 1);
282+
req->key = key_get(key);
281283
req->pos = (loff_t)page->index << PAGE_SHIFT;
282284
req->len = PAGE_SIZE;
283285
req->nr_pages = 1;
@@ -287,7 +289,7 @@ int afs_page_filler(void *data, struct page *page)
287289

288290
/* read the contents of the file from the server into the
289291
* page */
290-
ret = afs_fetch_data(vnode, key, req);
292+
ret = afs_fetch_data(vnode, req);
291293
afs_put_read(req);
292294

293295
if (ret < 0) {
@@ -372,7 +374,6 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
372374
struct afs_read *req;
373375
struct list_head *p;
374376
struct page *first, *page;
375-
struct key *key = afs_file_key(file);
376377
pgoff_t index;
377378
int ret, n, i;
378379

@@ -396,6 +397,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
396397

397398
refcount_set(&req->usage, 1);
398399
req->vnode = vnode;
400+
req->key = key_get(afs_file_key(file));
399401
req->page_done = afs_readpages_page_done;
400402
req->pos = first->index;
401403
req->pos <<= PAGE_SHIFT;
@@ -425,11 +427,11 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
425427
} while (req->nr_pages < n);
426428

427429
if (req->nr_pages == 0) {
428-
kfree(req);
430+
afs_put_read(req);
429431
return 0;
430432
}
431433

432-
ret = afs_fetch_data(vnode, key, req);
434+
ret = afs_fetch_data(vnode, req);
433435
if (ret < 0)
434436
goto error;
435437

fs/afs/internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ struct afs_read {
204204
loff_t actual_len; /* How much we're actually getting */
205205
loff_t remain; /* Amount remaining */
206206
loff_t file_size; /* File size returned by server */
207+
struct key *key; /* The key to use to reissue the read */
207208
afs_dataversion_t data_version; /* Version number returned by server */
208209
refcount_t usage;
209210
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 *);
10451046
extern void afs_put_wb_key(struct afs_wb_key *);
10461047
extern int afs_open(struct inode *, struct file *);
10471048
extern int afs_release(struct inode *, struct file *);
1048-
extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *);
1049+
extern int afs_fetch_data(struct afs_vnode *, struct afs_read *);
10491050
extern int afs_page_filler(void *, struct page *);
10501051
extern void afs_put_read(struct afs_read *);
10511052

fs/afs/write.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ int afs_set_page_dirty(struct page *page)
2525
/*
2626
* partly or wholly fill a page that's under preparation for writing
2727
*/
28-
static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
28+
static int afs_fill_page(struct file *file,
2929
loff_t pos, unsigned int len, struct page *page)
3030
{
31+
struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
3132
struct afs_read *req;
3233
size_t p;
3334
void *data;
@@ -49,14 +50,15 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
4950
return -ENOMEM;
5051

5152
refcount_set(&req->usage, 1);
53+
req->key = key_get(afs_file_key(file));
5254
req->pos = pos;
5355
req->len = len;
5456
req->nr_pages = 1;
5557
req->pages = req->array;
5658
req->pages[0] = page;
5759
get_page(page);
5860

59-
ret = afs_fetch_data(vnode, key, req);
61+
ret = afs_fetch_data(vnode, req);
6062
afs_put_read(req);
6163
if (ret < 0) {
6264
if (ret == -ENOENT) {
@@ -80,7 +82,6 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
8082
{
8183
struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
8284
struct page *page;
83-
struct key *key = afs_file_key(file);
8485
unsigned long priv;
8586
unsigned f, from = pos & (PAGE_SIZE - 1);
8687
unsigned t, to = from + len;
@@ -95,7 +96,7 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
9596
return -ENOMEM;
9697

9798
if (!PageUptodate(page) && len != PAGE_SIZE) {
98-
ret = afs_fill_page(vnode, key, pos & PAGE_MASK, PAGE_SIZE, page);
99+
ret = afs_fill_page(file, pos & PAGE_MASK, PAGE_SIZE, page);
99100
if (ret < 0) {
100101
unlock_page(page);
101102
put_page(page);
@@ -163,7 +164,6 @@ int afs_write_end(struct file *file, struct address_space *mapping,
163164
struct page *page, void *fsdata)
164165
{
165166
struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
166-
struct key *key = afs_file_key(file);
167167
unsigned long priv;
168168
unsigned int f, from = pos & (PAGE_SIZE - 1);
169169
unsigned int t, to = from + copied;
@@ -193,7 +193,7 @@ int afs_write_end(struct file *file, struct address_space *mapping,
193193
* unmarshalling routine will take care of clearing any
194194
* bits that are beyond the EOF.
195195
*/
196-
ret = afs_fill_page(vnode, key, pos + copied,
196+
ret = afs_fill_page(file, pos + copied,
197197
len - copied, page);
198198
if (ret < 0)
199199
goto out;

0 commit comments

Comments
 (0)