fix static linking of NFS
PATCH 1/1 fix static linking of NFS
Hi,
This patch solved the problem where certain functions in the NFS code goes missing due to the __exit section being discarded for static links.
I saw one other version of this patch from David Brownell, but it had clutter left on the lines where the __exit should simply be removed.
Cheers,
Jes
Remove __exit declarations from functions called from __init code to avoid link errors when the __exit section is discarded, eg NFS is linked statically into the kernel.
--- fs/nfs/direct.c | 2 +- fs/nfs/inode.c | 2 +- fs/nfs/pagelist.c | 2 +- fs/nfs/read.c | 2 +- fs/nfs/write.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
fs/nfs/direct.c +1 -1
@@ -909,7 +909,7 @@ int __init nfs_init_directcache(void)* nfs_destroy_directcache - destroy the slab cache for nfs_direct_req structures * */ -void __exit nfs_destroy_directcache(void) +void nfs_destroy_directcache (void ) {if (kmem_cache_destroy (nfs_direct_cachep))printk (KERN_INFO "nfs_direct_cache: not all structures were freed\n" );
fs/nfs/inode.c +1 -1
@@ -1132,7 +1132,7 @@ static int __init nfs_init_inodecache(voreturn 0 ; } -static void __exit nfs_destroy_inodecache(void) +static void nfs_destroy_inodecache (void ) {if (kmem_cache_destroy (nfs_inode_cachep))printk (KERN_INFO "nfs_inode_cache: not all structures were freed\n" );
fs/nfs/pagelist.c +1 -1
@@ -390,7 +390,7 @@ int __init nfs_init_nfspagecache(void)return 0 ; } -void __exit nfs_destroy_nfspagecache(void) +void nfs_destroy_nfspagecache (void ) {if (kmem_cache_destroy (nfs_page_cachep))printk (KERN_INFO "nfs_page: not all structures were freed\n" );
fs/nfs/read.c +1 -1
@@ -711,7 +711,7 @@ int __init nfs_init_readpagecache(void)return 0 ; } -void __exit nfs_destroy_readpagecache(void) +void nfs_destroy_readpagecache (void ) {mempool_destroy (nfs_rdata_mempool);if (kmem_cache_destroy (nfs_rdata_cachep))
fs/nfs/write.c +1 -1
@@ -1551,7 +1551,7 @@ int __init nfs_init_writepagecache(void)return 0 ; } -void __exit nfs_destroy_writepagecache(void) +void nfs_destroy_writepagecache (void ) {mempool_destroy (nfs_commit_mempool);mempool_destroy (nfs_wdata_mempool);
Quoted 9 lines · Jes Sorensen
Hi,
This patch solved the problem where certain functions in the NFS code goes missing due to the
__exitsection being discarded for static links.I saw one other version of this patch from David Brownell, but it had clutter left on the lines where the
__exitshould simply be removed.
Quoted 8 lines
Cheers,
JesRemove
__exitdeclarations from functions called from__initcode to avoid link errors when the__exitsection is discarded, eg NFS is linked statically into the kernel.Signed-off-by Jes Sorensen <[email protected]>
Cheers,
Trond
Quoted 78 lines
--- fs/nfs/direct.c | 2 +- fs/nfs/inode.c | 2 +- fs/nfs/pagelist.c | 2 +- fs/nfs/read.c | 2 +- fs/nfs/write.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)Index:
linux-2.6/fs/nfs/direct.c
===================================================================fs/nfs/direct.c +1
-1@@ -909,7 +909,7 @@ int __init nfs_init_directcache(void)* nfs_destroy_directcache - destroy the slab cache for nfs_direct_req structures * */ -void __exit nfs_destroy_directcache(void) +void nfs_destroy_directcache (void ) {if (kmem_cache_destroy (nfs_direct_cachep))printk (KERN_INFO "nfs_direct_cache: not all structures were freed\n" );Index:
linux-2.6/fs/nfs/inode.c
===================================================================fs/nfs/inode.c +1
-1@@ -1132,7 +1132,7 @@ static int __init nfs_init_inodecache(voreturn 0 ; } -static void __exit nfs_destroy_inodecache(void) +static void nfs_destroy_inodecache (void ) {if (kmem_cache_destroy (nfs_inode_cachep))printk (KERN_INFO "nfs_inode_cache: not all structures were freed\n" );Index:
linux-2.6/fs/nfs/pagelist.c
===================================================================fs/nfs/pagelist.c +1
-1@@ -390,7 +390,7 @@ int __init nfs_init_nfspagecache(void)return 0 ; } -void __exit nfs_destroy_nfspagecache(void) +void nfs_destroy_nfspagecache (void ) {if (kmem_cache_destroy (nfs_page_cachep))printk (KERN_INFO "nfs_page: not all structures were freed\n" );Index:
linux-2.6/fs/nfs/read.c
===================================================================fs/nfs/read.c +1
-1@@ -711,7 +711,7 @@ int __init nfs_init_readpagecache(void)return 0 ; } -void __exit nfs_destroy_readpagecache(void) +void nfs_destroy_readpagecache (void ) {mempool_destroy (nfs_rdata_mempool);if (kmem_cache_destroy (nfs_rdata_cachep))Index:
linux-2.6/fs/nfs/write.c
===================================================================fs/nfs/write.c +1
-2@@ -1551,7 +1551,7 @@ int __init nfs_init_writepagecache(void)return 0 ; } -void __exit nfs_destroy_writepagecache(void) +void nfs_destroy_writepagecache (void ) {mempool_destroy (nfs_commit_mempool);mempool_destroy (nfs_wdata_mempool); -To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 13 lines · Trond Myklebust
Quoted 12 lines · Jes Sorensen
Hi,
This patch solved the problem where certain functions in the NFS code goes missing due to the
__exitsection being discarded for static links.I saw one other version of this patch from David Brownell, but it had clutter left on the lines where the
__exitshould simply be removed.Cheers,
Jes
Quoted 6 lines
Quoted 5 lines
Remove
__exitdeclarations from functions called from__initcode to avoid link errors when the__exitsection is discarded, eg NFS is linked statically into the kernel.Signed-off-by Jes Sorensen <[email protected]>Acked-by Trond Myklebust <[email protected]>
Oops... I was a bit too quick there. Could you clean up the forward declarations in "internal.h" too, please.
Cheers,
Trond
Quoted 88 lines
Cheers,
TrondQuoted 74 lines
--- fs/nfs/direct.c | 2 +- fs/nfs/inode.c | 2 +- fs/nfs/pagelist.c | 2 +- fs/nfs/read.c | 2 +- fs/nfs/write.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)Index:
linux-2.6/fs/nfs/direct.c
===================================================================fs/nfs/direct.c +1
-1@@ -909,7 +909,7 @@ int __init nfs_init_directcache(void)* nfs_destroy_directcache - destroy the slab cache for nfs_direct_req structures * */ -void __exit nfs_destroy_directcache(void) +void nfs_destroy_directcache (void ) {if (kmem_cache_destroy (nfs_direct_cachep))printk (KERN_INFO "nfs_direct_cache: not all structures were freed\n" );Index:
linux-2.6/fs/nfs/inode.c
===================================================================fs/nfs/inode.c +1
-1@@ -1132,7 +1132,7 @@ static int __init nfs_init_inodecache(voreturn 0 ; } -static void __exit nfs_destroy_inodecache(void) +static void nfs_destroy_inodecache (void ) {if (kmem_cache_destroy (nfs_inode_cachep))printk (KERN_INFO "nfs_inode_cache: not all structures were freed\n" );Index:
linux-2.6/fs/nfs/pagelist.c
===================================================================fs/nfs/pagelist.c +1
-1@@ -390,7 +390,7 @@ int __init nfs_init_nfspagecache(void)return 0 ; } -void __exit nfs_destroy_nfspagecache(void) +void nfs_destroy_nfspagecache (void ) {if (kmem_cache_destroy (nfs_page_cachep))printk (KERN_INFO "nfs_page: not all structures were freed\n" );Index:
linux-2.6/fs/nfs/read.c
===================================================================fs/nfs/read.c +1
-1@@ -711,7 +711,7 @@ int __init nfs_init_readpagecache(void)return 0 ; } -void __exit nfs_destroy_readpagecache(void) +void nfs_destroy_readpagecache (void ) {mempool_destroy (nfs_rdata_mempool);if (kmem_cache_destroy (nfs_rdata_cachep))Index:
linux-2.6/fs/nfs/write.c
===================================================================fs/nfs/write.c +1
-2@@ -1551,7 +1551,7 @@ int __init nfs_init_writepagecache(void)return 0 ; } -void __exit nfs_destroy_writepagecache(void) +void nfs_destroy_writepagecache (void ) {mempool_destroy (nfs_commit_mempool);mempool_destroy (nfs_wdata_mempool); -Quoted 4 lines
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 5 lines · Trond Myklebust
Quoted 4 lines · Trond Myklebust
Quoted 4 lines
Remove
__exitdeclarations from functions called from__initcode to avoid link errors when the__exitsection is discarded, eg NFS is linked statically into the kernel.
Quoted 8 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Jes Sorensen <[email protected]>Acked-by Trond Myklebust <[email protected]>Oops... I was a bit too quick there. Could you clean up the forward declarations in "
internal.h" too, please.Cheers,
Trond
Good point, I didn't notice those because the compiler didn't moan. I'll look into doing another patch, but it might not be until Thursday.
Cheers,
Jes
OK here's a version of my patch that I edited to remove the comments Jes objected to ... /* init or exit */ to remind about the omitted section annotation. Having one of those would save multiple kbytes throughout the kernel, and I had include the comments as reminders for an eventual fix...
- Dave
Quoted 8 lines · David Brownell
OK here's a version of my patch that I edited to remove the comments Jes objected to ... /* init or exit */ to remind about the omitted section annotation. Having one of those would save multiple kbytes throughout the kernel, and I had include the comments as reminders for an eventual fix...
- Dave
Once more, with patch.
Builds on ARM report link problems with common configurations like statically linked NFS (for nfsroot). The symptom is that __init section code references __exit section code; that won't work since the exit sections are discarded (since they can never be called).
The best fix for these particular cases would be an "__init_or_exit" section annotation.
fs/nfs/direct.c +1 -1
@@ -909,7 +909,7 @@ int __init nfs_init_directcache(void)* nfs_destroy_directcache - destroy the slab cache for nfs_direct_req structures * */ -void __exit nfs_destroy_directcache(void) +void nfs_destroy_directcache (void ) {if (kmem_cache_destroy (nfs_direct_cachep))printk (KERN_INFO "nfs_direct_cache: not all structures were freed\n" );
fs/nfs/inode.c +1 -1
@@ -1132,7 +1132,7 @@ static int __init nfs_init_inodecache(voreturn 0 ; } -static void __exit nfs_destroy_inodecache(void) +static void nfs_destroy_inodecache (void ) {if (kmem_cache_destroy (nfs_inode_cachep))printk (KERN_INFO "nfs_inode_cache: not all structures were freed\n" );
fs/nfs/internal.h +4 -4
@@ -31,15 +31,15 @@ extern struct svc_version nfs4_callback_/* pagelist.c */ extern int __init nfs_init_nfspagecache (void ); -extern void __exit nfs_destroy_nfspagecache(void); +extern void nfs_destroy_nfspagecache (void );extern int __init nfs_init_readpagecache (void ); -extern void __exit nfs_destroy_readpagecache(void); +extern void nfs_destroy_readpagecache (void );extern int __init nfs_init_writepagecache (void ); -extern void __exit nfs_destroy_writepagecache(void); +extern void nfs_destroy_writepagecache (void );#ifdef CONFIG_NFS_DIRECTIO extern int __init nfs_init_directcache (void ); -extern void __exit nfs_destroy_directcache(void); +extern void nfs_destroy_directcache (void );#else #define nfs_init_directcache () (0)#define nfs_destroy_directcache () do {} while(0)
fs/nfs/pagelist.c +1 -1
@@ -390,7 +390,7 @@ int __init nfs_init_nfspagecache(void)return 0 ; } -void __exit nfs_destroy_nfspagecache(void) +void nfs_destroy_nfspagecache (void ) {if (kmem_cache_destroy (nfs_page_cachep))printk (KERN_INFO "nfs_page: not all structures were freed\n" );
fs/nfs/read.c +1 -1
@@ -711,7 +711,7 @@ int __init nfs_init_readpagecache(void)return 0 ; } -void __exit nfs_destroy_readpagecache(void) +void nfs_destroy_readpagecache (void ) {mempool_destroy (nfs_rdata_mempool);if (kmem_cache_destroy (nfs_rdata_cachep))
fs/nfs/write.c +1 -1
@@ -1551,7 +1551,7 @@ int __init nfs_init_writepagecache(void)return 0 ; } -void __exit nfs_destroy_writepagecache(void) +void nfs_destroy_writepagecache (void ) {mempool_destroy (nfs_commit_mempool);mempool_destroy (nfs_wdata_mempool);
Quoted 7 lines · David Brownell
Quoted 6 lines · David Brownell
OK here's a version of my patch that I edited to remove the comments Jes objected to ... /* init or exit */ to remind about the omitted section annotation. Having one of those would save multiple kbytes throughout the kernel, and I had include the comments as reminders for an eventual fix...
Quoted 5 lines
Quoted 2 lines
- Dave
Once more, with patch.
Acked...
Cheers,
Trond