From: Scott Bauer <sbauer@plzdonthack.me>
To: Revanth Rajashekar <revanth.rajashekar@intel.com>
Cc: linux-block@vger.kernel.org,
Jonathan Derrick <jonathan.derrick@intel.com>,
Jonas Rabenstine <jonas.rabenstein@studium.uni-erlangen.de>,
David Kozub <zub@linux.fjfi.cvut.cz>,
Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH v3 2/3] block: sed-opal: Add support to read/write opal tables generically
Date: Sun, 3 Nov 2019 19:15:19 -0500 [thread overview]
Message-ID: <20191104001519.GB12665@hacktheplanet> (raw)
In-Reply-To: <20191031161322.16624-3-revanth.rajashekar@intel.com>
On Thu, Oct 31, 2019 at 10:13:21AM -0600, Revanth Rajashekar wrote:
> This feature gives the user RW access to any opal table with admin1
> authority. The flags described in the new structure determines if the user
> wants to read/write the data. Flags are checked for valid values in
> order to allow future features to be added to the ioctl.
>
> The user can provide the desired table's UID. Also, the ioctl provides a
> size and offset field and internally will loop data accesses to return
> the full data block. Read overrun is prevented by the initiator's
> sec_send_recv() backend. The ioctl provides a private field with the
> intention to accommodate any future expansions to the ioctl.
>
> Reviewed-by: Jon Derrick <jonathan.derrick@intel.com>
> Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com>
Looks fine
Reviewed-by: Scott Bauer <sbauer@plzdonthack.me>
> +static int read_table_data(struct opal_dev *dev, void *data)
> +{
> + struct opal_read_write_table *read_tbl = data;
> + int err;
> + size_t off = 0, max_read_size = OPAL_MAX_READ_TABLE;
> + u64 table_len, len;
> + u64 offset = read_tbl->offset, read_size = read_tbl->size - 1;
> + u8 __user *dst;
> +
> + /* len+1: This includes the NULL terminator at the end*/
> + if (dev->prev_d_len > len + 1) {
> + err = -EOVERFLOW;
> + break;
> + }
> +
> + dst = (u8 __user *)(uintptr_t)read_tbl->data;
> + if (copy_to_user(dst + off, dev->prev_data, dev->prev_d_len)) {
> + pr_debug("Error copying data to userspace\n");
> + err = -EFAULT;
> + break;
> + }
> + dev->prev_data = NULL;
If you end up needing to spin a v4 can you please add a comment here reminding me that prev_data in this scenario is not kmalloc'd memory but an offset into the response buffer. I had to go track down why you were not kfree()ing this. I know in a year I'll have forgotten it and will review it again.
> +static int opal_generic_read_write_table(struct opal_dev *dev,
> + struct opal_read_write_table *rw_tbl)
> +{
> + int ret, bit_set;
> +
> + mutex_lock(&dev->dev_lock);
> + setup_opal_dev(dev);
> +
> + bit_set = fls64(rw_tbl->flags) - 1;
Maybe I am missing something obvious but why don't we just use flags as a number? Like instead of bit packing flags we just use it as a number like number 0 is read_table, 1 is write_table, 2 is delete_table, 3 is clear_table etc etc. I don't understand the neccessity for fls-ing some bit field when a number would suffice.
I don't want another revision --it's fine-- I'm just wondering why this method was chosen.
next prev parent reply other threads:[~2019-11-04 0:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-31 16:13 [PATCH v3 0/3] block: sed-opal: Generic Read/Write Opal Tables Revanth Rajashekar
2019-10-31 16:13 ` [PATCH v3 1/3] block: sed-opal: Generalizing write data to any opal table Revanth Rajashekar
2019-11-03 23:52 ` Scott Bauer
2019-10-31 16:13 ` [PATCH v3 2/3] block: sed-opal: Add support to read/write opal tables generically Revanth Rajashekar
2019-11-04 0:15 ` Scott Bauer [this message]
2019-10-31 16:13 ` [PATCH v3 3/3] block: sed-opal: Introduce Opal Datastore UID Revanth Rajashekar
2019-11-04 0:18 ` Scott Bauer
2019-11-04 14:12 ` [PATCH v3 0/3] block: sed-opal: Generic Read/Write Opal Tables Jens Axboe
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=20191104001519.GB12665@hacktheplanet \
--to=sbauer@plzdonthack.me \
--cc=axboe@kernel.dk \
--cc=jonas.rabenstein@studium.uni-erlangen.de \
--cc=jonathan.derrick@intel.com \
--cc=linux-block@vger.kernel.org \
--cc=revanth.rajashekar@intel.com \
--cc=zub@linux.fjfi.cvut.cz \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox