From: Christoph Hellwig <hch@infradead.org>
To: Satya Tangirala <satyat@google.com>
Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-ext4@vger.kernel.org,
Barani Muthukumaran <bmuthuku@qti.qualcomm.com>,
Kuohong Wang <kuohong.wang@mediatek.com>,
Kim Boojin <boojin.kim@samsung.com>
Subject: Re: [PATCH v7 1/9] block: Keyslot Manager for Inline Encryption
Date: Fri, 21 Feb 2020 09:04:34 -0800 [thread overview]
Message-ID: <20200221170434.GA438@infradead.org> (raw)
In-Reply-To: <20200221115050.238976-2-satyat@google.com>
> +#ifdef CONFIG_PM
> +static inline void blk_ksm_set_dev(struct keyslot_manager *ksm,
> + struct device *dev)
> +{
> + ksm->dev = dev;
> +}
> +
> +/* If there's an underlying device and it's suspended, resume it. */
> +static inline void blk_ksm_pm_get(struct keyslot_manager *ksm)
> +{
> + if (ksm->dev)
> + pm_runtime_get_sync(ksm->dev);
> +}
> +
> +static inline void blk_ksm_pm_put(struct keyslot_manager *ksm)
> +{
> + if (ksm->dev)
> + pm_runtime_put_sync(ksm->dev);
> +}
> +#else /* CONFIG_PM */
> +static inline void blk_ksm_set_dev(struct keyslot_manager *ksm,
> + struct device *dev)
> +{
> +}
> +
> +static inline void blk_ksm_pm_get(struct keyslot_manager *ksm)
> +{
> +}
> +
> +static inline void blk_ksm_pm_put(struct keyslot_manager *ksm)
> +{
> +}
> +#endif /* !CONFIG_PM */
I think no one is hurt by an unused dev field for the non-pm case.
I'd suggest to define the field unconditionally, and replace all
the above with direct calls below.
> +/**
> + * blk_ksm_get_slot() - Increment the refcount on the specified slot.
> + * @ksm: The keyslot manager that we want to modify.
> + * @slot: The slot to increment the refcount of.
> + *
> + * This function assumes that there is already an active reference to that slot
> + * and simply increments the refcount. This is useful when cloning a bio that
> + * already has a reference to a keyslot, and we want the cloned bio to also have
> + * its own reference.
> + *
> + * Context: Any context.
> + */
> +void blk_ksm_get_slot(struct keyslot_manager *ksm, unsigned int slot)
This function doesn't appear to be used at all in the whole series.
> +/**
> + * blk_ksm_put_slot() - Release a reference to a slot
> + * @ksm: The keyslot manager to release the reference from.
> + * @slot: The slot to release the reference from.
> + *
> + * Context: Any context.
> + */
> +void blk_ksm_put_slot(struct keyslot_manager *ksm, unsigned int slot)
> +{
> + unsigned long flags;
> +
> + if (WARN_ON(slot >= ksm->num_slots))
> + return;
> +
> + if (atomic_dec_and_lock_irqsave(&ksm->slots[slot].slot_refs,
> + &ksm->idle_slots_lock, flags)) {
> + list_add_tail(&ksm->slots[slot].idle_slot_node,
> + &ksm->idle_slots);
> + spin_unlock_irqrestore(&ksm->idle_slots_lock, flags);
> + wake_up(&ksm->idle_slots_wait_queue);
> + }
Given that blk_ksm_get_slot_for_key returns a signed keyslot that
can return errors, and the only callers stores it in a signed variable
I think this function should take a signed slot as well, and the check
for a non-negative slot should be moved here from the only caller.
> diff --git a/include/linux/bio.h b/include/linux/bio.h
> index 853d92ceee64..b2103e207ed5 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -8,6 +8,7 @@
> #include <linux/highmem.h>
> #include <linux/mempool.h>
> #include <linux/ioprio.h>
> +#include <linux/blk-crypto.h>
>
> #ifdef CONFIG_BLOCK
> /* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */
This doesn't belong here, but into the patch that actually requires
crypto definitions in bio.h.
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@infradead.org>
To: Satya Tangirala <satyat@google.com>
Cc: linux-scsi@vger.kernel.org, Kim Boojin <boojin.kim@samsung.com>,
Kuohong Wang <kuohong.wang@mediatek.com>,
Barani Muthukumaran <bmuthuku@qti.qualcomm.com>,
linux-f2fs-devel@lists.sourceforge.net,
linux-block@vger.kernel.org, linux-fscrypt@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org
Subject: Re: [f2fs-dev] [PATCH v7 1/9] block: Keyslot Manager for Inline Encryption
Date: Fri, 21 Feb 2020 09:04:34 -0800 [thread overview]
Message-ID: <20200221170434.GA438@infradead.org> (raw)
In-Reply-To: <20200221115050.238976-2-satyat@google.com>
> +#ifdef CONFIG_PM
> +static inline void blk_ksm_set_dev(struct keyslot_manager *ksm,
> + struct device *dev)
> +{
> + ksm->dev = dev;
> +}
> +
> +/* If there's an underlying device and it's suspended, resume it. */
> +static inline void blk_ksm_pm_get(struct keyslot_manager *ksm)
> +{
> + if (ksm->dev)
> + pm_runtime_get_sync(ksm->dev);
> +}
> +
> +static inline void blk_ksm_pm_put(struct keyslot_manager *ksm)
> +{
> + if (ksm->dev)
> + pm_runtime_put_sync(ksm->dev);
> +}
> +#else /* CONFIG_PM */
> +static inline void blk_ksm_set_dev(struct keyslot_manager *ksm,
> + struct device *dev)
> +{
> +}
> +
> +static inline void blk_ksm_pm_get(struct keyslot_manager *ksm)
> +{
> +}
> +
> +static inline void blk_ksm_pm_put(struct keyslot_manager *ksm)
> +{
> +}
> +#endif /* !CONFIG_PM */
I think no one is hurt by an unused dev field for the non-pm case.
I'd suggest to define the field unconditionally, and replace all
the above with direct calls below.
> +/**
> + * blk_ksm_get_slot() - Increment the refcount on the specified slot.
> + * @ksm: The keyslot manager that we want to modify.
> + * @slot: The slot to increment the refcount of.
> + *
> + * This function assumes that there is already an active reference to that slot
> + * and simply increments the refcount. This is useful when cloning a bio that
> + * already has a reference to a keyslot, and we want the cloned bio to also have
> + * its own reference.
> + *
> + * Context: Any context.
> + */
> +void blk_ksm_get_slot(struct keyslot_manager *ksm, unsigned int slot)
This function doesn't appear to be used at all in the whole series.
> +/**
> + * blk_ksm_put_slot() - Release a reference to a slot
> + * @ksm: The keyslot manager to release the reference from.
> + * @slot: The slot to release the reference from.
> + *
> + * Context: Any context.
> + */
> +void blk_ksm_put_slot(struct keyslot_manager *ksm, unsigned int slot)
> +{
> + unsigned long flags;
> +
> + if (WARN_ON(slot >= ksm->num_slots))
> + return;
> +
> + if (atomic_dec_and_lock_irqsave(&ksm->slots[slot].slot_refs,
> + &ksm->idle_slots_lock, flags)) {
> + list_add_tail(&ksm->slots[slot].idle_slot_node,
> + &ksm->idle_slots);
> + spin_unlock_irqrestore(&ksm->idle_slots_lock, flags);
> + wake_up(&ksm->idle_slots_wait_queue);
> + }
Given that blk_ksm_get_slot_for_key returns a signed keyslot that
can return errors, and the only callers stores it in a signed variable
I think this function should take a signed slot as well, and the check
for a non-negative slot should be moved here from the only caller.
> diff --git a/include/linux/bio.h b/include/linux/bio.h
> index 853d92ceee64..b2103e207ed5 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -8,6 +8,7 @@
> #include <linux/highmem.h>
> #include <linux/mempool.h>
> #include <linux/ioprio.h>
> +#include <linux/blk-crypto.h>
>
> #ifdef CONFIG_BLOCK
> /* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */
This doesn't belong here, but into the patch that actually requires
crypto definitions in bio.h.
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2020-02-21 17:04 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-21 11:50 [PATCH v7 0/9] Inline Encryption Support Satya Tangirala
2020-02-21 11:50 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-02-21 11:50 ` [PATCH v7 1/9] block: Keyslot Manager for Inline Encryption Satya Tangirala
2020-02-21 11:50 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-02-21 17:04 ` Christoph Hellwig [this message]
2020-02-21 17:04 ` Christoph Hellwig
2020-02-21 17:31 ` Christoph Hellwig
2020-02-21 17:31 ` [f2fs-dev] " Christoph Hellwig
2020-02-27 18:14 ` Eric Biggers
2020-02-27 18:14 ` [f2fs-dev] " Eric Biggers
2020-02-27 21:25 ` Satya Tangirala
2020-02-27 21:25 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-03-05 16:11 ` Christoph Hellwig
2020-03-05 16:11 ` [f2fs-dev] " Christoph Hellwig
2020-02-27 18:48 ` Eric Biggers
2020-02-27 18:48 ` [f2fs-dev] " Eric Biggers
2020-02-21 11:50 ` [PATCH v7 2/9] block: Inline encryption support for blk-mq Satya Tangirala
2020-02-21 11:50 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-02-21 17:22 ` Christoph Hellwig
2020-02-21 17:22 ` [f2fs-dev] " Christoph Hellwig
2020-02-22 0:52 ` Satya Tangirala
2020-02-22 0:52 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-02-24 23:34 ` Christoph Hellwig
2020-02-24 23:34 ` [f2fs-dev] " Christoph Hellwig
2020-02-27 18:25 ` Eric Biggers
2020-02-27 18:25 ` [f2fs-dev] " Eric Biggers
2020-02-21 11:50 ` [PATCH v7 3/9] block: blk-crypto-fallback for Inline Encryption Satya Tangirala
2020-02-21 11:50 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-02-21 16:51 ` Randy Dunlap
2020-02-21 16:51 ` [f2fs-dev] " Randy Dunlap
2020-02-21 17:25 ` Christoph Hellwig
2020-02-21 17:25 ` [f2fs-dev] " Christoph Hellwig
2020-02-21 17:35 ` Christoph Hellwig
2020-02-21 17:35 ` [f2fs-dev] " Christoph Hellwig
2020-02-21 18:34 ` Eric Biggers
2020-02-21 18:34 ` [f2fs-dev] " Eric Biggers
2020-02-24 23:36 ` Christoph Hellwig
2020-02-24 23:36 ` [f2fs-dev] " Christoph Hellwig
2020-02-27 19:25 ` Eric Biggers
2020-02-27 19:25 ` [f2fs-dev] " Eric Biggers
2020-02-21 11:50 ` [PATCH v7 4/9] scsi: ufs: UFS driver v2.1 spec crypto additions Satya Tangirala
2020-02-21 11:50 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-02-21 11:50 ` [PATCH v7 5/9] scsi: ufs: UFS crypto API Satya Tangirala
2020-02-21 11:50 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-02-22 4:59 ` Eric Biggers
2020-02-22 4:59 ` [f2fs-dev] " Eric Biggers
2020-02-21 11:50 ` [PATCH v7 6/9] scsi: ufs: Add inline encryption support to UFS Satya Tangirala
2020-02-21 11:50 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-02-21 17:22 ` Christoph Hellwig
2020-02-21 17:22 ` [f2fs-dev] " Christoph Hellwig
2020-02-21 18:11 ` Eric Biggers
2020-02-21 18:11 ` [f2fs-dev] " Eric Biggers
2020-02-23 13:47 ` Stanley Chu
2020-02-23 13:47 ` [f2fs-dev] " Stanley Chu
2020-02-24 23:37 ` Christoph Hellwig
2020-02-24 23:37 ` [f2fs-dev] " Christoph Hellwig
2020-02-25 7:21 ` Stanley Chu
2020-02-25 7:21 ` [f2fs-dev] " Stanley Chu
2020-02-26 1:12 ` Eric Biggers
2020-02-26 1:12 ` [f2fs-dev] " Eric Biggers
2020-02-26 6:43 ` Stanley Chu
2020-02-26 6:43 ` [f2fs-dev] " Stanley Chu
2020-03-02 9:17 ` Stanley Chu
2020-03-02 9:17 ` [f2fs-dev] " Stanley Chu
2020-02-21 11:50 ` [PATCH v7 7/9] fscrypt: add inline encryption support Satya Tangirala
2020-02-21 11:50 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-02-21 18:40 ` Eric Biggers
2020-02-21 18:40 ` [f2fs-dev] " Eric Biggers
2020-02-22 5:39 ` Eric Biggers
2020-02-22 5:39 ` [f2fs-dev] " Eric Biggers
2020-02-26 0:30 ` Eric Biggers
2020-02-26 0:30 ` [f2fs-dev] " Eric Biggers
2020-02-21 11:50 ` [PATCH v7 8/9] f2fs: " Satya Tangirala
2020-02-21 11:50 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-02-21 11:50 ` [PATCH v7 9/9] ext4: " Satya Tangirala
2020-02-21 11:50 ` [f2fs-dev] " Satya Tangirala via Linux-f2fs-devel
2020-02-22 5:21 ` Eric Biggers
2020-02-22 5:21 ` [f2fs-dev] " Eric Biggers
2020-02-21 17:16 ` [PATCH v7 0/9] Inline Encryption Support Eric Biggers
2020-02-21 17:16 ` [f2fs-dev] " Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200221170434.GA438@infradead.org \
--to=hch@infradead.org \
--cc=bmuthuku@qti.qualcomm.com \
--cc=boojin.kim@samsung.com \
--cc=kuohong.wang@mediatek.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=satyat@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.