Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1229166
| From | Jon Hunter <jonathanh@nvidia.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH V3] mmc: block: Add new ioctl to send multi commands |
| Date | 2015-09-21 12:00 +0200 |
| Message-ID | <qb637-33B-7@gated-at.bofh.it> (permalink) |
| References | <q8Dyi-1lu-15@gated-at.bofh.it> <q9p9W-3ca-73@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 16/09/15 18:54, Gwendal Grignou wrote:
[snip]
>> +static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev,
>> + struct mmc_ioc_multi_cmd __user *user)
>> +{
>> + struct mmc_blk_ioc_data **idata = NULL;
>> + struct mmc_ioc_cmd __user *cmds = user->cmds;
>> + struct mmc_card *card;
>> + struct mmc_blk_data *md;
>> + int i, err = -EFAULT;
>> + __u64 num_of_cmds;
>> +
>> + /*
>> + * The caller must have CAP_SYS_RAWIO, and must be calling this on the
>> + * whole block device, not on a partition. This prevents overspray
>> + * between sibling partitions.
>> + */
>> + if ((!capable(CAP_SYS_RAWIO)) || (bdev != bdev->bd_contains))
>> + return -EPERM;
>> +
>> + if (copy_from_user(&num_of_cmds, &user->num_of_cmds,
>> + sizeof(num_of_cmds)))
>> + return -EFAULT;
>> +
>> + if (num_of_cmds > MMC_IOC_MAX_CMDS)
>> + return -EINVAL;
>> +
>> + idata = kcalloc(num_of_cmds, sizeof(*idata), GFP_KERNEL);
>> + if (!idata)
>> + return -ENOMEM;
>> +
>> + for (i = 0; i < num_of_cmds; i++) {
>> + idata[i] = mmc_blk_ioctl_copy_from_user(&cmds[i]);
>> + if (IS_ERR(idata[i])) {
>> + err = PTR_ERR(idata[i]);
>> + num_of_cmds = i;
>> + goto cmd_err;
>> + }
>> + }
>> +
>> + md = mmc_blk_get(bdev->bd_disk);
>> + if (!md)
>> + goto cmd_err;
>> +
>> + card = md->queue.card;
>> + if (IS_ERR(card)) {
>> + err = PTR_ERR(card);
>> + goto cmd_done;
>> + }
>> +
>> + mmc_get_card(card);
>> +
>> + for (i = 0; i < num_of_cmds; i++) {
>> + err = __mmc_blk_ioctl_cmd(card, md, idata[i]);
>> + if (err) {
>> + mmc_put_card(card);
>> + goto cmd_done;
> Instead of exiting here, you should first copy to the user the data
> and response of successful commands, mark the failed command as failed
> and the remaining ones as "not executed".
> This way, it will be easier for the user space application to find out
> where the sequence failed. This especially true if some reverts are
> needed.
Yes that sounds like a sensible thing to do. I will incorporate that change.
Cheers
Jon
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH V3] mmc: block: Add new ioctl to send multi commands Jon Hunter <jonathanh@nvidia.com> - 2015-09-14 17:10 +0200
Re: [PATCH V3] mmc: block: Add new ioctl to send multi commands Grant Grundler <grundler@chromium.org> - 2015-09-14 18:40 +0200
Re: [PATCH V3] mmc: block: Add new ioctl to send multi commands Ulf Hansson <ulf.hansson@linaro.org> - 2015-09-16 13:10 +0200
Re: [PATCH V3] mmc: block: Add new ioctl to send multi commands Jon Hunter <jonathanh@nvidia.com> - 2015-09-16 18:10 +0200
Re: [PATCH V3] mmc: block: Add new ioctl to send multi commands Ulf Hansson <ulf.hansson@linaro.org> - 2015-09-17 09:00 +0200
Re: [PATCH V3] mmc: block: Add new ioctl to send multi commands Jon Hunter <jonathanh@nvidia.com> - 2015-09-18 12:30 +0200
Re: [PATCH V3] mmc: block: Add new ioctl to send multi commands Gwendal Grignou <gwendal@chromium.org> - 2015-09-16 20:00 +0200
Re: [PATCH V3] mmc: block: Add new ioctl to send multi commands Jon Hunter <jonathanh@nvidia.com> - 2015-09-21 12:00 +0200
Re: [PATCH V3] mmc: block: Add new ioctl to send multi commands Jon Hunter <jonathanh@nvidia.com> - 2015-09-21 13:30 +0200
Re: [PATCH V3] mmc: block: Add new ioctl to send multi commands Grant Grundler <grundler@google.com> - 2015-09-21 20:50 +0200
csiph-web