From: Alex Elder <alex.elder@linaro.org>
To: Josh Durgin <josh.durgin@inktank.com>
Cc: Guangliang Zhao <guangliang@unitedstack.com>,
ceph-devel@vger.kernel.org, sage@inktank.com,
lucienchao@gmail.com
Subject: Re: [PATCH v2] rbd: add ioctl for rbd
Date: Tue, 17 Sep 2013 11:11:36 -0500 [thread overview]
Message-ID: <52387F38.8020506@linaro.org> (raw)
In-Reply-To: <52387421.3080906@inktank.com>
On 09/17/2013 10:24 AM, Josh Durgin wrote:
. . .
>>
>> OK, now I have a very broad (and too detailed) suggestion.
>> (I got a little carried away, sorry about that.)
>>
>> At this point there is only one IOCTL request that is handled
>> by this function. I know it doesn't match the general-purpose
>> structure of your typical ioctl routine, but unless you think
>> there are more ioctls that should be added, I think this could
>> be made simpler by structuring the function something like:
>
> I like this refactoring of it, but there are two minor issues
> present in the original patch too:
>
>> rbd_ioctl(...)
>> {
>> ret = 0;
>> int argval;
>> bool want_ro;
>>
>> if (cmd != BLKROSET)
>> return -EINVAL;
>
> According to block/ioctl.c, this should be -ENOTTY or -ENOIOCTLCOMMAND,
> not -EINVAL.
I wondered about that, and actually looked at it but I thought
I saw other ioctl functions returning -EINVAL so I stopped looking
and didn't mention anything.
>> if (get_user(argval, ...))
>> return -EFAULT;
>> want_ro = !!argval;
>>
>> spin_lock();
>> if (rbd_dev->mapping.read_only == want_ro)
>> goto err_unlock; /* No change, OK */
>>
>> if (rbd_dev->spec->snap_id != CEPH_NOSNAP && !want_ro) {
>> ret = -EROFS;
>> goto err_unlock;
>> }
>>
>> /* Change requested; don't allow if already open */
>> if (rbd_dev->open_count) {
>> ret = -EBUSY;
>> goto err_unlock;
>> }
>>
>> rbd_dev->mapping.read_only = want_ro;
>> spin_unlock();
>> set_device_ro(bdev, want_ro ? 1 : 0);
>
> block/ioctl.c will already call set_device_ro() for us after this
> driver-specific handling completes successfully, so we don't need to
> call it here. Also, it appears the block layer has a bug in that
> it does the check for CAP_SYS_ADMIN *after* calling the driver-specific
> code for BLKROSET. So the driver-specific part could succeed, but the
> generic code could fail due to this later check without the driver
> knowing, possibly leaving the driver inconsistent with the block layer.
I wonder if that's intentional, but I doubt it. It predates
the original Linux-2.6.12-rc2 git commit.
But I agree with you, I think it's a bug. Do you plan to submit
a patch upstream to propose a fix?
-Alex
next prev parent reply other threads:[~2013-09-17 16:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-17 7:04 [PATCH v2] rbd: add ioctl for rbd Guangliang Zhao
2013-09-17 14:42 ` Alex Elder
2013-09-17 15:24 ` Josh Durgin
2013-09-17 16:11 ` Alex Elder [this message]
2013-09-17 16:35 ` Josh Durgin
2013-09-17 16:24 ` Alex Elder
2013-09-18 5:28 ` Guangliang Zhao
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=52387F38.8020506@linaro.org \
--to=alex.elder@linaro.org \
--cc=ceph-devel@vger.kernel.org \
--cc=guangliang@unitedstack.com \
--cc=josh.durgin@inktank.com \
--cc=lucienchao@gmail.com \
--cc=sage@inktank.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.