Skip to content

Commit acf913b

Browse files
committed
Merge tag 'for-linus-2019-10-26' of git://git.kernel.dk/linux-block
Pull block and io_uring fixes from Jens Axboe: "A bit bigger than usual at this point in time, mostly due to some good bug hunting work by Pavel that resulted in three io_uring fixes from him and two from me. Anyway, this pull request contains: - Revert of the submit-and-wait optimization for io_uring, it can't always be done safely. It depends on commands always making progress on their own, which isn't necessarily the case outside of strict file IO. (me) - Series of two patches from me and three from Pavel, fixing issues with shared data and sequencing for io_uring. - Lastly, two timeout sequence fixes for io_uring (zhangyi) - Two nbd patches fixing races (Josef) - libahci regulator_get_optional() fix (Mark)" * tag 'for-linus-2019-10-26' of git://git.kernel.dk/linux-block: nbd: verify socket is supported during setup ata: libahci_platform: Fix regulator_get_optional() misuse nbd: handle racing with error'ed out commands nbd: protect cmd->status with cmd->lock io_uring: fix bad inflight accounting for SETUP_IOPOLL|SETUP_SQTHREAD io_uring: used cached copies of sq->dropped and cq->overflow io_uring: Fix race for sqes with userspace io_uring: Fix broken links with offloading io_uring: Fix corrupted user_data io_uring: correct timeout req sequence when inserting a new entry io_uring : correct timeout req sequence when waiting timeout io_uring: revert "io_uring: optimize submit_and_wait API"
2 parents f877bee + cf1b232 commit acf913b

File tree

3 files changed

+161
-125
lines changed

3 files changed

+161
-125
lines changed

drivers/ata/libahci_platform.c

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,13 @@ int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv)
153153
{
154154
int rc, i;
155155

156-
if (hpriv->ahci_regulator) {
157-
rc = regulator_enable(hpriv->ahci_regulator);
158-
if (rc)
159-
return rc;
160-
}
156+
rc = regulator_enable(hpriv->ahci_regulator);
157+
if (rc)
158+
return rc;
161159

162-
if (hpriv->phy_regulator) {
163-
rc = regulator_enable(hpriv->phy_regulator);
164-
if (rc)
165-
goto disable_ahci_pwrs;
166-
}
160+
rc = regulator_enable(hpriv->phy_regulator);
161+
if (rc)
162+
goto disable_ahci_pwrs;
167163

168164
for (i = 0; i < hpriv->nports; i++) {
169165
if (!hpriv->target_pwrs[i])
@@ -181,11 +177,9 @@ int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv)
181177
if (hpriv->target_pwrs[i])
182178
regulator_disable(hpriv->target_pwrs[i]);
183179

184-
if (hpriv->phy_regulator)
185-
regulator_disable(hpriv->phy_regulator);
180+
regulator_disable(hpriv->phy_regulator);
186181
disable_ahci_pwrs:
187-
if (hpriv->ahci_regulator)
188-
regulator_disable(hpriv->ahci_regulator);
182+
regulator_disable(hpriv->ahci_regulator);
189183
return rc;
190184
}
191185
EXPORT_SYMBOL_GPL(ahci_platform_enable_regulators);
@@ -207,10 +201,8 @@ void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv)
207201
regulator_disable(hpriv->target_pwrs[i]);
208202
}
209203

210-
if (hpriv->ahci_regulator)
211-
regulator_disable(hpriv->ahci_regulator);
212-
if (hpriv->phy_regulator)
213-
regulator_disable(hpriv->phy_regulator);
204+
regulator_disable(hpriv->ahci_regulator);
205+
regulator_disable(hpriv->phy_regulator);
214206
}
215207
EXPORT_SYMBOL_GPL(ahci_platform_disable_regulators);
216208
/**
@@ -359,7 +351,7 @@ static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port,
359351
struct regulator *target_pwr;
360352
int rc = 0;
361353

362-
target_pwr = regulator_get_optional(dev, "target");
354+
target_pwr = regulator_get(dev, "target");
363355

364356
if (!IS_ERR(target_pwr))
365357
hpriv->target_pwrs[port] = target_pwr;
@@ -436,16 +428,14 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
436428
hpriv->clks[i] = clk;
437429
}
438430

439-
hpriv->ahci_regulator = devm_regulator_get_optional(dev, "ahci");
431+
hpriv->ahci_regulator = devm_regulator_get(dev, "ahci");
440432
if (IS_ERR(hpriv->ahci_regulator)) {
441433
rc = PTR_ERR(hpriv->ahci_regulator);
442-
if (rc == -EPROBE_DEFER)
434+
if (rc != 0)
443435
goto err_out;
444-
rc = 0;
445-
hpriv->ahci_regulator = NULL;
446436
}
447437

448-
hpriv->phy_regulator = devm_regulator_get_optional(dev, "phy");
438+
hpriv->phy_regulator = devm_regulator_get(dev, "phy");
449439
if (IS_ERR(hpriv->phy_regulator)) {
450440
rc = PTR_ERR(hpriv->phy_regulator);
451441
if (rc == -EPROBE_DEFER)

drivers/block/nbd.c

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,17 +385,16 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
385385
struct nbd_device *nbd = cmd->nbd;
386386
struct nbd_config *config;
387387

388+
if (!mutex_trylock(&cmd->lock))
389+
return BLK_EH_RESET_TIMER;
390+
388391
if (!refcount_inc_not_zero(&nbd->config_refs)) {
389392
cmd->status = BLK_STS_TIMEOUT;
393+
mutex_unlock(&cmd->lock);
390394
goto done;
391395
}
392396
config = nbd->config;
393397

394-
if (!mutex_trylock(&cmd->lock)) {
395-
nbd_config_put(nbd);
396-
return BLK_EH_RESET_TIMER;
397-
}
398-
399398
if (config->num_connections > 1) {
400399
dev_err_ratelimited(nbd_to_dev(nbd),
401400
"Connection timed out, retrying (%d/%d alive)\n",
@@ -711,6 +710,12 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)
711710
ret = -ENOENT;
712711
goto out;
713712
}
713+
if (cmd->status != BLK_STS_OK) {
714+
dev_err(disk_to_dev(nbd->disk), "Command already handled %p\n",
715+
req);
716+
ret = -ENOENT;
717+
goto out;
718+
}
714719
if (test_bit(NBD_CMD_REQUEUED, &cmd->flags)) {
715720
dev_err(disk_to_dev(nbd->disk), "Raced with timeout on req %p\n",
716721
req);
@@ -792,7 +797,10 @@ static bool nbd_clear_req(struct request *req, void *data, bool reserved)
792797
{
793798
struct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);
794799

800+
mutex_lock(&cmd->lock);
795801
cmd->status = BLK_STS_IOERR;
802+
mutex_unlock(&cmd->lock);
803+
796804
blk_mq_complete_request(req);
797805
return true;
798806
}
@@ -972,6 +980,25 @@ static blk_status_t nbd_queue_rq(struct blk_mq_hw_ctx *hctx,
972980
return ret;
973981
}
974982

983+
static struct socket *nbd_get_socket(struct nbd_device *nbd, unsigned long fd,
984+
int *err)
985+
{
986+
struct socket *sock;
987+
988+
*err = 0;
989+
sock = sockfd_lookup(fd, err);
990+
if (!sock)
991+
return NULL;
992+
993+
if (sock->ops->shutdown == sock_no_shutdown) {
994+
dev_err(disk_to_dev(nbd->disk), "Unsupported socket: shutdown callout must be supported.\n");
995+
*err = -EINVAL;
996+
return NULL;
997+
}
998+
999+
return sock;
1000+
}
1001+
9751002
static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
9761003
bool netlink)
9771004
{
@@ -981,7 +1008,7 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
9811008
struct nbd_sock *nsock;
9821009
int err;
9831010

984-
sock = sockfd_lookup(arg, &err);
1011+
sock = nbd_get_socket(nbd, arg, &err);
9851012
if (!sock)
9861013
return err;
9871014

@@ -1033,7 +1060,7 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
10331060
int i;
10341061
int err;
10351062

1036-
sock = sockfd_lookup(arg, &err);
1063+
sock = nbd_get_socket(nbd, arg, &err);
10371064
if (!sock)
10381065
return err;
10391066

0 commit comments

Comments
 (0)