Merge tag 'linux-kselftest-kunit-5.15-rc1' of git://git.kernel.org/pub/scm/linux...
[linux-2.6-microblaze.git] / drivers / md / dm-crypt.c
index 50f4cbd..916b7da 100644 (file)
@@ -2223,11 +2223,11 @@ static void kcryptd_queue_crypt(struct dm_crypt_io *io)
        if ((bio_data_dir(io->base_bio) == READ && test_bit(DM_CRYPT_NO_READ_WORKQUEUE, &cc->flags)) ||
            (bio_data_dir(io->base_bio) == WRITE && test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags))) {
                /*
-                * in_irq(): Crypto API's skcipher_walk_first() refuses to work in hard IRQ context.
+                * in_hardirq(): Crypto API's skcipher_walk_first() refuses to work in hard IRQ context.
                 * irqs_disabled(): the kernel may run some IO completion from the idle thread, but
                 * it is being executed with irqs disabled.
                 */
-               if (in_irq() || irqs_disabled()) {
+               if (in_hardirq() || irqs_disabled()) {
                        tasklet_init(&io->tasklet, kcryptd_crypt_tasklet, (unsigned long)&io->work);
                        tasklet_schedule(&io->tasklet);
                        return;
@@ -2661,7 +2661,12 @@ static void *crypt_page_alloc(gfp_t gfp_mask, void *pool_data)
        struct crypt_config *cc = pool_data;
        struct page *page;
 
-       if (unlikely(percpu_counter_compare(&cc->n_allocated_pages, dm_crypt_pages_per_client) >= 0) &&
+       /*
+        * Note, percpu_counter_read_positive() may over (and under) estimate
+        * the current usage by at most (batch - 1) * num_online_cpus() pages,
+        * but avoids potential spinlock contention of an exact result.
+        */
+       if (unlikely(percpu_counter_read_positive(&cc->n_allocated_pages) >= dm_crypt_pages_per_client) &&
            likely(gfp_mask & __GFP_NORETRY))
                return NULL;
 
@@ -3485,7 +3490,34 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
                        if (test_bit(CRYPT_IV_LARGE_SECTORS, &cc->cipher_flags))
                                DMEMIT(" iv_large_sectors");
                }
+               break;
 
+       case STATUSTYPE_IMA:
+               DMEMIT_TARGET_NAME_VERSION(ti->type);
+               DMEMIT(",allow_discards=%c", ti->num_discard_bios ? 'y' : 'n');
+               DMEMIT(",same_cpu_crypt=%c", test_bit(DM_CRYPT_SAME_CPU, &cc->flags) ? 'y' : 'n');
+               DMEMIT(",submit_from_crypt_cpus=%c", test_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags) ?
+                      'y' : 'n');
+               DMEMIT(",no_read_workqueue=%c", test_bit(DM_CRYPT_NO_READ_WORKQUEUE, &cc->flags) ?
+                      'y' : 'n');
+               DMEMIT(",no_write_workqueue=%c", test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags) ?
+                      'y' : 'n');
+               DMEMIT(",iv_large_sectors=%c", test_bit(CRYPT_IV_LARGE_SECTORS, &cc->cipher_flags) ?
+                      'y' : 'n');
+
+               if (cc->on_disk_tag_size)
+                       DMEMIT(",integrity_tag_size=%u,cipher_auth=%s",
+                              cc->on_disk_tag_size, cc->cipher_auth);
+               if (cc->sector_size != (1 << SECTOR_SHIFT))
+                       DMEMIT(",sector_size=%d", cc->sector_size);
+               if (cc->cipher_string)
+                       DMEMIT(",cipher_string=%s", cc->cipher_string);
+
+               DMEMIT(",key_size=%u", cc->key_size);
+               DMEMIT(",key_parts=%u", cc->key_parts);
+               DMEMIT(",key_extra_size=%u", cc->key_extra_size);
+               DMEMIT(",key_mac_size=%u", cc->key_mac_size);
+               DMEMIT(";");
                break;
        }
 }