Subject: Re: linux-next: build failure after merge of the vfs tree

From: Stephen Rothwell <[email-masked]>
Date: Wed, 13 May 2015 12:26:42 +1000

Hi all,

On Mon, 11 May 2015 11:26:12 +1000 Stephen Rothwell <[email-masked]> wrote:
>
> After merging the vfs tree, today's linux-next build (x86_64
> allmodconfig) failed like this:
> 
> fs/f2fs/namei.c: In function 'f2fs_encrypted_follow_link':
> fs/f2fs/namei.c:336:10: warning: passing argument 2 of 'f2fs_follow_link' from incompatible pointer type
>    return f2fs_follow_link(dentry, nd);
>           ^
> fs/f2fs/namei.c:311:20: note: expected 'void **' but argument is of type 'struct nameidata *'
>  static const char *f2fs_follow_link(struct dentry *dentry, void **cookie)
>                     ^
> fs/f2fs/namei.c:336:3: warning: return discards 'const' qualifier from pointer target type
>    return f2fs_follow_link(dentry, nd);
>    ^
> fs/f2fs/namei.c:379:2: error: implicit declaration of function 'nd_set_link' [-Werror=implicit-function-declaration]
>   nd_set_link(nd, paddr);
>   ^
> fs/f2fs/namei.c: In function 'f2fs_encrypted_put_link':
> fs/f2fs/namei.c:400:3: error: implicit declaration of function 'nd_get_link' [-Werror=implicit-function-declaration]
>    kfree(nd_get_link(nd));
>    ^
> fs/f2fs/namei.c:400:3: warning: passing argument 1 of 'kfree' makes pointer from integer without a cast
> In file included from fs/f2fs/f2fs.h:17:0,
>                  from fs/f2fs/namei.c:19:
> include/linux/slab.h:143:6: note: expected 'const void *' but argument is of type 'int'
>  void kfree(const void *);
>       ^
> fs/f2fs/namei.c: At top level:
> fs/f2fs/namei.c:960:2: warning: initialization from incompatible pointer type
>   .follow_link    = f2fs_encrypted_follow_link,
>   ^
> fs/f2fs/namei.c:960:2: warning: (near initialization for 'f2fs_symlink_inode_operations.follow_link')
> fs/f2fs/namei.c:961:2: warning: initialization from incompatible pointer type
>   .put_link       = f2fs_encrypted_put_link,
>   ^
> fs/f2fs/namei.c:961:2: warning: (near initialization for 'f2fs_symlink_inode_operations.put_link')
> 
> Caused by commits cf41cea5a829 ("new ->follow_link() and ->put_link()
> calling conventions") and 0ad7e33ea980 ("don't pass nameidata to
> ->follow_link()") from teh vfs tree interacting with commit
> 5270e98c341b ("f2fs crypto: add symlink encryption") from the f2fs tree.
> 
> I applied the following merge fix patch (which I suspect is not
> completely correct - especially the f2fs_encrypted_put_link part):
> 
> From: Stephen Rothwell <[email-masked]>
> Date: Mon, 11 May 2015 11:22:19 +1000
> Subject: [PATCH] f2fs: merge fix for follow_link and put_link changes
> 
> Signed-off-by: Stephen Rothwell <[email-masked]>
> ---
>  fs/f2fs/namei.c | 18 +++++++-----------
>  1 file changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index d7ed99ebe95b..42af89cdb9a4 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -320,8 +320,8 @@ static const char *f2fs_follow_link(struct dentry *dentry, void **cookie)
>  }
>  
>  #ifdef CONFIG_F2FS_FS_ENCRYPTION
> -static void *f2fs_encrypted_follow_link(struct dentry *dentry,
> -						struct nameidata *nd)
> +static const char *f2fs_encrypted_follow_link(struct dentry *dentry,
> +					void **cookie)
>  {
>  	struct page *cpage = NULL;
>  	char *caddr, *paddr = NULL;
> @@ -333,7 +333,7 @@ static void *f2fs_encrypted_follow_link(struct dentry *dentry,
>  	u32 max_size = inode->i_sb->s_blocksize;
>  
>  	if (!f2fs_encrypted_inode(inode))
> -		return f2fs_follow_link(dentry, nd);
> +		return f2fs_follow_link(dentry, cookie);
>  
>  	res = f2fs_setup_fname_crypto(inode);
>  	if (res)
> @@ -341,7 +341,7 @@ static void *f2fs_encrypted_follow_link(struct dentry *dentry,
>  
>  	cpage = read_mapping_page(inode->i_mapping, 0, NULL);
>  	if (IS_ERR(cpage))
> -		return cpage;
> +		return ERR_CAST(cpage);
>  	caddr = kmap(cpage);
>  	caddr[size] = 0;
>  
> @@ -376,12 +376,11 @@ static void *f2fs_encrypted_follow_link(struct dentry *dentry,
>  	/* Null-terminate the name */
>  	if (res <= cstr.len)
>  		paddr[res] = '\0';
> -	nd_set_link(nd, paddr);
>  	if (cpage) {
>  		kunmap(cpage);
>  		page_cache_release(cpage);
>  	}
> -	return NULL;
> +	return *cookie = paddr;
>  errout:
>  	if (cpage) {
>  		kunmap(cpage);
> @@ -391,14 +390,11 @@ errout:
>  	return ERR_PTR(res);
>  }
>  
> -static void f2fs_encrypted_put_link(struct dentry *dentry, struct nameidata *nd,
> -			  void *cookie)
> +static void f2fs_encrypted_put_link(struct dentry *dentry, void *cookie)
>  {
>  	struct page *page = cookie;
>  
> -	if (!page) {
> -		kfree(nd_get_link(nd));
> -	} else {
> +	if (page) {
>  		kunmap(page);
>  		page_cache_release(page);
>  	}
> -- 
> 2.1.4

This merge fix patch is now:

From: Stephen Rothwell <[email-masked]>
Date: Wed, 13 May 2015 11:03:18 +1000
Subject: [PATCH] f2fs: merge fix for follow_link changes

Signed-off-by: Stephen Rothwell <[email-masked]>
---
 fs/f2fs/namei.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index d58df3630b9c..9f7adba1893b 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -859,8 +859,8 @@ out:
 }
 
 #ifdef CONFIG_F2FS_FS_ENCRYPTION
-static void *f2fs_encrypted_follow_link(struct dentry *dentry,
-						struct nameidata *nd)
+static const char *f2fs_encrypted_follow_link(struct dentry *dentry,
+						void **cookie)
 {
 	struct page *cpage = NULL;
 	char *caddr, *paddr = NULL;
@@ -878,7 +878,7 @@ static void *f2fs_encrypted_follow_link(struct dentry *dentry,
 
 	cpage = read_mapping_page(inode->i_mapping, 0, NULL);
 	if (IS_ERR(cpage))
-		return cpage;
+		return ERR_CAST(cpage);
 	caddr = kmap(cpage);
 	caddr[size] = 0;
 
@@ -912,11 +912,10 @@ static void *f2fs_encrypted_follow_link(struct dentry *dentry,
 	/* Null-terminate the name */
 	if (res <= cstr.len)
 		paddr[res] = '\0';
-	nd_set_link(nd, paddr);
 
 	kunmap(cpage);
 	page_cache_release(cpage);
-	return NULL;
+	return *cookie = paddr;
 errout:
 	f2fs_fname_crypto_free_buffer(&pstr);
 	kunmap(cpage);
-- 
2.1.4

-- 
Cheers,
Stephen Rothwell                    [email-masked]