Merge tag 'for-5.3/dm-changes-2' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 18 Jul 2019 21:49:33 +0000 (14:49 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 18 Jul 2019 21:49:33 +0000 (14:49 -0700)
Pull more device mapper updates from Mike Snitzer:

 - Fix zone state management race in DM zoned target by eliminating the
   unnecessary DMZ_ACTIVE state.

 - A couple fixes for issues the DM snapshot target's optional discard
   support added during first week of the 5.3 merge.

 - Increase default size of outstanding IO that is allowed for a each
   dm-kcopyd client and introduce tunable to allow user adjust.

 - Update DM core to use printk ratelimiting functions rather than
   duplicate them and in doing so fix an issue where DMDEBUG_LIMIT()
   rate limited KERN_DEBUG messages had excessive "callbacks suppressed"
   messages.

* tag 'for-5.3/dm-changes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
  dm: use printk ratelimiting functions
  dm kcopyd: Increase default sub-job size to 512KB
  dm snapshot: fix oversights in optional discard support
  dm zoned: fix zone state management race

1  2 
drivers/md/dm-zoned-metadata.c
include/linux/device-mapper.h

index 9faf3e49c7affac9590b636b337f993f9261adc1,4cdde7a02e94a868cc9beb0923b47bb10530bd7e..8545dcee9fd0498d1334656881a02fac426276f5
@@@ -8,7 -8,6 +8,7 @@@
  
  #include <linux/module.h>
  #include <linux/crc32.h>
 +#include <linux/sched/mm.h>
  
  #define       DM_MSG_PREFIX           "zoned metadata"
  
@@@ -1163,7 -1162,8 +1163,7 @@@ static int dmz_init_zones(struct dmz_me
        while (sector < dev->capacity) {
                /* Get zone information */
                nr_blkz = DMZ_REPORT_NR_ZONES;
 -              ret = blkdev_report_zones(dev->bdev, sector, blkz,
 -                                        &nr_blkz, GFP_KERNEL);
 +              ret = blkdev_report_zones(dev->bdev, sector, blkz, &nr_blkz);
                if (ret) {
                        dmz_dev_err(dev, "Report zones failed %d", ret);
                        goto out;
  static int dmz_update_zone(struct dmz_metadata *zmd, struct dm_zone *zone)
  {
        unsigned int nr_blkz = 1;
 +      unsigned int noio_flag;
        struct blk_zone blkz;
        int ret;
  
 -      /* Get zone information from disk */
 +      /*
 +       * Get zone information from disk. Since blkdev_report_zones() uses
 +       * GFP_KERNEL by default for memory allocations, set the per-task
 +       * PF_MEMALLOC_NOIO flag so that all allocations are done as if
 +       * GFP_NOIO was specified.
 +       */
 +      noio_flag = memalloc_noio_save();
        ret = blkdev_report_zones(zmd->dev->bdev, dmz_start_sect(zmd, zone),
 -                                &blkz, &nr_blkz, GFP_NOIO);
 +                                &blkz, &nr_blkz);
 +      memalloc_noio_restore(noio_flag);
        if (!nr_blkz)
                ret = -EIO;
        if (ret) {
@@@ -1601,30 -1593,6 +1601,6 @@@ struct dm_zone *dmz_get_zone_for_reclai
        return zone;
  }
  
- /*
-  * Activate a zone (increment its reference count).
-  */
- void dmz_activate_zone(struct dm_zone *zone)
- {
-       set_bit(DMZ_ACTIVE, &zone->flags);
-       atomic_inc(&zone->refcount);
- }
- /*
-  * Deactivate a zone. This decrement the zone reference counter
-  * and clears the active state of the zone once the count reaches 0,
-  * indicating that all BIOs to the zone have completed. Returns
-  * true if the zone was deactivated.
-  */
- void dmz_deactivate_zone(struct dm_zone *zone)
- {
-       if (atomic_dec_and_test(&zone->refcount)) {
-               WARN_ON(!test_bit(DMZ_ACTIVE, &zone->flags));
-               clear_bit_unlock(DMZ_ACTIVE, &zone->flags);
-               smp_mb__after_atomic();
-       }
- }
  /*
   * Get the zone mapping a chunk, if the chunk is mapped already.
   * If no mapping exist and the operation is WRITE, a zone is
index 3b470cb03b668ff376f4e00c0f063415748cb832,603ce5bb4facc68676c3b0c1ad331350a7663abe..399ad8632356847f9a8ed0ded4d7f8cd70a8dddc
@@@ -95,7 -95,8 +95,7 @@@ typedef int (*dm_prepare_ioctl_fn) (str
  
  typedef int (*dm_report_zones_fn) (struct dm_target *ti, sector_t sector,
                                   struct blk_zone *zones,
 -                                 unsigned int *nr_zones,
 -                                 gfp_t gfp_mask);
 +                                 unsigned int *nr_zones);
  
  /*
   * These iteration functions are typically used to check (and combine)
@@@ -529,29 -530,20 +529,20 @@@ void *dm_vcalloc(unsigned long nmemb, u
   *---------------------------------------------------------------*/
  #define DM_NAME "device-mapper"
  
- #define DM_RATELIMIT(pr_func, fmt, ...)                                       \
- do {                                                                  \
-       static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,   \
-                                     DEFAULT_RATELIMIT_BURST);         \
-                                                                       \
-       if (__ratelimit(&rs))                                           \
-               pr_func(DM_FMT(fmt), ##__VA_ARGS__);                    \
- } while (0)
  #define DM_FMT(fmt) DM_NAME ": " DM_MSG_PREFIX ": " fmt "\n"
  
  #define DMCRIT(fmt, ...) pr_crit(DM_FMT(fmt), ##__VA_ARGS__)
  
  #define DMERR(fmt, ...) pr_err(DM_FMT(fmt), ##__VA_ARGS__)
- #define DMERR_LIMIT(fmt, ...) DM_RATELIMIT(pr_err, fmt, ##__VA_ARGS__)
+ #define DMERR_LIMIT(fmt, ...) pr_err_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
  #define DMWARN(fmt, ...) pr_warn(DM_FMT(fmt), ##__VA_ARGS__)
- #define DMWARN_LIMIT(fmt, ...) DM_RATELIMIT(pr_warn, fmt, ##__VA_ARGS__)
+ #define DMWARN_LIMIT(fmt, ...) pr_warn_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
  #define DMINFO(fmt, ...) pr_info(DM_FMT(fmt), ##__VA_ARGS__)
- #define DMINFO_LIMIT(fmt, ...) DM_RATELIMIT(pr_info, fmt, ##__VA_ARGS__)
+ #define DMINFO_LIMIT(fmt, ...) pr_info_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
  
  #ifdef CONFIG_DM_DEBUG
  #define DMDEBUG(fmt, ...) printk(KERN_DEBUG DM_FMT(fmt), ##__VA_ARGS__)
- #define DMDEBUG_LIMIT(fmt, ...) DM_RATELIMIT(pr_debug, fmt, ##__VA_ARGS__)
+ #define DMDEBUG_LIMIT(fmt, ...) pr_debug_ratelimited(DM_FMT(fmt), ##__VA_ARGS__)
  #else
  #define DMDEBUG(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
  #define DMDEBUG_LIMIT(fmt, ...) no_printk(fmt, ##__VA_ARGS__)