The patch titled make-kmem_cache_destroy-return-void versus ecryptfs has been added to the -mm tree. Its filename is make-kmem_cache_destroy-return-void-ecryptfs.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: make-kmem_cache_destroy-return-void versus ecryptfs From: Andrew Morton <akpm@xxxxxxxx> fs/ecryptfs/main.c: In function 'ecryptfs_free_kmem_caches': fs/ecryptfs/main.c:690: error: void value not ignored as it ought to be fs/ecryptfs/main.c:698: error: void value not ignored as it ought to be fs/ecryptfs/main.c:706: error: void value not ignored as it ought to be fs/ecryptfs/main.c:714: error: void value not ignored as it ought to be fs/ecryptfs/main.c:722: error: void value not ignored as it ought to be fs/ecryptfs/main.c:730: error: void value not ignored as it ought to be fs/ecryptfs/main.c:737: error: void value not ignored as it ought to be fs/ecryptfs/main.c:744: error: void value not ignored as it ought to be fs/ecryptfs/main.c:751: error: void value not ignored as it ought to be That code was, err, a little verbose. Make it table-driven. Cc: Alexey Dobriyan <adobriyan@xxxxxxxxx> Cc: Michael Halcrow <mhalcrow@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- fs/ecryptfs/main.c | 279 +++++++++++-------------------------------- 1 file changed, 77 insertions(+), 202 deletions(-) diff -puN fs/ecryptfs/main.c~make-kmem_cache_destroy-return-void-ecryptfs fs/ecryptfs/main.c --- a/fs/ecryptfs/main.c~make-kmem_cache_destroy-return-void-ecryptfs +++ a/fs/ecryptfs/main.c @@ -553,209 +553,96 @@ inode_info_init_once(void *vptr, struct inode_init_once(&ei->vfs_inode); } -/* This provides a means of backing out cache creations out of the kernel - * so that we can elegantly fail should we run out of memory. - */ -#define ECRYPTFS_AUTH_TOK_LIST_ITEM_CACHE 0x0001 -#define ECRYPTFS_AUTH_TOK_PKT_SET_CACHE 0x0002 -#define ECRYPTFS_AUTH_TOK_REQUEST_CACHE 0x0004 -#define ECRYPTFS_AUTH_TOK_REQUEST_BLOB_CACHE 0x0008 -#define ECRYPTFS_FILE_INFO_CACHE 0x0010 -#define ECRYPTFS_DENTRY_INFO_CACHE 0x0020 -#define ECRYPTFS_INODE_INFO_CACHE 0x0040 -#define ECRYPTFS_SB_INFO_CACHE 0x0080 -#define ECRYPTFS_HEADER_CACHE_0 0x0100 -#define ECRYPTFS_HEADER_CACHE_1 0x0200 -#define ECRYPTFS_HEADER_CACHE_2 0x0400 -#define ECRYPTFS_LOWER_PAGE_CACHE 0x0800 -#define ECRYPTFS_CACHE_CREATION_SUCCESS 0x0FF1 - -static short ecryptfs_allocated_caches; +static struct ecryptfs_cache_info { + kmem_cache_t **cache; + const char *name; + size_t size; + void (*ctor)(void*, struct kmem_cache *, unsigned long); +} ecryptfs_cache_infos[] = { + { + .cache = &ecryptfs_auth_tok_list_item_cache, + .name = "ecryptfs_auth_tok_list_item", + .size = sizeof(struct ecryptfs_auth_tok_list_item), + }, + { + .cache = &ecryptfs_file_info_cache, + .name = "ecryptfs_file_cache", + .size = sizeof(struct ecryptfs_file_info), + }, + { + .cache = &ecryptfs_dentry_info_cache, + .name = "ecryptfs_dentry_info_cache", + .size = sizeof(struct ecryptfs_dentry_info), + }, + { + .cache = &ecryptfs_inode_info_cache, + .name = "ecryptfs_inode_cache", + .size = sizeof(struct ecryptfs_inode_info), + .ctor = inode_info_init_once, + }, + { + .cache = &ecryptfs_sb_info_cache, + .name = "ecryptfs_sb_cache", + .size = sizeof(struct ecryptfs_sb_info), + }, + { + .cache = &ecryptfs_header_cache_0, + .name = "ecryptfs_headers_0", + .size = PAGE_CACHE_SIZE, + }, + { + .cache = &ecryptfs_header_cache_1, + .name = "ecryptfs_headers_1", + .size = PAGE_CACHE_SIZE, + }, + { + .cache = &ecryptfs_header_cache_2, + .name = "ecryptfs_headers_2", + .size = PAGE_CACHE_SIZE, + }, + { + .cache = &ecryptfs_lower_page_cache, + .name = "ecryptfs_lower_page_cache", + .size = PAGE_CACHE_SIZE, + }, +}; /** * ecryptfs_init_kmem_caches * - * Sets ecryptfs_allocated_caches with flags so that we can - * free created caches should we run out of memory during - * creation period. - * * Returns zero on success; non-zero otherwise */ static int ecryptfs_init_kmem_caches(void) { - int rc = 0; + int i; - ecryptfs_auth_tok_list_item_cache = - kmem_cache_create("ecryptfs_auth_tok_list_item", - sizeof(struct ecryptfs_auth_tok_list_item), - 0, SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ecryptfs_auth_tok_list_item_cache) - rc |= ECRYPTFS_AUTH_TOK_LIST_ITEM_CACHE; - else - ecryptfs_printk(KERN_WARNING, "ecryptfs_auth_tok_list_item " - "kmem_cache_create failed\n"); - - ecryptfs_file_info_cache = - kmem_cache_create("ecryptfs_file_cache", - sizeof(struct ecryptfs_file_info), - 0, SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ecryptfs_file_info_cache) - rc |= ECRYPTFS_FILE_INFO_CACHE; - else - ecryptfs_printk(KERN_WARNING, "ecryptfs_file_cache " - "kmem_cache_create failed\n"); - - ecryptfs_dentry_info_cache = - kmem_cache_create("ecryptfs_dentry_info_cache", - sizeof(struct ecryptfs_dentry_info), - 0, SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ecryptfs_dentry_info_cache) - rc |= ECRYPTFS_DENTRY_INFO_CACHE; - else - ecryptfs_printk(KERN_WARNING, "ecryptfs_dentry_info_cache " - "kmem_cache_create failed\n"); - - ecryptfs_inode_info_cache = - kmem_cache_create("ecryptfs_inode_cache", - sizeof(struct ecryptfs_inode_info), 0, - SLAB_HWCACHE_ALIGN, inode_info_init_once, NULL); - if (ecryptfs_inode_info_cache) - rc |= ECRYPTFS_INODE_INFO_CACHE; - else - ecryptfs_printk(KERN_WARNING, "ecryptfs_inode_cache " - "kmem_cache_create failed\n"); - - ecryptfs_sb_info_cache = - kmem_cache_create("ecryptfs_sb_cache", - sizeof(struct ecryptfs_sb_info), - 0, SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ecryptfs_sb_info_cache) - rc |= ECRYPTFS_SB_INFO_CACHE; - else - ecryptfs_printk(KERN_WARNING, "ecryptfs_sb_cache " - "kmem_cache_create failed\n"); - - ecryptfs_header_cache_0 = - kmem_cache_create("ecryptfs_headers_0", PAGE_CACHE_SIZE, - 0, SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ecryptfs_header_cache_0) - rc |= ECRYPTFS_HEADER_CACHE_0; - else - ecryptfs_printk(KERN_WARNING, "ecryptfs_headers_0 " - "kmem_cache_create failed\n"); - - ecryptfs_header_cache_1 = - kmem_cache_create("ecryptfs_headers_1", PAGE_CACHE_SIZE, - 0, SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ecryptfs_header_cache_1) - rc |= ECRYPTFS_HEADER_CACHE_1; - else - ecryptfs_printk(KERN_WARNING, "ecryptfs_headers_1 " - "kmem_cache_create failed\n"); - - ecryptfs_header_cache_2 = - kmem_cache_create("ecryptfs_headers_2", PAGE_CACHE_SIZE, - 0, SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ecryptfs_header_cache_2) - rc |= ECRYPTFS_HEADER_CACHE_2; - else - ecryptfs_printk(KERN_WARNING, "ecryptfs_headers_2 " - "kmem_cache_create failed\n"); - - ecryptfs_lower_page_cache = - kmem_cache_create("ecryptfs_lower_page_cache", PAGE_CACHE_SIZE, - 0, SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ecryptfs_lower_page_cache) - rc |= ECRYPTFS_LOWER_PAGE_CACHE; - else - ecryptfs_printk(KERN_WARNING, "ecryptfs_lower_page_cache " - "kmem_cache_create failed\n"); + for (i = 0; i < ARRAY_SIZE(ecryptfs_cache_infos); i++) { + struct ecryptfs_cache_info *info; - ecryptfs_allocated_caches = rc; - rc = ECRYPTFS_CACHE_CREATION_SUCCESS ^ rc; - return rc; + info = &ecryptfs_cache_infos[i]; + *(info->cache) = kmem_cache_create(info->name, info->size, + 0, SLAB_HWCACHE_ALIGN, info->ctor, NULL); + if (!*(info->cache)) { + ecryptfs_printk(KERN_WARNING, "%s: " + "kmem_cache_create failed\n", + info->name); + return -ENOMEM; + } + } + return 0; } -/** - * ecryptfs_free_kmem_caches - * - * Returns zero on success; non-zero otherwise - */ -static int ecryptfs_free_kmem_caches(void) +static void ecryptfs_free_kmem_caches(void) { - int rc = 0; - int err; + int i; - if (ecryptfs_allocated_caches & ECRYPTFS_AUTH_TOK_LIST_ITEM_CACHE) { - rc = kmem_cache_destroy(ecryptfs_auth_tok_list_item_cache); - if (rc) - ecryptfs_printk(KERN_WARNING, - "Not all ecryptfs_auth_tok_" - "list_item_cache structures were " - "freed\n"); - } - if (ecryptfs_allocated_caches & ECRYPTFS_FILE_INFO_CACHE) { - err = kmem_cache_destroy(ecryptfs_file_info_cache); - if (err) - ecryptfs_printk(KERN_WARNING, - "Not all ecryptfs_file_info_" - "cache regions were freed\n"); - rc |= err; - } - if (ecryptfs_allocated_caches & ECRYPTFS_DENTRY_INFO_CACHE) { - err = kmem_cache_destroy(ecryptfs_dentry_info_cache); - if (err) - ecryptfs_printk(KERN_WARNING, - "Not all ecryptfs_dentry_info_" - "cache regions were freed\n"); - rc |= err; - } - if (ecryptfs_allocated_caches & ECRYPTFS_INODE_INFO_CACHE) { - err = kmem_cache_destroy(ecryptfs_inode_info_cache); - if (err) - ecryptfs_printk(KERN_WARNING, - "Not all ecryptfs_inode_info_" - "cache regions were freed\n"); - rc |= err; - } - if (ecryptfs_allocated_caches & ECRYPTFS_SB_INFO_CACHE) { - err = kmem_cache_destroy(ecryptfs_sb_info_cache); - if (err) - ecryptfs_printk(KERN_WARNING, - "Not all ecryptfs_sb_info_" - "cache regions were freed\n"); - rc |= err; - } - if (ecryptfs_allocated_caches & ECRYPTFS_HEADER_CACHE_0) { - err = kmem_cache_destroy(ecryptfs_header_cache_0); - if (err) - ecryptfs_printk(KERN_WARNING, "Not all ecryptfs_" - "header_cache_0 regions were freed\n"); - rc |= err; - } - if (ecryptfs_allocated_caches & ECRYPTFS_HEADER_CACHE_1) { - err = kmem_cache_destroy(ecryptfs_header_cache_1); - if (err) - ecryptfs_printk(KERN_WARNING, "Not all ecryptfs_" - "header_cache_1 regions were freed\n"); - rc |= err; - } - if (ecryptfs_allocated_caches & ECRYPTFS_HEADER_CACHE_2) { - err = kmem_cache_destroy(ecryptfs_header_cache_2); - if (err) - ecryptfs_printk(KERN_WARNING, "Not all ecryptfs_" - "header_cache_2 regions were freed\n"); - rc |= err; - } - if (ecryptfs_allocated_caches & ECRYPTFS_LOWER_PAGE_CACHE) { - err = kmem_cache_destroy(ecryptfs_lower_page_cache); - if (err) - ecryptfs_printk(KERN_WARNING, "Not all ecryptfs_" - "lower_page_cache regions were " - "freed\n"); - rc |= err; + for (i = 0; i < ARRAY_SIZE(ecryptfs_cache_infos); i++) { + struct ecryptfs_cache_info *info; + + info = &ecryptfs_cache_infos[i]; + if (*(info->cache)) + kmem_cache_destroy(*(info->cache)); } - return rc; } static int __init init_ecryptfs_fs(void) @@ -773,15 +660,8 @@ static int __init init_ecryptfs_fs(void) goto out; } rc = ecryptfs_init_kmem_caches(); - if (rc) { - ecryptfs_printk(KERN_EMERG, "Failure occured while " - "attempting to create caches [Mask of created " - "caches: 0x%x]. Now freeing caches.\n", - ecryptfs_allocated_caches); - ecryptfs_free_kmem_caches(); - rc = -ENOMEM; + if (rc) goto out; - } ecryptfs_printk(KERN_DEBUG, "Registering eCryptfs\n"); rc = register_filesystem(&ecryptfs_fs_type); out: @@ -790,13 +670,8 @@ out: static void __exit exit_ecryptfs_fs(void) { - int rc; - unregister_filesystem(&ecryptfs_fs_type); - rc = ecryptfs_free_kmem_caches(); - if (rc) - ecryptfs_printk(KERN_EMERG, "Failure occured while " - "attempting to free caches: [%d]\n", rc); + ecryptfs_free_kmem_caches(); } MODULE_AUTHOR("Michael A. Halcrow <mhalcrow@xxxxxxxxxx>"); _ Patches currently in -mm which might be from akpm@xxxxxxxx are origin.patch oops-on-boot-fix-for-ide.patch revert-input-wistron-fix-section-reference-mismatches.patch lockdep-fix-blkdev_open-warning-fix.patch char-moxac-fix-endianess-and-multiple-card-issues-tidy.patch fix-for-minix-crash.patch manage-jbd-allocations-from-its-own-slabs-tidy.patch proc-meminfo-dont-put-spaces-in-names.patch git-acpi.patch acpi-asus-s3-resume-fix.patch sony_apci-resume.patch git-alsa.patch kauditd_thread-warning-fix.patch revert-gregkh-driver-class_device_rename-remove.patch revert-gregkh-driver-network-class_device-to-device.patch revert-gregkh-driver-tty-device.patch revert-gregkh-driver-mem-devices.patch drivers-base-check-errors.patch scsi-device_reprobe-can-fail.patch git-drm.patch git-gfs2.patch git-ia64.patch git-ieee1394-fixup.patch git-input.patch git-intelfb-fixup.patch git-kbuild.patch git-libata-all.patch asus-mv-device-ids.patch 1-of-2-jmicron-driver-fix.patch via-pata-controller-xfer-fixes-fix.patch git-netdev-all.patch drivers-net-ns83820c-add-paramter-to-disable-auto.patch git-net.patch git-net-fixup.patch git-nfs.patch git-nfs-fixup.patch git-pcmcia-fixup.patch git-powerpc.patch git-sas.patch git-block-vs-git-sas.patch tickle-nmi-watchdog-on-serial-output-fix.patch serial-fix-uart_bug_txen-test.patch pcie-check-and-return-bus_register-errors-fix.patch git-scsi-misc.patch revert-scsi-improve-inquiry-printing.patch fix-panic-when-reinserting-adaptec-pcmcia-scsi-card.patch git-scsi-target-fixup.patch git-scsi-target-vs-git-block.patch usb-hub-driver-improve-use-of-ifdef-fix.patch pm-usb-hcds-use-pm_event_prethaw-fix.patch rtl8150_disconnect-needs-tasklet_kill.patch git-supertrak-fixup.patch git-watchdog.patch kthread-airoc.patch mm-x86_64-mm-generic-getcpu-syscall-tweaks.patch revert-x86_64-mm-i386-remove-lock-section.patch revert-x86_64-mm-detect-cfi.patch git-cryptodev-fixup.patch git-cryptodev-fixup-2.patch git-cryptodev-broke-geode-aes.patch adix-tree-rcu-lockless-readside-update-tidy.patch mm-tracking-shared-dirty-pages-checks.patch mm-tracking-shared-dirty-pages-wimp.patch convert-i386-numa-kva-space-to-bootmem-tidy.patch reduce-max_nr_zones-make-display-of-highmem-counters-conditional-on-config_highmem-tidy.patch reduce-max_nr_zones-use-enum-to-define-zones-reformat-and-comment-cleanup.patch reduce-max_nr_zones-use-enum-to-define-zones-reformat-and-comment-fix.patch reduce-max_nr_zones-remove-display-of-counters-for-unconfigured-zones-s390-fix.patch out-of-memory-notifier-tidy.patch mm-swap-write-failure-fixup-fix.patch slab-optimize-kmalloc_node-the-same-way-as-kmalloc-fix.patch slab-fix-lockdep-warnings-fix-2.patch zvc-scale-thresholds-depending-on-the-size-of-the-system-fix.patch have-x86-use-add_active_range-and-free_area_init_nodes-fix.patch zone_reclaim-dynamic-slab-reclaim-tidy.patch acx1xx-wireless-driver.patch tiacx-pci-build-fix.patch tiacx-ia64-fix.patch tiacx-build-fix.patch selinux-2-3-change-isec-semaphore-to-a-mutex-vs-git-net.patch binfmt_elf-consistently-use-loff_t.patch convert-i386-summit-subarch-to-use-srat-info-for-apicid_to_node-calls-tidy.patch x86-increase-max_mp_busses-on-default-arch.patch i386-adds-smp_call_function_single-fix.patch swsusp-write-timer.patch swsusp-write-speedup.patch swsusp-read-timer.patch swsusp-read-speedup.patch swsusp-read-speedup-fix.patch swsusp-read-speedup-cleanup.patch swsusp-read-speedup-cleanup-2.patch swsusp-read-speedup-fix-fix-2.patch deprecate-smbfs-in-favour-of-cifs.patch edac-new-opteron-athlon64-memory-controller-driver-tidy.patch inode_diet-replace-inodeugeneric_ip-with-inodei_private-gfs-fix.patch x86-microcode-microcode-driver-cleanup-tidy.patch x86-microcode-add-sysfs-and-hotplug-support-fix.patch eisa-bus-modalias-attributes-support-1-fix-git-kbuild-fix.patch add-address_space_operationsbatch_write-fix.patch alloc_fdtable-cleanup.patch add-probe_kernel_address.patch x86-use-probe_kernel_address-in-handle_bug.patch blockdevc-check-errors.patch let-warn_on-warn_on_once-return-the-condition-fix.patch let-warn_on-warn_on_once-return-the-condition-fix-2.patch omap-add-watchdog-driver-support-tweaks.patch move-valid_dma_direction-from-x86_64-to-generic-code-fix.patch single-bit-flip-detector-tidy.patch fix-unserialized-task-files-changing-fix.patch tty-make-termios_sem-a-mutex-fix.patch ntp-move-all-the-ntp-related-code-to-ntpc-fix.patch reiserfs-on-demand-bitmap-loading.patch streamline-generic_file_-interfaces-and-filemap-gfs-fix.patch add-vector-aio-support-fix.patch csa-basic-accounting-over-taskstats-fix.patch fs-cache-make-kafs-use-fs-cache-fix.patch fs-cache-make-kafs-use-fs-cache-vs-streamline-generic_file_-interfaces-and-filemap.patch nfs-use-local-caching-12-fix.patch stack-overflow-safe-kdump-crash_use_safe_smp_processor_id-fix.patch generic-ioremap_page_range-x86_64-conversion-fix.patch vfs-make-filldir_t-and-struct-kstat-deal-in-64-bit-inode-numbers-alpha-fix.patch some-cleanup-in-the-pipe-code-tidy.patch support-piping-into-commands-in-proc-sys-kernel-core_pattern-fix.patch move-pidmap-to-pspaceh-fix.patch isdn-work-around-excessive-udelay.patch knfsd-add-a-callback-for-when-last-rpc-thread-finishes-tidy.patch knfsd-add-a-callback-for-when-last-rpc-thread-finishes-fix.patch knfsd-separate-out-some-parts-of-nfsd_svc-which-start-nfs-servers-tweaks.patch knfsd-define-new-nfsdfs-file-portlist-contains-list-of-ports-tidy.patch knfsd-define-new-nfsdfs-file-portlist-contains-list-of-ports-fix.patch knfsd-have-ext2-reject-file-handles-with-bad-inode-numbers-early-tidy.patch knfsd-make-ext3-reject-filehandles-referring-to-invalid-inode-numbers-tidy.patch knfsd-drop-serv-option-to-svc_recv-and-svc_process-nfs-callback-fix-nfs-callback-fix.patch knfsd-move-tempsock-aging-to-a-timer-tidy.patch sched-remove-unnecessary-sched-group-allocations-fix.patch swap_prefetch-vs-zoned-counters.patch ecryptfs-mmap-operations.patch ecryptfs-alpha-build-fix.patch ecryptfs-more-elegant-aes-key-size-manipulation.patch ecryptfs-get_sb_dev-fix.patch make-kmem_cache_destroy-return-void-ecryptfs.patch namespaces-add-nsproxy.patch namespaces-utsname-switch-to-using-uts-namespaces.patch namespaces-utsname-use-init_utsname-when-appropriate.patch namespaces-utsname-implement-utsname-namespaces.patch namespaces-utsname-sysctl-hack.patch namespaces-utsname-switch-to-using-uts-namespaces-klibc-bit-sparc.patch ipc-namespace-core.patch readahead-sysctl-parameters-fix.patch make-copy_from_user_inatomic-not-zero-the-tail-on-i386-vs-reiser4.patch reiser4-hardirq-include-fix.patch reiser4-run-truncate_inode_pages-in-reiser4_delete_inode.patch reiser4-get_sb_dev-fix.patch reiser4-vs-zoned-allocator.patch reiser4-rename-generic_sounding_globalspatch-fix.patch hpt3xx-rework-rate-filtering-tidy.patch asus-mv-ide-device-ids.patch genirq-convert-the-i386-architecture-to-irq-chips.patch genirq-x86_64-irq-reenable-migrating-irqs-to-other-cpus.patch genirq-msi-simplify-msi-enable-and-disable.patch genirq-ia64-irq-dynamic-irq-support.patch genirq-msi-only-build-msi-apicc-on-ia64-fix.patch genirq-i386-irq-remove-the-msi-assumption-that-irq-==-vector.patch genirq-x86_64-irq-make-vector_irq-per-cpu-fix.patch genirq-x86_64-irq-make-vector_irq-per-cpu-warning-fix.patch add-hypertransport-capability-defines-fix.patch initial-generic-hypertransport-interrupt-support-Kconfig-fix.patch srcu-report-out-of-memory-errors-fixlet.patch nr_blockdev_pages-in_interrupt-warning.patch device-suspend-debug.patch slab-leaks3-default-y.patch x86-kmap_atomic-debugging.patch restore-rogue-readahead-printk.patch input_register_device-debug.patch put_bh-debug.patch acpi_format_exception-debug.patch jmicron-warning-fix.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html