From 6a6c99049635473b64c384135a6906a10df2c916 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 17 Nov 2015 10:54:32 -0500 Subject: teach shmem_get_link() to work in RCU mode Signed-off-by: Al Viro --- mm/shmem.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'mm/shmem.c') diff --git a/mm/shmem.c b/mm/shmem.c index 684dbc32e233..0605716aee06 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2501,12 +2501,20 @@ static const char *shmem_get_link(struct dentry *dentry, { struct page *page = NULL; int error; - if (!dentry) - return ERR_PTR(-ECHILD); - error = shmem_getpage(inode, 0, &page, SGP_READ, NULL); - if (error) - return ERR_PTR(error); - unlock_page(page); + if (!dentry) { + page = find_get_page(inode->i_mapping, 0); + if (!page) + return ERR_PTR(-ECHILD); + if (!PageUptodate(page)) { + put_page(page); + return ERR_PTR(-ECHILD); + } + } else { + error = shmem_getpage(inode, 0, &page, SGP_READ, NULL); + if (error) + return ERR_PTR(error); + unlock_page(page); + } *cookie = page; return page_address(page); } -- cgit v1.2.3