CEPH filesystem development
 help / color / mirror / Atom feed
From: Ilya Dryomov <idryomov@gmail.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 7/9] rbd: kill rbd_is_lock_supported()
Date: Tue, 25 Apr 2017 11:33:43 +0200	[thread overview]
Message-ID: <1493112825-16403-8-git-send-email-idryomov@gmail.com> (raw)
In-Reply-To: <1493112825-16403-1-git-send-email-idryomov@gmail.com>

Currently the exclusive lock is acquired only if the mapping is
writable, i.e. an image HEAD mapped in rw mode.  This means that we
don't acquire the lock for executing a read from a snapshot or an image
HEAD mapped in ro mode, even if lock_on_read is set.  This is somewhat
weird and inconsistent with "no automatic exclusive lock transfers"
mode, where the lock is acquired unconditionally.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 drivers/block/rbd.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index b859ce00ee1e..bcc43fb8a9b3 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -478,13 +478,6 @@ static int minor_to_rbd_dev_id(int minor)
 	return minor >> RBD_SINGLE_MAJOR_PART_SHIFT;
 }
 
-static bool rbd_is_lock_supported(struct rbd_device *rbd_dev)
-{
-	return (rbd_dev->header.features & RBD_FEATURE_EXCLUSIVE_LOCK) &&
-	       rbd_dev->spec->snap_id == CEPH_NOSNAP &&
-	       !rbd_dev->mapping.read_only;
-}
-
 static bool __rbd_is_lock_owner(struct rbd_device *rbd_dev)
 {
 	return rbd_dev->lock_state == RBD_LOCK_STATE_LOCKED ||
@@ -4052,10 +4045,6 @@ static void rbd_queue_workfn(struct work_struct *work)
 	if (op_type != OBJ_OP_READ) {
 		snapc = rbd_dev->header.snapc;
 		ceph_get_snap_context(snapc);
-		must_be_locked = rbd_is_lock_supported(rbd_dev);
-	} else {
-		must_be_locked = rbd_dev->opts->lock_on_read &&
-					rbd_is_lock_supported(rbd_dev);
 	}
 	up_read(&rbd_dev->header_rwsem);
 
@@ -4066,6 +4055,9 @@ static void rbd_queue_workfn(struct work_struct *work)
 		goto err_rq;
 	}
 
+	must_be_locked =
+	    (rbd_dev->header.features & RBD_FEATURE_EXCLUSIVE_LOCK) &&
+	    (op_type != OBJ_OP_READ || rbd_dev->opts->lock_on_read);
 	if (must_be_locked) {
 		down_read(&rbd_dev->lock_rwsem);
 		if (rbd_dev->lock_state != RBD_LOCK_STATE_LOCKED &&
-- 
2.4.3


  parent reply	other threads:[~2017-04-25  9:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-25  9:33 [PATCH 0/9] rbd: support for rbd map --exclusive Ilya Dryomov
2017-04-25  9:33 ` [PATCH 1/9] rbd: move rbd_dev_destroy() call out of rbd_dev_image_release() Ilya Dryomov
2017-04-25  9:33 ` [PATCH 2/9] rbd: move rbd_unregister_watch() call into rbd_dev_image_release() Ilya Dryomov
2017-04-25  9:33 ` [PATCH 3/9] rbd: fix error handling around rbd_init_disk() Ilya Dryomov
2017-04-25  9:33 ` [PATCH 4/9] rbd: ignore unlock errors Ilya Dryomov
2017-04-25  9:33 ` [PATCH 5/9] rbd: store lock cookie Ilya Dryomov
2017-04-25  9:33 ` [PATCH 6/9] rbd: support updating the lock cookie without releasing the lock Ilya Dryomov
2017-04-25  9:33 ` Ilya Dryomov [this message]
2017-04-25  9:33 ` [PATCH 8/9] rbd: return ResponseMessage result from rbd_handle_request_lock() Ilya Dryomov
2017-04-25  9:33 ` [PATCH 9/9] rbd: exclusive map option Ilya Dryomov
2017-05-03 19:16 ` [PATCH 0/9] rbd: support for rbd map --exclusive Jason Dillaman

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=1493112825-16403-8-git-send-email-idryomov@gmail.com \
    --to=idryomov@gmail.com \
    --cc=ceph-devel@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