1. 18 4月, 2022 1 次提交
  2. 23 2月, 2022 1 次提交
  3. 15 2月, 2022 1 次提交
  4. 02 2月, 2022 2 次提交
  5. 17 6月, 2021 1 次提交
    • C
      block: export blk_next_bio() · c28a6147
      Chaitanya Kulkarni 提交于
      The block layer provides emulation of zone management operations
      targeting all zones of a zoned block device only for the zone reset
      operation (REQ_OP_ZONE_RESET). In order to correctly implement
      exporting of zoned block devices with NVMeOF, emulating zone management
      operations targeting all zones of a device is also necessary for the
      open, close and finish zone operations (REQ_OP_ZONE_OPEN,
      REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH).
      
      Instead of duplicating the code, export the existing helper from block
      layer so we can use a bio chaining pattern that is present in the block
      layer for REQ_OP_ZONE RESET all emulation in the NVMeOF zoned block
      device backend.
      Reviewed-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: NChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      c28a6147
  6. 11 3月, 2021 1 次提交
  7. 02 12月, 2020 1 次提交
  8. 25 9月, 2020 1 次提交
  9. 06 8月, 2020 1 次提交
    • C
      block: check queue's limits.discard_granularity in __blkdev_issue_discard() · b35fd742
      Coly Li 提交于
      If create a loop device with a backing NVMe SSD, current loop device
      driver doesn't correctly set its  queue's limits.discard_granularity and
      leaves it as 0. If a discard request at LBA 0 on this loop device, in
      __blkdev_issue_discard() the calculated req_sects will be 0, and a zero
      length discard request will trigger a BUG() panic in generic block layer
      code at block/blk-mq.c:563.
      
      [  955.565006][   C39] ------------[ cut here ]------------
      [  955.559660][   C39] invalid opcode: 0000 [#1] SMP NOPTI
      [  955.622171][   C39] CPU: 39 PID: 248 Comm: ksoftirqd/39 Tainted: G            E     5.8.0-default+ #40
      [  955.622171][   C39] Hardware name: Lenovo ThinkSystem SR650 -[7X05CTO1WW]-/-[7X05CTO1WW]-, BIOS -[IVE160M-2.70]- 07/17/2020
      [  955.622175][   C39] RIP: 0010:blk_mq_end_request+0x107/0x110
      [  955.622177][   C39] Code: 48 8b 03 e9 59 ff ff ff 48 89 df 5b 5d 41 5c e9 9f ed ff ff 48 8b 35 98 3c f4 00 48 83 c7 10 48 83 c6 19 e8 cb 56 c9 ff eb cb <0f> 0b 0f 1f 80 00 00 00 00 0f 1f 44 00 00 55 48 89 e5 41 56 41 54
      [  955.622179][   C39] RSP: 0018:ffffb1288701fe28 EFLAGS: 00010202
      [  955.749277][   C39] RAX: 0000000000000001 RBX: ffff956fffba5080 RCX: 0000000000004003
      [  955.749278][   C39] RDX: 0000000000000003 RSI: 0000000000000000 RDI: 0000000000000000
      [  955.749279][   C39] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
      [  955.749279][   C39] R10: ffffb1288701fd28 R11: 0000000000000001 R12: ffffffffa8e05160
      [  955.749280][   C39] R13: 0000000000000004 R14: 0000000000000004 R15: ffffffffa7ad3a1e
      [  955.749281][   C39] FS:  0000000000000000(0000) GS:ffff95bfbda00000(0000) knlGS:0000000000000000
      [  955.749282][   C39] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  955.749282][   C39] CR2: 00007f6f0ef766a8 CR3: 0000005a37012002 CR4: 00000000007606e0
      [  955.749283][   C39] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  955.749284][   C39] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  955.749284][   C39] PKRU: 55555554
      [  955.749285][   C39] Call Trace:
      [  955.749290][   C39]  blk_done_softirq+0x99/0xc0
      [  957.550669][   C39]  __do_softirq+0xd3/0x45f
      [  957.550677][   C39]  ? smpboot_thread_fn+0x2f/0x1e0
      [  957.550679][   C39]  ? smpboot_thread_fn+0x74/0x1e0
      [  957.550680][   C39]  ? smpboot_thread_fn+0x14e/0x1e0
      [  957.550684][   C39]  run_ksoftirqd+0x30/0x60
      [  957.550687][   C39]  smpboot_thread_fn+0x149/0x1e0
      [  957.886225][   C39]  ? sort_range+0x20/0x20
      [  957.886226][   C39]  kthread+0x137/0x160
      [  957.886228][   C39]  ? kthread_park+0x90/0x90
      [  957.886231][   C39]  ret_from_fork+0x22/0x30
      [  959.117120][   C39] ---[ end trace 3dacdac97e2ed164 ]---
      
      This is the procedure to reproduce the panic,
        # modprobe scsi_debug delay=0 dev_size_mb=2048 max_queue=1
        # losetup -f /dev/nvme0n1 --direct-io=on
        # blkdiscard /dev/loop0 -o 0 -l 0x200
      
      This patch fixes the issue by checking q->limits.discard_granularity in
      __blkdev_issue_discard() before composing the discard bio. If the value
      is 0, then prints a warning oops information and returns -EOPNOTSUPP to
      the caller to indicate that this buggy device driver doesn't support
      discard request.
      
      Fixes: 9b15d109 ("block: improve discard bio alignment in __blkdev_issue_discard()")
      Fixes: c52abf56 ("loop: Better discard support for block devices")
      Reported-and-suggested-by: NMing Lei <ming.lei@redhat.com>
      Signed-off-by: NColy Li <colyli@suse.de>
      Reviewed-by: NMing Lei <ming.lei@redhat.com>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Reviewed-by: NJack Wang <jinpu.wang@cloud.ionos.com>
      Cc: Bart Van Assche <bvanassche@acm.org>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Darrick J. Wong <darrick.wong@oracle.com>
      Cc: Enzo Matsumiya <ematsumiya@suse.com>
      Cc: Evan Green <evgreen@chromium.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Xiao Ni <xni@redhat.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      b35fd742
  10. 17 7月, 2020 1 次提交
    • C
      block: improve discard bio alignment in __blkdev_issue_discard() · 9b15d109
      Coly Li 提交于
      This patch improves discard bio split for address and size alignment in
      __blkdev_issue_discard(). The aligned discard bio may help underlying
      device controller to perform better discard and internal garbage
      collection, and avoid unnecessary internal fragment.
      
      Current discard bio split algorithm in __blkdev_issue_discard() may have
      non-discarded fregment on device even the discard bio LBA and size are
      both aligned to device's discard granularity size.
      
      Here is the example steps on how to reproduce the above problem.
      - On a VMWare ESXi 6.5 update3 installation, create a 51GB virtual disk
        with thin mode and give it to a Linux virtual machine.
      - Inside the Linux virtual machine, if the 50GB virtual disk shows up as
        /dev/sdb, fill data into the first 50GB by,
              # dd if=/dev/zero of=/dev/sdb bs=4096 count=13107200
      - Discard the 50GB range from offset 0 on /dev/sdb,
              # blkdiscard /dev/sdb -o 0 -l 53687091200
      - Observe the underlying mapping status of the device
              # sg_get_lba_status /dev/sdb -m 1048 --lba=0
        descriptor LBA: 0x0000000000000000  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000000000800  blocks: 16773120  deallocated
        descriptor LBA: 0x0000000000fff800  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000001000000  blocks: 8386560  deallocated
        descriptor LBA: 0x00000000017ff800  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000001800000  blocks: 8386560  deallocated
        descriptor LBA: 0x0000000001fff800  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000002000000  blocks: 8386560  deallocated
        descriptor LBA: 0x00000000027ff800  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000002800000  blocks: 8386560  deallocated
        descriptor LBA: 0x0000000002fff800  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000003000000  blocks: 8386560  deallocated
        descriptor LBA: 0x00000000037ff800  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000003800000  blocks: 8386560  deallocated
        descriptor LBA: 0x0000000003fff800  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000004000000  blocks: 8386560  deallocated
        descriptor LBA: 0x00000000047ff800  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000004800000  blocks: 8386560  deallocated
        descriptor LBA: 0x0000000004fff800  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000005000000  blocks: 8386560  deallocated
        descriptor LBA: 0x00000000057ff800  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000005800000  blocks: 8386560  deallocated
        descriptor LBA: 0x0000000005fff800  blocks: 2048  mapped (or unknown)
        descriptor LBA: 0x0000000006000000  blocks: 6291456  deallocated
        descriptor LBA: 0x0000000006600000  blocks: 0  deallocated
      
      Although the discard bio starts at LBA 0 and has 50<<30 bytes size which
      are perfect aligned to the discard granularity, from the above list
      these are many 1MB (2048 sectors) internal fragments exist unexpectedly.
      
      The problem is in __blkdev_issue_discard(), an improper algorithm causes
      an improper bio size which is not aligned.
      
       25 int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
       26                 sector_t nr_sects, gfp_t gfp_mask, int flags,
       27                 struct bio **biop)
       28 {
       29         struct request_queue *q = bdev_get_queue(bdev);
         [snipped]
       56
       57         while (nr_sects) {
       58                 sector_t req_sects = min_t(sector_t, nr_sects,
       59                                 bio_allowed_max_sectors(q));
       60
       61                 WARN_ON_ONCE((req_sects << 9) > UINT_MAX);
       62
       63                 bio = blk_next_bio(bio, 0, gfp_mask);
       64                 bio->bi_iter.bi_sector = sector;
       65                 bio_set_dev(bio, bdev);
       66                 bio_set_op_attrs(bio, op, 0);
       67
       68                 bio->bi_iter.bi_size = req_sects << 9;
       69                 sector += req_sects;
       70                 nr_sects -= req_sects;
         [snipped]
       79         }
       80
       81         *biop = bio;
       82         return 0;
       83 }
       84 EXPORT_SYMBOL(__blkdev_issue_discard);
      
      At line 58-59, to discard a 50GB range, req_sects is set as return value
      of bio_allowed_max_sectors(q), which is 8388607 sectors. In the above
      case, the discard granularity is 2048 sectors, although the start LBA
      and discard length are aligned to discard granularity, req_sects never
      has chance to be aligned to discard granularity. This is why there are
      some still-mapped 2048 sectors fragment in every 4 or 8 GB range.
      
      If req_sects at line 58 is set to a value aligned to discard_granularity
      and close to UNIT_MAX, then all consequent split bios inside device
      driver are (almostly) aligned to discard_granularity of the device
      queue. The 2048 sectors still-mapped fragment will disappear.
      
      This patch introduces bio_aligned_discard_max_sectors() to return the
      the value which is aligned to q->limits.discard_granularity and closest
      to UINT_MAX. Then this patch replaces bio_allowed_max_sectors() with
      this new routine to decide a more proper split bio length.
      
      But we still need to handle the situation when discard start LBA is not
      aligned to q->limits.discard_granularity, otherwise even the length is
      aligned, current code may still leave 2048 fragment around every 4GB
      range. Therefore, to calculate req_sects, firstly the start LBA of
      discard range is checked (including partition offset), if it is not
      aligned to discard granularity, the first split location should make
      sure following bio has bi_sector aligned to discard granularity. Then
      there won't be still-mapped fragment in the middle of the discard range.
      
      The above is how this patch improves discard bio alignment in
      __blkdev_issue_discard(). Now with this patch, after discard with same
      command line mentiond previously, sg_get_lba_status returns,
      descriptor LBA: 0x0000000000000000  blocks: 106954752  deallocated
      descriptor LBA: 0x0000000006600000  blocks: 0  deallocated
      
      We an see there is no 2048 sectors segment anymore, everything is clean.
      Reported-and-tested-by: NAcshai Manoj <acshai.manoj@microfocus.com>
      Signed-off-by: NColy Li <colyli@suse.de>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Reviewed-by: NMing Lei <ming.lei@redhat.com>
      Reviewed-by: NXiao Ni <xni@redhat.com>
      Cc: Bart Van Assche <bvanassche@acm.org>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Enzo Matsumiya <ematsumiya@suse.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      9b15d109
  11. 14 11月, 2018 1 次提交
    • D
      block: fix 32 bit overflow in __blkdev_issue_discard() · 4800bf7b
      Dave Chinner 提交于
      A discard cleanup merged into 4.20-rc2 causes fstests xfs/259 to
      fall into an endless loop in the discard code. The test is creating
      a device that is exactly 2^32 sectors in size to test mkfs boundary
      conditions around the 32 bit sector overflow region.
      
      mkfs issues a discard for the entire device size by default, and
      hence this throws a sector count of 2^32 into
      blkdev_issue_discard(). It takes the number of sectors to discard as
      a sector_t - a 64 bit value.
      
      The commit ba5d7385 ("block: cleanup __blkdev_issue_discard")
      takes this sector count and casts it to a 32 bit value before
      comapring it against the maximum allowed discard size the device
      has. This truncates away the upper 32 bits, and so if the lower 32
      bits of the sector count is zero, it starts issuing discards of
      length 0. This causes the code to fall into an endless loop, issuing
      a zero length discards over and over again on the same sector.
      
      Fixes: ba5d7385 ("block: cleanup __blkdev_issue_discard")
      Tested-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      
      Killed pointless WARN_ON().
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      4800bf7b
  12. 09 11月, 2018 3 次提交
  13. 26 10月, 2018 1 次提交
    • D
      block: Improve zone reset execution · a2d6b3a2
      Damien Le Moal 提交于
      There is no need to synchronously execute all REQ_OP_ZONE_RESET BIOs
      necessary to reset a range of zones. Similarly to what is done for
      discard BIOs in blk-lib.c, all zone reset BIOs can be chained and
      executed asynchronously and a synchronous call done only for the last
      BIO of the chain.
      
      Modify blkdev_reset_zones() to operate similarly to
      blkdev_issue_discard() using the next_bio() helper for chaining BIOs. To
      avoid code duplication of that function in blk_zoned.c, rename
      next_bio() into blk_next_bio() and declare it as a block internal
      function in blk.h.
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      a2d6b3a2
  14. 18 10月, 2018 1 次提交
  15. 09 7月, 2018 1 次提交
  16. 09 5月, 2018 1 次提交
  17. 19 1月, 2018 1 次提交
  18. 02 11月, 2017 1 次提交
    • G
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman 提交于
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  19. 26 10月, 2017 2 次提交
  20. 11 9月, 2017 1 次提交
  21. 24 8月, 2017 1 次提交
    • C
      block: replace bi_bdev with a gendisk pointer and partitions index · 74d46992
      Christoph Hellwig 提交于
      This way we don't need a block_device structure to submit I/O.  The
      block_device has different life time rules from the gendisk and
      request_queue and is usually only available when the block device node
      is open.  Other callers need to explicitly create one (e.g. the lightnvm
      passthrough code, or the new nvme multipathing code).
      
      For the actual I/O path all that we need is the gendisk, which exists
      once per block device.  But given that the block layer also does
      partition remapping we additionally need a partition index, which is
      used for said remapping in generic_make_request.
      
      Note that all the block drivers generally want request_queue or
      sometimes the gendisk, so this removes a layer of indirection all
      over the stack.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      74d46992
  22. 06 7月, 2017 1 次提交
    • D
      block: Fix __blkdev_issue_zeroout loop · 615d22a5
      Damien Le Moal 提交于
      The BIO issuing loop in __blkdev_issue_zeroout() is allocating BIOs
      with a maximum number of bvec (pages) equal to
      
      min(nr_sects, (sector_t)BIO_MAX_PAGES)
      
      This works since the requested number of bvecs will always be limited
      to the absolute maximum number supported (BIO_MAX_PAGES), but this is
      ineficient as too many bvec entries may be requested due to the
      different units being used in the min() operation (number of sectors vs
      number of pages).
      To fix this, introduce the helper __blkdev_sectors_to_bio_pages() to
      correctly calculate the number of bvecs for zeroout BIOs as the issuing
      loop progresses. The calculation is done using consistent units and
      makes sure that the number of pages return is at least 1 (for cases
      where the number of sectors is less that the number of sectors in
      a page).
      
      Also remove a trailing space after the bit shift in the internal loop
      min() call.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      615d22a5
  23. 09 4月, 2017 6 次提交
  24. 25 3月, 2017 1 次提交
  25. 07 2月, 2017 1 次提交
  26. 14 1月, 2017 1 次提交
  27. 09 12月, 2016 1 次提交
    • C
      block: improve handling of the magic discard payload · f9d03f96
      Christoph Hellwig 提交于
      Instead of allocating a single unused biovec for discard requests, send
      them down without any payload.  Instead we allow the driver to add a
      "special" payload using a biovec embedded into struct request (unioned
      over other fields never used while in the driver), and overloading
      the number of segments for this case.
      
      This has a couple of advantages:
      
       - we don't have to allocate the bio_vec
       - the amount of special casing for discard requests in the block
         layer is significantly reduced
       - using this same scheme for other request types is trivial,
         which will be important for implementing the new WRITE_ZEROES
         op on devices where it actually requires a payload (e.g. SCSI)
       - we can get rid of playing games with the request length, as
         we'll never touch it and completions will work just fine
       - it will allow us to support ranged discard operations in the
         future by merging non-contiguous discard bios into a single
         request
       - last but not least it removes a lot of code
      
      This patch is the common base for my WIP series for ranges discards and to
      remove discard_zeroes_data in favor of always using REQ_OP_WRITE_ZEROES,
      so it would be good to get it in quickly.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      f9d03f96
  28. 01 12月, 2016 2 次提交
  29. 28 10月, 2016 1 次提交
    • C
      block: better op and flags encoding · ef295ecf
      Christoph Hellwig 提交于
      Now that we don't need the common flags to overflow outside the range
      of a 32-bit type we can encode them the same way for both the bio and
      request fields.  This in addition allows us to place the operation
      first (and make some room for more ops while we're at it) and to
      stop having to shift around the operation values.
      
      In addition this allows passing around only one value in the block layer
      instead of two (and eventuall also in the file systems, but we can do
      that later) and thus clean up a lot of code.
      
      Last but not least this allows decreasing the size of the cmd_flags
      field in struct request to 32-bits.  Various functions passing this
      value could also be updated, but I'd like to avoid the churn for now.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      ef295ecf
  30. 12 10月, 2016 1 次提交