Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'mm-nonmm-stable-2024-09-21-07-52' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Pull non-MM updates from Andrew Morton:
"Many singleton patches - please see the various changelogs for
details.

Quite a lot of nilfs2 work this time around.

Notable patch series in this pull request are:

- "mul_u64_u64_div_u64: new implementation" by Nicolas Pitre, with
assistance from Uwe Kleine-König. Reimplement mul_u64_u64_div_u64()
to provide (much) more accurate results. The current implementation
was causing Uwe some issues in the PWM drivers.

- "xz: Updates to license, filters, and compression options" from
Lasse Collin. Miscellaneous maintenance and kinor feature work to
the xz decompressor.

- "Fix some GDB command error and add some GDB commands" from
Kuan-Ying Lee. Fixes and enhancements to the gdb scripts.

- "treewide: add missing MODULE_DESCRIPTION() macros" from Jeff
Johnson. Adds lots of MODULE_DESCRIPTIONs, thus fixing lots of
warnings about this.

- "nilfs2: add support for some common ioctls" from Ryusuke Konishi.
Adds various commonly-available ioctls to nilfs2.

- "This series fixes a number of formatting issues in kernel doc
comments" from Ryusuke Konishi does that.

- "nilfs2: prevent unexpected ENOENT propagation" from Ryusuke
Konishi. Fix issues where -ENOENT was being unintentionally and
inappropriately returned to userspace.

- "nilfs2: assorted cleanups" from Huang Xiaojia.

- "nilfs2: fix potential issues with empty b-tree nodes" from Ryusuke
Konishi fixes some issues which can occur on corrupted nilfs2
filesystems.

- "scripts/decode_stacktrace.sh: improve error reporting and
usability" from Luca Ceresoli does those things"

* tag 'mm-nonmm-stable-2024-09-21-07-52' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (103 commits)
list: test: increase coverage of list_test_list_replace*()
list: test: fix tests for list_cut_position()
proc: use __auto_type more
treewide: correct the typo 'retun'
ocfs2: cleanup return value and mlog in ocfs2_global_read_info()
nilfs2: remove duplicate 'unlikely()' usage
nilfs2: fix potential oob read in nilfs_btree_check_delete()
nilfs2: determine empty node blocks as corrupted
nilfs2: fix potential null-ptr-deref in nilfs_btree_insert()
user_namespace: use kmemdup_array() instead of kmemdup() for multiple allocation
tools/mm: rm thp_swap_allocator_test when make clean
squashfs: fix percpu address space issues in decompressor_multi_percpu.c
lib: glob.c: added null check for character class
nilfs2: refactor nilfs_segctor_thread()
nilfs2: use kthread_create and kthread_stop for the log writer thread
nilfs2: remove sc_timer_task
nilfs2: do not repair reserved inode bitmap in nilfs_new_inode()
nilfs2: eliminate the shared counter and spinlock for i_generation
nilfs2: separate inode type information from i_state field
nilfs2: use the BITS_PER_LONG macro
...

+1677 -853
+3 -3
Documentation/ABI/testing/sysfs-devices-memory
··· 115 115 Date: Aug 2023 116 116 Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org> 117 117 Description: 118 - (RO) indicates whether or not the kernel directly supports 119 - modifying the crash elfcorehdr for memory hot un/plug and/or 120 - on/offline changes. 118 + (RO) indicates whether or not the kernel updates relevant kexec 119 + segments on memory hot un/plug and/or on/offline events, avoiding the 120 + need to reload kdump kernel.
+3 -3
Documentation/ABI/testing/sysfs-devices-system-cpu
··· 704 704 Date: Aug 2023 705 705 Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org> 706 706 Description: 707 - (RO) indicates whether or not the kernel directly supports 708 - modifying the crash elfcorehdr for CPU hot un/plug and/or 709 - on/offline changes. 707 + (RO) indicates whether or not the kernel updates relevant kexec 708 + segments on memory hot un/plug and/or on/offline events, avoiding the 709 + need to reload kdump kernel. 710 710 711 711 What: /sys/devices/system/cpu/enabled 712 712 Date: Nov 2022
+3 -2
Documentation/admin-guide/mm/memory-hotplug.rst
··· 294 294 ``crash_hotplug`` read-only: when changes to the system memory map 295 295 occur due to hot un/plug of memory, this file contains 296 296 '1' if the kernel updates the kdump capture kernel memory 297 - map itself (via elfcorehdr), or '0' if userspace must update 298 - the kdump capture kernel memory map. 297 + map itself (via elfcorehdr and other relevant kexec 298 + segments), or '0' if userspace must update the kdump 299 + capture kernel memory map. 299 300 300 301 Availability depends on the CONFIG_MEMORY_HOTPLUG kernel 301 302 configuration option.
+6 -4
Documentation/core-api/cpu_hotplug.rst
··· 737 737 738 738 When changes to the CPUs in the system occur, the sysfs file 739 739 /sys/devices/system/cpu/crash_hotplug contains '1' if the kernel 740 - updates the kdump capture kernel list of CPUs itself (via elfcorehdr), 741 - or '0' if userspace must update the kdump capture kernel list of CPUs. 740 + updates the kdump capture kernel list of CPUs itself (via elfcorehdr and 741 + other relevant kexec segment), or '0' if userspace must update the kdump 742 + capture kernel list of CPUs. 742 743 743 744 The availability depends on the CONFIG_HOTPLUG_CPU kernel configuration 744 745 option. ··· 751 750 SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" 752 751 753 752 For a CPU hot un/plug event, if the architecture supports kernel updates 754 - of the elfcorehdr (which contains the list of CPUs), then the rule skips 755 - the unload-then-reload of the kdump capture kernel. 753 + of the elfcorehdr (which contains the list of CPUs) and other relevant 754 + kexec segments, then the rule skips the unload-then-reload of the kdump 755 + capture kernel. 756 756 757 757 Kernel Inline Documentations Reference 758 758 ======================================
+56 -85
Documentation/staging/xz.rst
··· 1 + .. SPDX-License-Identifier: 0BSD 2 + 1 3 ============================ 2 4 XZ data compression in Linux 3 5 ============================ ··· 8 6 ============ 9 7 10 8 XZ is a general purpose data compression format with high compression 11 - ratio and relatively fast decompression. The primary compression 12 - algorithm (filter) is LZMA2. Additional filters can be used to improve 13 - compression ratio even further. E.g. Branch/Call/Jump (BCJ) filters 14 - improve compression ratio of executable data. 9 + ratio. The XZ decompressor in Linux is called XZ Embedded. It supports 10 + the LZMA2 filter and optionally also Branch/Call/Jump (BCJ) filters 11 + for executable code. CRC32 is supported for integrity checking. 15 12 16 - The XZ decompressor in Linux is called XZ Embedded. It supports 17 - the LZMA2 filter and optionally also BCJ filters. CRC32 is supported 18 - for integrity checking. The home page of XZ Embedded is at 19 - <https://tukaani.org/xz/embedded.html>, where you can find the 20 - latest version and also information about using the code outside 21 - the Linux kernel. 13 + See the `XZ Embedded`_ home page for the latest version which includes 14 + a few optional extra features that aren't required in the Linux kernel 15 + and information about using the code outside the Linux kernel. 22 16 23 - For userspace, XZ Utils provide a zlib-like compression library 24 - and a gzip-like command line tool. XZ Utils can be downloaded from 25 - <https://tukaani.org/xz/>. 17 + For userspace, `XZ Utils`_ provide a zlib-like compression library 18 + and a gzip-like command line tool. 19 + 20 + .. _XZ Embedded: https://tukaani.org/xz/embedded.html 21 + .. _XZ Utils: https://tukaani.org/xz/ 26 22 27 23 XZ related components in the kernel 28 24 =================================== 29 25 30 26 The xz_dec module provides XZ decompressor with single-call (buffer 31 - to buffer) and multi-call (stateful) APIs. The usage of the xz_dec 32 - module is documented in include/linux/xz.h. 33 - 34 - The xz_dec_test module is for testing xz_dec. xz_dec_test is not 35 - useful unless you are hacking the XZ decompressor. xz_dec_test 36 - allocates a char device major dynamically to which one can write 37 - .xz files from userspace. The decompressed output is thrown away. 38 - Keep an eye on dmesg to see diagnostics printed by xz_dec_test. 39 - See the xz_dec_test source code for the details. 27 + to buffer) and multi-call (stateful) APIs in include/linux/xz.h. 40 28 41 29 For decompressing the kernel image, initramfs, and initrd, there 42 30 is a wrapper function in lib/decompress_unxz.c. Its API is the 43 31 same as in other decompress_*.c files, which is defined in 44 32 include/linux/decompress/generic.h. 45 33 46 - scripts/xz_wrap.sh is a wrapper for the xz command line tool found 47 - from XZ Utils. The wrapper sets compression options to values suitable 48 - for compressing the kernel image. 34 + For kernel makefiles, three commands are provided for use with 35 + ``$(call if_changed)``. They require the xz tool from XZ Utils. 49 36 50 - For kernel makefiles, two commands are provided for use with 51 - $(call if_needed). The kernel image should be compressed with 52 - $(call if_needed,xzkern) which will use a BCJ filter and a big LZMA2 53 - dictionary. It will also append a four-byte trailer containing the 54 - uncompressed size of the file, which is needed by the boot code. 55 - Other things should be compressed with $(call if_needed,xzmisc) 56 - which will use no BCJ filter and 1 MiB LZMA2 dictionary. 37 + - ``$(call if_changed,xzkern)`` is for compressing the kernel image. 38 + It runs the script scripts/xz_wrap.sh which uses arch-optimized 39 + options and a big LZMA2 dictionary. 40 + 41 + - ``$(call if_changed,xzkern_with_size)`` is like ``xzkern`` above but 42 + this also appends a four-byte trailer containing the uncompressed size 43 + of the file. The trailer is needed by the boot code on some archs. 44 + 45 + - Other things can be compressed with ``$(call if_needed,xzmisc)`` 46 + which will use no BCJ filter and 1 MiB LZMA2 dictionary. 57 47 58 48 Notes on compression options 59 49 ============================ 60 50 61 - Since the XZ Embedded supports only streams with no integrity check or 62 - CRC32, make sure that you don't use some other integrity check type 63 - when encoding files that are supposed to be decoded by the kernel. With 64 - liblzma, you need to use either LZMA_CHECK_NONE or LZMA_CHECK_CRC32 65 - when encoding. With the xz command line tool, use --check=none or 66 - --check=crc32. 51 + Since the XZ Embedded supports only streams with CRC32 or no integrity 52 + check, make sure that you don't use some other integrity check type 53 + when encoding files that are supposed to be decoded by the kernel. 54 + With liblzma from XZ Utils, you need to use either ``LZMA_CHECK_CRC32`` 55 + or ``LZMA_CHECK_NONE`` when encoding. With the ``xz`` command line tool, 56 + use ``--check=crc32`` or ``--check=none`` to override the default 57 + ``--check=crc64``. 67 58 68 59 Using CRC32 is strongly recommended unless there is some other layer 69 60 which will verify the integrity of the uncompressed data anyway. ··· 66 71 disable it) for the actual uncompressed data. 67 72 68 73 In userspace, LZMA2 is typically used with dictionary sizes of several 69 - megabytes. The decoder needs to have the dictionary in RAM, thus big 70 - dictionaries cannot be used for files that are intended to be decoded 71 - by the kernel. 1 MiB is probably the maximum reasonable dictionary 72 - size for in-kernel use (maybe more is OK for initramfs). The presets 73 - in XZ Utils may not be optimal when creating files for the kernel, 74 - so don't hesitate to use custom settings. Example:: 74 + megabytes. The decoder needs to have the dictionary in RAM: 75 75 76 - xz --check=crc32 --lzma2=dict=512KiB inputfile 76 + - In multi-call mode the dictionary is allocated as part of the 77 + decoder state. The reasonable maximum dictionary size for in-kernel 78 + use will depend on the target hardware: a few megabytes is fine for 79 + desktop systems while 64 KiB to 1 MiB might be more appropriate on 80 + some embedded systems. 77 81 78 - An exception to above dictionary size limitation is when the decoder 79 - is used in single-call mode. Decompressing the kernel itself is an 80 - example of this situation. In single-call mode, the memory usage 81 - doesn't depend on the dictionary size, and it is perfectly fine to 82 - use a big dictionary: for maximum compression, the dictionary should 83 - be at least as big as the uncompressed data itself. 82 + - In single-call mode the output buffer is used as the dictionary 83 + buffer. That is, the size of the dictionary doesn't affect the 84 + decompressor memory usage at all. Only the base data structures 85 + are allocated which take a little less than 30 KiB of memory. 86 + For the best compression, the dictionary should be at least 87 + as big as the uncompressed data. A notable example of single-call 88 + mode is decompressing the kernel itself (except on PowerPC). 84 89 85 - Future plans 86 - ============ 90 + The compression presets in XZ Utils may not be optimal when creating 91 + files for the kernel, so don't hesitate to use custom settings to, 92 + for example, set the dictionary size. Also, xz may produce a smaller 93 + file in single-threaded mode so setting that explicitly is recommended. 94 + Example:: 87 95 88 - Creating a limited XZ encoder may be considered if people think it is 89 - useful. LZMA2 is slower to compress than e.g. Deflate or LZO even at 90 - the fastest settings, so it isn't clear if LZMA2 encoder is wanted 91 - into the kernel. 96 + xz --threads=1 --check=crc32 --lzma2=dict=512KiB inputfile 92 97 93 - Support for limited random-access reading is planned for the 94 - decompression code. I don't know if it could have any use in the 95 - kernel, but I know that it would be useful in some embedded projects 96 - outside the Linux kernel. 98 + xz_dec API 99 + ========== 97 100 98 - Conformance to the .xz file format specification 99 - ================================================ 101 + This is available with ``#include <linux/xz.h>``. 100 102 101 - There are a couple of corner cases where things have been simplified 102 - at expense of detecting errors as early as possible. These should not 103 - matter in practice all, since they don't cause security issues. But 104 - it is good to know this if testing the code e.g. with the test files 105 - from XZ Utils. 106 - 107 - Reporting bugs 108 - ============== 109 - 110 - Before reporting a bug, please check that it's not fixed already 111 - at upstream. See <https://tukaani.org/xz/embedded.html> to get the 112 - latest code. 113 - 114 - Report bugs to <lasse.collin@tukaani.org> or visit #tukaani on 115 - Freenode and talk to Larhzu. I don't actively read LKML or other 116 - kernel-related mailing lists, so if there's something I should know, 117 - you should email to me personally or use IRC. 118 - 119 - Don't bother Igor Pavlov with questions about the XZ implementation 120 - in the kernel or about XZ Utils. While these two implementations 121 - include essential code that is directly based on Igor Pavlov's code, 122 - these implementations aren't maintained nor supported by him. 103 + .. kernel-doc:: include/linux/xz.h
+23
LICENSES/deprecated/0BSD
··· 1 + Valid-License-Identifier: 0BSD 2 + SPDX-URL: https://spdx.org/licenses/0BSD.html 3 + Usage-Guide: 4 + To use the BSD Zero Clause License put the following SPDX tag/value 5 + pair into a comment according to the placement guidelines in the 6 + licensing rules documentation: 7 + SPDX-License-Identifier: 0BSD 8 + License-Text: 9 + 10 + BSD Zero Clause License 11 + 12 + Copyright (c) <year> <copyright holders> 13 + 14 + Permission to use, copy, modify, and/or distribute this software for any 15 + purpose with or without fee is hereby granted. 16 + 17 + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 18 + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 19 + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 20 + SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 21 + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 22 + OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 23 + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+14
MAINTAINERS
··· 8612 8612 S: Supported 8613 8613 F: Documentation/fault-injection/ 8614 8614 F: lib/fault-inject.c 8615 + F: tools/testing/fault-injection/ 8615 8616 8616 8617 FBTFT Framebuffer drivers 8617 8618 L: dri-devel@lists.freedesktop.org ··· 25459 25458 S: Maintained 25460 25459 F: drivers/spi/spi-xtensa-xtfpga.c 25461 25460 F: sound/soc/xtensa/xtfpga-i2s.c 25461 + 25462 + XZ EMBEDDED 25463 + M: Lasse Collin <lasse.collin@tukaani.org> 25464 + S: Maintained 25465 + W: https://tukaani.org/xz/embedded.html 25466 + B: https://github.com/tukaani-project/xz-embedded/issues 25467 + C: irc://irc.libera.chat/tukaani 25468 + F: Documentation/staging/xz.rst 25469 + F: include/linux/decompress/unxz.h 25470 + F: include/linux/xz.h 25471 + F: lib/decompress_unxz.c 25472 + F: lib/xz/ 25473 + F: scripts/xz_wrap.sh 25462 25474 25463 25475 YAM DRIVER FOR AX.25 25464 25476 M: Jean-Paul Roubelat <jpr@f6fbb.org>
+1
arch/arm/lib/xor-neon.c
··· 8 8 #include <linux/raid/xor.h> 9 9 #include <linux/module.h> 10 10 11 + MODULE_DESCRIPTION("NEON accelerated XOR implementation"); 11 12 MODULE_LICENSE("GPL"); 12 13 13 14 #ifndef __ARM_NEON__
+1 -1
arch/arm/mach-omap2/omap-mpuss-lowpower.c
··· 333 333 omap_pm_ops.scu_prepare(cpu, power_state); 334 334 335 335 /* 336 - * CPU never retuns back if targeted power state is OFF mode. 336 + * CPU never returns back if targeted power state is OFF mode. 337 337 * CPU ONLINE follows normal CPU ONLINE ptah via 338 338 * omap4_secondary_startup(). 339 339 */
+4 -1
arch/arm64/boot/Makefile
··· 17 17 OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S 18 18 19 19 targets := Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo \ 20 - Image.zst image.fit 20 + Image.zst Image.xz image.fit 21 21 22 22 $(obj)/Image: vmlinux FORCE 23 23 $(call if_changed,objcopy) ··· 39 39 40 40 $(obj)/Image.zst: $(obj)/Image FORCE 41 41 $(call if_changed,zstd) 42 + 43 + $(obj)/Image.xz: $(obj)/Image FORCE 44 + $(call if_changed,xzkern) 42 45 43 46 $(obj)/image.fit: $(obj)/Image $(obj)/dts/dtbs-list FORCE 44 47 $(call if_changed,fit)
-3
arch/powerpc/boot/xz_config.h
··· 50 50 /* prevent the inclusion of the xz-preboot MM headers */ 51 51 #define DECOMPR_MM_H 52 52 #define memmove memmove 53 - #define XZ_EXTERN static 54 53 55 54 /* xz.h needs to be included directly since we need enum xz_mode */ 56 55 #include "../../../include/linux/xz.h" 57 - 58 - #undef XZ_EXTERN 59 56 60 57 #endif
+1
arch/riscv/Kconfig
··· 158 158 select HAVE_KERNEL_LZO if !XIP_KERNEL && !EFI_ZBOOT 159 159 select HAVE_KERNEL_UNCOMPRESSED if !XIP_KERNEL && !EFI_ZBOOT 160 160 select HAVE_KERNEL_ZSTD if !XIP_KERNEL && !EFI_ZBOOT 161 + select HAVE_KERNEL_XZ if !XIP_KERNEL && !EFI_ZBOOT 161 162 select HAVE_KPROBES if !XIP_KERNEL 162 163 select HAVE_KRETPROBES if !XIP_KERNEL 163 164 # https://github.com/ClangBuiltLinux/linux/issues/1881
+4 -2
arch/riscv/Makefile
··· 159 159 boot-image-$(CONFIG_KERNEL_LZMA) := Image.lzma 160 160 boot-image-$(CONFIG_KERNEL_LZO) := Image.lzo 161 161 boot-image-$(CONFIG_KERNEL_ZSTD) := Image.zst 162 + boot-image-$(CONFIG_KERNEL_XZ) := Image.xz 162 163 ifdef CONFIG_RISCV_M_MODE 163 164 boot-image-$(CONFIG_ARCH_CANAAN) := loader.bin 164 165 endif ··· 184 183 vdso-install-y += arch/riscv/kernel/vdso/vdso.so.dbg 185 184 vdso-install-$(CONFIG_COMPAT) += arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg 186 185 187 - BOOT_TARGETS := Image Image.gz Image.bz2 Image.lz4 Image.lzma Image.lzo Image.zst loader loader.bin xipImage vmlinuz.efi 186 + BOOT_TARGETS := Image Image.gz Image.bz2 Image.lz4 Image.lzma Image.lzo Image.zst Image.xz loader loader.bin xipImage vmlinuz.efi 188 187 189 188 all: $(notdir $(KBUILD_IMAGE)) 190 189 191 190 loader.bin: loader 192 - Image.gz Image.bz2 Image.lz4 Image.lzma Image.lzo Image.zst loader xipImage vmlinuz.efi: Image 191 + Image.gz Image.bz2 Image.lz4 Image.lzma Image.lzo Image.zst Image.xz loader xipImage vmlinuz.efi: Image 193 192 194 193 $(BOOT_TARGETS): vmlinux 195 194 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ ··· 226 225 echo ' Image.lzma - Compressed kernel image (arch/riscv/boot/Image.lzma)' 227 226 echo ' Image.lzo - Compressed kernel image (arch/riscv/boot/Image.lzo)' 228 227 echo ' Image.zst - Compressed kernel image (arch/riscv/boot/Image.zst)' 228 + echo ' Image.xz - Compressed kernel image (arch/riscv/boot/Image.xz)' 229 229 echo ' vmlinuz.efi - Compressed EFI kernel image (arch/riscv/boot/vmlinuz.efi)' 230 230 echo ' Default when CONFIG_EFI_ZBOOT=y' 231 231 echo ' xipImage - Execute-in-place kernel image (arch/riscv/boot/xipImage)'
+3
arch/riscv/boot/Makefile
··· 64 64 $(obj)/Image.zst: $(obj)/Image FORCE 65 65 $(call if_changed,zstd) 66 66 67 + $(obj)/Image.xz: $(obj)/Image FORCE 68 + $(call if_changed,xzkern) 69 + 67 70 $(obj)/loader.bin: $(obj)/loader FORCE 68 71 $(call if_changed,objcopy) 69 72
+1
arch/x86/mm/testmmiotrace.c
··· 144 144 module_init(init); 145 145 module_exit(cleanup); 146 146 MODULE_LICENSE("GPL"); 147 + MODULE_DESCRIPTION("Test module for mmiotrace");
+1 -1
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h
··· 231 231 container_of(x, struct dpu_crtc_state, base) 232 232 233 233 /** 234 - * dpu_crtc_frame_pending - retun the number of pending frames 234 + * dpu_crtc_frame_pending - return the number of pending frames 235 235 * @crtc: Pointer to drm crtc object 236 236 */ 237 237 static inline int dpu_crtc_frame_pending(struct drm_crtc *crtc)
-2
drivers/gpu/drm/msm/msm_debugfs.c
··· 357 357 if (priv->kms && priv->kms->funcs->debugfs_init) 358 358 priv->kms->funcs->debugfs_init(priv->kms, minor); 359 359 360 - #ifdef CONFIG_FAULT_INJECTION 361 360 fault_create_debugfs_attr("fail_gem_alloc", minor->debugfs_root, 362 361 &fail_gem_alloc); 363 362 fault_create_debugfs_attr("fail_gem_iova", minor->debugfs_root, 364 363 &fail_gem_iova); 365 - #endif 366 364 } 367 365 #endif 368 366
+1 -2
drivers/gpu/drm/msm/msm_drv.c
··· 7 7 8 8 #include <linux/dma-mapping.h> 9 9 #include <linux/fault-inject.h> 10 + #include <linux/debugfs.h> 10 11 #include <linux/of_address.h> 11 12 #include <linux/uaccess.h> 12 13 ··· 59 58 MODULE_PARM_DESC(modeset, "Use kernel modesetting [KMS] (1=on (default), 0=disable)"); 60 59 module_param(modeset, bool, 0600); 61 60 62 - #ifdef CONFIG_FAULT_INJECTION 63 61 DECLARE_FAULT_ATTR(fail_gem_alloc); 64 62 DECLARE_FAULT_ATTR(fail_gem_iova); 65 - #endif 66 63 67 64 static int msm_drm_uninit(struct device *dev) 68 65 {
-4
drivers/gpu/drm/msm/msm_drv.h
··· 33 33 #include <drm/msm_drm.h> 34 34 #include <drm/drm_gem.h> 35 35 36 - #ifdef CONFIG_FAULT_INJECTION 37 36 extern struct fault_attr fail_gem_alloc; 38 37 extern struct fault_attr fail_gem_iova; 39 - #else 40 - # define should_fail(attr, size) 0 41 - #endif 42 38 43 39 struct msm_kms; 44 40 struct msm_gpu;
+1 -6
drivers/gpu/drm/xe/xe_debugfs.c
··· 6 6 #include "xe_debugfs.h" 7 7 8 8 #include <linux/debugfs.h> 9 + #include <linux/fault-inject.h> 9 10 #include <linux/string_helpers.h> 10 11 11 12 #include <drm/drm_debugfs.h> ··· 27 26 #include "xe_vm.h" 28 27 #endif 29 28 30 - #ifdef CONFIG_FAULT_INJECTION 31 - #include <linux/fault-inject.h> /* XXX: fault-inject.h is broken */ 32 29 DECLARE_FAULT_ATTR(gt_reset_failure); 33 - #endif 34 30 35 31 static struct xe_device *node_to_xe(struct drm_info_node *node) 36 32 { ··· 211 213 for_each_gt(gt, xe, id) 212 214 xe_gt_debugfs_register(gt); 213 215 214 - #ifdef CONFIG_FAULT_INJECTION 215 216 fault_create_debugfs_attr("fail_gt_reset", root, &gt_reset_failure); 216 - #endif 217 - 218 217 }
+2 -8
drivers/gpu/drm/xe/xe_gt.h
··· 6 6 #ifndef _XE_GT_H_ 7 7 #define _XE_GT_H_ 8 8 9 + #include <linux/fault-inject.h> 10 + 9 11 #include <drm/drm_util.h> 10 12 11 13 #include "xe_device.h" ··· 21 19 22 20 #define CCS_MASK(gt) (((gt)->info.engine_mask & XE_HW_ENGINE_CCS_MASK) >> XE_HW_ENGINE_CCS0) 23 21 24 - #ifdef CONFIG_FAULT_INJECTION 25 - #include <linux/fault-inject.h> /* XXX: fault-inject.h is broken */ 26 22 extern struct fault_attr gt_reset_failure; 27 23 static inline bool xe_fault_inject_gt_reset(void) 28 24 { 29 25 return should_fail(&gt_reset_failure, 1); 30 26 } 31 - #else 32 - static inline bool xe_fault_inject_gt_reset(void) 33 - { 34 - return false; 35 - } 36 - #endif 37 27 38 28 struct xe_gt *xe_gt_alloc(struct xe_tile *tile); 39 29 int xe_gt_init_hwconfig(struct xe_gt *gt);
+1 -1
drivers/infiniband/core/sa_query.c
··· 1420 1420 /* 1421 1421 * opa_pr_query_possible - Check if current PR query can be an OPA query. 1422 1422 * 1423 - * Retuns PR_NOT_SUPPORTED if a path record query is not 1423 + * Returns PR_NOT_SUPPORTED if a path record query is not 1424 1424 * possible, PR_OPA_SUPPORTED if an OPA path record query 1425 1425 * is possible and PR_IB_SUPPORTED if an IB path record 1426 1426 * query is possible.
+1 -1
drivers/input/misc/wistron_btns.c
··· 1075 1075 } 1076 1076 1077 1077 if (leds_present & FE_MAIL_LED) { 1078 - /* bios_get_default_setting(MAIL) always retuns 0, so just turn the led off */ 1078 + /* bios_get_default_setting(MAIL) always returns 0, so just turn the led off */ 1079 1079 wistron_mail_led.brightness = LED_OFF; 1080 1080 if (led_classdev_register(parent, &wistron_mail_led)) 1081 1081 leds_present &= ~FE_MAIL_LED;
+1
drivers/iommu/iommufd/selftest.c
··· 7 7 #include <linux/iommu.h> 8 8 #include <linux/xarray.h> 9 9 #include <linux/file.h> 10 + #include <linux/debugfs.h> 10 11 #include <linux/anon_inodes.h> 11 12 #include <linux/fault-inject.h> 12 13 #include <linux/platform_device.h>
+1
drivers/misc/xilinx_tmr_inject.c
··· 12 12 #include <asm/xilinx_mb_manager.h> 13 13 #include <linux/module.h> 14 14 #include <linux/of.h> 15 + #include <linux/debugfs.h> 15 16 #include <linux/platform_device.h> 16 17 #include <linux/fault-inject.h> 17 18
+1 -1
drivers/mtd/nand/raw/nandsim.c
··· 1381 1381 } 1382 1382 1383 1383 /* 1384 - * Retuns a pointer to the current byte, within the current page. 1384 + * Returns a pointer to the current byte, within the current page. 1385 1385 */ 1386 1386 static inline u_char *NS_PAGE_BYTE_OFF(struct nandsim *ns) 1387 1387 {
+1
drivers/nvme/host/fault_inject.c
··· 6 6 */ 7 7 8 8 #include <linux/moduleparam.h> 9 + #include <linux/debugfs.h> 9 10 #include "nvme.h" 10 11 11 12 static DECLARE_FAULT_ATTR(fail_default_attr);
+1 -1
drivers/scsi/bfa/bfa_fcs.c
··· 1431 1431 * param[in] vf_id - VF_ID 1432 1432 * 1433 1433 * return 1434 - * If lookup succeeds, retuns fcs vf object, otherwise returns NULL 1434 + * If lookup succeeds, returns fcs vf object, otherwise returns NULL 1435 1435 */ 1436 1436 bfa_fcs_vf_t * 1437 1437 bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id)
+1 -1
drivers/scsi/pmcraid.c
··· 4009 4009 * This routine un-registers registered interrupt handler and 4010 4010 * also frees irqs/vectors. 4011 4011 * 4012 - * Retun Value 4012 + * Return Value 4013 4013 * None 4014 4014 */ 4015 4015 static
+1
drivers/ufs/core/ufs-fault-injection.c
··· 3 3 #include <linux/kconfig.h> 4 4 #include <linux/types.h> 5 5 #include <linux/fault-inject.h> 6 + #include <linux/debugfs.h> 6 7 #include <linux/module.h> 7 8 #include <ufs/ufshcd.h> 8 9 #include "ufs-fault-injection.h"
+5 -6
fs/nfs/nfs4xdr.c
··· 3447 3447 *res = be32_to_cpup(p); 3448 3448 bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; 3449 3449 } 3450 - dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); 3450 + dprintk("%s: link support=%s\n", __func__, str_false_true(*res == 0)); 3451 3451 return 0; 3452 3452 } 3453 3453 ··· 3465 3465 *res = be32_to_cpup(p); 3466 3466 bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; 3467 3467 } 3468 - dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); 3468 + dprintk("%s: symlink support=%s\n", __func__, str_false_true(*res == 0)); 3469 3469 return 0; 3470 3470 } 3471 3471 ··· 3607 3607 *res = be32_to_cpup(p); 3608 3608 bitmap[0] &= ~FATTR4_WORD0_CASE_INSENSITIVE; 3609 3609 } 3610 - dprintk("%s: case_insensitive=%s\n", __func__, *res == 0 ? "false" : "true"); 3610 + dprintk("%s: case_insensitive=%s\n", __func__, str_false_true(*res == 0)); 3611 3611 return 0; 3612 3612 } 3613 3613 ··· 3625 3625 *res = be32_to_cpup(p); 3626 3626 bitmap[0] &= ~FATTR4_WORD0_CASE_PRESERVING; 3627 3627 } 3628 - dprintk("%s: case_preserving=%s\n", __func__, *res == 0 ? "false" : "true"); 3628 + dprintk("%s: case_preserving=%s\n", __func__, str_false_true(*res == 0)); 3629 3629 return 0; 3630 3630 } 3631 3631 ··· 4333 4333 *res = be32_to_cpup(p); 4334 4334 bitmap[2] &= ~FATTR4_WORD2_XATTR_SUPPORT; 4335 4335 } 4336 - dprintk("%s: XATTR support=%s\n", __func__, 4337 - *res == 0 ? "false" : "true"); 4336 + dprintk("%s: XATTR support=%s\n", __func__, str_false_true(*res == 0)); 4338 4337 return 0; 4339 4338 } 4340 4339
+1 -1
fs/nilfs2/alloc.h
··· 37 37 int nilfs_palloc_count_max_entries(struct inode *, u64, u64 *); 38 38 39 39 /** 40 - * nilfs_palloc_req - persistent allocator request and reply 40 + * struct nilfs_palloc_req - persistent allocator request and reply 41 41 * @pr_entry_nr: entry number (vblocknr or inode number) 42 42 * @pr_desc_bh: buffer head of the buffer containing block group descriptors 43 43 * @pr_bitmap_bh: buffer head of the buffer containing a block group bitmap
+1 -1
fs/nilfs2/bmap.c
··· 349 349 } 350 350 351 351 /** 352 - * nilfs_bmap_lookup_dirty_buffers - 352 + * nilfs_bmap_lookup_dirty_buffers - collect dirty block buffers 353 353 * @bmap: bmap 354 354 * @listp: pointer to buffer head list 355 355 */
+16 -4
fs/nilfs2/bmap.h
··· 44 44 45 45 /** 46 46 * struct nilfs_bmap_operations - bmap operation table 47 + * @bop_lookup: single block search operation 48 + * @bop_lookup_contig: consecutive block search operation 49 + * @bop_insert: block insertion operation 50 + * @bop_delete: block delete operation 51 + * @bop_clear: block mapping resource release operation 52 + * @bop_propagate: operation to propagate dirty state towards the 53 + * mapping root 54 + * @bop_lookup_dirty_buffers: operation to collect dirty block buffers 55 + * @bop_assign: disk block address assignment operation 56 + * @bop_mark: operation to mark in-use blocks as dirty for 57 + * relocation by GC 58 + * @bop_seek_key: find valid block key operation 59 + * @bop_last_key: find last valid block key operation 47 60 */ 48 61 struct nilfs_bmap_operations { 49 62 int (*bop_lookup)(const struct nilfs_bmap *, __u64, int, __u64 *); ··· 79 66 int (*bop_seek_key)(const struct nilfs_bmap *, __u64, __u64 *); 80 67 int (*bop_last_key)(const struct nilfs_bmap *, __u64 *); 81 68 82 - /* The following functions are internal use only. */ 69 + /* private: internal use only */ 83 70 int (*bop_check_insert)(const struct nilfs_bmap *, __u64); 84 71 int (*bop_check_delete)(struct nilfs_bmap *, __u64); 85 72 int (*bop_gather_data)(struct nilfs_bmap *, __u64 *, __u64 *, int); ··· 87 74 88 75 89 76 #define NILFS_BMAP_SIZE (NILFS_INODE_BMAP_SIZE * sizeof(__le64)) 90 - #define NILFS_BMAP_KEY_BIT (sizeof(unsigned long) * 8 /* CHAR_BIT */) 91 - #define NILFS_BMAP_NEW_PTR_INIT \ 92 - (1UL << (sizeof(unsigned long) * 8 /* CHAR_BIT */ - 1)) 77 + #define NILFS_BMAP_KEY_BIT BITS_PER_LONG 78 + #define NILFS_BMAP_NEW_PTR_INIT (1UL << (BITS_PER_LONG - 1)) 93 79 94 80 static inline int nilfs_bmap_is_new_ptr(unsigned long ptr) 95 81 {
+54 -9
fs/nilfs2/btnode.c
··· 179 179 } 180 180 181 181 /** 182 - * nilfs_btnode_prepare_change_key 183 - * prepare to move contents of the block for old key to one of new key. 184 - * the old buffer will not be removed, but might be reused for new buffer. 185 - * it might return -ENOMEM because of memory allocation errors, 186 - * and might return -EIO because of disk read errors. 182 + * nilfs_btnode_prepare_change_key - prepare to change the search key of a 183 + * b-tree node block 184 + * @btnc: page cache in which the b-tree node block is buffered 185 + * @ctxt: structure for exchanging context information for key change 186 + * 187 + * nilfs_btnode_prepare_change_key() prepares to move the contents of the 188 + * b-tree node block of the old key given in the "oldkey" member of @ctxt to 189 + * the position of the new key given in the "newkey" member of @ctxt in the 190 + * page cache @btnc. Here, the key of the block is an index in units of 191 + * blocks, and if the page and block sizes match, it matches the page index 192 + * in the page cache. 193 + * 194 + * If the page size and block size match, this function attempts to move the 195 + * entire folio, and in preparation for this, inserts the original folio into 196 + * the new index of the cache. If this insertion fails or if the page size 197 + * and block size are different, it falls back to a copy preparation using 198 + * nilfs_btnode_create_block(), inserts a new block at the position 199 + * corresponding to "newkey", and stores the buffer head pointer in the 200 + * "newbh" member of @ctxt. 201 + * 202 + * Note that the current implementation does not support folio sizes larger 203 + * than the page size. 204 + * 205 + * Return: 0 on success, or the following negative error code on failure. 206 + * * %-EIO - I/O error (metadata corruption). 207 + * * %-ENOMEM - Insufficient memory available. 187 208 */ 188 209 int nilfs_btnode_prepare_change_key(struct address_space *btnc, 189 210 struct nilfs_btnode_chkey_ctxt *ctxt) ··· 266 245 } 267 246 268 247 /** 269 - * nilfs_btnode_commit_change_key 270 - * commit the change_key operation prepared by prepare_change_key(). 248 + * nilfs_btnode_commit_change_key - commit the change of the search key of 249 + * a b-tree node block 250 + * @btnc: page cache in which the b-tree node block is buffered 251 + * @ctxt: structure for exchanging context information for key change 252 + * 253 + * nilfs_btnode_commit_change_key() executes the key change based on the 254 + * context @ctxt prepared by nilfs_btnode_prepare_change_key(). If no valid 255 + * block buffer is prepared in "newbh" of @ctxt (i.e., a full folio move), 256 + * this function removes the folio from the old index and completes the move. 257 + * Otherwise, it copies the block data and inherited flag states of "oldbh" 258 + * to "newbh" and clears the "oldbh" from the cache. In either case, the 259 + * relocated buffer is marked as dirty. 260 + * 261 + * As with nilfs_btnode_prepare_change_key(), the current implementation does 262 + * not support folio sizes larger than the page size. 271 263 */ 272 264 void nilfs_btnode_commit_change_key(struct address_space *btnc, 273 265 struct nilfs_btnode_chkey_ctxt *ctxt) ··· 319 285 } 320 286 321 287 /** 322 - * nilfs_btnode_abort_change_key 323 - * abort the change_key operation prepared by prepare_change_key(). 288 + * nilfs_btnode_abort_change_key - abort the change of the search key of a 289 + * b-tree node block 290 + * @btnc: page cache in which the b-tree node block is buffered 291 + * @ctxt: structure for exchanging context information for key change 292 + * 293 + * nilfs_btnode_abort_change_key() cancels the key change associated with the 294 + * context @ctxt prepared via nilfs_btnode_prepare_change_key() and performs 295 + * any necessary cleanup. If no valid block buffer is prepared in "newbh" of 296 + * @ctxt, this function removes the folio from the destination index and aborts 297 + * the move. Otherwise, it clears "newbh" from the cache. 298 + * 299 + * As with nilfs_btnode_prepare_change_key(), the current implementation does 300 + * not support folio sizes larger than the page size. 324 301 */ 325 302 void nilfs_btnode_abort_change_key(struct address_space *btnc, 326 303 struct nilfs_btnode_chkey_ctxt *ctxt)
+8 -4
fs/nilfs2/btree.c
··· 350 350 if (unlikely(level < NILFS_BTREE_LEVEL_NODE_MIN || 351 351 level >= NILFS_BTREE_LEVEL_MAX || 352 352 (flags & NILFS_BTREE_NODE_ROOT) || 353 - nchildren < 0 || 353 + nchildren <= 0 || 354 354 nchildren > NILFS_BTREE_NODE_NCHILDREN_MAX(size))) { 355 355 nilfs_crit(inode->i_sb, 356 356 "bad btree node (ino=%lu, blocknr=%llu): level = %d, flags = 0x%x, nchildren = %d", ··· 381 381 if (unlikely(level < NILFS_BTREE_LEVEL_NODE_MIN || 382 382 level >= NILFS_BTREE_LEVEL_MAX || 383 383 nchildren < 0 || 384 - nchildren > NILFS_BTREE_ROOT_NCHILDREN_MAX)) { 384 + nchildren > NILFS_BTREE_ROOT_NCHILDREN_MAX || 385 + (nchildren == 0 && level > NILFS_BTREE_LEVEL_NODE_MIN))) { 385 386 nilfs_crit(inode->i_sb, 386 387 "bad btree root (ino=%lu): level = %d, flags = 0x%x, nchildren = %d", 387 388 inode->i_ino, level, flags, nchildren); ··· 1659 1658 int nchildren, ret; 1660 1659 1661 1660 root = nilfs_btree_get_root(btree); 1661 + nchildren = nilfs_btree_node_get_nchildren(root); 1662 + if (unlikely(nchildren == 0)) 1663 + return 0; 1664 + 1662 1665 switch (nilfs_btree_height(btree)) { 1663 1666 case 2: 1664 1667 bh = NULL; 1665 1668 node = root; 1666 1669 break; 1667 1670 case 3: 1668 - nchildren = nilfs_btree_node_get_nchildren(root); 1669 1671 if (nchildren > 1) 1670 1672 return 0; 1671 1673 ptr = nilfs_btree_node_get_ptr(root, nchildren - 1, ··· 1677 1673 if (ret < 0) 1678 1674 return ret; 1679 1675 node = (struct nilfs_btree_node *)bh->b_data; 1676 + nchildren = nilfs_btree_node_get_nchildren(node); 1680 1677 break; 1681 1678 default: 1682 1679 return 0; 1683 1680 } 1684 1681 1685 - nchildren = nilfs_btree_node_get_nchildren(node); 1686 1682 maxkey = nilfs_btree_node_get_key(node, nchildren - 1); 1687 1683 nextmaxkey = (nchildren > 1) ? 1688 1684 nilfs_btree_node_get_key(node, nchildren - 2) : 0;
+1
fs/nilfs2/btree.h
··· 24 24 * @bp_index: index of child node 25 25 * @bp_oldreq: ptr end request for old ptr 26 26 * @bp_newreq: ptr alloc request for new ptr 27 + * @bp_ctxt: context information for changing the key of a b-tree node block 27 28 * @bp_op: rebalance operation 28 29 */ 29 30 struct nilfs_btree_path {
+28 -26
fs/nilfs2/cpfile.c
··· 125 125 } 126 126 } 127 127 128 - static inline int nilfs_cpfile_get_header_block(struct inode *cpfile, 129 - struct buffer_head **bhp) 128 + static int nilfs_cpfile_get_header_block(struct inode *cpfile, 129 + struct buffer_head **bhp) 130 130 { 131 - return nilfs_mdt_get_block(cpfile, 0, 0, NULL, bhp); 131 + int err = nilfs_mdt_get_block(cpfile, 0, 0, NULL, bhp); 132 + 133 + if (unlikely(err == -ENOENT)) { 134 + nilfs_error(cpfile->i_sb, 135 + "missing header block in checkpoint metadata"); 136 + err = -EIO; 137 + } 138 + return err; 132 139 } 133 140 134 141 static inline int nilfs_cpfile_get_checkpoint_block(struct inode *cpfile, ··· 290 283 291 284 down_write(&NILFS_MDT(cpfile)->mi_sem); 292 285 ret = nilfs_cpfile_get_header_block(cpfile, &header_bh); 293 - if (unlikely(ret < 0)) { 294 - if (ret == -ENOENT) { 295 - nilfs_error(cpfile->i_sb, 296 - "checkpoint creation failed due to metadata corruption."); 297 - ret = -EIO; 298 - } 286 + if (unlikely(ret < 0)) 299 287 goto out_sem; 300 - } 288 + 301 289 ret = nilfs_cpfile_get_checkpoint_block(cpfile, cno, 1, &cp_bh); 302 290 if (unlikely(ret < 0)) 303 291 goto out_header; ··· 706 704 } 707 705 708 706 /** 709 - * nilfs_cpfile_delete_checkpoint - 710 - * @cpfile: 711 - * @cno: 707 + * nilfs_cpfile_delete_checkpoint - delete a checkpoint 708 + * @cpfile: checkpoint file inode 709 + * @cno: checkpoint number to delete 710 + * 711 + * Return: 0 on success, or the following negative error code on failure. 712 + * * %-EBUSY - Checkpoint in use (snapshot specified). 713 + * * %-EIO - I/O error (including metadata corruption). 714 + * * %-ENOENT - No valid checkpoint found. 715 + * * %-ENOMEM - Insufficient memory available. 712 716 */ 713 717 int nilfs_cpfile_delete_checkpoint(struct inode *cpfile, __u64 cno) 714 718 { ··· 976 968 } 977 969 978 970 /** 979 - * nilfs_cpfile_is_snapshot - 971 + * nilfs_cpfile_is_snapshot - determine if checkpoint is a snapshot 980 972 * @cpfile: inode of checkpoint file 981 - * @cno: checkpoint number 973 + * @cno: checkpoint number 982 974 * 983 - * Description: 984 - * 985 - * Return Value: On success, 1 is returned if the checkpoint specified by 986 - * @cno is a snapshot, or 0 if not. On error, one of the following negative 987 - * error codes is returned. 988 - * 989 - * %-EIO - I/O error. 990 - * 991 - * %-ENOMEM - Insufficient amount of memory available. 992 - * 993 - * %-ENOENT - No such checkpoint. 975 + * Return: 1 if the checkpoint specified by @cno is a snapshot, 0 if not, or 976 + * the following negative error code on failure. 977 + * * %-EIO - I/O error (including metadata corruption). 978 + * * %-ENOENT - No such checkpoint. 979 + * * %-ENOMEM - Insufficient memory available. 994 980 */ 995 981 int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 cno) 996 982 {
+7 -10
fs/nilfs2/dat.c
··· 271 271 } 272 272 273 273 /** 274 - * nilfs_dat_mark_dirty - 275 - * @dat: DAT file inode 274 + * nilfs_dat_mark_dirty - mark the DAT block buffer containing the specified 275 + * virtual block address entry as dirty 276 + * @dat: DAT file inode 276 277 * @vblocknr: virtual block number 277 278 * 278 - * Description: 279 - * 280 - * Return Value: On success, 0 is returned. On error, one of the following 281 - * negative error codes is returned. 282 - * 283 - * %-EIO - I/O error. 284 - * 285 - * %-ENOMEM - Insufficient amount of memory available. 279 + * Return: 0 on success, or the following negative error code on failure. 280 + * * %-EINVAL - Invalid DAT entry (internal code). 281 + * * %-EIO - I/O error (including metadata corruption). 282 + * * %-ENOMEM - Insufficient memory available. 286 283 */ 287 284 int nilfs_dat_mark_dirty(struct inode *dat, __u64 vblocknr) 288 285 {
+5 -39
fs/nilfs2/dir.c
··· 231 231 nilfs_rec_len_from_disk(p->rec_len)); 232 232 } 233 233 234 - static unsigned char 235 - nilfs_filetype_table[NILFS_FT_MAX] = { 236 - [NILFS_FT_UNKNOWN] = DT_UNKNOWN, 237 - [NILFS_FT_REG_FILE] = DT_REG, 238 - [NILFS_FT_DIR] = DT_DIR, 239 - [NILFS_FT_CHRDEV] = DT_CHR, 240 - [NILFS_FT_BLKDEV] = DT_BLK, 241 - [NILFS_FT_FIFO] = DT_FIFO, 242 - [NILFS_FT_SOCK] = DT_SOCK, 243 - [NILFS_FT_SYMLINK] = DT_LNK, 244 - }; 245 - 246 - #define S_SHIFT 12 247 - static unsigned char 248 - nilfs_type_by_mode[(S_IFMT >> S_SHIFT) + 1] = { 249 - [S_IFREG >> S_SHIFT] = NILFS_FT_REG_FILE, 250 - [S_IFDIR >> S_SHIFT] = NILFS_FT_DIR, 251 - [S_IFCHR >> S_SHIFT] = NILFS_FT_CHRDEV, 252 - [S_IFBLK >> S_SHIFT] = NILFS_FT_BLKDEV, 253 - [S_IFIFO >> S_SHIFT] = NILFS_FT_FIFO, 254 - [S_IFSOCK >> S_SHIFT] = NILFS_FT_SOCK, 255 - [S_IFLNK >> S_SHIFT] = NILFS_FT_SYMLINK, 256 - }; 257 - 258 - static void nilfs_set_de_type(struct nilfs_dir_entry *de, struct inode *inode) 259 - { 260 - umode_t mode = inode->i_mode; 261 - 262 - de->file_type = nilfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; 263 - } 264 - 265 234 static int nilfs_readdir(struct file *file, struct dir_context *ctx) 266 235 { 267 236 loff_t pos = ctx->pos; ··· 266 297 if (de->inode) { 267 298 unsigned char t; 268 299 269 - if (de->file_type < NILFS_FT_MAX) 270 - t = nilfs_filetype_table[de->file_type]; 271 - else 272 - t = DT_UNKNOWN; 300 + t = fs_ftype_to_dtype(de->file_type); 273 301 274 302 if (!dir_emit(ctx, de->name, de->name_len, 275 303 le64_to_cpu(de->inode), t)) { ··· 410 444 err = nilfs_prepare_chunk(folio, from, to); 411 445 BUG_ON(err); 412 446 de->inode = cpu_to_le64(inode->i_ino); 413 - nilfs_set_de_type(de, inode); 447 + de->file_type = fs_umode_to_ftype(inode->i_mode); 414 448 nilfs_commit_chunk(folio, mapping, from, to); 415 449 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); 416 450 } ··· 497 531 de->name_len = namelen; 498 532 memcpy(de->name, name, namelen); 499 533 de->inode = cpu_to_le64(inode->i_ino); 500 - nilfs_set_de_type(de, inode); 534 + de->file_type = fs_umode_to_ftype(inode->i_mode); 501 535 nilfs_commit_chunk(folio, folio->mapping, from, to); 502 536 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); 503 537 nilfs_mark_inode_dirty(dir); ··· 578 612 de->rec_len = nilfs_rec_len_to_disk(NILFS_DIR_REC_LEN(1)); 579 613 memcpy(de->name, ".\0\0", 4); 580 614 de->inode = cpu_to_le64(inode->i_ino); 581 - nilfs_set_de_type(de, inode); 615 + de->file_type = fs_umode_to_ftype(inode->i_mode); 582 616 583 617 de = (struct nilfs_dir_entry *)(kaddr + NILFS_DIR_REC_LEN(1)); 584 618 de->name_len = 2; 585 619 de->rec_len = nilfs_rec_len_to_disk(chunk_size - NILFS_DIR_REC_LEN(1)); 586 620 de->inode = cpu_to_le64(parent->i_ino); 587 621 memcpy(de->name, "..\0", 4); 588 - nilfs_set_de_type(de, inode); 622 + de->file_type = fs_umode_to_ftype(inode->i_mode); 589 623 kunmap_local(kaddr); 590 624 nilfs_commit_chunk(folio, mapping, 0, chunk_size); 591 625 fail:
+18 -61
fs/nilfs2/inode.c
··· 15 15 #include <linux/writeback.h> 16 16 #include <linux/uio.h> 17 17 #include <linux/fiemap.h> 18 + #include <linux/random.h> 18 19 #include "nilfs.h" 19 20 #include "btnode.h" 20 21 #include "segment.h" ··· 29 28 * @ino: inode number 30 29 * @cno: checkpoint number 31 30 * @root: pointer on NILFS root object (mounted checkpoint) 32 - * @for_gc: inode for GC flag 33 - * @for_btnc: inode for B-tree node cache flag 34 - * @for_shadow: inode for shadowed page cache flag 31 + * @type: inode type 35 32 */ 36 33 struct nilfs_iget_args { 37 34 u64 ino; 38 35 __u64 cno; 39 36 struct nilfs_root *root; 40 - bool for_gc; 41 - bool for_btnc; 42 - bool for_shadow; 37 + unsigned int type; 43 38 }; 44 39 45 40 static int nilfs_iget_test(struct inode *inode, void *opaque); ··· 159 162 int err = 0; 160 163 161 164 if (sb_rdonly(inode->i_sb)) { 162 - nilfs_clear_dirty_pages(mapping, false); 165 + nilfs_clear_dirty_pages(mapping); 163 166 return -EROFS; 164 167 } 165 168 ··· 183 186 * have dirty pages that try to be flushed in background. 184 187 * So, here we simply discard this dirty page. 185 188 */ 186 - nilfs_clear_folio_dirty(folio, false); 189 + nilfs_clear_folio_dirty(folio); 187 190 folio_unlock(folio); 188 191 return -EROFS; 189 192 } ··· 312 315 unsigned long ino) 313 316 { 314 317 struct nilfs_iget_args args = { 315 - .ino = ino, .root = root, .cno = 0, .for_gc = false, 316 - .for_btnc = false, .for_shadow = false 318 + .ino = ino, .root = root, .cno = 0, .type = NILFS_I_TYPE_NORMAL 317 319 }; 318 320 319 321 return insert_inode_locked4(inode, ino, nilfs_iget_test, &args); ··· 321 325 struct inode *nilfs_new_inode(struct inode *dir, umode_t mode) 322 326 { 323 327 struct super_block *sb = dir->i_sb; 324 - struct the_nilfs *nilfs = sb->s_fs_info; 325 328 struct inode *inode; 326 329 struct nilfs_inode_info *ii; 327 330 struct nilfs_root *root; ··· 338 343 root = NILFS_I(dir)->i_root; 339 344 ii = NILFS_I(inode); 340 345 ii->i_state = BIT(NILFS_I_NEW); 346 + ii->i_type = NILFS_I_TYPE_NORMAL; 341 347 ii->i_root = root; 342 348 343 349 err = nilfs_ifile_create_inode(root->ifile, &ino, &bh); 344 350 if (unlikely(err)) 345 351 goto failed_ifile_create_inode; 346 352 /* reference count of i_bh inherits from nilfs_mdt_read_block() */ 347 - 348 - if (unlikely(ino < NILFS_USER_INO)) { 349 - nilfs_warn(sb, 350 - "inode bitmap is inconsistent for reserved inodes"); 351 - do { 352 - brelse(bh); 353 - err = nilfs_ifile_create_inode(root->ifile, &ino, &bh); 354 - if (unlikely(err)) 355 - goto failed_ifile_create_inode; 356 - } while (ino < NILFS_USER_INO); 357 - 358 - nilfs_info(sb, "repaired inode bitmap for reserved inodes"); 359 - } 360 353 ii->i_bh = bh; 361 354 362 355 atomic64_inc(&root->inodes_count); ··· 368 385 /* ii->i_dir_acl = 0; */ 369 386 ii->i_dir_start_lookup = 0; 370 387 nilfs_set_inode_flags(inode); 371 - spin_lock(&nilfs->ns_next_gen_lock); 372 - inode->i_generation = nilfs->ns_next_generation++; 373 - spin_unlock(&nilfs->ns_next_gen_lock); 388 + inode->i_generation = get_random_u32(); 374 389 if (nilfs_insert_inode_locked(inode, root, ino) < 0) { 375 390 err = -EIO; 376 391 goto failed_after_creation; ··· 527 546 return 0; 528 547 529 548 ii = NILFS_I(inode); 530 - if (test_bit(NILFS_I_BTNC, &ii->i_state)) { 531 - if (!args->for_btnc) 532 - return 0; 533 - } else if (args->for_btnc) { 549 + if (ii->i_type != args->type) 534 550 return 0; 535 - } 536 - if (test_bit(NILFS_I_SHADOW, &ii->i_state)) { 537 - if (!args->for_shadow) 538 - return 0; 539 - } else if (args->for_shadow) { 540 - return 0; 541 - } 542 551 543 - if (!test_bit(NILFS_I_GCINODE, &ii->i_state)) 544 - return !args->for_gc; 545 - 546 - return args->for_gc && args->cno == ii->i_cno; 552 + return !(args->type & NILFS_I_TYPE_GC) || args->cno == ii->i_cno; 547 553 } 548 554 549 555 static int nilfs_iget_set(struct inode *inode, void *opaque) ··· 540 572 inode->i_ino = args->ino; 541 573 NILFS_I(inode)->i_cno = args->cno; 542 574 NILFS_I(inode)->i_root = args->root; 575 + NILFS_I(inode)->i_type = args->type; 543 576 if (args->root && args->ino == NILFS_ROOT_INO) 544 577 nilfs_get_root(args->root); 545 - 546 - if (args->for_gc) 547 - NILFS_I(inode)->i_state = BIT(NILFS_I_GCINODE); 548 - if (args->for_btnc) 549 - NILFS_I(inode)->i_state |= BIT(NILFS_I_BTNC); 550 - if (args->for_shadow) 551 - NILFS_I(inode)->i_state |= BIT(NILFS_I_SHADOW); 552 578 return 0; 553 579 } 554 580 ··· 550 588 unsigned long ino) 551 589 { 552 590 struct nilfs_iget_args args = { 553 - .ino = ino, .root = root, .cno = 0, .for_gc = false, 554 - .for_btnc = false, .for_shadow = false 591 + .ino = ino, .root = root, .cno = 0, .type = NILFS_I_TYPE_NORMAL 555 592 }; 556 593 557 594 return ilookup5(sb, ino, nilfs_iget_test, &args); ··· 560 599 unsigned long ino) 561 600 { 562 601 struct nilfs_iget_args args = { 563 - .ino = ino, .root = root, .cno = 0, .for_gc = false, 564 - .for_btnc = false, .for_shadow = false 602 + .ino = ino, .root = root, .cno = 0, .type = NILFS_I_TYPE_NORMAL 565 603 }; 566 604 567 605 return iget5_locked(sb, ino, nilfs_iget_test, nilfs_iget_set, &args); ··· 591 631 __u64 cno) 592 632 { 593 633 struct nilfs_iget_args args = { 594 - .ino = ino, .root = NULL, .cno = cno, .for_gc = true, 595 - .for_btnc = false, .for_shadow = false 634 + .ino = ino, .root = NULL, .cno = cno, .type = NILFS_I_TYPE_GC 596 635 }; 597 636 struct inode *inode; 598 637 int err; ··· 636 677 args.ino = inode->i_ino; 637 678 args.root = ii->i_root; 638 679 args.cno = ii->i_cno; 639 - args.for_gc = test_bit(NILFS_I_GCINODE, &ii->i_state) != 0; 640 - args.for_btnc = true; 641 - args.for_shadow = test_bit(NILFS_I_SHADOW, &ii->i_state) != 0; 680 + args.type = ii->i_type | NILFS_I_TYPE_BTNC; 642 681 643 682 btnc_inode = iget5_locked(inode->i_sb, inode->i_ino, nilfs_iget_test, 644 683 nilfs_iget_set, &args); ··· 690 733 struct inode *nilfs_iget_for_shadow(struct inode *inode) 691 734 { 692 735 struct nilfs_iget_args args = { 693 - .ino = inode->i_ino, .root = NULL, .cno = 0, .for_gc = false, 694 - .for_btnc = false, .for_shadow = true 736 + .ino = inode->i_ino, .root = NULL, .cno = 0, 737 + .type = NILFS_I_TYPE_SHADOW 695 738 }; 696 739 struct inode *s_inode; 697 740 int err; ··· 857 900 if (test_bit(NILFS_I_BMAP, &ii->i_state)) 858 901 nilfs_bmap_clear(ii->i_bmap); 859 902 860 - if (!test_bit(NILFS_I_BTNC, &ii->i_state)) 903 + if (!(ii->i_type & NILFS_I_TYPE_BTNC)) 861 904 nilfs_detach_btree_node_cache(inode); 862 905 863 906 if (ii->i_root && inode->i_ino == NILFS_ROOT_INO)
+107 -2
fs/nilfs2/ioctl.c
··· 17 17 #include <linux/mount.h> /* mnt_want_write_file(), mnt_drop_write_file() */ 18 18 #include <linux/buffer_head.h> 19 19 #include <linux/fileattr.h> 20 + #include <linux/string.h> 20 21 #include "nilfs.h" 21 22 #include "segment.h" 22 23 #include "bmap.h" ··· 115 114 } 116 115 117 116 /** 118 - * nilfs_fileattr_get - ioctl to support lsattr 117 + * nilfs_fileattr_get - retrieve miscellaneous file attributes 118 + * @dentry: the object to retrieve from 119 + * @fa: fileattr pointer 120 + * 121 + * Return: always 0 as success. 119 122 */ 120 123 int nilfs_fileattr_get(struct dentry *dentry, struct fileattr *fa) 121 124 { ··· 131 126 } 132 127 133 128 /** 134 - * nilfs_fileattr_set - ioctl to support chattr 129 + * nilfs_fileattr_set - change miscellaneous file attributes 130 + * @idmap: idmap of the mount 131 + * @dentry: the object to change 132 + * @fa: fileattr pointer 133 + * 134 + * Return: 0 on success, or a negative error code on failure. 135 135 */ 136 136 int nilfs_fileattr_set(struct mnt_idmap *idmap, 137 137 struct dentry *dentry, struct fileattr *fa) ··· 169 159 170 160 /** 171 161 * nilfs_ioctl_getversion - get info about a file's version (generation number) 162 + * @inode: inode object 163 + * @argp: userspace memory where the generation number of @inode is stored 164 + * 165 + * Return: 0 on success, or %-EFAULT on error. 172 166 */ 173 167 static int nilfs_ioctl_getversion(struct inode *inode, void __user *argp) 174 168 { ··· 1280 1266 return ret; 1281 1267 } 1282 1268 1269 + /** 1270 + * nilfs_ioctl_get_fslabel - get the volume name of the file system 1271 + * @sb: super block instance 1272 + * @argp: pointer to userspace memory where the volume name should be stored 1273 + * 1274 + * Return: 0 on success, %-EFAULT if copying to userspace memory fails. 1275 + */ 1276 + static int nilfs_ioctl_get_fslabel(struct super_block *sb, void __user *argp) 1277 + { 1278 + struct the_nilfs *nilfs = sb->s_fs_info; 1279 + char label[NILFS_MAX_VOLUME_NAME + 1]; 1280 + 1281 + BUILD_BUG_ON(NILFS_MAX_VOLUME_NAME >= FSLABEL_MAX); 1282 + 1283 + down_read(&nilfs->ns_sem); 1284 + memtostr_pad(label, nilfs->ns_sbp[0]->s_volume_name); 1285 + up_read(&nilfs->ns_sem); 1286 + 1287 + if (copy_to_user(argp, label, sizeof(label))) 1288 + return -EFAULT; 1289 + return 0; 1290 + } 1291 + 1292 + /** 1293 + * nilfs_ioctl_set_fslabel - set the volume name of the file system 1294 + * @sb: super block instance 1295 + * @filp: file object 1296 + * @argp: pointer to userspace memory that contains the volume name 1297 + * 1298 + * Return: 0 on success, or the following negative error code on failure. 1299 + * * %-EFAULT - Error copying input data. 1300 + * * %-EINVAL - Label length exceeds record size in superblock. 1301 + * * %-EIO - I/O error. 1302 + * * %-EPERM - Operation not permitted (insufficient permissions). 1303 + * * %-EROFS - Read only file system. 1304 + */ 1305 + static int nilfs_ioctl_set_fslabel(struct super_block *sb, struct file *filp, 1306 + void __user *argp) 1307 + { 1308 + char label[NILFS_MAX_VOLUME_NAME + 1]; 1309 + struct the_nilfs *nilfs = sb->s_fs_info; 1310 + struct nilfs_super_block **sbp; 1311 + size_t len; 1312 + int ret; 1313 + 1314 + if (!capable(CAP_SYS_ADMIN)) 1315 + return -EPERM; 1316 + 1317 + ret = mnt_want_write_file(filp); 1318 + if (ret) 1319 + return ret; 1320 + 1321 + if (copy_from_user(label, argp, NILFS_MAX_VOLUME_NAME + 1)) { 1322 + ret = -EFAULT; 1323 + goto out_drop_write; 1324 + } 1325 + 1326 + len = strnlen(label, NILFS_MAX_VOLUME_NAME + 1); 1327 + if (len > NILFS_MAX_VOLUME_NAME) { 1328 + nilfs_err(sb, "unable to set label with more than %zu bytes", 1329 + NILFS_MAX_VOLUME_NAME); 1330 + ret = -EINVAL; 1331 + goto out_drop_write; 1332 + } 1333 + 1334 + down_write(&nilfs->ns_sem); 1335 + sbp = nilfs_prepare_super(sb, false); 1336 + if (unlikely(!sbp)) { 1337 + ret = -EIO; 1338 + goto out_unlock; 1339 + } 1340 + 1341 + strtomem_pad(sbp[0]->s_volume_name, label, 0); 1342 + if (sbp[1]) 1343 + strtomem_pad(sbp[1]->s_volume_name, label, 0); 1344 + 1345 + ret = nilfs_commit_super(sb, NILFS_SB_COMMIT_ALL); 1346 + 1347 + out_unlock: 1348 + up_write(&nilfs->ns_sem); 1349 + out_drop_write: 1350 + mnt_drop_write_file(filp); 1351 + return ret; 1352 + } 1353 + 1283 1354 long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 1284 1355 { 1285 1356 struct inode *inode = file_inode(filp); ··· 1407 1308 return nilfs_ioctl_set_alloc_range(inode, argp); 1408 1309 case FITRIM: 1409 1310 return nilfs_ioctl_trim_fs(inode, argp); 1311 + case FS_IOC_GETFSLABEL: 1312 + return nilfs_ioctl_get_fslabel(inode->i_sb, argp); 1313 + case FS_IOC_SETFSLABEL: 1314 + return nilfs_ioctl_set_fslabel(inode->i_sb, filp, argp); 1410 1315 default: 1411 1316 return -ENOTTY; 1412 1317 } ··· 1437 1334 case NILFS_IOCTL_RESIZE: 1438 1335 case NILFS_IOCTL_SET_ALLOC_RANGE: 1439 1336 case FITRIM: 1337 + case FS_IOC_GETFSLABEL: 1338 + case FS_IOC_SETFSLABEL: 1440 1339 break; 1441 1340 default: 1442 1341 return -ENOIOCTLCMD;
+3 -3
fs/nilfs2/mdt.c
··· 411 411 * have dirty folios that try to be flushed in background. 412 412 * So, here we simply discard this dirty folio. 413 413 */ 414 - nilfs_clear_folio_dirty(folio, false); 414 + nilfs_clear_folio_dirty(folio); 415 415 folio_unlock(folio); 416 416 return -EROFS; 417 417 } ··· 638 638 if (mi->mi_palloc_cache) 639 639 nilfs_palloc_clear_cache(inode); 640 640 641 - nilfs_clear_dirty_pages(inode->i_mapping, true); 641 + nilfs_clear_dirty_pages(inode->i_mapping); 642 642 nilfs_copy_back_pages(inode->i_mapping, shadow->inode->i_mapping); 643 643 644 - nilfs_clear_dirty_pages(ii->i_assoc_inode->i_mapping, true); 644 + nilfs_clear_dirty_pages(ii->i_assoc_inode->i_mapping); 645 645 nilfs_copy_back_pages(ii->i_assoc_inode->i_mapping, 646 646 NILFS_I(shadow->inode)->i_assoc_inode->i_mapping); 647 647
+24 -3
fs/nilfs2/nilfs.h
··· 22 22 /** 23 23 * struct nilfs_inode_info - nilfs inode data in memory 24 24 * @i_flags: inode flags 25 + * @i_type: inode type (combination of flags that inidicate usage) 25 26 * @i_state: dynamic state flags 26 27 * @i_bmap: pointer on i_bmap_data 27 28 * @i_bmap_data: raw block mapping ··· 38 37 */ 39 38 struct nilfs_inode_info { 40 39 __u32 i_flags; 40 + unsigned int i_type; 41 41 unsigned long i_state; /* Dynamic state flags */ 42 42 struct nilfs_bmap *i_bmap; 43 43 struct nilfs_bmap i_bmap_data; ··· 92 90 NILFS_I_UPDATED, /* The file has been written back */ 93 91 NILFS_I_INODE_SYNC, /* dsync is not allowed for inode */ 94 92 NILFS_I_BMAP, /* has bmap and btnode_cache */ 95 - NILFS_I_GCINODE, /* inode for GC, on memory only */ 96 - NILFS_I_BTNC, /* inode for btree node cache */ 97 - NILFS_I_SHADOW, /* inode for shadowed page cache */ 93 + }; 94 + 95 + /* 96 + * Flags to identify the usage of on-memory inodes (i_type) 97 + */ 98 + enum { 99 + NILFS_I_TYPE_NORMAL = 0, 100 + NILFS_I_TYPE_GC = 0x0001, /* For data caching during GC */ 101 + NILFS_I_TYPE_BTNC = 0x0002, /* For btree node cache */ 102 + NILFS_I_TYPE_SHADOW = 0x0004, /* For shadowed page cache */ 98 103 }; 99 104 100 105 /* ··· 111 102 NILFS_SB_COMMIT = 0, /* Commit a super block alternately */ 112 103 NILFS_SB_COMMIT_ALL /* Commit both super blocks */ 113 104 }; 105 + 106 + /** 107 + * define NILFS_MAX_VOLUME_NAME - maximum number of characters (bytes) in a 108 + * file system volume name 109 + * 110 + * Defined by the size of the volume name field in the on-disk superblocks. 111 + * This volume name does not include the terminating NULL byte if the string 112 + * length matches the field size, so use (NILFS_MAX_VOLUME_NAME + 1) for the 113 + * size of the buffer that requires a NULL byte termination. 114 + */ 115 + #define NILFS_MAX_VOLUME_NAME \ 116 + sizeof_field(struct nilfs_super_block, s_volume_name) 114 117 115 118 /* 116 119 * Macros to check inode numbers
+4 -17
fs/nilfs2/page.c
··· 262 262 NILFS_FOLIO_BUG(folio, "inconsistent dirty state"); 263 263 264 264 dfolio = filemap_grab_folio(dmap, folio->index); 265 - if (unlikely(IS_ERR(dfolio))) { 265 + if (IS_ERR(dfolio)) { 266 266 /* No empty page is added to the page cache */ 267 267 folio_unlock(folio); 268 268 err = PTR_ERR(dfolio); ··· 357 357 /** 358 358 * nilfs_clear_dirty_pages - discard dirty pages in address space 359 359 * @mapping: address space with dirty pages for discarding 360 - * @silent: suppress [true] or print [false] warning messages 361 360 */ 362 - void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent) 361 + void nilfs_clear_dirty_pages(struct address_space *mapping) 363 362 { 364 363 struct folio_batch fbatch; 365 364 unsigned int i; ··· 379 380 * was acquired. Skip processing in that case. 380 381 */ 381 382 if (likely(folio->mapping == mapping)) 382 - nilfs_clear_folio_dirty(folio, silent); 383 + nilfs_clear_folio_dirty(folio); 383 384 384 385 folio_unlock(folio); 385 386 } ··· 391 392 /** 392 393 * nilfs_clear_folio_dirty - discard dirty folio 393 394 * @folio: dirty folio that will be discarded 394 - * @silent: suppress [true] or print [false] warning messages 395 395 */ 396 - void nilfs_clear_folio_dirty(struct folio *folio, bool silent) 396 + void nilfs_clear_folio_dirty(struct folio *folio) 397 397 { 398 - struct inode *inode = folio->mapping->host; 399 - struct super_block *sb = inode->i_sb; 400 398 struct buffer_head *bh, *head; 401 399 402 400 BUG_ON(!folio_test_locked(folio)); 403 - 404 - if (!silent) 405 - nilfs_warn(sb, "discard dirty page: offset=%lld, ino=%lu", 406 - folio_pos(folio), inode->i_ino); 407 401 408 402 folio_clear_uptodate(folio); 409 403 folio_clear_mappedtodisk(folio); ··· 411 419 bh = head; 412 420 do { 413 421 lock_buffer(bh); 414 - if (!silent) 415 - nilfs_warn(sb, 416 - "discard dirty block: blocknr=%llu, size=%zu", 417 - (u64)bh->b_blocknr, bh->b_size); 418 - 419 422 set_mask_bits(&bh->b_state, clear_bits, 0); 420 423 unlock_buffer(bh); 421 424 } while (bh = bh->b_this_page, bh != head);
+2 -2
fs/nilfs2/page.h
··· 41 41 42 42 int nilfs_copy_dirty_pages(struct address_space *, struct address_space *); 43 43 void nilfs_copy_back_pages(struct address_space *, struct address_space *); 44 - void nilfs_clear_folio_dirty(struct folio *, bool); 45 - void nilfs_clear_dirty_pages(struct address_space *, bool); 44 + void nilfs_clear_folio_dirty(struct folio *folio); 45 + void nilfs_clear_dirty_pages(struct address_space *mapping); 46 46 unsigned int nilfs_page_count_clean_buffers(struct page *, unsigned int, 47 47 unsigned int); 48 48 unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
+10 -1
fs/nilfs2/recovery.c
··· 433 433 * The next segment is invalidated by this recovery. 434 434 */ 435 435 err = nilfs_sufile_free(sufile, segnum[1]); 436 - if (unlikely(err)) 436 + if (unlikely(err)) { 437 + if (err == -ENOENT) { 438 + nilfs_err(sb, 439 + "checkpoint log inconsistency at block %llu (segment %llu): next segment %llu is unallocated", 440 + (unsigned long long)nilfs->ns_last_pseg, 441 + (unsigned long long)nilfs->ns_segnum, 442 + (unsigned long long)segnum[1]); 443 + err = -EINVAL; 444 + } 437 445 goto failed; 446 + } 438 447 439 448 for (i = 1; i < 4; i++) { 440 449 err = nilfs_segment_list_add(head, segnum[i]);
+129 -107
fs/nilfs2/segment.c
··· 519 519 520 520 ii = NILFS_I(inode); 521 521 522 - if (test_bit(NILFS_I_GCINODE, &ii->i_state)) 522 + if (ii->i_type & NILFS_I_TYPE_GC) 523 523 cno = ii->i_cno; 524 524 else if (NILFS_ROOT_METADATA_FILE(inode->i_ino)) 525 525 cno = 0; ··· 1102 1102 return err; 1103 1103 } 1104 1104 1105 + /** 1106 + * nilfs_free_segments - free the segments given by an array of segment numbers 1107 + * @nilfs: nilfs object 1108 + * @segnumv: array of segment numbers to be freed 1109 + * @nsegs: number of segments to be freed in @segnumv 1110 + * 1111 + * nilfs_free_segments() wraps nilfs_sufile_freev() and 1112 + * nilfs_sufile_cancel_freev(), and edits the segment usage metadata file 1113 + * (sufile) to free all segments given by @segnumv and @nsegs at once. If 1114 + * it fails midway, it cancels the changes so that none of the segments are 1115 + * freed. If @nsegs is 0, this function does nothing. 1116 + * 1117 + * The freeing of segments is not finalized until the writing of a log with 1118 + * a super root block containing this sufile change is complete, and it can 1119 + * be canceled with nilfs_sufile_cancel_freev() until then. 1120 + * 1121 + * Return: 0 on success, or the following negative error code on failure. 1122 + * * %-EINVAL - Invalid segment number. 1123 + * * %-EIO - I/O error (including metadata corruption). 1124 + * * %-ENOMEM - Insufficient memory available. 1125 + */ 1126 + static int nilfs_free_segments(struct the_nilfs *nilfs, __u64 *segnumv, 1127 + size_t nsegs) 1128 + { 1129 + size_t ndone; 1130 + int ret; 1131 + 1132 + if (!nsegs) 1133 + return 0; 1134 + 1135 + ret = nilfs_sufile_freev(nilfs->ns_sufile, segnumv, nsegs, &ndone); 1136 + if (unlikely(ret)) { 1137 + nilfs_sufile_cancel_freev(nilfs->ns_sufile, segnumv, ndone, 1138 + NULL); 1139 + /* 1140 + * If a segment usage of the segments to be freed is in a 1141 + * hole block, nilfs_sufile_freev() will return -ENOENT. 1142 + * In this case, -EINVAL should be returned to the caller 1143 + * since there is something wrong with the given segment 1144 + * number array. This error can only occur during GC, so 1145 + * there is no need to worry about it propagating to other 1146 + * callers (such as fsync). 1147 + */ 1148 + if (ret == -ENOENT) { 1149 + nilfs_err(nilfs->ns_sb, 1150 + "The segment usage entry %llu to be freed is invalid (in a hole)", 1151 + (unsigned long long)segnumv[ndone]); 1152 + ret = -EINVAL; 1153 + } 1154 + } 1155 + return ret; 1156 + } 1157 + 1105 1158 static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode) 1106 1159 { 1107 1160 struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 1108 1161 struct list_head *head; 1109 1162 struct nilfs_inode_info *ii; 1110 - size_t ndone; 1111 1163 int err = 0; 1112 1164 1113 1165 switch (nilfs_sc_cstage_get(sci)) { ··· 1253 1201 nilfs_sc_cstage_inc(sci); 1254 1202 fallthrough; 1255 1203 case NILFS_ST_SUFILE: 1256 - err = nilfs_sufile_freev(nilfs->ns_sufile, sci->sc_freesegs, 1257 - sci->sc_nfreesegs, &ndone); 1258 - if (unlikely(err)) { 1259 - nilfs_sufile_cancel_freev(nilfs->ns_sufile, 1260 - sci->sc_freesegs, ndone, 1261 - NULL); 1204 + err = nilfs_free_segments(nilfs, sci->sc_freesegs, 1205 + sci->sc_nfreesegs); 1206 + if (unlikely(err)) 1262 1207 break; 1263 - } 1264 1208 sci->sc_stage.flags |= NILFS_CF_SUFREED; 1265 1209 1266 1210 err = nilfs_segctor_scan_file(sci, nilfs->ns_sufile, ··· 2504 2456 { 2505 2457 struct nilfs_sc_info *sci = from_timer(sci, t, sc_timer); 2506 2458 2507 - wake_up_process(sci->sc_timer_task); 2459 + wake_up_process(sci->sc_task); 2508 2460 } 2509 2461 2510 2462 static void ··· 2630 2582 } 2631 2583 2632 2584 /** 2633 - * nilfs_segctor_thread - main loop of the segment constructor thread. 2585 + * nilfs_log_write_required - determine whether log writing is required 2586 + * @sci: nilfs_sc_info struct 2587 + * @modep: location for storing log writing mode 2588 + * 2589 + * Return: true if log writing is required, false otherwise. If log writing 2590 + * is required, the mode is stored in the location pointed to by @modep. 2591 + */ 2592 + static bool nilfs_log_write_required(struct nilfs_sc_info *sci, int *modep) 2593 + { 2594 + bool timedout, ret = true; 2595 + 2596 + spin_lock(&sci->sc_state_lock); 2597 + timedout = ((sci->sc_state & NILFS_SEGCTOR_COMMIT) && 2598 + time_after_eq(jiffies, sci->sc_timer.expires)); 2599 + if (timedout || sci->sc_seq_request != sci->sc_seq_done) 2600 + *modep = SC_LSEG_SR; 2601 + else if (sci->sc_flush_request) 2602 + *modep = nilfs_segctor_flush_mode(sci); 2603 + else 2604 + ret = false; 2605 + 2606 + spin_unlock(&sci->sc_state_lock); 2607 + return ret; 2608 + } 2609 + 2610 + /** 2611 + * nilfs_segctor_thread - main loop of the log writer thread 2634 2612 * @arg: pointer to a struct nilfs_sc_info. 2635 2613 * 2636 - * nilfs_segctor_thread() initializes a timer and serves as a daemon 2637 - * to execute segment constructions. 2614 + * nilfs_segctor_thread() is the main loop function of the log writer kernel 2615 + * thread, which determines whether log writing is necessary, and if so, 2616 + * performs the log write in the background, or waits if not. It is also 2617 + * used to decide the background writeback of the superblock. 2618 + * 2619 + * Return: Always 0. 2638 2620 */ 2639 2621 static int nilfs_segctor_thread(void *arg) 2640 2622 { 2641 2623 struct nilfs_sc_info *sci = (struct nilfs_sc_info *)arg; 2642 2624 struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 2643 - int timeout = 0; 2644 2625 2645 - sci->sc_timer_task = current; 2646 - timer_setup(&sci->sc_timer, nilfs_construction_timeout, 0); 2647 - 2648 - /* start sync. */ 2649 - sci->sc_task = current; 2650 - wake_up(&sci->sc_wait_task); /* for nilfs_segctor_start_thread() */ 2651 2626 nilfs_info(sci->sc_super, 2652 2627 "segctord starting. Construction interval = %lu seconds, CP frequency < %lu seconds", 2653 2628 sci->sc_interval / HZ, sci->sc_mjcp_freq / HZ); 2654 2629 2655 2630 set_freezable(); 2656 - spin_lock(&sci->sc_state_lock); 2657 - loop: 2658 - for (;;) { 2631 + 2632 + while (!kthread_should_stop()) { 2633 + DEFINE_WAIT(wait); 2634 + bool should_write; 2659 2635 int mode; 2660 2636 2661 - if (sci->sc_state & NILFS_SEGCTOR_QUIT) 2662 - goto end_thread; 2663 - 2664 - if (timeout || sci->sc_seq_request != sci->sc_seq_done) 2665 - mode = SC_LSEG_SR; 2666 - else if (sci->sc_flush_request) 2667 - mode = nilfs_segctor_flush_mode(sci); 2668 - else 2669 - break; 2670 - 2671 - spin_unlock(&sci->sc_state_lock); 2672 - nilfs_segctor_thread_construct(sci, mode); 2673 - spin_lock(&sci->sc_state_lock); 2674 - timeout = 0; 2675 - } 2676 - 2677 - 2678 - if (freezing(current)) { 2679 - spin_unlock(&sci->sc_state_lock); 2680 - try_to_freeze(); 2681 - spin_lock(&sci->sc_state_lock); 2682 - } else { 2683 - DEFINE_WAIT(wait); 2684 - int should_sleep = 1; 2637 + if (freezing(current)) { 2638 + try_to_freeze(); 2639 + continue; 2640 + } 2685 2641 2686 2642 prepare_to_wait(&sci->sc_wait_daemon, &wait, 2687 2643 TASK_INTERRUPTIBLE); 2688 - 2689 - if (sci->sc_seq_request != sci->sc_seq_done) 2690 - should_sleep = 0; 2691 - else if (sci->sc_flush_request) 2692 - should_sleep = 0; 2693 - else if (sci->sc_state & NILFS_SEGCTOR_COMMIT) 2694 - should_sleep = time_before(jiffies, 2695 - sci->sc_timer.expires); 2696 - 2697 - if (should_sleep) { 2698 - spin_unlock(&sci->sc_state_lock); 2644 + should_write = nilfs_log_write_required(sci, &mode); 2645 + if (!should_write) 2699 2646 schedule(); 2700 - spin_lock(&sci->sc_state_lock); 2701 - } 2702 2647 finish_wait(&sci->sc_wait_daemon, &wait); 2703 - timeout = ((sci->sc_state & NILFS_SEGCTOR_COMMIT) && 2704 - time_after_eq(jiffies, sci->sc_timer.expires)); 2705 2648 2706 2649 if (nilfs_sb_dirty(nilfs) && nilfs_sb_need_update(nilfs)) 2707 2650 set_nilfs_discontinued(nilfs); 2708 - } 2709 - goto loop; 2710 2651 2711 - end_thread: 2652 + if (should_write) 2653 + nilfs_segctor_thread_construct(sci, mode); 2654 + } 2655 + 2712 2656 /* end sync. */ 2657 + spin_lock(&sci->sc_state_lock); 2713 2658 sci->sc_task = NULL; 2714 2659 timer_shutdown_sync(&sci->sc_timer); 2715 - wake_up(&sci->sc_wait_task); /* for nilfs_segctor_kill_thread() */ 2716 2660 spin_unlock(&sci->sc_state_lock); 2717 2661 return 0; 2718 - } 2719 - 2720 - static int nilfs_segctor_start_thread(struct nilfs_sc_info *sci) 2721 - { 2722 - struct task_struct *t; 2723 - 2724 - t = kthread_run(nilfs_segctor_thread, sci, "segctord"); 2725 - if (IS_ERR(t)) { 2726 - int err = PTR_ERR(t); 2727 - 2728 - nilfs_err(sci->sc_super, "error %d creating segctord thread", 2729 - err); 2730 - return err; 2731 - } 2732 - wait_event(sci->sc_wait_task, sci->sc_task != NULL); 2733 - return 0; 2734 - } 2735 - 2736 - static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci) 2737 - __acquires(&sci->sc_state_lock) 2738 - __releases(&sci->sc_state_lock) 2739 - { 2740 - sci->sc_state |= NILFS_SEGCTOR_QUIT; 2741 - 2742 - while (sci->sc_task) { 2743 - wake_up(&sci->sc_wait_daemon); 2744 - spin_unlock(&sci->sc_state_lock); 2745 - wait_event(sci->sc_wait_task, sci->sc_task == NULL); 2746 - spin_lock(&sci->sc_state_lock); 2747 - } 2748 2662 } 2749 2663 2750 2664 /* ··· 2729 2719 2730 2720 init_waitqueue_head(&sci->sc_wait_request); 2731 2721 init_waitqueue_head(&sci->sc_wait_daemon); 2732 - init_waitqueue_head(&sci->sc_wait_task); 2733 2722 spin_lock_init(&sci->sc_state_lock); 2734 2723 INIT_LIST_HEAD(&sci->sc_dirty_files); 2735 2724 INIT_LIST_HEAD(&sci->sc_segbufs); ··· 2783 2774 2784 2775 up_write(&nilfs->ns_segctor_sem); 2785 2776 2777 + if (sci->sc_task) { 2778 + wake_up(&sci->sc_wait_daemon); 2779 + kthread_stop(sci->sc_task); 2780 + } 2781 + 2786 2782 spin_lock(&sci->sc_state_lock); 2787 - nilfs_segctor_kill_thread(sci); 2788 2783 flag = ((sci->sc_state & NILFS_SEGCTOR_COMMIT) || sci->sc_flush_request 2789 2784 || sci->sc_seq_request != sci->sc_seq_done); 2790 2785 spin_unlock(&sci->sc_state_lock); ··· 2836 2823 * This allocates a log writer object, initializes it, and starts the 2837 2824 * log writer. 2838 2825 * 2839 - * Return Value: On success, 0 is returned. On error, one of the following 2840 - * negative error code is returned. 2841 - * 2842 - * %-ENOMEM - Insufficient memory available. 2826 + * Return: 0 on success, or the following negative error code on failure. 2827 + * * %-EINTR - Log writer thread creation failed due to interruption. 2828 + * * %-ENOMEM - Insufficient memory available. 2843 2829 */ 2844 2830 int nilfs_attach_log_writer(struct super_block *sb, struct nilfs_root *root) 2845 2831 { 2846 2832 struct the_nilfs *nilfs = sb->s_fs_info; 2833 + struct nilfs_sc_info *sci; 2834 + struct task_struct *t; 2847 2835 int err; 2848 2836 2849 2837 if (nilfs->ns_writer) { ··· 2857 2843 return 0; 2858 2844 } 2859 2845 2860 - nilfs->ns_writer = nilfs_segctor_new(sb, root); 2861 - if (!nilfs->ns_writer) 2846 + sci = nilfs_segctor_new(sb, root); 2847 + if (unlikely(!sci)) 2862 2848 return -ENOMEM; 2863 2849 2864 - err = nilfs_segctor_start_thread(nilfs->ns_writer); 2865 - if (unlikely(err)) 2850 + nilfs->ns_writer = sci; 2851 + t = kthread_create(nilfs_segctor_thread, sci, "segctord"); 2852 + if (IS_ERR(t)) { 2853 + err = PTR_ERR(t); 2854 + nilfs_err(sb, "error %d creating segctord thread", err); 2866 2855 nilfs_detach_log_writer(sb); 2856 + return err; 2857 + } 2858 + sci->sc_task = t; 2859 + timer_setup(&sci->sc_timer, nilfs_construction_timeout, 0); 2867 2860 2868 - return err; 2861 + wake_up_process(sci->sc_task); 2862 + return 0; 2869 2863 } 2870 2864 2871 2865 /**
+3 -7
fs/nilfs2/segment.h
··· 22 22 * struct nilfs_recovery_info - Recovery information 23 23 * @ri_need_recovery: Recovery status 24 24 * @ri_super_root: Block number of the last super root 25 - * @ri_ri_cno: Number of the last checkpoint 25 + * @ri_cno: Number of the last checkpoint 26 26 * @ri_lsegs_start: Region for roll-forwarding (start block number) 27 27 * @ri_lsegs_end: Region for roll-forwarding (end block number) 28 - * @ri_lseg_start_seq: Sequence value of the segment at ri_lsegs_start 28 + * @ri_lsegs_start_seq: Sequence value of the segment at ri_lsegs_start 29 29 * @ri_used_segments: List of segments to be mark active 30 30 * @ri_pseg_start: Block number of the last partial segment 31 31 * @ri_seq: Sequence number on the last partial segment ··· 105 105 * @sc_flush_request: inode bitmap of metadata files to be flushed 106 106 * @sc_wait_request: Client request queue 107 107 * @sc_wait_daemon: Daemon wait queue 108 - * @sc_wait_task: Start/end wait queue to control segctord task 109 108 * @sc_seq_request: Request counter 110 - * @sc_seq_accept: Accepted request count 109 + * @sc_seq_accepted: Accepted request count 111 110 * @sc_seq_done: Completion counter 112 111 * @sc_sync: Request of explicit sync operation 113 112 * @sc_interval: Timeout value of background construction ··· 157 158 158 159 wait_queue_head_t sc_wait_request; 159 160 wait_queue_head_t sc_wait_daemon; 160 - wait_queue_head_t sc_wait_task; 161 161 162 162 __u32 sc_seq_request; 163 163 __u32 sc_seq_accepted; ··· 169 171 unsigned long sc_watermark; 170 172 171 173 struct timer_list sc_timer; 172 - struct task_struct *sc_timer_task; 173 174 struct task_struct *sc_task; 174 175 }; 175 176 ··· 189 192 }; 190 193 191 194 /* sc_state */ 192 - #define NILFS_SEGCTOR_QUIT 0x0001 /* segctord is being destroyed */ 193 195 #define NILFS_SEGCTOR_COMMIT 0x0004 /* committed transaction exists */ 194 196 195 197 /*
+34 -18
fs/nilfs2/sufile.c
··· 79 79 NILFS_MDT(sufile)->mi_entry_size; 80 80 } 81 81 82 - static inline int nilfs_sufile_get_header_block(struct inode *sufile, 83 - struct buffer_head **bhp) 82 + static int nilfs_sufile_get_header_block(struct inode *sufile, 83 + struct buffer_head **bhp) 84 84 { 85 - return nilfs_mdt_get_block(sufile, 0, 0, NULL, bhp); 85 + int err = nilfs_mdt_get_block(sufile, 0, 0, NULL, bhp); 86 + 87 + if (unlikely(err == -ENOENT)) { 88 + nilfs_error(sufile->i_sb, 89 + "missing header block in segment usage metadata"); 90 + err = -EIO; 91 + } 92 + return err; 86 93 } 87 94 88 95 static inline int ··· 513 506 514 507 down_write(&NILFS_MDT(sufile)->mi_sem); 515 508 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, &bh); 516 - if (ret) 509 + if (unlikely(ret)) { 510 + if (ret == -ENOENT) { 511 + nilfs_error(sufile->i_sb, 512 + "segment usage for segment %llu is unreadable due to a hole block", 513 + (unsigned long long)segnum); 514 + ret = -EIO; 515 + } 517 516 goto out_sem; 517 + } 518 518 519 519 kaddr = kmap_local_page(bh->b_page); 520 520 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, bh, kaddr); ··· 854 840 } 855 841 856 842 /** 857 - * nilfs_sufile_get_suinfo - 843 + * nilfs_sufile_get_suinfo - get segment usage information 858 844 * @sufile: inode of segment usage file 859 845 * @segnum: segment number to start looking 860 - * @buf: array of suinfo 861 - * @sisz: byte size of suinfo 862 - * @nsi: size of suinfo array 846 + * @buf: array of suinfo 847 + * @sisz: byte size of suinfo 848 + * @nsi: size of suinfo array 863 849 * 864 - * Description: 865 - * 866 - * Return Value: On success, 0 is returned and .... On error, one of the 867 - * following negative error codes is returned. 868 - * 869 - * %-EIO - I/O error. 870 - * 871 - * %-ENOMEM - Insufficient amount of memory available. 850 + * Return: Count of segment usage info items stored in the output buffer on 851 + * success, or the following negative error code on failure. 852 + * * %-EIO - I/O error (including metadata corruption). 853 + * * %-ENOMEM - Insufficient memory available. 872 854 */ 873 855 ssize_t nilfs_sufile_get_suinfo(struct inode *sufile, __u64 segnum, void *buf, 874 856 unsigned int sisz, size_t nsi) ··· 1251 1241 if (err) 1252 1242 goto failed; 1253 1243 1254 - err = nilfs_sufile_get_header_block(sufile, &header_bh); 1255 - if (err) 1244 + err = nilfs_mdt_get_block(sufile, 0, 0, NULL, &header_bh); 1245 + if (unlikely(err)) { 1246 + if (err == -ENOENT) { 1247 + nilfs_err(sb, 1248 + "missing header block in segment usage metadata"); 1249 + err = -EINVAL; 1250 + } 1256 1251 goto failed; 1252 + } 1257 1253 1258 1254 sui = NILFS_SUI(sufile); 1259 1255 kaddr = kmap_local_page(header_bh->b_page);
+9
fs/nilfs2/super.c
··· 105 105 106 106 /** 107 107 * __nilfs_error() - report failure condition on a filesystem 108 + * @sb: super block instance 109 + * @function: name of calling function 110 + * @fmt: format string for message to be output 111 + * @...: optional arguments to @fmt 108 112 * 109 113 * __nilfs_error() sets an ERROR_FS flag on the superblock as well as 110 114 * reporting an error message. This function should be called when ··· 160 156 return NULL; 161 157 ii->i_bh = NULL; 162 158 ii->i_state = 0; 159 + ii->i_type = 0; 163 160 ii->i_cno = 0; 164 161 ii->i_assoc_inode = NULL; 165 162 ii->i_bmap = &ii->i_bmap_data; ··· 1067 1062 err = load_nilfs(nilfs, sb); 1068 1063 if (err) 1069 1064 goto failed_nilfs; 1065 + 1066 + super_set_uuid(sb, nilfs->ns_sbp[0]->s_uuid, 1067 + sizeof(nilfs->ns_sbp[0]->s_uuid)); 1068 + super_set_sysfs_name_bdev(sb); 1070 1069 1071 1070 cno = nilfs_last_cno(nilfs); 1072 1071 err = nilfs_attach_checkpoint(sb, cno, true, &fsroot);
-5
fs/nilfs2/the_nilfs.c
··· 12 12 #include <linux/slab.h> 13 13 #include <linux/blkdev.h> 14 14 #include <linux/backing-dev.h> 15 - #include <linux/random.h> 16 15 #include <linux/log2.h> 17 16 #include <linux/crc32.h> 18 17 #include "nilfs.h" ··· 68 69 INIT_LIST_HEAD(&nilfs->ns_dirty_files); 69 70 INIT_LIST_HEAD(&nilfs->ns_gc_inodes); 70 71 spin_lock_init(&nilfs->ns_inode_lock); 71 - spin_lock_init(&nilfs->ns_next_gen_lock); 72 72 spin_lock_init(&nilfs->ns_last_segment_lock); 73 73 nilfs->ns_cptree = RB_ROOT; 74 74 spin_lock_init(&nilfs->ns_cptree_lock); ··· 751 753 } 752 754 nilfs->ns_blocksize_bits = sb->s_blocksize_bits; 753 755 nilfs->ns_blocksize = blocksize; 754 - 755 - get_random_bytes(&nilfs->ns_next_generation, 756 - sizeof(nilfs->ns_next_generation)); 757 756 758 757 err = nilfs_store_disk_layout(nilfs, sbp); 759 758 if (err)
-6
fs/nilfs2/the_nilfs.h
··· 71 71 * @ns_dirty_files: list of dirty files 72 72 * @ns_inode_lock: lock protecting @ns_dirty_files 73 73 * @ns_gc_inodes: dummy inodes to keep live blocks 74 - * @ns_next_generation: next generation number for inodes 75 - * @ns_next_gen_lock: lock protecting @ns_next_generation 76 74 * @ns_mount_opt: mount options 77 75 * @ns_resuid: uid for reserved blocks 78 76 * @ns_resgid: gid for reserved blocks ··· 158 160 159 161 /* GC inode list */ 160 162 struct list_head ns_gc_inodes; 161 - 162 - /* Inode allocator */ 163 - u32 ns_next_generation; 164 - spinlock_t ns_next_gen_lock; 165 163 166 164 /* Mount options */ 167 165 unsigned long ns_mount_opt;
+1 -1
fs/ocfs2/aops.c
··· 1187 1187 1188 1188 /* This is the direct io target page. */ 1189 1189 if (wc->w_pages[i] == NULL) { 1190 - p_blkno++; 1190 + p_blkno += (1 << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits)); 1191 1191 continue; 1192 1192 } 1193 1193
+1 -11
fs/ocfs2/dir.c
··· 3512 3512 return 0; 3513 3513 } 3514 3514 3515 - static void dx_leaf_sort_swap(void *a, void *b, int size) 3516 - { 3517 - struct ocfs2_dx_entry *entry1 = a; 3518 - struct ocfs2_dx_entry *entry2 = b; 3519 - 3520 - BUG_ON(size != sizeof(*entry1)); 3521 - 3522 - swap(*entry1, *entry2); 3523 - } 3524 - 3525 3515 static int ocfs2_dx_leaf_same_major(struct ocfs2_dx_leaf *dx_leaf) 3526 3516 { 3527 3517 struct ocfs2_dx_entry_list *dl_list = &dx_leaf->dl_list; ··· 3772 3782 */ 3773 3783 sort(dx_leaf->dl_list.de_entries, num_used, 3774 3784 sizeof(struct ocfs2_dx_entry), dx_leaf_sort_cmp, 3775 - dx_leaf_sort_swap); 3785 + NULL); 3776 3786 3777 3787 ocfs2_journal_dirty(handle, dx_leaf_bh); 3778 3788
+2 -5
fs/ocfs2/dlmglue.c
··· 3151 3151 #ifdef CONFIG_OCFS2_FS_STATS 3152 3152 if (!lockres->l_lock_wait && dlm_debug->d_filter_secs) { 3153 3153 now = ktime_to_us(ktime_get_real()); 3154 - if (lockres->l_lock_prmode.ls_last > 3155 - lockres->l_lock_exmode.ls_last) 3156 - last = lockres->l_lock_prmode.ls_last; 3157 - else 3158 - last = lockres->l_lock_exmode.ls_last; 3154 + last = max(lockres->l_lock_prmode.ls_last, 3155 + lockres->l_lock_exmode.ls_last); 3159 3156 /* 3160 3157 * Use d_filter_secs field to filter lock resources dump, 3161 3158 * the default d_filter_secs(0) value filters nothing,
+19
fs/ocfs2/localalloc.c
··· 1002 1002 start = bit_off + 1; 1003 1003 } 1004 1004 1005 + /* clear the contiguous bits until the end boundary */ 1006 + if (count) { 1007 + blkno = la_start_blk + 1008 + ocfs2_clusters_to_blocks(osb->sb, 1009 + start - count); 1010 + 1011 + trace_ocfs2_sync_local_to_main_free( 1012 + count, start - count, 1013 + (unsigned long long)la_start_blk, 1014 + (unsigned long long)blkno); 1015 + 1016 + status = ocfs2_release_clusters(handle, 1017 + main_bm_inode, 1018 + main_bm_bh, blkno, 1019 + count); 1020 + if (status < 0) 1021 + mlog_errno(status); 1022 + } 1023 + 1005 1024 bail: 1006 1025 if (status) 1007 1026 mlog_errno(status);
+9 -6
fs/ocfs2/quota_global.c
··· 371 371 372 372 status = ocfs2_extent_map_get_blocks(oinfo->dqi_gqinode, 0, &oinfo->dqi_giblk, 373 373 &pcount, NULL); 374 - if (status < 0) 374 + if (status < 0) { 375 + mlog_errno(status); 375 376 goto out_unlock; 377 + } 376 378 377 379 status = ocfs2_qinfo_lock(oinfo, 0); 378 - if (status < 0) 380 + if (status < 0) { 381 + mlog_errno(status); 379 382 goto out_unlock; 383 + } 380 384 status = sb->s_op->quota_read(sb, type, (char *)&dinfo, 381 385 sizeof(struct ocfs2_global_disk_dqinfo), 382 386 OCFS2_GLOBAL_INFO_OFF); ··· 408 404 schedule_delayed_work(&oinfo->dqi_sync_work, 409 405 msecs_to_jiffies(oinfo->dqi_syncms)); 410 406 411 - out_err: 412 - return status; 407 + return 0; 413 408 out_unlock: 414 409 ocfs2_unlock_global_qf(oinfo, 0); 415 - mlog_errno(status); 416 - goto out_err; 410 + out_err: 411 + return status; 417 412 } 418 413 419 414 /* Write information to global quota file. Expects exclusive lock on quota
+3 -10
fs/ocfs2/refcounttree.c
··· 1392 1392 return 0; 1393 1393 } 1394 1394 1395 - static void swap_refcount_rec(void *a, void *b, int size) 1396 - { 1397 - struct ocfs2_refcount_rec *l = a, *r = b; 1398 - 1399 - swap(*l, *r); 1400 - } 1401 - 1402 1395 /* 1403 1396 * The refcount cpos are ordered by their 64bit cpos, 1404 1397 * But we will use the low 32 bit to be the e_cpos in the b-tree. ··· 1467 1474 */ 1468 1475 sort(&rl->rl_recs, le16_to_cpu(rl->rl_used), 1469 1476 sizeof(struct ocfs2_refcount_rec), 1470 - cmp_refcount_rec_by_low_cpos, swap_refcount_rec); 1477 + cmp_refcount_rec_by_low_cpos, NULL); 1471 1478 1472 1479 ret = ocfs2_find_refcount_split_pos(rl, &cpos, &split_index); 1473 1480 if (ret) { ··· 1492 1499 1493 1500 sort(&rl->rl_recs, le16_to_cpu(rl->rl_used), 1494 1501 sizeof(struct ocfs2_refcount_rec), 1495 - cmp_refcount_rec_by_cpos, swap_refcount_rec); 1502 + cmp_refcount_rec_by_cpos, NULL); 1496 1503 1497 1504 sort(&new_rl->rl_recs, le16_to_cpu(new_rl->rl_used), 1498 1505 sizeof(struct ocfs2_refcount_rec), 1499 - cmp_refcount_rec_by_cpos, swap_refcount_rec); 1506 + cmp_refcount_rec_by_cpos, NULL); 1500 1507 1501 1508 *split_cpos = cpos; 1502 1509 return 0;
+2 -2
fs/ocfs2/super.c
··· 2357 2357 (unsigned long long)bh->b_blocknr); 2358 2358 } else if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 12 || 2359 2359 le32_to_cpu(di->id2.i_super.s_clustersize_bits) > 20) { 2360 - mlog(ML_ERROR, "bad cluster size found: %u\n", 2361 - 1 << le32_to_cpu(di->id2.i_super.s_clustersize_bits)); 2360 + mlog(ML_ERROR, "bad cluster size bit found: %u\n", 2361 + le32_to_cpu(di->id2.i_super.s_clustersize_bits)); 2362 2362 } else if (!le64_to_cpu(di->id2.i_super.s_root_blkno)) { 2363 2363 mlog(ML_ERROR, "bad root_blkno: 0\n"); 2364 2364 } else if (!le64_to_cpu(di->id2.i_super.s_system_dir_blkno)) {
+3 -12
fs/ocfs2/xattr.c
··· 4167 4167 return 0; 4168 4168 } 4169 4169 4170 - static void swap_xe(void *a, void *b, int size) 4171 - { 4172 - struct ocfs2_xattr_entry *l = a, *r = b, tmp; 4173 - 4174 - tmp = *l; 4175 - memcpy(l, r, sizeof(struct ocfs2_xattr_entry)); 4176 - memcpy(r, &tmp, sizeof(struct ocfs2_xattr_entry)); 4177 - } 4178 - 4179 4170 /* 4180 4171 * When the ocfs2_xattr_block is filled up, new bucket will be created 4181 4172 * and all the xattr entries will be moved to the new bucket. ··· 4232 4241 trace_ocfs2_cp_xattr_block_to_bucket_end(offset, size, off_change); 4233 4242 4234 4243 sort(target + offset, count, sizeof(struct ocfs2_xattr_entry), 4235 - cmp_xe, swap_xe); 4244 + cmp_xe, NULL); 4236 4245 } 4237 4246 4238 4247 /* ··· 4427 4436 */ 4428 4437 sort(entries, le16_to_cpu(xh->xh_count), 4429 4438 sizeof(struct ocfs2_xattr_entry), 4430 - cmp_xe_offset, swap_xe); 4439 + cmp_xe_offset, NULL); 4431 4440 4432 4441 /* Move all name/values to the end of the bucket. */ 4433 4442 xe = xh->xh_entries; ··· 4469 4478 /* sort the entries by their name_hash. */ 4470 4479 sort(entries, le16_to_cpu(xh->xh_count), 4471 4480 sizeof(struct ocfs2_xattr_entry), 4472 - cmp_xe, swap_xe); 4481 + cmp_xe, NULL); 4473 4482 4474 4483 buf = bucket_buf; 4475 4484 for (i = 0; i < bucket->bu_blocks; i++, buf += blocksize)
+8 -23
fs/proc/inode.c
··· 303 303 304 304 static ssize_t pde_read(struct proc_dir_entry *pde, struct file *file, char __user *buf, size_t count, loff_t *ppos) 305 305 { 306 - typeof_member(struct proc_ops, proc_read) read; 307 - 308 - read = pde->proc_ops->proc_read; 306 + __auto_type read = pde->proc_ops->proc_read; 309 307 if (read) 310 308 return read(file, buf, count, ppos); 311 309 return -EIO; ··· 325 327 326 328 static ssize_t pde_write(struct proc_dir_entry *pde, struct file *file, const char __user *buf, size_t count, loff_t *ppos) 327 329 { 328 - typeof_member(struct proc_ops, proc_write) write; 329 - 330 - write = pde->proc_ops->proc_write; 330 + __auto_type write = pde->proc_ops->proc_write; 331 331 if (write) 332 332 return write(file, buf, count, ppos); 333 333 return -EIO; ··· 347 351 348 352 static __poll_t pde_poll(struct proc_dir_entry *pde, struct file *file, struct poll_table_struct *pts) 349 353 { 350 - typeof_member(struct proc_ops, proc_poll) poll; 351 - 352 - poll = pde->proc_ops->proc_poll; 354 + __auto_type poll = pde->proc_ops->proc_poll; 353 355 if (poll) 354 356 return poll(file, pts); 355 357 return DEFAULT_POLLMASK; ··· 369 375 370 376 static long pde_ioctl(struct proc_dir_entry *pde, struct file *file, unsigned int cmd, unsigned long arg) 371 377 { 372 - typeof_member(struct proc_ops, proc_ioctl) ioctl; 373 - 374 - ioctl = pde->proc_ops->proc_ioctl; 378 + __auto_type ioctl = pde->proc_ops->proc_ioctl; 375 379 if (ioctl) 376 380 return ioctl(file, cmd, arg); 377 381 return -ENOTTY; ··· 392 400 #ifdef CONFIG_COMPAT 393 401 static long pde_compat_ioctl(struct proc_dir_entry *pde, struct file *file, unsigned int cmd, unsigned long arg) 394 402 { 395 - typeof_member(struct proc_ops, proc_compat_ioctl) compat_ioctl; 396 - 397 - compat_ioctl = pde->proc_ops->proc_compat_ioctl; 403 + __auto_type compat_ioctl = pde->proc_ops->proc_compat_ioctl; 398 404 if (compat_ioctl) 399 405 return compat_ioctl(file, cmd, arg); 400 406 return -ENOTTY; ··· 414 424 415 425 static int pde_mmap(struct proc_dir_entry *pde, struct file *file, struct vm_area_struct *vma) 416 426 { 417 - typeof_member(struct proc_ops, proc_mmap) mmap; 418 - 419 - mmap = pde->proc_ops->proc_mmap; 427 + __auto_type mmap = pde->proc_ops->proc_mmap; 420 428 if (mmap) 421 429 return mmap(file, vma); 422 430 return -EIO; ··· 471 483 struct proc_dir_entry *pde = PDE(inode); 472 484 int rv = 0; 473 485 typeof_member(struct proc_ops, proc_open) open; 474 - typeof_member(struct proc_ops, proc_release) release; 475 486 struct pde_opener *pdeo; 476 487 477 488 if (!pde->proc_ops->proc_lseek) ··· 497 510 if (!use_pde(pde)) 498 511 return -ENOENT; 499 512 500 - release = pde->proc_ops->proc_release; 513 + __auto_type release = pde->proc_ops->proc_release; 501 514 if (release) { 502 515 pdeo = kmem_cache_alloc(pde_opener_cache, GFP_KERNEL); 503 516 if (!pdeo) { ··· 534 547 struct pde_opener *pdeo; 535 548 536 549 if (pde_is_permanent(pde)) { 537 - typeof_member(struct proc_ops, proc_release) release; 538 - 539 - release = pde->proc_ops->proc_release; 550 + __auto_type release = pde->proc_ops->proc_release; 540 551 if (release) { 541 552 return release(inode, file); 542 553 }
-15
fs/proc/task_mmu.c
··· 543 543 } 544 544 } 545 545 546 - if (karg.build_id_size) { 547 - __u32 build_id_sz; 548 - 549 - err = build_id_parse(vma, build_id_buf, &build_id_sz); 550 - if (err) { 551 - karg.build_id_size = 0; 552 - } else { 553 - if (karg.build_id_size < build_id_sz) { 554 - err = -ENAMETOOLONG; 555 - goto out; 556 - } 557 - karg.build_id_size = build_id_sz; 558 - } 559 - } 560 - 561 546 if (karg.vma_name_size) { 562 547 size_t name_buf_sz = min_t(size_t, PATH_MAX, karg.vma_name_size); 563 548 const struct path *path;
+3 -3
fs/squashfs/decompressor_multi_percpu.c
··· 46 46 } 47 47 48 48 kfree(comp_opts); 49 - return (__force void *) percpu; 49 + return (void *)(__force unsigned long) percpu; 50 50 51 51 out: 52 52 for_each_possible_cpu(cpu) { ··· 61 61 static void squashfs_decompressor_destroy(struct squashfs_sb_info *msblk) 62 62 { 63 63 struct squashfs_stream __percpu *percpu = 64 - (struct squashfs_stream __percpu *) msblk->stream; 64 + (void __percpu *)(unsigned long) msblk->stream; 65 65 struct squashfs_stream *stream; 66 66 int cpu; 67 67 ··· 79 79 { 80 80 struct squashfs_stream *stream; 81 81 struct squashfs_stream __percpu *percpu = 82 - (struct squashfs_stream __percpu *) msblk->stream; 82 + (void __percpu *)(unsigned long) msblk->stream; 83 83 int res; 84 84 85 85 local_lock(&percpu->lock);
+2 -3
include/linux/decompress/unxz.h
··· 1 + /* SPDX-License-Identifier: 0BSD */ 2 + 1 3 /* 2 4 * Wrapper for decompressing XZ-compressed kernel, initramfs, and initrd 3 5 * 4 6 * Author: Lasse Collin <lasse.collin@tukaani.org> 5 - * 6 - * This file has been put into the public domain. 7 - * You can do whatever you want with this file. 8 7 */ 9 8 10 9 #ifndef DECOMPRESS_UNXZ_H
+29 -7
include/linux/fault-inject.h
··· 2 2 #ifndef _LINUX_FAULT_INJECT_H 3 3 #define _LINUX_FAULT_INJECT_H 4 4 5 + #include <linux/err.h> 6 + #include <linux/types.h> 7 + 8 + struct dentry; 9 + struct kmem_cache; 10 + 5 11 #ifdef CONFIG_FAULT_INJECTION 6 12 7 - #include <linux/types.h> 8 - #include <linux/debugfs.h> 13 + #include <linux/atomic.h> 9 14 #include <linux/configfs.h> 10 15 #include <linux/ratelimit.h> 11 - #include <linux/atomic.h> 12 16 13 17 /* 14 18 * For explanation of the elements of this struct, see ··· 55 51 bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags); 56 52 bool should_fail(struct fault_attr *attr, ssize_t size); 57 53 54 + #else /* CONFIG_FAULT_INJECTION */ 55 + 56 + struct fault_attr { 57 + }; 58 + 59 + #define DECLARE_FAULT_ATTR(name) struct fault_attr name = {} 60 + 61 + static inline int setup_fault_attr(struct fault_attr *attr, char *str) 62 + { 63 + return 0; /* Note: 0 means error for __setup() handlers! */ 64 + } 65 + static inline bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags) 66 + { 67 + return false; 68 + } 69 + static inline bool should_fail(struct fault_attr *attr, ssize_t size) 70 + { 71 + return false; 72 + } 73 + 74 + #endif /* CONFIG_FAULT_INJECTION */ 75 + 58 76 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS 59 77 60 78 struct dentry *fault_create_debugfs_attr(const char *name, ··· 112 86 } 113 87 114 88 #endif /* CONFIG_FAULT_INJECTION_CONFIGFS */ 115 - 116 - #endif /* CONFIG_FAULT_INJECTION */ 117 - 118 - struct kmem_cache; 119 89 120 90 #ifdef CONFIG_FAIL_PAGE_ALLOC 121 91 bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order);
+2 -2
include/linux/lru_cache.h
··· 119 119 */ 120 120 121 121 /* this defines an element in a tracked set 122 - * .colision is for hash table lookup. 122 + * .collision is for hash table lookup. 123 123 * When we process a new IO request, we know its sector, thus can deduce the 124 124 * region number (label) easily. To do the label -> object lookup without a 125 125 * full list walk, we use a simple hash table. ··· 145 145 * But it avoids high order page allocations in kmalloc. 146 146 */ 147 147 struct lc_element { 148 - struct hlist_node colision; 148 + struct hlist_node collision; 149 149 struct list_head list; /* LRU list or free list */ 150 150 unsigned refcnt; 151 151 /* back "pointer" into lc_cache->element[index],
+1
include/linux/mmc/host.h
··· 10 10 #include <linux/sched.h> 11 11 #include <linux/device.h> 12 12 #include <linux/fault-inject.h> 13 + #include <linux/debugfs.h> 13 14 14 15 #include <linux/mmc/core.h> 15 16 #include <linux/mmc/card.h>
+1 -1
include/linux/ratelimit_types.h
··· 19 19 int burst; 20 20 int printed; 21 21 int missed; 22 + unsigned int flags; 22 23 unsigned long begin; 23 - unsigned long flags; 24 24 }; 25 25 26 26 #define RATELIMIT_STATE_INIT_FLAGS(name, interval_init, burst_init, flags_init) { \
+36 -47
include/linux/xz.h
··· 1 + /* SPDX-License-Identifier: 0BSD */ 2 + 1 3 /* 2 4 * XZ decompressor 3 5 * 4 6 * Authors: Lasse Collin <lasse.collin@tukaani.org> 5 7 * Igor Pavlov <https://7-zip.org/> 6 - * 7 - * This file has been put into the public domain. 8 - * You can do whatever you want with this file. 9 8 */ 10 9 11 10 #ifndef XZ_H ··· 16 17 #else 17 18 # include <stddef.h> 18 19 # include <stdint.h> 19 - #endif 20 - 21 - /* In Linux, this is used to make extern functions static when needed. */ 22 - #ifndef XZ_EXTERN 23 - # define XZ_EXTERN extern 24 20 #endif 25 21 26 22 /** ··· 137 143 size_t out_size; 138 144 }; 139 145 140 - /** 146 + /* 141 147 * struct xz_dec - Opaque type to hold the XZ decoder state 142 148 */ 143 149 struct xz_dec; ··· 185 191 * ready to be used with xz_dec_run(). If memory allocation fails, 186 192 * xz_dec_init() returns NULL. 187 193 */ 188 - XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max); 194 + struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max); 189 195 190 196 /** 191 197 * xz_dec_run() - Run the XZ decoder ··· 205 211 * get that amount valid data from the beginning of the stream. You must use 206 212 * the multi-call decoder if you don't want to uncompress the whole stream. 207 213 */ 208 - XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b); 214 + enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b); 209 215 210 216 /** 211 217 * xz_dec_reset() - Reset an already allocated decoder state ··· 218 224 * xz_dec_run(). Thus, explicit call to xz_dec_reset() is useful only in 219 225 * multi-call mode. 220 226 */ 221 - XZ_EXTERN void xz_dec_reset(struct xz_dec *s); 227 + void xz_dec_reset(struct xz_dec *s); 222 228 223 229 /** 224 230 * xz_dec_end() - Free the memory allocated for the decoder state 225 231 * @s: Decoder state allocated using xz_dec_init(). If s is NULL, 226 232 * this function does nothing. 227 233 */ 228 - XZ_EXTERN void xz_dec_end(struct xz_dec *s); 234 + void xz_dec_end(struct xz_dec *s); 235 + 236 + /** 237 + * DOC: MicroLZMA decompressor 238 + * 239 + * This MicroLZMA header format was created for use in EROFS but may be used 240 + * by others too. **In most cases one needs the XZ APIs above instead.** 241 + * 242 + * The compressed format supported by this decoder is a raw LZMA stream 243 + * whose first byte (always 0x00) has been replaced with bitwise-negation 244 + * of the LZMA properties (lc/lp/pb) byte. For example, if lc/lp/pb is 245 + * 3/0/2, the first byte is 0xA2. This way the first byte can never be 0x00. 246 + * Just like with LZMA2, lc + lp <= 4 must be true. The LZMA end-of-stream 247 + * marker must not be used. The unused values are reserved for future use. 248 + */ 229 249 230 250 /* 231 - * Decompressor for MicroLZMA, an LZMA variant with a very minimal header. 232 - * See xz_dec_microlzma_alloc() below for details. 233 - * 234 - * These functions aren't used or available in preboot code and thus aren't 235 - * marked with XZ_EXTERN. This avoids warnings about static functions that 236 - * are never defined. 237 - */ 238 - /** 239 251 * struct xz_dec_microlzma - Opaque type to hold the MicroLZMA decoder state 240 252 */ 241 253 struct xz_dec_microlzma; 242 254 243 255 /** 244 256 * xz_dec_microlzma_alloc() - Allocate memory for the MicroLZMA decoder 245 - * @mode XZ_SINGLE or XZ_PREALLOC 246 - * @dict_size LZMA dictionary size. This must be at least 4 KiB and 257 + * @mode: XZ_SINGLE or XZ_PREALLOC 258 + * @dict_size: LZMA dictionary size. This must be at least 4 KiB and 247 259 * at most 3 GiB. 248 260 * 249 261 * In contrast to xz_dec_init(), this function only allocates the memory ··· 262 262 * On success, xz_dec_microlzma_alloc() returns a pointer to 263 263 * struct xz_dec_microlzma. If memory allocation fails or 264 264 * dict_size is invalid, NULL is returned. 265 - * 266 - * The compressed format supported by this decoder is a raw LZMA stream 267 - * whose first byte (always 0x00) has been replaced with bitwise-negation 268 - * of the LZMA properties (lc/lp/pb) byte. For example, if lc/lp/pb is 269 - * 3/0/2, the first byte is 0xA2. This way the first byte can never be 0x00. 270 - * Just like with LZMA2, lc + lp <= 4 must be true. The LZMA end-of-stream 271 - * marker must not be used. The unused values are reserved for future use. 272 - * This MicroLZMA header format was created for use in EROFS but may be used 273 - * by others too. 274 265 */ 275 - extern struct xz_dec_microlzma *xz_dec_microlzma_alloc(enum xz_mode mode, 276 - uint32_t dict_size); 266 + struct xz_dec_microlzma *xz_dec_microlzma_alloc(enum xz_mode mode, 267 + uint32_t dict_size); 277 268 278 269 /** 279 270 * xz_dec_microlzma_reset() - Reset the MicroLZMA decoder state 280 - * @s Decoder state allocated using xz_dec_microlzma_alloc() 281 - * @comp_size Compressed size of the input stream 282 - * @uncomp_size Uncompressed size of the input stream. A value smaller 271 + * @s: Decoder state allocated using xz_dec_microlzma_alloc() 272 + * @comp_size: Compressed size of the input stream 273 + * @uncomp_size: Uncompressed size of the input stream. A value smaller 283 274 * than the real uncompressed size of the input stream can 284 275 * be specified if uncomp_size_is_exact is set to false. 285 276 * uncomp_size can never be set to a value larger than the 286 277 * expected real uncompressed size because it would eventually 287 278 * result in XZ_DATA_ERROR. 288 - * @uncomp_size_is_exact This is an int instead of bool to avoid 279 + * @uncomp_size_is_exact: This is an int instead of bool to avoid 289 280 * requiring stdbool.h. This should normally be set to true. 290 281 * When this is set to false, error detection is weaker. 291 282 */ 292 - extern void xz_dec_microlzma_reset(struct xz_dec_microlzma *s, 293 - uint32_t comp_size, uint32_t uncomp_size, 294 - int uncomp_size_is_exact); 283 + void xz_dec_microlzma_reset(struct xz_dec_microlzma *s, uint32_t comp_size, 284 + uint32_t uncomp_size, int uncomp_size_is_exact); 295 285 296 286 /** 297 287 * xz_dec_microlzma_run() - Run the MicroLZMA decoder 298 - * @s Decoder state initialized using xz_dec_microlzma_reset() 288 + * @s: Decoder state initialized using xz_dec_microlzma_reset() 299 289 * @b: Input and output buffers 300 290 * 301 291 * This works similarly to xz_dec_run() with a few important differences. ··· 319 329 * may be changed normally like with XZ_PREALLOC. This way input data can be 320 330 * provided from non-contiguous memory. 321 331 */ 322 - extern enum xz_ret xz_dec_microlzma_run(struct xz_dec_microlzma *s, 323 - struct xz_buf *b); 332 + enum xz_ret xz_dec_microlzma_run(struct xz_dec_microlzma *s, struct xz_buf *b); 324 333 325 334 /** 326 335 * xz_dec_microlzma_end() - Free the memory allocated for the decoder state 327 336 * @s: Decoder state allocated using xz_dec_microlzma_alloc(). 328 337 * If s is NULL, this function does nothing. 329 338 */ 330 - extern void xz_dec_microlzma_end(struct xz_dec_microlzma *s); 339 + void xz_dec_microlzma_end(struct xz_dec_microlzma *s); 331 340 332 341 /* 333 342 * Standalone build (userspace build or in-kernel build for boot time use) ··· 347 358 * This must be called before any other xz_* function to initialize 348 359 * the CRC32 lookup table. 349 360 */ 350 - XZ_EXTERN void xz_crc32_init(void); 361 + void xz_crc32_init(void); 351 362 352 363 /* 353 364 * Update CRC32 value using the polynomial from IEEE-802.3. To start a new 354 365 * calculation, the third argument must be zero. To continue the calculation, 355 366 * the previously returned value is passed as the third argument. 356 367 */ 357 - XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc); 368 + uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc); 358 369 #endif 359 370 #endif
+1
include/ufs/ufshcd.h
··· 17 17 #include <linux/blk-mq.h> 18 18 #include <linux/devfreq.h> 19 19 #include <linux/fault-inject.h> 20 + #include <linux/debugfs.h> 20 21 #include <linux/msi.h> 21 22 #include <linux/pm_runtime.h> 22 23 #include <linux/dma-direction.h>
+3 -2
init/Kconfig
··· 310 310 BCJ filters which can improve compression ratio of executable 311 311 code. The size of the kernel is about 30% smaller with XZ in 312 312 comparison to gzip. On architectures for which there is a BCJ 313 - filter (i386, x86_64, ARM, IA-64, PowerPC, and SPARC), XZ 314 - will create a few percent smaller kernel than plain LZMA. 313 + filter (i386, x86_64, ARM, ARM64, RISC-V, big endian PowerPC, 314 + and SPARC), XZ will create a few percent smaller kernel than 315 + plain LZMA. 315 316 316 317 The speed is about the same as with LZMA: The decompression 317 318 speed of XZ is better than that of bzip2 but worse than gzip
+20 -13
kernel/crash_core.c
··· 505 505 crash_hotplug_lock(); 506 506 /* Obtain lock while reading crash information */ 507 507 if (!kexec_trylock()) { 508 - pr_info("kexec_trylock() failed, elfcorehdr may be inaccurate\n"); 508 + pr_info("kexec_trylock() failed, kdump image may be inaccurate\n"); 509 509 crash_hotplug_unlock(); 510 510 return 0; 511 511 } ··· 520 520 } 521 521 522 522 /* 523 - * To accurately reflect hot un/plug changes of cpu and memory resources 524 - * (including onling and offlining of those resources), the elfcorehdr 525 - * (which is passed to the crash kernel via the elfcorehdr= parameter) 526 - * must be updated with the new list of CPUs and memories. 523 + * To accurately reflect hot un/plug changes of CPU and Memory resources 524 + * (including onling and offlining of those resources), the relevant 525 + * kexec segments must be updated with latest CPU and Memory resources. 527 526 * 528 - * In order to make changes to elfcorehdr, two conditions are needed: 529 - * First, the segment containing the elfcorehdr must be large enough 530 - * to permit a growing number of resources; the elfcorehdr memory size 531 - * is based on NR_CPUS_DEFAULT and CRASH_MAX_MEMORY_RANGES. 532 - * Second, purgatory must explicitly exclude the elfcorehdr from the 533 - * list of segments it checks (since the elfcorehdr changes and thus 534 - * would require an update to purgatory itself to update the digest). 527 + * Architectures must ensure two things for all segments that need 528 + * updating during hotplug events: 529 + * 530 + * 1. Segments must be large enough to accommodate a growing number of 531 + * resources. 532 + * 2. Exclude the segments from SHA verification. 533 + * 534 + * For example, on most architectures, the elfcorehdr (which is passed 535 + * to the crash kernel via the elfcorehdr= parameter) must include the 536 + * new list of CPUs and memory. To make changes to the elfcorehdr, it 537 + * should be large enough to permit a growing number of CPU and Memory 538 + * resources. One can estimate the elfcorehdr memory size based on 539 + * NR_CPUS_DEFAULT and CRASH_MAX_MEMORY_RANGES. The elfcorehdr is 540 + * excluded from SHA verification by default if the architecture 541 + * supports crash hotplug. 535 542 */ 536 543 static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu, void *arg) 537 544 { ··· 547 540 crash_hotplug_lock(); 548 541 /* Obtain lock while changing crash information */ 549 542 if (!kexec_trylock()) { 550 - pr_info("kexec_trylock() failed, elfcorehdr may be inaccurate\n"); 543 + pr_info("kexec_trylock() failed, kdump image may be inaccurate\n"); 551 544 crash_hotplug_unlock(); 552 545 return; 553 546 }
+3
kernel/crash_reserve.c
··· 335 335 if (!*crash_size) 336 336 ret = -EINVAL; 337 337 338 + if (*crash_size >= system_ram) 339 + ret = -EINVAL; 340 + 338 341 return ret; 339 342 } 340 343
+1
kernel/futex/core.c
··· 34 34 #include <linux/compat.h> 35 35 #include <linux/jhash.h> 36 36 #include <linux/pagemap.h> 37 + #include <linux/debugfs.h> 37 38 #include <linux/plist.h> 38 39 #include <linux/memblock.h> 39 40 #include <linux/fault-inject.h>
+2 -1
kernel/kexec_internal.h
··· 23 23 extern atomic_t __kexec_lock; 24 24 static inline bool kexec_trylock(void) 25 25 { 26 - return atomic_cmpxchg_acquire(&__kexec_lock, 0, 1) == 0; 26 + int old = 0; 27 + return atomic_try_cmpxchg_acquire(&__kexec_lock, &old, 1); 27 28 } 28 29 static inline void kexec_unlock(void) 29 30 {
+1
kernel/locking/test-ww_mutex.c
··· 697 697 698 698 MODULE_LICENSE("GPL"); 699 699 MODULE_AUTHOR("Intel Corporation"); 700 + MODULE_DESCRIPTION("API test facility for ww_mutexes");
+2 -3
kernel/user_namespace.c
··· 853 853 cmp_extents_forward, NULL); 854 854 855 855 /* Only copy the memory from forward we actually need. */ 856 - map->reverse = kmemdup(map->forward, 857 - map->nr_extents * sizeof(struct uid_gid_extent), 858 - GFP_KERNEL); 856 + map->reverse = kmemdup_array(map->forward, map->nr_extents, 857 + sizeof(struct uid_gid_extent), GFP_KERNEL); 859 858 if (!map->reverse) 860 859 return -ENOMEM; 861 860
+4 -1
kernel/watchdog.c
··· 1203 1203 1204 1204 ret = watchdog_hardlockup_probe(); 1205 1205 if (ret) { 1206 - pr_info("Delayed init of the lockup detector failed: %d\n", ret); 1206 + if (ret == -ENODEV) 1207 + pr_info("NMI not fully supported\n"); 1208 + else 1209 + pr_info("Delayed init of the lockup detector failed: %d\n", ret); 1207 1210 pr_info("Hard watchdog permanently disabled\n"); 1208 1211 return; 1209 1212 }
+11 -1
lib/Kconfig.debug
··· 1515 1515 config LOCKDEP_CHAINS_BITS 1516 1516 int "Bitsize for MAX_LOCKDEP_CHAINS" 1517 1517 depends on LOCKDEP && !LOCKDEP_SMALL 1518 - range 10 30 1518 + range 10 21 1519 1519 default 16 1520 1520 help 1521 1521 Try increasing this value if you hit "BUG: MAX_LOCKDEP_CHAINS too low!" message. ··· 2286 2286 Enable this to turn on 'do_div()' function test. This test is 2287 2287 executed only once during system boot (so affects only boot time), 2288 2288 or at module load time. 2289 + 2290 + If unsure, say N. 2291 + 2292 + config TEST_MULDIV64 2293 + tristate "mul_u64_u64_div_u64() test" 2294 + depends on DEBUG_KERNEL || m 2295 + help 2296 + Enable this to turn on 'mul_u64_u64_div_u64()' function test. 2297 + This test is executed only once during system boot (so affects 2298 + only boot time), or at module load time. 2289 2299 2290 2300 If unsure, say N. 2291 2301
+1
lib/Makefile
··· 14 14 KCOV_INSTRUMENT_debugobjects.o := n 15 15 KCOV_INSTRUMENT_dynamic_debug.o := n 16 16 KCOV_INSTRUMENT_fault-inject.o := n 17 + KCOV_INSTRUMENT_find_bit.o := n 17 18 18 19 # string.o implements standard library functions like memset/memcpy etc. 19 20 # Use -ffreestanding to ensure that the compiler does not try to "optimize"
+3 -1
lib/bcd.c
··· 10 10 11 11 unsigned char _bin2bcd(unsigned val) 12 12 { 13 - return ((val / 10) << 4) + val % 10; 13 + const unsigned int t = (val * 103) >> 10; 14 + 15 + return (t << 4) | (val - t * 10); 14 16 } 15 17 EXPORT_SYMBOL(_bin2bcd);
+3 -6
lib/checksum_kunit.c
··· 468 468 469 469 static void assert_setup_correct(struct kunit *test) 470 470 { 471 - CHECK_EQ(sizeof(random_buf) / sizeof(random_buf[0]), MAX_LEN); 472 - CHECK_EQ(sizeof(expected_results) / sizeof(expected_results[0]), 473 - MAX_LEN); 474 - CHECK_EQ(sizeof(init_sums_no_overflow) / 475 - sizeof(init_sums_no_overflow[0]), 476 - MAX_LEN); 471 + CHECK_EQ(ARRAY_SIZE(random_buf), MAX_LEN); 472 + CHECK_EQ(ARRAY_SIZE(expected_results), MAX_LEN); 473 + CHECK_EQ(ARRAY_SIZE(init_sums_no_overflow), MAX_LEN); 477 474 } 478 475 479 476 /*
+1 -1
lib/closure.c
··· 278 278 seq_printf(f, " W %pS\n", 279 279 (void *) cl->waiting_on); 280 280 281 - seq_puts(f, "\n"); 281 + seq_putc(f, '\n'); 282 282 } 283 283 284 284 spin_unlock_irq(&closure_list_lock);
+24 -16
lib/decompress_unxz.c
··· 1 + // SPDX-License-Identifier: 0BSD 2 + 1 3 /* 2 4 * Wrapper for decompressing XZ-compressed kernel, initramfs, and initrd 3 5 * 4 6 * Author: Lasse Collin <lasse.collin@tukaani.org> 5 - * 6 - * This file has been put into the public domain. 7 - * You can do whatever you want with this file. 8 7 */ 9 8 10 9 /* ··· 102 103 #ifdef STATIC 103 104 # define XZ_PREBOOT 104 105 #else 105 - #include <linux/decompress/unxz.h> 106 + # include <linux/decompress/unxz.h> 106 107 #endif 107 108 #ifdef __KERNEL__ 108 109 # include <linux/decompress/mm.h> 109 110 #endif 110 - #define XZ_EXTERN STATIC 111 111 112 112 #ifndef XZ_PREBOOT 113 113 # include <linux/slab.h> ··· 125 127 #ifdef CONFIG_X86 126 128 # define XZ_DEC_X86 127 129 #endif 128 - #ifdef CONFIG_PPC 130 + #if defined(CONFIG_PPC) && defined(CONFIG_CPU_BIG_ENDIAN) 129 131 # define XZ_DEC_POWERPC 130 132 #endif 131 133 #ifdef CONFIG_ARM 132 - # define XZ_DEC_ARM 134 + # ifdef CONFIG_THUMB2_KERNEL 135 + # define XZ_DEC_ARMTHUMB 136 + # else 137 + # define XZ_DEC_ARM 138 + # endif 139 + #endif 140 + #ifdef CONFIG_ARM64 141 + # define XZ_DEC_ARM64 142 + #endif 143 + #ifdef CONFIG_RISCV 144 + # define XZ_DEC_RISCV 133 145 #endif 134 146 #ifdef CONFIG_SPARC 135 147 # define XZ_DEC_SPARC ··· 228 220 #endif 229 221 230 222 /* 231 - * Since we need memmove anyway, would use it as memcpy too. 223 + * Since we need memmove anyway, we could use it as memcpy too. 232 224 * Commented out for now to avoid breaking things. 233 225 */ 234 226 /* ··· 398 390 } 399 391 400 392 /* 401 - * This macro is used by architecture-specific files to decompress 393 + * This function is used by architecture-specific files to decompress 402 394 * the kernel image. 403 395 */ 404 396 #ifdef XZ_PREBOOT 405 - STATIC int INIT __decompress(unsigned char *buf, long len, 406 - long (*fill)(void*, unsigned long), 407 - long (*flush)(void*, unsigned long), 408 - unsigned char *out_buf, long olen, 409 - long *pos, 410 - void (*error)(char *x)) 397 + STATIC int INIT __decompress(unsigned char *in, long in_size, 398 + long (*fill)(void *dest, unsigned long size), 399 + long (*flush)(void *src, unsigned long size), 400 + unsigned char *out, long out_size, 401 + long *in_used, 402 + void (*error)(char *x)) 411 403 { 412 - return unxz(buf, len, fill, flush, out_buf, pos, error); 404 + return unxz(in, in_size, fill, flush, out, in_used, error); 413 405 } 414 406 #endif
+1 -1
lib/dim/Makefile
··· 4 4 5 5 obj-$(CONFIG_DIMLIB) += dimlib.o 6 6 7 - dimlib-objs := dim.o net_dim.o rdma_dim.o 7 + dimlib-y := dim.o net_dim.o rdma_dim.o
+2 -2
lib/dynamic_debug.c
··· 1147 1147 iter->table->mod_name, dp->function, 1148 1148 ddebug_describe_flags(dp->flags, &flags)); 1149 1149 seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); 1150 - seq_puts(m, "\""); 1150 + seq_putc(m, '"'); 1151 1151 1152 1152 if (dp->class_id != _DPRINTK_CLASS_DFLT) { 1153 1153 class = ddebug_class_name(iter, dp); ··· 1156 1156 else 1157 1157 seq_printf(m, " class unknown, _id:%d", dp->class_id); 1158 1158 } 1159 - seq_puts(m, "\n"); 1159 + seq_putc(m, '\n'); 1160 1160 1161 1161 return 0; 1162 1162 }
+1
lib/fault-inject.c
··· 2 2 #include <linux/kernel.h> 3 3 #include <linux/init.h> 4 4 #include <linux/random.h> 5 + #include <linux/debugfs.h> 5 6 #include <linux/sched.h> 6 7 #include <linux/stat.h> 7 8 #include <linux/types.h>
+2
lib/glob.c
··· 68 68 back_str = --str; /* Allow zero-length match */ 69 69 break; 70 70 case '[': { /* Character class */ 71 + if (c == '\0') /* No possible match */ 72 + return false; 71 73 bool match = false, inverted = (*pat == '!'); 72 74 char const *class = pat + inverted; 73 75 unsigned char a = *class++;
+10
lib/list-test.c
··· 102 102 /* now: [list] -> a_new -> b */ 103 103 KUNIT_EXPECT_PTR_EQ(test, list.next, &a_new); 104 104 KUNIT_EXPECT_PTR_EQ(test, b.prev, &a_new); 105 + KUNIT_EXPECT_PTR_EQ(test, a_new.next, &b); 106 + KUNIT_EXPECT_PTR_EQ(test, a_new.prev, &list); 105 107 } 106 108 107 109 static void list_test_list_replace_init(struct kunit *test) ··· 120 118 /* now: [list] -> a_new -> b */ 121 119 KUNIT_EXPECT_PTR_EQ(test, list.next, &a_new); 122 120 KUNIT_EXPECT_PTR_EQ(test, b.prev, &a_new); 121 + KUNIT_EXPECT_PTR_EQ(test, a_new.next, &b); 122 + KUNIT_EXPECT_PTR_EQ(test, a_new.prev, &list); 123 123 124 124 /* check a_old is empty (initialized) */ 125 125 KUNIT_EXPECT_TRUE(test, list_empty_careful(&a_old)); ··· 408 404 409 405 KUNIT_EXPECT_EQ(test, i, 2); 410 406 407 + i = 0; 411 408 list_for_each(cur, &list1) { 412 409 KUNIT_EXPECT_PTR_EQ(test, cur, &entries[i]); 413 410 i++; 414 411 } 412 + 413 + KUNIT_EXPECT_EQ(test, i, 1); 415 414 } 416 415 417 416 static void list_test_list_cut_before(struct kunit *test) ··· 439 432 440 433 KUNIT_EXPECT_EQ(test, i, 1); 441 434 435 + i = 0; 442 436 list_for_each(cur, &list1) { 443 437 KUNIT_EXPECT_PTR_EQ(test, cur, &entries[i]); 444 438 i++; 445 439 } 440 + 441 + KUNIT_EXPECT_EQ(test, i, 2); 446 442 } 447 443 448 444 static void list_test_list_splice(struct kunit *test)
+5 -5
lib/lru_cache.c
··· 243 243 244 244 BUG_ON(!lc); 245 245 BUG_ON(!lc->nr_elements); 246 - hlist_for_each_entry(e, lc_hash_slot(lc, enr), colision) { 246 + hlist_for_each_entry(e, lc_hash_slot(lc, enr), collision) { 247 247 /* "about to be changed" elements, pending transaction commit, 248 248 * are hashed by their "new number". "Normal" elements have 249 249 * lc_number == lc_new_number. */ ··· 303 303 BUG_ON(e->refcnt); 304 304 305 305 e->lc_number = e->lc_new_number = LC_FREE; 306 - hlist_del_init(&e->colision); 306 + hlist_del_init(&e->collision); 307 307 list_move(&e->list, &lc->free); 308 308 RETURN(); 309 309 } ··· 324 324 PARANOIA_LC_ELEMENT(lc, e); 325 325 326 326 e->lc_new_number = new_number; 327 - if (!hlist_unhashed(&e->colision)) 328 - __hlist_del(&e->colision); 329 - hlist_add_head(&e->colision, lc_hash_slot(lc, new_number)); 327 + if (!hlist_unhashed(&e->collision)) 328 + __hlist_del(&e->collision); 329 + hlist_add_head(&e->collision, lc_hash_slot(lc, new_number)); 330 330 list_move(&e->list, &lc->to_be_changed); 331 331 332 332 return e;
+1
lib/math/Makefile
··· 7 7 8 8 obj-$(CONFIG_INT_POW_TEST) += tests/int_pow_kunit.o 9 9 obj-$(CONFIG_TEST_DIV64) += test_div64.o 10 + obj-$(CONFIG_TEST_MULDIV64) += test_mul_u64_u64_div_u64.o 10 11 obj-$(CONFIG_RATIONAL_KUNIT_TEST) += rational-test.o
+73 -44
lib/math/div64.c
··· 186 186 #ifndef mul_u64_u64_div_u64 187 187 u64 mul_u64_u64_div_u64(u64 a, u64 b, u64 c) 188 188 { 189 - u64 res = 0, div, rem; 190 - int shift; 189 + if (ilog2(a) + ilog2(b) <= 62) 190 + return div64_u64(a * b, c); 191 191 192 - /* can a * b overflow ? */ 193 - if (ilog2(a) + ilog2(b) > 62) { 192 + #if defined(__SIZEOF_INT128__) 193 + 194 + /* native 64x64=128 bits multiplication */ 195 + u128 prod = (u128)a * b; 196 + u64 n_lo = prod, n_hi = prod >> 64; 197 + 198 + #else 199 + 200 + /* perform a 64x64=128 bits multiplication manually */ 201 + u32 a_lo = a, a_hi = a >> 32, b_lo = b, b_hi = b >> 32; 202 + u64 x, y, z; 203 + 204 + x = (u64)a_lo * b_lo; 205 + y = (u64)a_lo * b_hi + (u32)(x >> 32); 206 + z = (u64)a_hi * b_hi + (u32)(y >> 32); 207 + y = (u64)a_hi * b_lo + (u32)y; 208 + z += (u32)(y >> 32); 209 + x = (y << 32) + (u32)x; 210 + 211 + u64 n_lo = x, n_hi = z; 212 + 213 + #endif 214 + 215 + /* make sure c is not zero, trigger exception otherwise */ 216 + #pragma GCC diagnostic push 217 + #pragma GCC diagnostic ignored "-Wdiv-by-zero" 218 + if (unlikely(c == 0)) 219 + return 1/0; 220 + #pragma GCC diagnostic pop 221 + 222 + int shift = __builtin_ctzll(c); 223 + 224 + /* try reducing the fraction in case the dividend becomes <= 64 bits */ 225 + if ((n_hi >> shift) == 0) { 226 + u64 n = shift ? (n_lo >> shift) | (n_hi << (64 - shift)) : n_lo; 227 + 228 + return div64_u64(n, c >> shift); 194 229 /* 195 - * Note that the algorithm after the if block below might lose 196 - * some precision and the result is more exact for b > a. So 197 - * exchange a and b if a is bigger than b. 198 - * 199 - * For example with a = 43980465100800, b = 100000000, c = 1000000000 200 - * the below calculation doesn't modify b at all because div == 0 201 - * and then shift becomes 45 + 26 - 62 = 9 and so the result 202 - * becomes 4398035251080. However with a and b swapped the exact 203 - * result is calculated (i.e. 4398046510080). 230 + * The remainder value if needed would be: 231 + * res = div64_u64_rem(n, c >> shift, &rem); 232 + * rem = (rem << shift) + (n_lo - (n << shift)); 204 233 */ 205 - if (a > b) 206 - swap(a, b); 207 - 208 - /* 209 - * (b * a) / c is equal to 210 - * 211 - * (b / c) * a + 212 - * (b % c) * a / c 213 - * 214 - * if nothing overflows. Can the 1st multiplication 215 - * overflow? Yes, but we do not care: this can only 216 - * happen if the end result can't fit in u64 anyway. 217 - * 218 - * So the code below does 219 - * 220 - * res = (b / c) * a; 221 - * b = b % c; 222 - */ 223 - div = div64_u64_rem(b, c, &rem); 224 - res = div * a; 225 - b = rem; 226 - 227 - shift = ilog2(a) + ilog2(b) - 62; 228 - if (shift > 0) { 229 - /* drop precision */ 230 - b >>= shift; 231 - c >>= shift; 232 - if (!c) 233 - return res; 234 - } 235 234 } 236 235 237 - return res + div64_u64(a * b, c); 236 + if (n_hi >= c) { 237 + /* overflow: result is unrepresentable in a u64 */ 238 + return -1; 239 + } 240 + 241 + /* Do the full 128 by 64 bits division */ 242 + 243 + shift = __builtin_clzll(c); 244 + c <<= shift; 245 + 246 + int p = 64 + shift; 247 + u64 res = 0; 248 + bool carry; 249 + 250 + do { 251 + carry = n_hi >> 63; 252 + shift = carry ? 1 : __builtin_clzll(n_hi); 253 + if (p < shift) 254 + break; 255 + p -= shift; 256 + n_hi <<= shift; 257 + n_hi |= n_lo >> (64 - shift); 258 + n_lo <<= shift; 259 + if (carry || (n_hi >= c)) { 260 + n_hi -= c; 261 + res |= 1ULL << p; 262 + } 263 + } while (n_hi); 264 + /* The remainder value if needed would be n_hi << p */ 265 + 266 + return res; 238 267 } 239 268 EXPORT_SYMBOL(mul_u64_u64_div_u64); 240 269 #endif
+99
lib/math/test_mul_u64_u64_div_u64.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2024 BayLibre SAS 4 + */ 5 + 6 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 7 + 8 + #include <linux/init.h> 9 + #include <linux/module.h> 10 + #include <linux/printk.h> 11 + #include <linux/math64.h> 12 + 13 + typedef struct { u64 a; u64 b; u64 c; u64 result; } test_params; 14 + 15 + static test_params test_values[] = { 16 + /* this contains many edge values followed by a couple random values */ 17 + { 0xb, 0x7, 0x3, 0x19 }, 18 + { 0xffff0000, 0xffff0000, 0xf, 0x1110eeef00000000 }, 19 + { 0xffffffff, 0xffffffff, 0x1, 0xfffffffe00000001 }, 20 + { 0xffffffff, 0xffffffff, 0x2, 0x7fffffff00000000 }, 21 + { 0x1ffffffff, 0xffffffff, 0x2, 0xfffffffe80000000 }, 22 + { 0x1ffffffff, 0xffffffff, 0x3, 0xaaaaaaa9aaaaaaab }, 23 + { 0x1ffffffff, 0x1ffffffff, 0x4, 0xffffffff00000000 }, 24 + { 0xffff000000000000, 0xffff000000000000, 0xffff000000000001, 0xfffeffffffffffff }, 25 + { 0x3333333333333333, 0x3333333333333333, 0x5555555555555555, 0x1eb851eb851eb851 }, 26 + { 0x7fffffffffffffff, 0x2, 0x3, 0x5555555555555554 }, 27 + { 0xffffffffffffffff, 0x2, 0x8000000000000000, 0x3 }, 28 + { 0xffffffffffffffff, 0x2, 0xc000000000000000, 0x2 }, 29 + { 0xffffffffffffffff, 0x4000000000000004, 0x8000000000000000, 0x8000000000000007 }, 30 + { 0xffffffffffffffff, 0x4000000000000001, 0x8000000000000000, 0x8000000000000001 }, 31 + { 0xffffffffffffffff, 0x8000000000000001, 0xffffffffffffffff, 0x8000000000000001 }, 32 + { 0xfffffffffffffffe, 0x8000000000000001, 0xffffffffffffffff, 0x8000000000000000 }, 33 + { 0xffffffffffffffff, 0x8000000000000001, 0xfffffffffffffffe, 0x8000000000000001 }, 34 + { 0xffffffffffffffff, 0x8000000000000001, 0xfffffffffffffffd, 0x8000000000000002 }, 35 + { 0x7fffffffffffffff, 0xffffffffffffffff, 0xc000000000000000, 0xaaaaaaaaaaaaaaa8 }, 36 + { 0xffffffffffffffff, 0x7fffffffffffffff, 0xa000000000000000, 0xccccccccccccccca }, 37 + { 0xffffffffffffffff, 0x7fffffffffffffff, 0x9000000000000000, 0xe38e38e38e38e38b }, 38 + { 0x7fffffffffffffff, 0x7fffffffffffffff, 0x5000000000000000, 0xccccccccccccccc9 }, 39 + { 0xffffffffffffffff, 0xfffffffffffffffe, 0xffffffffffffffff, 0xfffffffffffffffe }, 40 + { 0xe6102d256d7ea3ae, 0x70a77d0be4c31201, 0xd63ec35ab3220357, 0x78f8bf8cc86c6e18 }, 41 + { 0xf53bae05cb86c6e1, 0x3847b32d2f8d32e0, 0xcfd4f55a647f403c, 0x42687f79d8998d35 }, 42 + { 0x9951c5498f941092, 0x1f8c8bfdf287a251, 0xa3c8dc5f81ea3fe2, 0x1d887cb25900091f }, 43 + { 0x374fee9daa1bb2bb, 0x0d0bfbff7b8ae3ef, 0xc169337bd42d5179, 0x03bb2dbaffcbb961 }, 44 + { 0xeac0d03ac10eeaf0, 0x89be05dfa162ed9b, 0x92bb1679a41f0e4b, 0xdc5f5cc9e270d216 }, 45 + }; 46 + 47 + /* 48 + * The above table can be verified with the following shell script: 49 + * 50 + * #!/bin/sh 51 + * sed -ne 's/^{ \+\(.*\), \+\(.*\), \+\(.*\), \+\(.*\) },$/\1 \2 \3 \4/p' \ 52 + * lib/math/test_mul_u64_u64_div_u64.c | 53 + * while read a b c r; do 54 + * expected=$( printf "obase=16; ibase=16; %X * %X / %X\n" $a $b $c | bc ) 55 + * given=$( printf "%X\n" $r ) 56 + * if [ "$expected" = "$given" ]; then 57 + * echo "$a * $b / $c = $r OK" 58 + * else 59 + * echo "$a * $b / $c = $r is wrong" >&2 60 + * echo "should be equivalent to 0x$expected" >&2 61 + * exit 1 62 + * fi 63 + * done 64 + */ 65 + 66 + static int __init test_init(void) 67 + { 68 + int i; 69 + 70 + pr_info("Starting mul_u64_u64_div_u64() test\n"); 71 + 72 + for (i = 0; i < ARRAY_SIZE(test_values); i++) { 73 + u64 a = test_values[i].a; 74 + u64 b = test_values[i].b; 75 + u64 c = test_values[i].c; 76 + u64 expected_result = test_values[i].result; 77 + u64 result = mul_u64_u64_div_u64(a, b, c); 78 + 79 + if (result != expected_result) { 80 + pr_err("ERROR: 0x%016llx * 0x%016llx / 0x%016llx\n", a, b, c); 81 + pr_err("ERROR: expected result: %016llx\n", expected_result); 82 + pr_err("ERROR: obtained result: %016llx\n", result); 83 + } 84 + } 85 + 86 + pr_info("Completed mul_u64_u64_div_u64() test\n"); 87 + return 0; 88 + } 89 + 90 + static void __exit test_exit(void) 91 + { 92 + } 93 + 94 + module_init(test_init); 95 + module_exit(test_exit); 96 + 97 + MODULE_AUTHOR("Nicolas Pitre"); 98 + MODULE_LICENSE("GPL"); 99 + MODULE_DESCRIPTION("mul_u64_u64_div_u64() test module");
+1 -1
lib/percpu_counter.c
··· 209 209 INIT_LIST_HEAD(&fbc[i].list); 210 210 #endif 211 211 fbc[i].count = amount; 212 - fbc[i].counters = (void *)counters + (i * counter_size); 212 + fbc[i].counters = (void __percpu *)counters + i * counter_size; 213 213 214 214 debug_percpu_counter_activate(&fbc[i]); 215 215 }
+1 -1
lib/rhashtable.c
··· 189 189 190 190 size = nbuckets; 191 191 192 - if (tbl == NULL && (gfp & ~__GFP_NOFAIL) != GFP_KERNEL) { 192 + if (tbl == NULL && !gfpflags_allow_blocking(gfp)) { 193 193 tbl = nested_bucket_table_alloc(ht, nbuckets, gfp); 194 194 nbuckets = 0; 195 195 }
+1 -1
lib/test_fpu_glue.c
··· 42 42 return -EINVAL; 43 43 44 44 selftest_dir = debugfs_create_dir("selftest_helpers", NULL); 45 - if (!selftest_dir) 45 + if (IS_ERR(selftest_dir)) 46 46 return -ENOMEM; 47 47 48 48 debugfs_create_file_unsafe("test_fpu", 0444, selftest_dir, NULL,
+1
lib/test_objpool.c
··· 687 687 module_init(ot_mod_init); 688 688 module_exit(ot_mod_exit); 689 689 690 + MODULE_DESCRIPTION("Test module for lockless object pool"); 690 691 MODULE_LICENSE("GPL");
+12 -1
lib/xz/Kconfig
··· 5 5 help 6 6 LZMA2 compression algorithm and BCJ filters are supported using 7 7 the .xz file format as the container. For integrity checking, 8 - CRC32 is supported. See Documentation/staging/xz.rst for more information. 8 + CRC32 is supported. See Documentation/staging/xz.rst for more 9 + information. 9 10 10 11 if XZ_DEC 11 12 ··· 30 29 default y 31 30 select XZ_DEC_BCJ 32 31 32 + config XZ_DEC_ARM64 33 + bool "ARM64 BCJ filter decoder" if EXPERT 34 + default y 35 + select XZ_DEC_BCJ 36 + 33 37 config XZ_DEC_SPARC 34 38 bool "SPARC BCJ filter decoder" if EXPERT 39 + default y 40 + select XZ_DEC_BCJ 41 + 42 + config XZ_DEC_RISCV 43 + bool "RISC-V BCJ filter decoder" if EXPERT 35 44 default y 36 45 select XZ_DEC_BCJ 37 46
+5 -6
lib/xz/xz_crc32.c
··· 1 + // SPDX-License-Identifier: 0BSD 2 + 1 3 /* 2 4 * CRC32 using the polynomial from IEEE-802.3 3 5 * 4 6 * Authors: Lasse Collin <lasse.collin@tukaani.org> 5 7 * Igor Pavlov <https://7-zip.org/> 6 - * 7 - * This file has been put into the public domain. 8 - * You can do whatever you want with this file. 9 8 */ 10 9 11 10 /* ··· 26 27 27 28 STATIC_RW_DATA uint32_t xz_crc32_table[256]; 28 29 29 - XZ_EXTERN void xz_crc32_init(void) 30 + void xz_crc32_init(void) 30 31 { 31 - const uint32_t poly = CRC32_POLY_LE; 32 + const uint32_t poly = 0xEDB88320; 32 33 33 34 uint32_t i; 34 35 uint32_t j; ··· 45 46 return; 46 47 } 47 48 48 - XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc) 49 + uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc) 49 50 { 50 51 crc = ~crc; 51 52
+177 -14
lib/xz/xz_dec_bcj.c
··· 1 + // SPDX-License-Identifier: 0BSD 2 + 1 3 /* 2 4 * Branch/Call/Jump (BCJ) filter decoders 3 5 * 4 6 * Authors: Lasse Collin <lasse.collin@tukaani.org> 5 7 * Igor Pavlov <https://7-zip.org/> 6 - * 7 - * This file has been put into the public domain. 8 - * You can do whatever you want with this file. 9 8 */ 10 9 11 10 #include "xz_private.h" ··· 23 24 BCJ_IA64 = 6, /* Big or little endian */ 24 25 BCJ_ARM = 7, /* Little endian only */ 25 26 BCJ_ARMTHUMB = 8, /* Little endian only */ 26 - BCJ_SPARC = 9 /* Big or little endian */ 27 + BCJ_SPARC = 9, /* Big or little endian */ 28 + BCJ_ARM64 = 10, /* AArch64 */ 29 + BCJ_RISCV = 11 /* RV32GQC_Zfh, RV64GQC_Zfh */ 27 30 } type; 28 31 29 32 /* ··· 163 162 size_t i; 164 163 uint32_t instr; 165 164 166 - for (i = 0; i + 4 <= size; i += 4) { 165 + size &= ~(size_t)3; 166 + 167 + for (i = 0; i < size; i += 4) { 167 168 instr = get_unaligned_be32(buf + i); 168 169 if ((instr & 0xFC000003) == 0x48000001) { 169 170 instr &= 0x03FFFFFC; ··· 222 219 /* Instruction normalized with bit_res for easier manipulation */ 223 220 uint64_t norm; 224 221 225 - for (i = 0; i + 16 <= size; i += 16) { 222 + size &= ~(size_t)15; 223 + 224 + for (i = 0; i < size; i += 16) { 226 225 mask = branch_table[buf[i] & 0x1F]; 227 226 for (slot = 0, bit_pos = 5; slot < 3; ++slot, bit_pos += 41) { 228 227 if (((mask >> slot) & 1) == 0) ··· 272 267 size_t i; 273 268 uint32_t addr; 274 269 275 - for (i = 0; i + 4 <= size; i += 4) { 270 + size &= ~(size_t)3; 271 + 272 + for (i = 0; i < size; i += 4) { 276 273 if (buf[i + 3] == 0xEB) { 277 274 addr = (uint32_t)buf[i] | ((uint32_t)buf[i + 1] << 8) 278 275 | ((uint32_t)buf[i + 2] << 16); ··· 297 290 size_t i; 298 291 uint32_t addr; 299 292 300 - for (i = 0; i + 4 <= size; i += 2) { 293 + if (size < 4) 294 + return 0; 295 + 296 + size -= 4; 297 + 298 + for (i = 0; i <= size; i += 2) { 301 299 if ((buf[i + 1] & 0xF8) == 0xF0 302 300 && (buf[i + 3] & 0xF8) == 0xF8) { 303 301 addr = (((uint32_t)buf[i + 1] & 0x07) << 19) ··· 330 318 size_t i; 331 319 uint32_t instr; 332 320 333 - for (i = 0; i + 4 <= size; i += 4) { 321 + size &= ~(size_t)3; 322 + 323 + for (i = 0; i < size; i += 4) { 334 324 instr = get_unaligned_be32(buf + i); 335 325 if ((instr >> 22) == 0x100 || (instr >> 22) == 0x1FF) { 336 326 instr <<= 2; ··· 341 327 instr = ((uint32_t)0x40000000 - (instr & 0x400000)) 342 328 | 0x40000000 | (instr & 0x3FFFFF); 343 329 put_unaligned_be32(instr, buf + i); 330 + } 331 + } 332 + 333 + return i; 334 + } 335 + #endif 336 + 337 + #ifdef XZ_DEC_ARM64 338 + static size_t bcj_arm64(struct xz_dec_bcj *s, uint8_t *buf, size_t size) 339 + { 340 + size_t i; 341 + uint32_t instr; 342 + uint32_t addr; 343 + 344 + size &= ~(size_t)3; 345 + 346 + for (i = 0; i < size; i += 4) { 347 + instr = get_unaligned_le32(buf + i); 348 + 349 + if ((instr >> 26) == 0x25) { 350 + /* BL instruction */ 351 + addr = instr - ((s->pos + (uint32_t)i) >> 2); 352 + instr = 0x94000000 | (addr & 0x03FFFFFF); 353 + put_unaligned_le32(instr, buf + i); 354 + 355 + } else if ((instr & 0x9F000000) == 0x90000000) { 356 + /* ADRP instruction */ 357 + addr = ((instr >> 29) & 3) | ((instr >> 3) & 0x1FFFFC); 358 + 359 + /* Only convert values in the range +/-512 MiB. */ 360 + if ((addr + 0x020000) & 0x1C0000) 361 + continue; 362 + 363 + addr -= (s->pos + (uint32_t)i) >> 12; 364 + 365 + instr &= 0x9000001F; 366 + instr |= (addr & 3) << 29; 367 + instr |= (addr & 0x03FFFC) << 3; 368 + instr |= (0U - (addr & 0x020000)) & 0xE00000; 369 + 370 + put_unaligned_le32(instr, buf + i); 371 + } 372 + } 373 + 374 + return i; 375 + } 376 + #endif 377 + 378 + #ifdef XZ_DEC_RISCV 379 + static size_t bcj_riscv(struct xz_dec_bcj *s, uint8_t *buf, size_t size) 380 + { 381 + size_t i; 382 + uint32_t b1; 383 + uint32_t b2; 384 + uint32_t b3; 385 + uint32_t instr; 386 + uint32_t instr2; 387 + uint32_t instr2_rs1; 388 + uint32_t addr; 389 + 390 + if (size < 8) 391 + return 0; 392 + 393 + size -= 8; 394 + 395 + for (i = 0; i <= size; i += 2) { 396 + instr = buf[i]; 397 + 398 + if (instr == 0xEF) { 399 + /* JAL */ 400 + b1 = buf[i + 1]; 401 + if ((b1 & 0x0D) != 0) 402 + continue; 403 + 404 + b2 = buf[i + 2]; 405 + b3 = buf[i + 3]; 406 + 407 + addr = ((b1 & 0xF0) << 13) | (b2 << 9) | (b3 << 1); 408 + addr -= s->pos + (uint32_t)i; 409 + 410 + buf[i + 1] = (uint8_t)((b1 & 0x0F) 411 + | ((addr >> 8) & 0xF0)); 412 + 413 + buf[i + 2] = (uint8_t)(((addr >> 16) & 0x0F) 414 + | ((addr >> 7) & 0x10) 415 + | ((addr << 4) & 0xE0)); 416 + 417 + buf[i + 3] = (uint8_t)(((addr >> 4) & 0x7F) 418 + | ((addr >> 13) & 0x80)); 419 + 420 + i += 4 - 2; 421 + 422 + } else if ((instr & 0x7F) == 0x17) { 423 + /* AUIPC */ 424 + instr |= (uint32_t)buf[i + 1] << 8; 425 + instr |= (uint32_t)buf[i + 2] << 16; 426 + instr |= (uint32_t)buf[i + 3] << 24; 427 + 428 + if (instr & 0xE80) { 429 + /* AUIPC's rd doesn't equal x0 or x2. */ 430 + instr2 = get_unaligned_le32(buf + i + 4); 431 + 432 + if (((instr << 8) ^ (instr2 - 3)) & 0xF8003) { 433 + i += 6 - 2; 434 + continue; 435 + } 436 + 437 + addr = (instr & 0xFFFFF000) + (instr2 >> 20); 438 + 439 + instr = 0x17 | (2 << 7) | (instr2 << 12); 440 + instr2 = addr; 441 + } else { 442 + /* AUIPC's rd equals x0 or x2. */ 443 + instr2_rs1 = instr >> 27; 444 + 445 + if ((uint32_t)((instr - 0x3117) << 18) 446 + >= (instr2_rs1 & 0x1D)) { 447 + i += 4 - 2; 448 + continue; 449 + } 450 + 451 + addr = get_unaligned_be32(buf + i + 4); 452 + addr -= s->pos + (uint32_t)i; 453 + 454 + instr2 = (instr >> 12) | (addr << 20); 455 + 456 + instr = 0x17 | (instr2_rs1 << 7) 457 + | ((addr + 0x800) & 0xFFFFF000); 458 + } 459 + 460 + put_unaligned_le32(instr, buf + i); 461 + put_unaligned_le32(instr2, buf + i + 4); 462 + 463 + i += 8 - 2; 344 464 } 345 465 } 346 466 ··· 529 381 filtered = bcj_sparc(s, buf, size); 530 382 break; 531 383 #endif 384 + #ifdef XZ_DEC_ARM64 385 + case BCJ_ARM64: 386 + filtered = bcj_arm64(s, buf, size); 387 + break; 388 + #endif 389 + #ifdef XZ_DEC_RISCV 390 + case BCJ_RISCV: 391 + filtered = bcj_riscv(s, buf, size); 392 + break; 393 + #endif 532 394 default: 533 395 /* Never reached but silence compiler warnings. */ 534 396 filtered = 0; ··· 572 414 * data in chunks of 1-16 bytes. To hide this issue, this function does 573 415 * some buffering. 574 416 */ 575 - XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, 576 - struct xz_dec_lzma2 *lzma2, 577 - struct xz_buf *b) 417 + enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, struct xz_dec_lzma2 *lzma2, 418 + struct xz_buf *b) 578 419 { 579 420 size_t out_start; 580 421 ··· 681 524 return s->ret; 682 525 } 683 526 684 - XZ_EXTERN struct xz_dec_bcj *xz_dec_bcj_create(bool single_call) 527 + struct xz_dec_bcj *xz_dec_bcj_create(bool single_call) 685 528 { 686 529 struct xz_dec_bcj *s = kmalloc(sizeof(*s), GFP_KERNEL); 687 530 if (s != NULL) ··· 690 533 return s; 691 534 } 692 535 693 - XZ_EXTERN enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id) 536 + enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id) 694 537 { 695 538 switch (id) { 696 539 #ifdef XZ_DEC_X86 ··· 710 553 #endif 711 554 #ifdef XZ_DEC_SPARC 712 555 case BCJ_SPARC: 556 + #endif 557 + #ifdef XZ_DEC_ARM64 558 + case BCJ_ARM64: 559 + #endif 560 + #ifdef XZ_DEC_RISCV 561 + case BCJ_RISCV: 713 562 #endif 714 563 break; 715 564
+6 -9
lib/xz/xz_dec_lzma2.c
··· 1 + // SPDX-License-Identifier: 0BSD 2 + 1 3 /* 2 4 * LZMA2 decoder 3 5 * 4 6 * Authors: Lasse Collin <lasse.collin@tukaani.org> 5 7 * Igor Pavlov <https://7-zip.org/> 6 - * 7 - * This file has been put into the public domain. 8 - * You can do whatever you want with this file. 9 8 */ 10 9 11 10 #include "xz_private.h" ··· 960 961 * Take care of the LZMA2 control layer, and forward the job of actual LZMA 961 962 * decoding or copying of uncompressed chunks to other functions. 962 963 */ 963 - XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, 964 - struct xz_buf *b) 964 + enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, struct xz_buf *b) 965 965 { 966 966 uint32_t tmp; 967 967 ··· 1136 1138 return XZ_OK; 1137 1139 } 1138 1140 1139 - XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, 1140 - uint32_t dict_max) 1141 + struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, uint32_t dict_max) 1141 1142 { 1142 1143 struct xz_dec_lzma2 *s = kmalloc(sizeof(*s), GFP_KERNEL); 1143 1144 if (s == NULL) ··· 1159 1162 return s; 1160 1163 } 1161 1164 1162 - XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props) 1165 + enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props) 1163 1166 { 1164 1167 /* This limits dictionary size to 3 GiB to keep parsing simpler. */ 1165 1168 if (props > 39) ··· 1195 1198 return XZ_OK; 1196 1199 } 1197 1200 1198 - XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s) 1201 + void xz_dec_lzma2_end(struct xz_dec_lzma2 *s) 1199 1202 { 1200 1203 if (DEC_IS_MULTI(s->dict.mode)) 1201 1204 vfree(s->dict.buf);
+6 -7
lib/xz/xz_dec_stream.c
··· 1 + // SPDX-License-Identifier: 0BSD 2 + 1 3 /* 2 4 * .xz Stream decoder 3 5 * 4 6 * Author: Lasse Collin <lasse.collin@tukaani.org> 5 - * 6 - * This file has been put into the public domain. 7 - * You can do whatever you want with this file. 8 7 */ 9 8 10 9 #include "xz_private.h" ··· 746 747 * actually succeeds (that's the price to pay of using the output buffer as 747 748 * the workspace). 748 749 */ 749 - XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b) 750 + enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b) 750 751 { 751 752 size_t in_start; 752 753 size_t out_start; ··· 782 783 return ret; 783 784 } 784 785 785 - XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max) 786 + struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max) 786 787 { 787 788 struct xz_dec *s = kmalloc(sizeof(*s), GFP_KERNEL); 788 789 if (s == NULL) ··· 812 813 return NULL; 813 814 } 814 815 815 - XZ_EXTERN void xz_dec_reset(struct xz_dec *s) 816 + void xz_dec_reset(struct xz_dec *s) 816 817 { 817 818 s->sequence = SEQ_STREAM_HEADER; 818 819 s->allow_buf_error = false; ··· 824 825 s->temp.size = STREAM_HEADER_SIZE; 825 826 } 826 827 827 - XZ_EXTERN void xz_dec_end(struct xz_dec *s) 828 + void xz_dec_end(struct xz_dec *s) 828 829 { 829 830 if (s != NULL) { 830 831 xz_dec_lzma2_end(s->lzma2);
+4 -10
lib/xz/xz_dec_syms.c
··· 1 + // SPDX-License-Identifier: 0BSD 2 + 1 3 /* 2 4 * XZ decoder module information 3 5 * 4 6 * Author: Lasse Collin <lasse.collin@tukaani.org> 5 - * 6 - * This file has been put into the public domain. 7 - * You can do whatever you want with this file. 8 7 */ 9 8 10 9 #include <linux/module.h> ··· 22 23 #endif 23 24 24 25 MODULE_DESCRIPTION("XZ decompressor"); 25 - MODULE_VERSION("1.1"); 26 + MODULE_VERSION("1.2"); 26 27 MODULE_AUTHOR("Lasse Collin <lasse.collin@tukaani.org> and Igor Pavlov"); 27 - 28 - /* 29 - * This code is in the public domain, but in Linux it's simplest to just 30 - * say it's GPL and consider the authors as the copyright holders. 31 - */ 32 - MODULE_LICENSE("GPL"); 28 + MODULE_LICENSE("Dual BSD/GPL");
+3 -9
lib/xz/xz_dec_test.c
··· 1 + // SPDX-License-Identifier: 0BSD 2 + 1 3 /* 2 4 * XZ decoder tester 3 5 * 4 6 * Author: Lasse Collin <lasse.collin@tukaani.org> 5 - * 6 - * This file has been put into the public domain. 7 - * You can do whatever you want with this file. 8 7 */ 9 8 10 9 #include <linux/kernel.h> ··· 211 212 MODULE_DESCRIPTION("XZ decompressor tester"); 212 213 MODULE_VERSION("1.0"); 213 214 MODULE_AUTHOR("Lasse Collin <lasse.collin@tukaani.org>"); 214 - 215 - /* 216 - * This code is in the public domain, but in Linux it's simplest to just 217 - * say it's GPL and consider the authors as the copyright holders. 218 - */ 219 - MODULE_LICENSE("GPL"); 215 + MODULE_LICENSE("Dual BSD/GPL");
+2 -3
lib/xz/xz_lzma2.h
··· 1 + /* SPDX-License-Identifier: 0BSD */ 2 + 1 3 /* 2 4 * LZMA2 definitions 3 5 * 4 6 * Authors: Lasse Collin <lasse.collin@tukaani.org> 5 7 * Igor Pavlov <https://7-zip.org/> 6 - * 7 - * This file has been put into the public domain. 8 - * You can do whatever you want with this file. 9 8 */ 10 9 11 10 #ifndef XZ_LZMA2_H
+19 -21
lib/xz/xz_private.h
··· 1 + /* SPDX-License-Identifier: 0BSD */ 2 + 1 3 /* 2 4 * Private includes and definitions 3 5 * 4 6 * Author: Lasse Collin <lasse.collin@tukaani.org> 5 - * 6 - * This file has been put into the public domain. 7 - * You can do whatever you want with this file. 8 7 */ 9 8 10 9 #ifndef XZ_PRIVATE_H ··· 35 36 # endif 36 37 # ifdef CONFIG_XZ_DEC_SPARC 37 38 # define XZ_DEC_SPARC 39 + # endif 40 + # ifdef CONFIG_XZ_DEC_ARM64 41 + # define XZ_DEC_ARM64 42 + # endif 43 + # ifdef CONFIG_XZ_DEC_RISCV 44 + # define XZ_DEC_RISCV 38 45 # endif 39 46 # ifdef CONFIG_XZ_DEC_MICROLZMA 40 47 # define XZ_DEC_MICROLZMA ··· 103 98 */ 104 99 #ifndef XZ_DEC_BCJ 105 100 # if defined(XZ_DEC_X86) || defined(XZ_DEC_POWERPC) \ 106 - || defined(XZ_DEC_IA64) || defined(XZ_DEC_ARM) \ 101 + || defined(XZ_DEC_IA64) \ 107 102 || defined(XZ_DEC_ARM) || defined(XZ_DEC_ARMTHUMB) \ 108 - || defined(XZ_DEC_SPARC) 103 + || defined(XZ_DEC_SPARC) || defined(XZ_DEC_ARM64) \ 104 + || defined(XZ_DEC_RISCV) 109 105 # define XZ_DEC_BCJ 110 106 # endif 111 - #endif 112 - 113 - #ifndef CRC32_POLY_LE 114 - #define CRC32_POLY_LE 0xedb88320 115 107 #endif 116 108 117 109 /* 118 110 * Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used 119 111 * before calling xz_dec_lzma2_run(). 120 112 */ 121 - XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, 122 - uint32_t dict_max); 113 + struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, uint32_t dict_max); 123 114 124 115 /* 125 116 * Decode the LZMA2 properties (one byte) and reset the decoder. Return ··· 123 122 * big enough, and XZ_OPTIONS_ERROR if props indicates something that this 124 123 * decoder doesn't support. 125 124 */ 126 - XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, 127 - uint8_t props); 125 + enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props); 128 126 129 127 /* Decode raw LZMA2 stream from b->in to b->out. */ 130 - XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, 131 - struct xz_buf *b); 128 + enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, struct xz_buf *b); 132 129 133 130 /* Free the memory allocated for the LZMA2 decoder. */ 134 - XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s); 131 + void xz_dec_lzma2_end(struct xz_dec_lzma2 *s); 135 132 136 133 #ifdef XZ_DEC_BCJ 137 134 /* 138 135 * Allocate memory for BCJ decoders. xz_dec_bcj_reset() must be used before 139 136 * calling xz_dec_bcj_run(). 140 137 */ 141 - XZ_EXTERN struct xz_dec_bcj *xz_dec_bcj_create(bool single_call); 138 + struct xz_dec_bcj *xz_dec_bcj_create(bool single_call); 142 139 143 140 /* 144 141 * Decode the Filter ID of a BCJ filter. This implementation doesn't ··· 144 145 * is needed. Returns XZ_OK if the given Filter ID is supported. 145 146 * Otherwise XZ_OPTIONS_ERROR is returned. 146 147 */ 147 - XZ_EXTERN enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id); 148 + enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id); 148 149 149 150 /* 150 151 * Decode raw BCJ + LZMA2 stream. This must be used only if there actually is 151 152 * a BCJ filter in the chain. If the chain has only LZMA2, xz_dec_lzma2_run() 152 153 * must be called directly. 153 154 */ 154 - XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, 155 - struct xz_dec_lzma2 *lzma2, 156 - struct xz_buf *b); 155 + enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, struct xz_dec_lzma2 *lzma2, 156 + struct xz_buf *b); 157 157 158 158 /* Free the memory allocated for the BCJ filters. */ 159 159 #define xz_dec_bcj_end(s) kfree(s)
+2 -3
lib/xz/xz_stream.h
··· 1 + /* SPDX-License-Identifier: 0BSD */ 2 + 1 3 /* 2 4 * Definitions for handling the .xz file format 3 5 * 4 6 * Author: Lasse Collin <lasse.collin@tukaani.org> 5 - * 6 - * This file has been put into the public domain. 7 - * You can do whatever you want with this file. 8 7 */ 9 8 10 9 #ifndef XZ_STREAM_H
+1
mm/fail_page_alloc.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <linux/fault-inject.h> 3 + #include <linux/debugfs.h> 3 4 #include <linux/error-injection.h> 4 5 #include <linux/mm.h> 5 6
+1
mm/failslab.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <linux/fault-inject.h> 3 3 #include <linux/error-injection.h> 4 + #include <linux/debugfs.h> 4 5 #include <linux/slab.h> 5 6 #include <linux/mm.h> 6 7 #include "slab.h"
+1 -2
mm/memory-tiers.c
··· 941 941 static ssize_t demotion_enabled_show(struct kobject *kobj, 942 942 struct kobj_attribute *attr, char *buf) 943 943 { 944 - return sysfs_emit(buf, "%s\n", 945 - numa_demotion_enabled ? "true" : "false"); 944 + return sysfs_emit(buf, "%s\n", str_true_false(numa_demotion_enabled)); 946 945 } 947 946 948 947 static ssize_t demotion_enabled_store(struct kobject *kobj,
+8 -5
scripts/Makefile.lib
··· 530 530 531 531 # XZ 532 532 # --------------------------------------------------------------------------- 533 - # Use xzkern to compress the kernel image and xzmisc to compress other things. 533 + # Use xzkern or xzkern_with_size to compress the kernel image and xzmisc to 534 + # compress other things. 534 535 # 535 536 # xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage 536 537 # of the kernel decompressor. A BCJ filter is used if it is available for 537 - # the target architecture. xzkern also appends uncompressed size of the data 538 - # using size_append. The .xz format has the size information available at 539 - # the end of the file too, but it's in more complex format and it's good to 540 - # avoid changing the part of the boot code that reads the uncompressed size. 538 + # the target architecture. 539 + # 540 + # xzkern_with_size also appends uncompressed size of the data using 541 + # size_append. The .xz format has the size information available at the end 542 + # of the file too, but it's in more complex format and it's good to avoid 543 + # changing the part of the boot code that reads the uncompressed size. 541 544 # Note that the bytes added by size_append will make the xz tool think that 542 545 # the file is corrupt. This is expected. 543 546 #
+28 -23
scripts/decode_stacktrace.sh
··· 1 - #!/bin/bash 1 + #!/usr/bin/env bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # (c) 2014, Sasha Levin <sasha.levin@oracle.com> 4 4 #set -x 5 5 6 6 usage() { 7 7 echo "Usage:" 8 - echo " $0 -r <release> | <vmlinux> [<base path>|auto] [<modules path>]" 8 + echo " $0 -r <release>" 9 + echo " $0 [<vmlinux> [<base_path>|auto [<modules_path>]]]" 10 + echo " $0 -h" 9 11 } 10 12 11 13 # Try to find a Rust demangler ··· 34 32 ADDR2LINE=${UTIL_PREFIX}addr2line${UTIL_SUFFIX} 35 33 NM=${UTIL_PREFIX}nm${UTIL_SUFFIX} 36 34 37 - if [[ $1 == "-r" ]] ; then 35 + if [[ $1 == "-h" ]] ; then 36 + usage 37 + exit 0 38 + elif [[ $1 == "-r" ]] ; then 38 39 vmlinux="" 39 40 basepath="auto" 40 41 modpath="" ··· 94 89 fi 95 90 fi 96 91 97 - if [[ "$modpath" != "" ]] ; then 98 - for fn in $(find "$modpath" -name "${module//_/[-_]}.ko*") ; do 99 - if ${READELF} -WS "$fn" | grep -qwF .debug_line ; then 100 - echo $fn 101 - return 102 - fi 103 - done 104 - return 1 105 - fi 106 - 107 - modpath=$(dirname "$vmlinux") 108 - find_module && return 109 - 110 - if [[ $release == "" ]] ; then 92 + if [ -z $release ] ; then 111 93 release=$(gdb -ex 'print init_uts_ns.name.release' -ex 'quit' -quiet -batch "$vmlinux" 2>/dev/null | sed -n 's/\$1 = "\(.*\)".*/\1/p') 112 94 fi 95 + if [ -n "${release}" ] ; then 96 + release_dirs="/usr/lib/debug/lib/modules/$release /lib/modules/$release" 97 + fi 113 98 114 - for dn in {/usr/lib/debug,}/lib/modules/$release ; do 115 - if [ -e "$dn" ] ; then 116 - modpath="$dn" 117 - find_module && return 99 + found_without_debug_info=false 100 + for dir in "$modpath" "$(dirname "$vmlinux")" ${release_dirs}; do 101 + if [ -n "${dir}" ] && [ -e "${dir}" ]; then 102 + for fn in $(find "$dir" -name "${module//_/[-_]}.ko*") ; do 103 + if ${READELF} -WS "$fn" | grep -qwF .debug_line ; then 104 + echo $fn 105 + return 106 + fi 107 + found_without_debug_info=true 108 + done 118 109 fi 119 110 done 120 111 121 - modpath="" 112 + if [[ ${found_without_debug_info} == true ]]; then 113 + echo "WARNING! No debugging info in module ${module}, rebuild with DEBUG_KERNEL and DEBUG_INFO" >&2 114 + else 115 + echo "WARNING! Cannot find .ko for module ${module}, please pass a valid module path" >&2 116 + fi 117 + 122 118 return 1 123 119 } 124 120 ··· 137 131 else 138 132 local objfile=$(find_module) 139 133 if [[ $objfile == "" ]] ; then 140 - echo "WARNING! Modules path isn't set, but is needed to parse this symbol" >&2 141 134 return 142 135 fi 143 136 if [[ $aarray_support == true ]]; then
+44
scripts/gdb/linux/kasan.py
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # 3 + # Copyright 2024 Canonical Ltd. 4 + # 5 + # Authors: 6 + # Kuan-Ying Lee <kuan-ying.lee@canonical.com> 7 + # 8 + 9 + import gdb 10 + from linux import constants, mm 11 + 12 + def help(): 13 + t = """Usage: lx-kasan_mem_to_shadow [Hex memory addr] 14 + Example: 15 + lx-kasan_mem_to_shadow 0xffff000008eca008\n""" 16 + gdb.write("Unrecognized command\n") 17 + raise gdb.GdbError(t) 18 + 19 + class KasanMemToShadow(gdb.Command): 20 + """Translate memory address to kasan shadow address""" 21 + 22 + p_ops = None 23 + 24 + def __init__(self): 25 + if constants.LX_CONFIG_KASAN_GENERIC or constants.LX_CONFIG_KASAN_SW_TAGS: 26 + super(KasanMemToShadow, self).__init__("lx-kasan_mem_to_shadow", gdb.COMMAND_SUPPORT) 27 + 28 + def invoke(self, args, from_tty): 29 + if not constants.LX_CONFIG_KASAN_GENERIC or constants.LX_CONFIG_KASAN_SW_TAGS: 30 + raise gdb.GdbError('CONFIG_KASAN_GENERIC or CONFIG_KASAN_SW_TAGS is not set') 31 + 32 + argv = gdb.string_to_argv(args) 33 + if len(argv) == 1: 34 + if self.p_ops is None: 35 + self.p_ops = mm.page_ops().ops 36 + addr = int(argv[0], 16) 37 + shadow_addr = self.kasan_mem_to_shadow(addr) 38 + gdb.write('shadow addr: 0x%x\n' % shadow_addr) 39 + else: 40 + help() 41 + def kasan_mem_to_shadow(self, addr): 42 + return (addr >> self.p_ops.KASAN_SHADOW_SCALE_SHIFT) + self.p_ops.KASAN_SHADOW_OFFSET 43 + 44 + KasanMemToShadow()
+2 -2
scripts/gdb/linux/proc.py
··· 18 18 from linux import tasks 19 19 from linux import lists 20 20 from linux import vfs 21 + from linux import rbtree 21 22 from struct import * 22 23 23 24 ··· 173 172 gdb.write("{:^18} {:^15} {:>9} {} {} options\n".format( 174 173 "mount", "super_block", "devname", "pathname", "fstype")) 175 174 176 - for mnt in lists.list_for_each_entry(namespace['list'], 177 - mount_ptr_type, "mnt_list"): 175 + for mnt in rbtree.rb_inorder_for_each_entry(namespace['mounts'], mount_ptr_type, "mnt_node"): 178 176 devname = mnt['mnt_devname'].string() 179 177 devname = devname if devname else "none" 180 178
+12
scripts/gdb/linux/rbtree.py
··· 9 9 rb_root_type = utils.CachedType("struct rb_root") 10 10 rb_node_type = utils.CachedType("struct rb_node") 11 11 12 + def rb_inorder_for_each(root): 13 + def inorder(node): 14 + if node: 15 + yield from inorder(node['rb_left']) 16 + yield node 17 + yield from inorder(node['rb_right']) 18 + 19 + yield from inorder(root['rb_node']) 20 + 21 + def rb_inorder_for_each_entry(root, gdbtype, member): 22 + for node in rb_inorder_for_each(root): 23 + yield utils.container_of(node, gdbtype, member) 12 24 13 25 def rb_first(root): 14 26 if root.type == rb_root_type.get_type():
+27
scripts/gdb/linux/stackdepot.py
··· 13 13 stack_record_type = utils.CachedType('struct stack_record') 14 14 DEPOT_STACK_ALIGN = 4 15 15 16 + def help(): 17 + t = """Usage: lx-stack_depot_lookup [Hex handle value] 18 + Example: 19 + lx-stack_depot_lookup 0x00c80300\n""" 20 + gdb.write("Unrecognized command\n") 21 + raise gdb.GdbError(t) 22 + 16 23 def stack_depot_fetch(handle): 17 24 global DEPOT_STACK_ALIGN 18 25 global stack_record_type ··· 64 57 gdb.execute("x /i 0x%x" % (int(entries[i]))) 65 58 except Exception as e: 66 59 gdb.write("%s\n" % e) 60 + 61 + class StackDepotLookup(gdb.Command): 62 + """Search backtrace by handle""" 63 + 64 + def __init__(self): 65 + if constants.LX_CONFIG_STACKDEPOT: 66 + super(StackDepotLookup, self).__init__("lx-stack_depot_lookup", gdb.COMMAND_SUPPORT) 67 + 68 + def invoke(self, args, from_tty): 69 + if not constants.LX_CONFIG_STACKDEPOT: 70 + raise gdb.GdbError('CONFIG_STACKDEPOT is not set') 71 + 72 + argv = gdb.string_to_argv(args) 73 + if len(argv) == 1: 74 + handle = int(argv[0], 16) 75 + stack_depot_print(gdb.Value(handle).cast(utils.get_uint_type())) 76 + else: 77 + help() 78 + 79 + StackDepotLookup()
+16 -15
scripts/gdb/linux/timerlist.py
··· 87 87 text += "\n" 88 88 89 89 if constants.LX_CONFIG_TICK_ONESHOT: 90 - fmts = [(" .{} : {}", 'nohz_mode'), 91 - (" .{} : {} nsecs", 'last_tick'), 92 - (" .{} : {}", 'tick_stopped'), 93 - (" .{} : {}", 'idle_jiffies'), 94 - (" .{} : {}", 'idle_calls'), 95 - (" .{} : {}", 'idle_sleeps'), 96 - (" .{} : {} nsecs", 'idle_entrytime'), 97 - (" .{} : {} nsecs", 'idle_waketime'), 98 - (" .{} : {} nsecs", 'idle_exittime'), 99 - (" .{} : {} nsecs", 'idle_sleeptime'), 100 - (" .{}: {} nsecs", 'iowait_sleeptime'), 101 - (" .{} : {}", 'last_jiffies'), 102 - (" .{} : {}", 'next_timer'), 103 - (" .{} : {} nsecs", 'idle_expires')] 104 - text += "\n".join([s.format(f, ts[f]) for s, f in fmts]) 90 + TS_FLAG_STOPPED = 1 << 1 91 + TS_FLAG_NOHZ = 1 << 4 92 + text += f" .{'nohz':15s}: {int(bool(ts['flags'] & TS_FLAG_NOHZ))}\n" 93 + text += f" .{'last_tick':15s}: {ts['last_tick']}\n" 94 + text += f" .{'tick_stopped':15s}: {int(bool(ts['flags'] & TS_FLAG_STOPPED))}\n" 95 + text += f" .{'idle_jiffies':15s}: {ts['idle_jiffies']}\n" 96 + text += f" .{'idle_calls':15s}: {ts['idle_calls']}\n" 97 + text += f" .{'idle_sleeps':15s}: {ts['idle_sleeps']}\n" 98 + text += f" .{'idle_entrytime':15s}: {ts['idle_entrytime']} nsecs\n" 99 + text += f" .{'idle_waketime':15s}: {ts['idle_waketime']} nsecs\n" 100 + text += f" .{'idle_exittime':15s}: {ts['idle_exittime']} nsecs\n" 101 + text += f" .{'idle_sleeptime':15s}: {ts['idle_sleeptime']} nsecs\n" 102 + text += f" .{'iowait_sleeptime':15s}: {ts['iowait_sleeptime']} nsecs\n" 103 + text += f" .{'last_jiffies':15s}: {ts['last_jiffies']}\n" 104 + text += f" .{'next_timer':15s}: {ts['next_timer']}\n" 105 + text += f" .{'idle_expires':15s}: {ts['idle_expires']} nsecs\n" 105 106 text += "\njiffies: {}\n".format(jiffies) 106 107 107 108 text += "\n"
+1
scripts/gdb/vmlinux-gdb.py
··· 49 49 import linux.page_owner 50 50 import linux.slab 51 51 import linux.vmalloc 52 + import linux.kasan
+131
scripts/macro_checker.py
··· 1 + #!/usr/bin/python3 2 + # SPDX-License-Identifier: GPL-2.0 3 + # Author: Julian Sun <sunjunchao2870@gmail.com> 4 + 5 + """ Find macro definitions with unused parameters. """ 6 + 7 + import argparse 8 + import os 9 + import re 10 + 11 + parser = argparse.ArgumentParser() 12 + 13 + parser.add_argument("path", type=str, help="The file or dir path that needs check") 14 + parser.add_argument("-v", "--verbose", action="store_true", 15 + help="Check conditional macros, but may lead to more false positives") 16 + args = parser.parse_args() 17 + 18 + macro_pattern = r"#define\s+(\w+)\(([^)]*)\)" 19 + # below vars were used to reduce false positives 20 + fp_patterns = [r"\s*do\s*\{\s*\}\s*while\s*\(\s*0\s*\)", 21 + r"\(?0\)?", r"\(?1\)?"] 22 + correct_macros = [] 23 + cond_compile_mark = "#if" 24 + cond_compile_end = "#endif" 25 + 26 + def check_macro(macro_line, report): 27 + match = re.match(macro_pattern, macro_line) 28 + if match: 29 + macro_def = re.sub(macro_pattern, '', macro_line) 30 + identifier = match.group(1) 31 + content = match.group(2) 32 + arguments = [item.strip() for item in content.split(',') if item.strip()] 33 + 34 + macro_def = macro_def.strip() 35 + if not macro_def: 36 + return 37 + # used to reduce false positives, like #define endfor_nexthops(rt) } 38 + if len(macro_def) == 1: 39 + return 40 + 41 + for fp_pattern in fp_patterns: 42 + if (re.match(fp_pattern, macro_def)): 43 + return 44 + 45 + for arg in arguments: 46 + # used to reduce false positives 47 + if "..." in arg: 48 + return 49 + for arg in arguments: 50 + if not arg in macro_def and report == False: 51 + return 52 + # if there is a correct macro with the same name, do not report it. 53 + if not arg in macro_def and identifier not in correct_macros: 54 + print(f"Argument {arg} is not used in function-line macro {identifier}") 55 + return 56 + 57 + correct_macros.append(identifier) 58 + 59 + 60 + # remove comment and whitespace 61 + def macro_strip(macro): 62 + comment_pattern1 = r"\/\/*" 63 + comment_pattern2 = r"\/\**\*\/" 64 + 65 + macro = macro.strip() 66 + macro = re.sub(comment_pattern1, '', macro) 67 + macro = re.sub(comment_pattern2, '', macro) 68 + 69 + return macro 70 + 71 + def file_check_macro(file_path, report): 72 + # number of conditional compiling 73 + cond_compile = 0 74 + # only check .c and .h file 75 + if not file_path.endswith(".c") and not file_path.endswith(".h"): 76 + return 77 + 78 + with open(file_path, "r") as f: 79 + while True: 80 + line = f.readline() 81 + if not line: 82 + break 83 + line = line.strip() 84 + if line.startswith(cond_compile_mark): 85 + cond_compile += 1 86 + continue 87 + if line.startswith(cond_compile_end): 88 + cond_compile -= 1 89 + continue 90 + 91 + macro = re.match(macro_pattern, line) 92 + if macro: 93 + macro = macro_strip(macro.string) 94 + while macro[-1] == '\\': 95 + macro = macro[0:-1] 96 + macro = macro.strip() 97 + macro += f.readline() 98 + macro = macro_strip(macro) 99 + if not args.verbose: 100 + if file_path.endswith(".c") and cond_compile != 0: 101 + continue 102 + # 1 is for #ifdef xxx at the beginning of the header file 103 + if file_path.endswith(".h") and cond_compile != 1: 104 + continue 105 + check_macro(macro, report) 106 + 107 + def get_correct_macros(path): 108 + file_check_macro(path, False) 109 + 110 + def dir_check_macro(dir_path): 111 + 112 + for dentry in os.listdir(dir_path): 113 + path = os.path.join(dir_path, dentry) 114 + if os.path.isdir(path): 115 + dir_check_macro(path) 116 + elif os.path.isfile(path): 117 + get_correct_macros(path) 118 + file_check_macro(path, True) 119 + 120 + 121 + def main(): 122 + if os.path.isfile(args.path): 123 + get_correct_macros(args.path) 124 + file_check_macro(args.path, True) 125 + elif os.path.isdir(args.path): 126 + dir_check_macro(args.path) 127 + else: 128 + print(f"{args.path} doesn't exit or is neither a file nor a dir") 129 + 130 + if __name__ == "__main__": 131 + main()
+150 -10
scripts/xz_wrap.sh
··· 1 1 #!/bin/sh 2 + # SPDX-License-Identifier: 0BSD 2 3 # 3 4 # This is a wrapper for xz to compress the kernel image using appropriate 4 5 # compression options depending on the architecture. 5 6 # 6 7 # Author: Lasse Collin <lasse.collin@tukaani.org> 7 - # 8 - # This file has been put into the public domain. 9 - # You can do whatever you want with this file. 10 - # 11 8 9 + # This has specialized settings for the following archs. However, 10 + # XZ-compressed kernel isn't currently supported on every listed arch. 11 + # 12 + # Arch Align Notes 13 + # arm 2/4 ARM and ARM-Thumb2 14 + # arm64 4 15 + # csky 2 16 + # loongarch 4 17 + # mips 2/4 MicroMIPS is 2-byte aligned 18 + # parisc 4 19 + # powerpc 4 Uses its own wrapper for compressors instead of this. 20 + # riscv 2/4 21 + # s390 2 22 + # sh 2 23 + # sparc 4 24 + # x86 1 25 + 26 + # A few archs use 2-byte or 4-byte aligned instructions depending on 27 + # the kernel config. This function is used to check if the relevant 28 + # config option is set to "y". 29 + is_enabled() 30 + { 31 + grep -q "^$1=y$" include/config/auto.conf 32 + } 33 + 34 + # XZ_VERSION is needed to disable features that aren't available in 35 + # old XZ Utils versions. 36 + XZ_VERSION=$($XZ --robot --version) || exit 37 + XZ_VERSION=$(printf '%s\n' "$XZ_VERSION" | sed -n 's/^XZ_VERSION=//p') 38 + 39 + # Assume that no BCJ filter is available. 12 40 BCJ= 13 - LZMA2OPTS= 14 41 42 + # Set the instruction alignment to 1, 2, or 4 bytes. 43 + # 44 + # Set the BCJ filter if one is available. 45 + # It must match the #ifdef usage in lib/decompress_unxz.c. 15 46 case $SRCARCH in 16 - x86) BCJ=--x86 ;; 17 - powerpc) BCJ=--powerpc ;; 18 - arm) BCJ=--arm ;; 19 - sparc) BCJ=--sparc ;; 47 + arm) 48 + if is_enabled CONFIG_THUMB2_KERNEL; then 49 + ALIGN=2 50 + BCJ=--armthumb 51 + else 52 + ALIGN=4 53 + BCJ=--arm 54 + fi 55 + ;; 56 + 57 + arm64) 58 + ALIGN=4 59 + 60 + # ARM64 filter was added in XZ Utils 5.4.0. 61 + if [ "$XZ_VERSION" -ge 50040002 ]; then 62 + BCJ=--arm64 63 + else 64 + echo "$0: Upgrading to xz >= 5.4.0" \ 65 + "would enable the ARM64 filter" \ 66 + "for better compression" >&2 67 + fi 68 + ;; 69 + 70 + csky) 71 + ALIGN=2 72 + ;; 73 + 74 + loongarch) 75 + ALIGN=4 76 + ;; 77 + 78 + mips) 79 + if is_enabled CONFIG_CPU_MICROMIPS; then 80 + ALIGN=2 81 + else 82 + ALIGN=4 83 + fi 84 + ;; 85 + 86 + parisc) 87 + ALIGN=4 88 + ;; 89 + 90 + powerpc) 91 + ALIGN=4 92 + 93 + # The filter is only for big endian instruction encoding. 94 + if is_enabled CONFIG_CPU_BIG_ENDIAN; then 95 + BCJ=--powerpc 96 + fi 97 + ;; 98 + 99 + riscv) 100 + if is_enabled CONFIG_RISCV_ISA_C; then 101 + ALIGN=2 102 + else 103 + ALIGN=4 104 + fi 105 + 106 + # RISC-V filter was added in XZ Utils 5.6.0. 107 + if [ "$XZ_VERSION" -ge 50060002 ]; then 108 + BCJ=--riscv 109 + else 110 + echo "$0: Upgrading to xz >= 5.6.0" \ 111 + "would enable the RISC-V filter" \ 112 + "for better compression" >&2 113 + fi 114 + ;; 115 + 116 + s390) 117 + ALIGN=2 118 + ;; 119 + 120 + sh) 121 + ALIGN=2 122 + ;; 123 + 124 + sparc) 125 + ALIGN=4 126 + BCJ=--sparc 127 + ;; 128 + 129 + x86) 130 + ALIGN=1 131 + BCJ=--x86 132 + ;; 133 + 134 + *) 135 + echo "$0: Arch-specific tuning is missing for '$SRCARCH'" >&2 136 + 137 + # Guess 2-byte-aligned instructions. Guessing too low 138 + # should hurt less than guessing too high. 139 + ALIGN=2 140 + ;; 20 141 esac 21 142 22 - exec $XZ --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB 143 + # Select the LZMA2 options matching the instruction alignment. 144 + case $ALIGN in 145 + 1) LZMA2OPTS= ;; 146 + 2) LZMA2OPTS=lp=1 ;; 147 + 4) LZMA2OPTS=lp=2,lc=2 ;; 148 + *) echo "$0: ALIGN wrong or missing" >&2; exit 1 ;; 149 + esac 150 + 151 + # Use single-threaded mode because it compresses a little better 152 + # (and uses less RAM) than multithreaded mode. 153 + # 154 + # For the best compression, the dictionary size shouldn't be 155 + # smaller than the uncompressed kernel. 128 MiB dictionary 156 + # needs less than 1400 MiB of RAM in single-threaded mode. 157 + # 158 + # On the archs that use this script to compress the kernel, 159 + # decompression in the preboot code is done in single-call mode. 160 + # Thus the dictionary size doesn't affect the memory requirements 161 + # of the preboot decompressor at all. 162 + exec $XZ --check=crc32 --threads=1 $BCJ --lzma2=$LZMA2OPTS,dict=128MiB
+1 -1
tools/mm/Makefile
··· 23 23 $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) 24 24 25 25 clean: 26 - $(RM) page-types slabinfo page_owner_sort 26 + $(RM) page-types slabinfo page_owner_sort thp_swap_allocator_test 27 27 make -C $(LIB_DIR) clean 28 28 29 29 sbindir ?= /usr/sbin
+12
tools/testing/fault-injection/failcmd.sh
··· 64 64 EOF 65 65 } 66 66 67 + exit_if_not_hex() { 68 + local value="$1" 69 + if ! [[ $value =~ ^0x[0-9a-fA-F]+$ ]]; then 70 + echo "Error: The provided value '$value' is not a valid hexadecimal number." >&2 71 + exit 1 72 + fi 73 + } 74 + 67 75 if [ $UID != 0 ]; then 68 76 echo must be run as root >&2 69 77 exit 1 ··· 168 160 shift 2 169 161 ;; 170 162 --require-start) 163 + exit_if_not_hex "$2" 171 164 echo $2 > $FAULTATTR/require-start 172 165 shift 2 173 166 ;; 174 167 --require-end) 168 + exit_if_not_hex "$2" 175 169 echo $2 > $FAULTATTR/require-end 176 170 shift 2 177 171 ;; 178 172 --reject-start) 173 + exit_if_not_hex "$2" 179 174 echo $2 > $FAULTATTR/reject-start 180 175 shift 2 181 176 ;; 182 177 --reject-end) 178 + exit_if_not_hex "$2" 183 179 echo $2 > $FAULTATTR/reject-end 184 180 shift 2 185 181 ;;