Skip to content

Commit 75bd228

Browse files
committed
afs: Sort out symlink reading
afs_readpage() doesn't get a file pointer when called for a symlink, so separate it from regular file pointer handling. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Link: https://lore.kernel.org/r/162687508008.276387.6418924257569297305.stgit@warthog.procyon.org.uk/ # rfc Link: https://lore.kernel.org/r/162981152280.1901565.2264055504466731917.stgit@warthog.procyon.org.uk/ Link: https://lore.kernel.org/r/163005742570.2472992.7800423440314043178.stgit@warthog.procyon.org.uk/ # v2
1 parent 8bb7eca commit 75bd228

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

fs/afs/file.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
static int afs_file_mmap(struct file *file, struct vm_area_struct *vma);
2121
static int afs_readpage(struct file *file, struct page *page);
22+
static int afs_symlink_readpage(struct file *file, struct page *page);
2223
static void afs_invalidatepage(struct page *page, unsigned int offset,
2324
unsigned int length);
2425
static int afs_releasepage(struct page *page, gfp_t gfp_flags);
@@ -49,7 +50,7 @@ const struct inode_operations afs_file_inode_operations = {
4950
.permission = afs_permission,
5051
};
5152

52-
const struct address_space_operations afs_fs_aops = {
53+
const struct address_space_operations afs_file_aops = {
5354
.readpage = afs_readpage,
5455
.readahead = afs_readahead,
5556
.set_page_dirty = afs_set_page_dirty,
@@ -62,6 +63,12 @@ const struct address_space_operations afs_fs_aops = {
6263
.writepages = afs_writepages,
6364
};
6465

66+
const struct address_space_operations afs_symlink_aops = {
67+
.readpage = afs_symlink_readpage,
68+
.releasepage = afs_releasepage,
69+
.invalidatepage = afs_invalidatepage,
70+
};
71+
6572
static const struct vm_operations_struct afs_vm_ops = {
6673
.open = afs_vm_open,
6774
.close = afs_vm_close,
@@ -313,7 +320,7 @@ static void afs_req_issue_op(struct netfs_read_subrequest *subreq)
313320
afs_put_read(fsreq);
314321
}
315322

316-
static int afs_symlink_readpage(struct page *page)
323+
static int afs_symlink_readpage(struct file *file, struct page *page)
317324
{
318325
struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
319326
struct afs_read *fsreq;
@@ -378,9 +385,6 @@ const struct netfs_read_request_ops afs_req_ops = {
378385

379386
static int afs_readpage(struct file *file, struct page *page)
380387
{
381-
if (!file)
382-
return afs_symlink_readpage(page);
383-
384388
return netfs_readpage(file, page, &afs_req_ops, NULL);
385389
}
386390

fs/afs/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int afs_inode_init_from_status(struct afs_operation *op,
9595
inode->i_mode = S_IFREG | (status->mode & S_IALLUGO);
9696
inode->i_op = &afs_file_inode_operations;
9797
inode->i_fop = &afs_file_operations;
98-
inode->i_mapping->a_ops = &afs_fs_aops;
98+
inode->i_mapping->a_ops = &afs_file_aops;
9999
break;
100100
case AFS_FTYPE_DIR:
101101
inode->i_mode = S_IFDIR | (status->mode & S_IALLUGO);
@@ -113,11 +113,11 @@ static int afs_inode_init_from_status(struct afs_operation *op,
113113
inode->i_mode = S_IFDIR | 0555;
114114
inode->i_op = &afs_mntpt_inode_operations;
115115
inode->i_fop = &afs_mntpt_file_operations;
116-
inode->i_mapping->a_ops = &afs_fs_aops;
116+
inode->i_mapping->a_ops = &afs_symlink_aops;
117117
} else {
118118
inode->i_mode = S_IFLNK | status->mode;
119119
inode->i_op = &afs_symlink_inode_operations;
120-
inode->i_mapping->a_ops = &afs_fs_aops;
120+
inode->i_mapping->a_ops = &afs_symlink_aops;
121121
}
122122
inode_nohighmem(inode);
123123
break;

fs/afs/internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,8 @@ extern void afs_dynroot_depopulate(struct super_block *);
10551055
/*
10561056
* file.c
10571057
*/
1058-
extern const struct address_space_operations afs_fs_aops;
1058+
extern const struct address_space_operations afs_file_aops;
1059+
extern const struct address_space_operations afs_symlink_aops;
10591060
extern const struct inode_operations afs_file_inode_operations;
10601061
extern const struct file_operations afs_file_operations;
10611062
extern const struct netfs_read_request_ops afs_req_ops;

0 commit comments

Comments
 (0)