From: Philipp Reisner <philipp.reisner@linbit.com>
To: linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: drbd-dev@lists.linbit.com
Subject: [PATCH 14/16] drbd: fix schedule in atomic
Date: Wed, 5 Oct 2011 11:38:02 +0200 [thread overview]
Message-ID: <1317807484-24628-15-git-send-email-philipp.reisner@linbit.com> (raw)
In-Reply-To: <1317807484-24628-1-git-send-email-philipp.reisner@linbit.com>
From: Lars Ellenberg <lars.ellenberg@linbit.com>
An administrative detach used to request a state change directly to D_DISKLESS,
first suspending IO to avoid the last put_ldev() occuring from an endio handler,
potentially in irq context.
This is not enough on the receiving side (typically secondary), we may miss
some peer_req on the way to local disk, which then may do the last put_ldev()
from their drbd_peer_request_endio().
This patch makes the detach always go through the intermediate D_FAILED state.
We may consider to rename it D_DETACHING.
Alternative approach would be to create yet an other work item to be scheduled
on the worker, do the destructor work from there, and get the timing right.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
---
drivers/block/drbd/drbd_nl.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 019f762..414503a 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1706,12 +1706,17 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
static int adm_detach(struct drbd_conf *mdev)
{
enum drbd_ret_code retcode;
+ int ret;
drbd_suspend_io(mdev); /* so no-one is stuck in drbd_al_begin_io */
- retcode = drbd_request_state(mdev, NS(disk, D_DISKLESS));
- wait_event(mdev->misc_wait,
- mdev->state.disk != D_DISKLESS ||
- !atomic_read(&mdev->local_cnt));
+ retcode = drbd_request_state(mdev, NS(disk, D_FAILED));
+ /* D_FAILED will transition to DISKLESS. */
+ ret = wait_event_interruptible(mdev->misc_wait,
+ mdev->state.disk != D_FAILED);
drbd_resume_io(mdev);
+ if (retcode == SS_IS_DISKLESS)
+ retcode = SS_NOTHING_TO_DO;
+ if (ret)
+ retcode = ERR_INTR;
return retcode;
}
--
1.7.4.1
next prev parent reply other threads:[~2011-10-05 9:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-05 9:37 [RFC 00/16] drbd: part 14 of adding multiple volume support to drbd Philipp Reisner
2011-10-05 9:37 ` [PATCH 01/16] drbd: Consider all crypto options in connect and in net-options Philipp Reisner
2011-10-05 9:37 ` [PATCH 02/16] drbd: on reconfiguration requests, mind the SET_DEFAULTS flag Philipp Reisner
2011-10-05 9:37 ` [PATCH 03/16] drbd: rename variable ndc to new_disk_conf Philipp Reisner
2011-10-05 9:37 ` [PATCH 04/16] drbd: rename variable sc to res_opts Philipp Reisner
2011-10-05 9:37 ` [PATCH 05/16] drbd: fix copy/paste error in comment Philipp Reisner
2011-10-05 9:37 ` [PATCH 06/16] drbd: Wrong use of RCU in receive_protocol() Philipp Reisner
2011-10-05 9:37 ` [PATCH 07/16] drbd: Rename integrity_w_tfm -> integrity_tfm Philipp Reisner
2011-10-05 9:37 ` [PATCH 08/16] drbd: Rename integrity_r_tfm -> peer_integrity_tfm Philipp Reisner
2011-10-05 9:37 ` [PATCH 09/16] drbd: Remove obsolete drbd_crypto_is_hash() Philipp Reisner
2011-10-05 9:37 ` [PATCH 10/16] drbd: Introduce a "lockless" variant of drbd_send_protocoll() Philipp Reisner
2011-10-05 9:37 ` [PATCH 11/16] drbd: Allow to change data-integrity-alg on the fly Philipp Reisner
2011-10-05 9:38 ` [PATCH 12/16] drbd: fix race when forcefully disconnecting Philipp Reisner
2011-10-05 9:38 ` [PATCH 13/16] drbd: fix thread stop deadlock Philipp Reisner
2011-10-05 9:38 ` Philipp Reisner [this message]
2011-10-05 9:38 ` [PATCH 15/16] drbd: Remove left-over unused define Philipp Reisner
2011-10-05 9:38 ` [PATCH 16/16] drbd: Generate the drbd_set_*_defaults() functions from drbd_genl.h Philipp Reisner
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=1317807484-24628-15-git-send-email-philipp.reisner@linbit.com \
--to=philipp.reisner@linbit.com \
--cc=axboe@kernel.dk \
--cc=drbd-dev@lists.linbit.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®