[PATCH v2 3/3] vfs: use the new debug macros in inode_set_cached_link()

Mateusz Guzik posted 3 patches 10 months, 1 week ago
There is a newer version of this series
[PATCH v2 3/3] vfs: use the new debug macros in inode_set_cached_link()
Posted by Mateusz Guzik 10 months, 1 week ago
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
 include/linux/fs.h | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 034745af9702..e71d58c7f59c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -792,19 +792,8 @@ struct inode {
 
 static inline void inode_set_cached_link(struct inode *inode, char *link, int linklen)
 {
-	int testlen;
-
-	/*
-	 * TODO: patch it into a debug-only check if relevant macros show up.
-	 * In the meantime, since we are suffering strlen even on production kernels
-	 * to find the right length, do a fixup if the wrong value got passed.
-	 */
-	testlen = strlen(link);
-	if (testlen != linklen) {
-		WARN_ONCE(1, "bad length passed for symlink [%s] (got %d, expected %d)",
-			  link, linklen, testlen);
-		linklen = testlen;
-	}
+	VFS_WARN_ON_INODE(strlen(link) != linklen, inode);
+	VFS_WARN_ON_INODE(inode->i_opflags & IOP_CACHED_LINK, inode);
 	inode->i_link = link;
 	inode->i_linklen = linklen;
 	inode->i_opflags |= IOP_CACHED_LINK;
-- 
2.43.0
Re: [PATCH v2 3/3] vfs: use the new debug macros in inode_set_cached_link()
Posted by Jan Kara 10 months, 1 week ago
On Thu 06-02-25 18:03:07, Mateusz Guzik wrote:
> Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  include/linux/fs.h | 15 ++-------------
>  1 file changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 034745af9702..e71d58c7f59c 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -792,19 +792,8 @@ struct inode {
>  
>  static inline void inode_set_cached_link(struct inode *inode, char *link, int linklen)
>  {
> -	int testlen;
> -
> -	/*
> -	 * TODO: patch it into a debug-only check if relevant macros show up.
> -	 * In the meantime, since we are suffering strlen even on production kernels
> -	 * to find the right length, do a fixup if the wrong value got passed.
> -	 */
> -	testlen = strlen(link);
> -	if (testlen != linklen) {
> -		WARN_ONCE(1, "bad length passed for symlink [%s] (got %d, expected %d)",
> -			  link, linklen, testlen);
> -		linklen = testlen;
> -	}
> +	VFS_WARN_ON_INODE(strlen(link) != linklen, inode);
> +	VFS_WARN_ON_INODE(inode->i_opflags & IOP_CACHED_LINK, inode);
>  	inode->i_link = link;
>  	inode->i_linklen = linklen;
>  	inode->i_opflags |= IOP_CACHED_LINK;
> -- 
> 2.43.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR