Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 197994
b: refs/heads/master
c: f6d335c
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro committed May 21, 2010
1 parent f4ce3c2 commit 74be0e5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 37 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: 4403158ba295c8e36f6736b1bb12d0f7e1923dac
refs/heads/master: f6d335c08df48b318187a087c9c38ba3d416e115
6 changes: 1 addition & 5 deletions trunk/fs/afs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,9 @@ static struct page *afs_dir_get_page(struct inode *dir, unsigned long index,
struct key *key)
{
struct page *page;
struct file file = {
.private_data = key,
};

_enter("{%lu},%lu", dir->i_ino, index);

page = read_mapping_page(dir->i_mapping, index, &file);
page = read_cache_page(dir->i_mapping, index, afs_page_filler, key);
if (!IS_ERR(page)) {
kmap(page);
if (!PageChecked(page))
Expand Down
64 changes: 37 additions & 27 deletions trunk/fs/afs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,34 +121,19 @@ static void afs_file_readpage_read_complete(struct page *page,
#endif

/*
* AFS read page from file, directory or symlink
* read page from file, directory or symlink, given a key to use
*/
static int afs_readpage(struct file *file, struct page *page)
int afs_page_filler(void *data, struct page *page)
{
struct afs_vnode *vnode;
struct inode *inode;
struct key *key;
struct inode *inode = page->mapping->host;
struct afs_vnode *vnode = AFS_FS_I(inode);
struct key *key = data;
size_t len;
off_t offset;
int ret;

inode = page->mapping->host;

if (file) {
key = file->private_data;
ASSERT(key != NULL);
} else {
key = afs_request_key(AFS_FS_S(inode->i_sb)->volume->cell);
if (IS_ERR(key)) {
ret = PTR_ERR(key);
goto error_nokey;
}
}

_enter("{%x},{%lu},{%lu}", key_serial(key), inode->i_ino, page->index);

vnode = AFS_FS_I(inode);

BUG_ON(!PageLocked(page));

ret = -ESTALE;
Expand Down Expand Up @@ -214,31 +199,56 @@ static int afs_readpage(struct file *file, struct page *page)
unlock_page(page);
}

if (!file)
key_put(key);
_leave(" = 0");
return 0;

error:
SetPageError(page);
unlock_page(page);
if (!file)
key_put(key);
error_nokey:
_leave(" = %d", ret);
return ret;
}

/*
* read page from file, directory or symlink, given a file to nominate the key
* to be used
*/
static int afs_readpage(struct file *file, struct page *page)
{
struct key *key;
int ret;

if (file) {
key = file->private_data;
ASSERT(key != NULL);
ret = afs_page_filler(key, page);
} else {
struct inode *inode = page->mapping->host;
key = afs_request_key(AFS_FS_S(inode->i_sb)->volume->cell);
if (IS_ERR(key)) {
ret = PTR_ERR(key);
} else {
ret = afs_page_filler(key, page);
key_put(key);
}
}
return ret;
}

/*
* read a set of pages
*/
static int afs_readpages(struct file *file, struct address_space *mapping,
struct list_head *pages, unsigned nr_pages)
{
struct key *key = file->private_data;
struct afs_vnode *vnode;
int ret = 0;

_enter(",{%lu},,%d", mapping->host->i_ino, nr_pages);
_enter("{%d},{%lu},,%d",
key_serial(key), mapping->host->i_ino, nr_pages);

ASSERT(key != NULL);

vnode = AFS_FS_I(mapping->host);
if (vnode->flags & AFS_VNODE_DELETED) {
Expand Down Expand Up @@ -279,7 +289,7 @@ static int afs_readpages(struct file *file, struct address_space *mapping,
}

/* load the missing pages from the network */
ret = read_cache_pages(mapping, pages, (void *) afs_readpage, file);
ret = read_cache_pages(mapping, pages, afs_page_filler, key);

_leave(" = %d [netting]", ret);
return ret;
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/afs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ extern const struct file_operations afs_file_operations;

extern int afs_open(struct inode *, struct file *);
extern int afs_release(struct inode *, struct file *);
extern int afs_page_filler(void *, struct page *);

/*
* flock.c
Expand Down
6 changes: 2 additions & 4 deletions trunk/fs/afs/mntpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ static unsigned long afs_mntpt_expiry_timeout = 10 * 60;
*/
int afs_mntpt_check_symlink(struct afs_vnode *vnode, struct key *key)
{
struct file file = {
.private_data = key,
};
struct page *page;
size_t size;
char *buf;
Expand All @@ -61,7 +58,8 @@ int afs_mntpt_check_symlink(struct afs_vnode *vnode, struct key *key)
vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique);

/* read the contents of the symlink into the pagecache */
page = read_mapping_page(AFS_VNODE_TO_I(vnode)->i_mapping, 0, &file);
page = read_cache_page(AFS_VNODE_TO_I(vnode)->i_mapping, 0,
afs_page_filler, key);
if (IS_ERR(page)) {
ret = PTR_ERR(page);
goto out;
Expand Down

0 comments on commit 74be0e5

Please sign in to comment.