diff options
author | David Howells <dhowells@redhat.com> | 2017-11-02 18:27:52 +0300 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2017-11-13 18:38:20 +0300 |
commit | 215804a99283c57fdd869aab350fdf6acc3460b6 (patch) | |
tree | a06a57ba4b15decbd079c0f9d17ca964280d570c /fs/afs/file.c | |
parent | 83732ec5146916bd49b3036b0ea7dedb7831b90e (diff) | |
download | linux-215804a99283c57fdd869aab350fdf6acc3460b6.tar.xz |
afs: Introduce a file-private data record
Introduce a file-private data record for kAFS and put the key into it
rather than storing the key in file->private_data.
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/afs/file.c')
-rw-r--r-- | fs/afs/file.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/fs/afs/file.c b/fs/afs/file.c index 5786f68f87f1..e33b34f01795 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -68,6 +68,7 @@ const struct address_space_operations afs_fs_aops = { int afs_open(struct inode *inode, struct file *file) { struct afs_vnode *vnode = AFS_FS_I(inode); + struct afs_file *af; struct key *key; int ret; @@ -75,19 +76,32 @@ int afs_open(struct inode *inode, struct file *file) key = afs_request_key(vnode->volume->cell); if (IS_ERR(key)) { - _leave(" = %ld [key]", PTR_ERR(key)); - return PTR_ERR(key); + ret = PTR_ERR(key); + goto error; } - ret = afs_validate(vnode, key); - if (ret < 0) { - _leave(" = %d [val]", ret); - return ret; + af = kzalloc(sizeof(*af), GFP_KERNEL); + if (!af) { + ret = -ENOMEM; + goto error_key; } - file->private_data = key; + ret = afs_validate(vnode, key); + if (ret < 0) + goto error_af; + + af->key = key; + file->private_data = af; _leave(" = 0"); return 0; + +error_af: + kfree(af); +error_key: + key_put(key); +error: + _leave(" = %d", ret); + return ret; } /* @@ -96,10 +110,13 @@ int afs_open(struct inode *inode, struct file *file) int afs_release(struct inode *inode, struct file *file) { struct afs_vnode *vnode = AFS_FS_I(inode); + struct afs_file *af = file->private_data; _enter("{%x:%u},", vnode->fid.vid, vnode->fid.vnode); - key_put(file->private_data); + file->private_data = NULL; + key_put(af->key); + kfree(af); _leave(" = 0"); return 0; } @@ -295,7 +312,7 @@ static int afs_readpage(struct file *file, struct page *page) int ret; if (file) { - key = file->private_data; + key = afs_file_key(file); ASSERT(key != NULL); ret = afs_page_filler(key, page); } else { @@ -346,7 +363,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping, struct afs_read *req; struct list_head *p; struct page *first, *page; - struct key *key = file->private_data; + struct key *key = afs_file_key(file); pgoff_t index; int ret, n, i; @@ -442,7 +459,7 @@ error: 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 key *key = afs_file_key(file); struct afs_vnode *vnode; int ret = 0; |