From patchwork Tue Mar 20 10:32:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Yang X-Patchwork-Id: 10296793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 13E35602C2 for ; Tue, 20 Mar 2018 10:39:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 046C829048 for ; Tue, 20 Mar 2018 10:39:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA3E829581; Tue, 20 Mar 2018 10:39:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10A8D29048 for ; Tue, 20 Mar 2018 10:39:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752701AbeCTKjZ (ORCPT ); Tue, 20 Mar 2018 06:39:25 -0400 Received: from m6562.mail.qiye.163.com ([123.126.65.62]:37204 "EHLO m6562.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752597AbeCTKjU (ORCPT ); Tue, 20 Mar 2018 06:39:20 -0400 Received: from atest-guest.localdomain (unknown [218.94.118.90]) by smtp12 (Coremail) with SMTP id WtOowAC3189e47BaWEJgAA--.11203S4; Tue, 20 Mar 2018 18:33:03 +0800 (CST) From: Dongsheng Yang To: idryomov@gmail.com, sage@redhat.com, elder@kernel.org, jdillama@redhat.com Cc: ceph-devel@vger.kernel.org, Dongsheng Yang Subject: [PATCH 2/3] rbd: add an option to set state_lock_timeout Date: Tue, 20 Mar 2018 06:32:58 -0400 Message-Id: <1521541979-15995-3-git-send-email-dongsheng.yang@easystack.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1521541979-15995-1-git-send-email-dongsheng.yang@easystack.cn> References: <1521541979-15995-1-git-send-email-dongsheng.yang@easystack.cn> X-CM-TRANSID: WtOowAC3189e47BaWEJgAA--.11203S4 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjfUpHmDUUUUU X-Originating-IP: [218.94.118.90] X-CM-SenderInfo: 5grqw2pkhqwhp1dqwq5hdv52pwdfyhdfq/1tbiZh8PellZuIeAzgAAs9 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch allow user to set the state_lock_timeout in rbd mapping. Signed-off-by: Dongsheng Yang --- drivers/block/rbd.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 199819d..6bfbfe5 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -726,6 +726,7 @@ static struct rbd_client *rbd_client_find(struct ceph_options *ceph_opts) */ enum { Opt_queue_depth, + Opt_state_lock_timeout, Opt_last_int, /* int args above */ Opt_last_string, @@ -739,6 +740,7 @@ enum { static match_table_t rbd_opts_tokens = { {Opt_queue_depth, "queue_depth=%d"}, + {Opt_state_lock_timeout, "state_lock_timeout=%d"}, /* int args above */ /* string args above */ {Opt_read_only, "read_only"}, @@ -752,6 +754,7 @@ enum { struct rbd_options { int queue_depth; + long state_lock_timeout; bool read_only; bool lock_on_read; bool exclusive; @@ -761,7 +764,7 @@ struct rbd_options { #define RBD_READ_ONLY_DEFAULT false #define RBD_LOCK_ON_READ_DEFAULT false #define RBD_EXCLUSIVE_DEFAULT false -#define RBD_WAIT_LOCK_TIMEOUT_DEFAULT MAX_SCHEDULE_TIMEOUT +#define RBD_STATE_LOCK_TIMEOUT_DEFAULT (jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT) / 1000) static int parse_rbd_opts_token(char *c, void *private) { @@ -791,6 +794,13 @@ static int parse_rbd_opts_token(char *c, void *private) } rbd_opts->queue_depth = intval; break; + case Opt_state_lock_timeout: + if (intval < 0) { + pr_err("state_lock_timeout out of range\n"); + return -EINVAL; + } + rbd_opts->state_lock_timeout = intval; + break; case Opt_read_only: rbd_opts->read_only = true; break; @@ -3497,7 +3507,8 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev, */ static int rbd_wait_state_locked(struct rbd_device *rbd_dev) { - long timeo = RBD_WAIT_LOCK_TIMEOUT_DEFAULT; + /* convert seconds to jiffies */ + long timeo = msecs_to_jiffies(rbd_dev->opts->state_lock_timeout * 1000); DEFINE_WAIT(wait); do { @@ -5201,6 +5212,7 @@ static int rbd_add_parse_args(const char *buf, rbd_opts->read_only = RBD_READ_ONLY_DEFAULT; rbd_opts->queue_depth = RBD_QUEUE_DEPTH_DEFAULT; + rbd_opts->state_lock_timeout = RBD_STATE_LOCK_TIMEOUT_DEFAULT; rbd_opts->lock_on_read = RBD_LOCK_ON_READ_DEFAULT; rbd_opts->exclusive = RBD_EXCLUSIVE_DEFAULT;