Skip to content
Snippets Groups Projects
  1. Oct 02, 2024
    • Al Viro's avatar
      move asm/unaligned.h to linux/unaligned.h · 5f60d5f6
      Al Viro authored
      asm/unaligned.h is always an include of asm-generic/unaligned.h;
      might as well move that thing to linux/unaligned.h and include
      that - there's nothing arch-specific in that header.
      
      auto-generated by the following:
      
      for i in `git grep -l -w asm/unaligned.h`; do
      	sed -i -e "s/asm\/unaligned.h/linux\/unaligned.h/" $i
      done
      for i in `git grep -l -w asm-generic/unaligned.h`; do
      	sed -i -e "s/asm-generic\/unaligned.h/linux\/unaligned.h/" $i
      done
      git mv include/asm-generic/unaligned.h include/linux/unaligned.h
      git mv tools/include/asm-generic/unaligned.h tools/include/linux/unaligned.h
      sed -i -e "/unaligned.h/d" include/asm-generic/Kbuild
      sed -i -e "s/__ASM_GENERIC/__LINUX/" include/linux/unaligned.h tools/include/linux/unaligned.h
      5f60d5f6
  2. Sep 12, 2024
  3. May 03, 2024
    • INAGAKI Hiroshi's avatar
      block: fix and simplify blkdevparts= cmdline parsing · bc2e07df
      INAGAKI Hiroshi authored
      
      Fix the cmdline parsing of the "blkdevparts=" parameter using strsep(),
      which makes the code simpler.
      
      Before commit 146afeb2 ("block: use strscpy() to instead of
      strncpy()"), we used a strncpy() to copy a block device name and partition
      names. The commit simply replaced a strncpy() and NULL termination with
      a strscpy(). It did not update calculations of length passed to strscpy().
      While the length passed to strncpy() is just a length of valid characters
      without NULL termination ('\0'), strscpy() takes it as a length of the
      destination buffer, including a NULL termination.
      
      Since the source buffer is not necessarily NULL terminated, the current
      code copies "length - 1" characters and puts a NULL character in the
      destination buffer. It replaces the last character with NULL and breaks
      the parsing.
      
      As an example, that buffer will be passed to parse_parts() and breaks
      parsing sub-partitions due to the missing ')' at the end, like the
      following.
      
      example (Check Point V-80 & OpenWrt):
      
      - Linux Kernel 6.6
      
        [    0.000000] Kernel command line: console=ttyS0,115200 earlycon=uart8250,mmio32,0xf0512000 crashkernel=30M mvpp2x.queue_mode=1 blkdevparts=mmcblk1:48M@10M(kernel-1),1M(dtb-1),720M(rootfs-1),48M(kernel-2),1M(dtb-2),720M(rootfs-2),300M(default_sw),650M(logs),1M(preset_cfg),1M(adsl),-(storage) maxcpus=4
        ...
        [    0.884016] mmc1: new HS200 MMC card at address 0001
        [    0.889951] mmcblk1: mmc1:0001 004GA0 3.69 GiB
        [    0.895043] cmdline partition format is invalid.
        [    0.895704]  mmcblk1: p1
        [    0.903447] mmcblk1boot0: mmc1:0001 004GA0 2.00 MiB
        [    0.908667] mmcblk1boot1: mmc1:0001 004GA0 2.00 MiB
        [    0.913765] mmcblk1rpmb: mmc1:0001 004GA0 512 KiB, chardev (248:0)
      
        1. "48M@10M(kernel-1),..." is passed to strscpy() with length=17
           from parse_parts()
        2. strscpy() returns -E2BIG and the destination buffer has
           "48M@10M(kernel-1\0"
        3. "48M@10M(kernel-1\0" is passed to parse_subpart()
        4. parse_subpart() fails to find ')' when parsing a partition name,
           and returns error
      
      - Linux Kernel 6.1
      
        [    0.000000] Kernel command line: console=ttyS0,115200 earlycon=uart8250,mmio32,0xf0512000 crashkernel=30M mvpp2x.queue_mode=1 blkdevparts=mmcblk1:48M@10M(kernel-1),1M(dtb-1),720M(rootfs-1),48M(kernel-2),1M(dtb-2),720M(rootfs-2),300M(default_sw),650M(logs),1M(preset_cfg),1M(adsl),-(storage) maxcpus=4
        ...
        [    0.953142] mmc1: new HS200 MMC card at address 0001
        [    0.959114] mmcblk1: mmc1:0001 004GA0 3.69 GiB
        [    0.964259]  mmcblk1: p1(kernel-1) p2(dtb-1) p3(rootfs-1) p4(kernel-2) p5(dtb-2) 6(rootfs-2) p7(default_sw) p8(logs) p9(preset_cfg) p10(adsl) p11(storage)
        [    0.979174] mmcblk1boot0: mmc1:0001 004GA0 2.00 MiB
        [    0.984674] mmcblk1boot1: mmc1:0001 004GA0 2.00 MiB
        [    0.989926] mmcblk1rpmb: mmc1:0001 004GA0 512 KiB, chardev (248:0
      
      By the way, strscpy() takes a length of destination buffer and it is
      often confusing when copying characters with a specified length. Using
      strsep() helps to separate the string by the specified character. Then,
      we can use strscpy() naturally with the size of the destination buffer.
      
      Separating the string on the fly is also useful to omit the redundant
      string copy, reducing memory usage and improve the code readability.
      
      Fixes: 146afeb2 ("block: use strscpy() to instead of strncpy()")
      Suggested-by: default avatarNaohiro Aota <naota@elisp.net>
      Signed-off-by: default avatarINAGAKI Hiroshi <musashino.open@gmail.com>
      Reviewed-by: default avatarDaniel Golle <daniel@makrotopia.org>
      Link: https://lore.kernel.org/r/20240421074005.565-1-musashino.open@gmail.com
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      bc2e07df
    • Christoph Hellwig's avatar
      block: add a disk_has_partscan helper · 140ce28d
      Christoph Hellwig authored
      
      Add a helper to check if partition scanning is enabled instead of
      open coding the check in a few places.  This now always checks for
      the hidden flag even if all but one of the callers are never reachable
      for hidden gendisks.
      
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Link: https://lore.kernel.org/r/20240502130033.1958492-2-hch@lst.de
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      140ce28d
    • Al Viro's avatar
    • Al Viro's avatar
      missing helpers: bdev_unhash(), bdev_drop() · 2638c208
      Al Viro authored
      
      bdev_unhash(): make block device invisible to lookups by device number
      bdev_drop(): drop reference to associated inode.
      
      Both are internal, for use by genhd and partition-related code - similar
      to bdev_add().  The logics in there (especially the lifetime-related
      parts of it) ought to be cleaned up, but that's a separate story; here
      we just encapsulate getting to associated inode.
      
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      2638c208
  4. May 02, 2024
  5. Apr 26, 2024
    • Arnd Bergmann's avatar
      block/partitions/ldm: convert strncpy() to strscpy() · 597bc741
      Arnd Bergmann authored
      The strncpy() here can cause a non-terminated string, which older gcc
      versions such as gcc-9 warn about:
      
      In function 'ldm_parse_tocblock',
          inlined from 'ldm_validate_tocblocks' at block/partitions/ldm.c:386:7,
          inlined from 'ldm_partition' at block/partitions/ldm.c:1457:7:
      block/partitions/ldm.c:134:2: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
        134 |  strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name));
            |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      block/partitions/ldm.c:145:2: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
        145 |  strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name));
            |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      New versions notice that the code is correct after all because of the
      following termination, but replacing the strncpy() with strscpy_pad()
      or strcpy() avoids the warning and simplifies the code at the same time.
      
      Use the padding version here to keep the existing behavior, in case
      the code relies on not including uninitialized data.
      
      Link: https://lkml.kernel.org/r/20240409140059.3806717-4-arnd@kernel.org
      
      
      Reviewed-by: default avatarJustin Stitt <justinstitt@google.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Alexey Starikovskiy <astarikovskiy@suse.de>
      Cc: Bob Moore <robert.moore@intel.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Lin Ming <ming.m.lin@intel.com>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicolas Schier <nicolas@fjasle.eu>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: "Richard Russon (FlatCap)" <ldm@flatcap.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      597bc741
  6. Mar 09, 2024
  7. Mar 06, 2024
  8. Jan 22, 2024
  9. Jan 12, 2024
  10. Dec 20, 2023
    • Christoph Hellwig's avatar
      block: remove support for the host aware zone model · 7437bb73
      Christoph Hellwig authored
      
      When zones were first added the SCSI and ATA specs, two different
      models were supported (in addition to the drive managed one that
      is invisible to the host):
      
       - host managed where non-conventional zones there is strict requirement
         to write at the write pointer, or else an error is returned
       - host aware where a write point is maintained if writes always happen
         at it, otherwise it is left in an under-defined state and the
         sequential write preferred zones behave like conventional zones
         (probably very badly performing ones, though)
      
      Not surprisingly this lukewarm model didn't prove to be very useful and
      was finally removed from the ZBC and SBC specs (NVMe never implemented
      it).  Due to to the easily disappearing write pointer host software
      could never rely on the write pointer to actually be useful for say
      recovery.
      
      Fortunately only a few HDD prototypes shipped using this model which
      never made it to mass production.  Drop the support before it is too
      late.  Note that any such host aware prototype HDD can still be used
      with Linux as we'll now treat it as a conventional HDD.
      
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Link: https://lore.kernel.org/r/20231217165359.604246-4-hch@lst.de
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      7437bb73
  11. Oct 28, 2023
  12. Oct 04, 2023
  13. Aug 23, 2023
  14. Aug 21, 2023
    • Christoph Hellwig's avatar
      block: consolidate __invalidate_device and fsync_bdev · 560e20e4
      Christoph Hellwig authored
      
      We currently have two interfaces that take a block_devices and the find
      a mounted file systems to flush or invaldidate data on it.  Both are a
      bit problematic because they only work for the "main" block devices
      that is used as s_dev for the super_block, and because they don't call
      into the file system at all.
      
      Merge the two into a new bdev_mark_dead helper that does both the
      syncing and invalidation and which is properly documented.  This is
      in preparation of merging the functionality into the ->mark_dead
      holder operation so that it will work on additional block devices
      used by a file systems and give us a single entry point for invalidation
      of dead devices or media.
      
      Note that a single standalone fsync_bdev call for an obscure ioctl
      remains for now, but that one will also be deal with in a bit.
      
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Message-Id: <20230811100828.1897174-14-hch@lst.de>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      560e20e4
  15. Jul 05, 2023
  16. Jun 20, 2023
  17. Jun 05, 2023
  18. May 30, 2023
  19. Apr 24, 2023
  20. Jan 27, 2023
  21. Sep 03, 2022
  22. Aug 02, 2022
  23. Jul 06, 2022
  24. Jun 29, 2022
Loading