Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1345086 > unrolled thread

[PATCH] fs/crypto: make crypto.c explicitly non-modular

Started byPaul Gortmaker <paul.gortmaker@windriver.com>
First post2016-02-27 21:30 +0100
Last post2016-03-02 18:40 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] fs/crypto: make crypto.c explicitly non-modular Paul Gortmaker <paul.gortmaker@windriver.com> - 2016-02-27 21:30 +0100
    Re: [PATCH] fs/crypto: make crypto.c explicitly non-modular Arnd Bergmann <arnd@arndb.de> - 2016-02-29 11:00 +0100
      Re: [PATCH] fs/crypto: make crypto.c explicitly non-modular Paul Gortmaker <paul.gortmaker@windriver.com> - 2016-02-29 15:40 +0100
        Re: [PATCH] fs/crypto: make crypto.c explicitly non-modular Jaegeuk Kim <jaegeuk@kernel.org> - 2016-03-02 18:40 +0100

#1345086 — [PATCH] fs/crypto: make crypto.c explicitly non-modular

FromPaul Gortmaker <paul.gortmaker@windriver.com>
Date2016-02-27 21:30 +0100
Subject[PATCH] fs/crypto: make crypto.c explicitly non-modular
Message-ID<r6TEZ-8jB-1@gated-at.bofh.it>
As of commit 47134e6084f70fdf4381af75d4569cec6c7ebd50 ("fs crypto:
add Makefile and Kconfig") the compile of fs/crypto/crypto.c tripped
my local audit for non-modules using modular infrastructure vs. their
built in counterparts.

The Kconfig currently controlling compilation of this code is:

config FS_ENCRYPTION
        bool "FS Encryption (Per-file encryption)"

combined with:

obj-$(CONFIG_FS_ENCRYPTION)     += crypto.o policy.o keyinfo.o

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the use of fs_initcall (which seems appropriate for fs code)
means the init comes slightly earlier.  However boot testing an
x86-64 defconfig didn't show this to be causing any issues.

We replace module.h with moduleparam.h since the file does declare
some module parameters, and leaving them as such is currently the
easiest way to remain compatible with existing boot arg use cases.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 fs/crypto/crypto.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index ed17895cda11..abca51e75572 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -23,7 +23,7 @@
 #include <linux/ecryptfs.h>
 #include <linux/pagemap.h>
 #include <linux/mempool.h>
-#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/scatterlist.h>
 #include <linux/ratelimit.h>
 #include <linux/bio.h>
@@ -33,6 +33,10 @@
 static unsigned int num_prealloc_crypto_pages = 32;
 static unsigned int num_prealloc_crypto_ctxs = 128;
 
+/*
+ * Not really modular but using module_param is the easiest way to
+ * remain consistent with existing use cases for now.
+ */
 module_param(num_prealloc_crypto_pages, uint, 0444);
 MODULE_PARM_DESC(num_prealloc_crypto_pages,
 		"Number of crypto pages to preallocate");
@@ -537,18 +541,4 @@ fail_free_queue:
 fail:
 	return -ENOMEM;
 }
-module_init(fscrypt_init)
-
-/**
- * fscrypt_exit() - Shutdown the fs encryption system
- */
-void __exit fscrypt_exit(void)
-{
-	fscrypt_destroy();
-
-	if (fscrypt_read_workqueue)
-		destroy_workqueue(fscrypt_read_workqueue);
-	kmem_cache_destroy(fscrypt_ctx_cachep);
-	kmem_cache_destroy(fscrypt_info_cachep);
-}
-module_exit(fscrypt_exit);
+fs_initcall(fscrypt_init)
-- 
2.6.1

[toc] | [next] | [standalone]


#1345612

FromArnd Bergmann <arnd@arndb.de>
Date2016-02-29 11:00 +0100
Message-ID<r7sMq-1iX-13@gated-at.bofh.it>
In reply to#1345086
On Saturday 27 February 2016 15:20:49 Paul Gortmaker wrote:
> As of commit 47134e6084f70fdf4381af75d4569cec6c7ebd50 ("fs crypto:
> add Makefile and Kconfig") the compile of fs/crypto/crypto.c tripped
> my local audit for non-modules using modular infrastructure vs. their
> built in counterparts.
> 
> The Kconfig currently controlling compilation of this code is:
> 
> config FS_ENCRYPTION
>         bool "FS Encryption (Per-file encryption)"
> 
> combined with:
> 
> obj-$(CONFIG_FS_ENCRYPTION)     += crypto.o policy.o keyinfo.o
> 
> ...meaning that it currently is not being built as a module by anyone.
> 
> Lets remove the modular code that is essentially orphaned, so that
> when reading the driver there is no doubt it is builtin-only.
> 
> Since module_init translates to device_initcall in the non-modular
> case, the use of fs_initcall (which seems appropriate for fs code)
> means the init comes slightly earlier.  However boot testing an
> x86-64 defconfig didn't show this to be causing any issues.
> 
> We replace module.h with moduleparam.h since the file does declare
> some module parameters, and leaving them as such is currently the
> easiest way to remain compatible with existing boot arg use cases.
> 

So why not make the option a 'tristate' instead? It looks like
that was intended here, and we should always try to make all
code loadable as modules if possible.

	Arnd

[toc] | [prev] | [next] | [standalone]


#1345868

FromPaul Gortmaker <paul.gortmaker@windriver.com>
Date2016-02-29 15:40 +0100
Message-ID<r7x9o-4er-11@gated-at.bofh.it>
In reply to#1345612
[Re: [PATCH] fs/crypto: make crypto.c explicitly non-modular] On 29/02/2016 (Mon 10:56) Arnd Bergmann wrote:

> On Saturday 27 February 2016 15:20:49 Paul Gortmaker wrote:
> > As of commit 47134e6084f70fdf4381af75d4569cec6c7ebd50 ("fs crypto:
> > add Makefile and Kconfig") the compile of fs/crypto/crypto.c tripped
> > my local audit for non-modules using modular infrastructure vs. their
> > built in counterparts.
> > 
> > The Kconfig currently controlling compilation of this code is:
> > 
> > config FS_ENCRYPTION
> >         bool "FS Encryption (Per-file encryption)"
> > 
> > combined with:
> > 
> > obj-$(CONFIG_FS_ENCRYPTION)     += crypto.o policy.o keyinfo.o
> > 
> > ...meaning that it currently is not being built as a module by anyone.
> > 
> > Lets remove the modular code that is essentially orphaned, so that
> > when reading the driver there is no doubt it is builtin-only.
> > 
> > Since module_init translates to device_initcall in the non-modular
> > case, the use of fs_initcall (which seems appropriate for fs code)
> > means the init comes slightly earlier.  However boot testing an
> > x86-64 defconfig didn't show this to be causing any issues.
> > 
> > We replace module.h with moduleparam.h since the file does declare
> > some module parameters, and leaving them as such is currently the
> > easiest way to remain compatible with existing boot arg use cases.
> > 
> 
> So why not make the option a 'tristate' instead? It looks like
> that was intended here, and we should always try to make all
> code loadable as modules if possible.

It wasn't that obvious to me, and at the risk of repeating myself, I'll
always default to making the code consistent with existing functionality
vs. making assumptions about what was intended and implicitly adding new
functionality that may be invalid for reasons I'd never spot.

Of course authors, and maintainers are welcome to chime in and steer it
one way or another as per the PCI patches.

Paul.
--

> 
> 	Arnd

[toc] | [prev] | [next] | [standalone]


#1348354

FromJaegeuk Kim <jaegeuk@kernel.org>
Date2016-03-02 18:40 +0100
Message-ID<r8iUF-2nk-13@gated-at.bofh.it>
In reply to#1345868
Hi Paul,

On Mon, Feb 29, 2016 at 09:31:59AM -0500, Paul Gortmaker wrote:
> [Re: [PATCH] fs/crypto: make crypto.c explicitly non-modular] On 29/02/2016 (Mon 10:56) Arnd Bergmann wrote:
> 
> > On Saturday 27 February 2016 15:20:49 Paul Gortmaker wrote:
> > > As of commit 47134e6084f70fdf4381af75d4569cec6c7ebd50 ("fs crypto:
> > > add Makefile and Kconfig") the compile of fs/crypto/crypto.c tripped
> > > my local audit for non-modules using modular infrastructure vs. their
> > > built in counterparts.
> > > 
> > > The Kconfig currently controlling compilation of this code is:
> > > 
> > > config FS_ENCRYPTION
> > >         bool "FS Encryption (Per-file encryption)"
> > > 
> > > combined with:
> > > 
> > > obj-$(CONFIG_FS_ENCRYPTION)     += crypto.o policy.o keyinfo.o
> > > 
> > > ...meaning that it currently is not being built as a module by anyone.
> > > 
> > > Lets remove the modular code that is essentially orphaned, so that
> > > when reading the driver there is no doubt it is builtin-only.
> > > 
> > > Since module_init translates to device_initcall in the non-modular
> > > case, the use of fs_initcall (which seems appropriate for fs code)
> > > means the init comes slightly earlier.  However boot testing an
> > > x86-64 defconfig didn't show this to be causing any issues.
> > > 
> > > We replace module.h with moduleparam.h since the file does declare
> > > some module parameters, and leaving them as such is currently the
> > > easiest way to remain compatible with existing boot arg use cases.
> > > 
> > 
> > So why not make the option a 'tristate' instead? It looks like
> > that was intended here, and we should always try to make all
> > code loadable as modules if possible.
> 
> It wasn't that obvious to me, and at the risk of repeating myself, I'll
> always default to making the code consistent with existing functionality
> vs. making assumptions about what was intended and implicitly adding new
> functionality that may be invalid for reasons I'd never spot.
> 
> Of course authors, and maintainers are welcome to chime in and steer it
> one way or another as per the PCI patches.

Meanwhile, I've modified and tested fscrypt as a module, as Arnd commented.
I'll submit v3 to resolve this inconsistency.
Thank you for the point that I missed.
> 
> Paul.
> --
> 
> > 
> > 	Arnd

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web