From patchwork Mon Feb 3 23:50:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Easwar Hariharan X-Patchwork-Id: 13958411 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D06BE209F57; Mon, 3 Feb 2025 23:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738626625; cv=none; b=hy5AmEF2cw4hys/qtBbMxV1RfUSApuEqh+zpe9PCq1ISlC/9ZaEanSIk5PJUkB4/MBwKyfAnw9R2JrJ6gDzQjr6TgeMt4Y8heqXDLO5N7OCqdNQv9tZUJNuFw72nQTDcCOqZSlb20EKXpoO/Wf6XqdbY2Rx6OrH7OhJZ4t+vqDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738626625; c=relaxed/simple; bh=KhNEyo7WFu+pfBKWpwr7dBCkfYqG9oS0AfyoC6gzP2I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ivVt71X8r46Jpal5Fro4mFCD2JBJDR02MVi/cMmJeJHAS+E2+EF4YApR4nSHaNhrVsXVikVzA50j+ID4I0k7GcphWPqFyQwYlqjBj4NUlh0fmFDgTeL18qBDu40AfUkhSb5KYdEkDQn4aYMqRNb/SUsyY7hbZmNhhu9hyAhr9VQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=oEhdTh0Q; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="oEhdTh0Q" Received: from eahariha-devbox.internal.cloudapp.net (unknown [40.91.112.99]) by linux.microsoft.com (Postfix) with ESMTPSA id 50B64205493C; Mon, 3 Feb 2025 15:50:23 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 50B64205493C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1738626623; bh=iYMbK5A793RDdkoEPga+PoRyWET+ntXiAELhCjFiDKo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oEhdTh0QOjAvgDcCvjUZsTTf0lTUPwUPP4F7dTpmwoMR8Uf43qW2ThQjODVfBeW0b 0A6YDdlPjF9Czqd/5/jjq41qeq/60xuBa1N/Q6LH7mm4uy7SMYZgwshRZgXGrP3Sf2 WEnpJG8ujT5WK9I6pJnS/o5zRDHyBdC0zkVrN8s8= From: Easwar Hariharan Date: Mon, 03 Feb 2025 23:50:22 +0000 Subject: [PATCH v2 1/3] coccinelle: misc: secs_to_jiffies: Patch expressions too Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250203-converge-secs-to-jiffies-part-two-v2-1-d7058a01fd0e@linux.microsoft.com> References: <20250203-converge-secs-to-jiffies-part-two-v2-0-d7058a01fd0e@linux.microsoft.com> In-Reply-To: <20250203-converge-secs-to-jiffies-part-two-v2-0-d7058a01fd0e@linux.microsoft.com> To: Andrew Morton , Julia Lawall , Nicolas Palix , Ilya Dryomov , Dongsheng Yang , Jens Axboe , Xiubo Li Cc: cocci@inria.fr, linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, linux-block@vger.kernel.org, Easwar Hariharan X-Mailer: b4 0.14.2 Teach the script to suggest conversions for timeout patterns where the arguments to msecs_to_jiffies() are expressions as well. Signed-off-by: Easwar Hariharan --- scripts/coccinelle/misc/secs_to_jiffies.cocci | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/coccinelle/misc/secs_to_jiffies.cocci b/scripts/coccinelle/misc/secs_to_jiffies.cocci index 8bbb2884ea5db939c63fd4513cf5ca8c977aa8cb..416f348174ca659b544441f5f68f04a41d1ad4a3 100644 --- a/scripts/coccinelle/misc/secs_to_jiffies.cocci +++ b/scripts/coccinelle/misc/secs_to_jiffies.cocci @@ -20,3 +20,13 @@ virtual patch - msecs_to_jiffies(C * MSEC_PER_SEC) + secs_to_jiffies(C) + +@depends on patch@ expression E; @@ + +- msecs_to_jiffies(E * 1000) ++ secs_to_jiffies(E) + +@depends on patch@ expression E; @@ + +- msecs_to_jiffies(E * MSEC_PER_SEC) ++ secs_to_jiffies(E) From patchwork Mon Feb 3 23:50:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Easwar Hariharan X-Patchwork-Id: 13958412 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D065D209692; Mon, 3 Feb 2025 23:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738626625; cv=none; b=OTIPqy6IOlAglvMJ7oDiizV7XXUaRAmoW+QbxBQAFDG1nBN/AOQ1S4seW6x/wvNymENqBlkRZkKE1NqFbDG9zgnxTK5ZNbEwg6PrCH+EQg2my9tn8n+sAKtbjX6NuMsFUtO6TNd3vqZqBZ82uy+09veYknBTjBg1aUlnHl/OU9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738626625; c=relaxed/simple; bh=lcNBHMv7OMgX6nqVil6HxIOjmC/ftCct7tDml36hpRA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J7QZVvW8st3e+u4oUba4a7frJoh4HA/B0Fz/QvtTrnSR/uU+sFnbvCvjXLJk47PWVHJmE+RMp+ibm2tZ1Qb4xi6dqfDJM5J4xLi1JWuGmEpQcM7QpS4ESUC7j8rYctVO9E0mWMhEngty/i2mMUlf1vntLWC2ANqtKm68iN3DP5c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=ReXLE283; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="ReXLE283" Received: from eahariha-devbox.internal.cloudapp.net (unknown [40.91.112.99]) by linux.microsoft.com (Postfix) with ESMTPSA id 6B0C9205493D; Mon, 3 Feb 2025 15:50:23 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6B0C9205493D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1738626623; bh=inEJFlb8r1npYTsCShTPXzeDexvNBQKU3TCcAYSm03w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ReXLE283sX5Tuc0xrvz7bAVvEIGcJWw0rsBAmKKW/ZsT5S61O5VtjQ66Z15h9nzhF 36WfZ+35qfNmyQRvN0ihBKzifDLm1J6exfsCS9sn+0/ui+NUyQWAcEYxIkhW55TQ/5 imD44gbuz+LkK2jsREe0wluFIj6KbR/2Q+blP1Ck= From: Easwar Hariharan Date: Mon, 03 Feb 2025 23:50:23 +0000 Subject: [PATCH v2 2/3] rbd: convert timeouts to secs_to_jiffies() Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250203-converge-secs-to-jiffies-part-two-v2-2-d7058a01fd0e@linux.microsoft.com> References: <20250203-converge-secs-to-jiffies-part-two-v2-0-d7058a01fd0e@linux.microsoft.com> In-Reply-To: <20250203-converge-secs-to-jiffies-part-two-v2-0-d7058a01fd0e@linux.microsoft.com> To: Andrew Morton , Julia Lawall , Nicolas Palix , Ilya Dryomov , Dongsheng Yang , Jens Axboe , Xiubo Li Cc: cocci@inria.fr, linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, linux-block@vger.kernel.org, Easwar Hariharan X-Mailer: b4 0.14.2 Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced secs_to_jiffies(). As the value here is a multiple of 1000, use secs_to_jiffies() instead of msecs_to_jiffies to avoid the multiplication. This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with the following Coccinelle rules: @depends on patch@ expression E; @@ -msecs_to_jiffies(E * 1000) +secs_to_jiffies(E) @depends on patch@ expression E; @@ -msecs_to_jiffies(E * MSEC_PER_SEC) +secs_to_jiffies(E) While here, remove the no-longer necessary check for range since there's no multiplication involved. Signed-off-by: Easwar Hariharan Acked-by: Ilya Dryomov --- drivers/block/rbd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index faafd7ff43d6ef53110ab3663cc7ac322214cc8c..41207133e21e9203192adf3b92390818e8fa5a58 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -108,7 +108,7 @@ static int atomic_dec_return_safe(atomic_t *v) #define RBD_OBJ_PREFIX_LEN_MAX 64 #define RBD_NOTIFY_TIMEOUT 5 /* seconds */ -#define RBD_RETRY_DELAY msecs_to_jiffies(1000) +#define RBD_RETRY_DELAY secs_to_jiffies(1) /* Feature bits */ @@ -4162,7 +4162,7 @@ static void rbd_acquire_lock(struct work_struct *work) dout("%s rbd_dev %p requeuing lock_dwork\n", __func__, rbd_dev); mod_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork, - msecs_to_jiffies(2 * RBD_NOTIFY_TIMEOUT * MSEC_PER_SEC)); + secs_to_jiffies(2 * RBD_NOTIFY_TIMEOUT)); } } @@ -6283,9 +6283,7 @@ static int rbd_parse_param(struct fs_parameter *param, break; case Opt_lock_timeout: /* 0 is "wait forever" (i.e. infinite timeout) */ - if (result.uint_32 > INT_MAX / 1000) - goto out_of_range; - opt->lock_timeout = msecs_to_jiffies(result.uint_32 * 1000); + opt->lock_timeout = secs_to_jiffies(result.uint_32); break; case Opt_pool_ns: kfree(pctx->spec->pool_ns); From patchwork Mon Feb 3 23:50:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Easwar Hariharan X-Patchwork-Id: 13958413 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0134C20ADCF; Mon, 3 Feb 2025 23:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738626625; cv=none; b=m6NW5OvMIUNeMKywYW7QCd/CNrk5/8zMBLulpuSyHTiegjQrpANyyAqfhpE68tEXZjBsM/YK50TWvC2XhT8kBnarodrl9/VY6vwXKFUYS/yomGDfckoRPALzuixiqcuRWAQemA1hju4ccIi1PNd1k2ScsJGUtV4SdOp6UZ9EZ9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738626625; c=relaxed/simple; bh=ptKQwSeZ4N5bue1bB0zgDpOlUIKszvN84grZSQCcReQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pQ032g7apSrbeoRewfVrJT9KEiOcWqy1Y6aNP0VLDxdjPXeH45ZgnBVWQt9ramc21uFUoaN1UpICbtbjzJlb1FHrAuChr59OMSu33gqEAfVIZBFWMiNB/Dnt8Z7dcpCQINVHAiTLMRtG9tpNSsgp55aoVrxGld5EfGbd5aSe0hY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=StqwqgSN; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="StqwqgSN" Received: from eahariha-devbox.internal.cloudapp.net (unknown [40.91.112.99]) by linux.microsoft.com (Postfix) with ESMTPSA id 84A00205493E; Mon, 3 Feb 2025 15:50:23 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 84A00205493E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1738626623; bh=jl/YrVgNHMJyuougsZ83XWkAHGEtBSCoppF53ehyxrQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=StqwqgSNG2KkJyJsRG/IWgyvZ5UocaH2m/+dfcXUagDXBgaYXw89QgEKxugfrep4v dLKXw3DPl9XGMIJreixUiyn7yAWneAEebfFyONYlzSWFZngQlphknQdYWu13Rs37yX 3WP+/AGKzQjgplcS2c3XKuSfIiY+hG9bzK/eU1/c= From: Easwar Hariharan Date: Mon, 03 Feb 2025 23:50:24 +0000 Subject: [PATCH v2 3/3] libceph: convert timeouts to secs_to_jiffies() Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250203-converge-secs-to-jiffies-part-two-v2-3-d7058a01fd0e@linux.microsoft.com> References: <20250203-converge-secs-to-jiffies-part-two-v2-0-d7058a01fd0e@linux.microsoft.com> In-Reply-To: <20250203-converge-secs-to-jiffies-part-two-v2-0-d7058a01fd0e@linux.microsoft.com> To: Andrew Morton , Julia Lawall , Nicolas Palix , Ilya Dryomov , Dongsheng Yang , Jens Axboe , Xiubo Li Cc: cocci@inria.fr, linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, linux-block@vger.kernel.org, Easwar Hariharan X-Mailer: b4 0.14.2 Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced secs_to_jiffies(). As the value here is a multiple of 1000, use secs_to_jiffies() instead of msecs_to_jiffies to avoid the multiplication. This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with the following Coccinelle rules: @depends on patch@ expression E; @@ -msecs_to_jiffies(E * 1000) +secs_to_jiffies(E) @depends on patch@ expression E; @@ -msecs_to_jiffies(E * MSEC_PER_SEC) +secs_to_jiffies(E) While here, remove the no-longer necessary checks for range since there's no multiplication involved. Signed-off-by: Easwar Hariharan Acked-by: Ilya Dryomov --- include/linux/ceph/libceph.h | 12 ++++++------ net/ceph/ceph_common.c | 18 ++++++------------ net/ceph/osd_client.c | 3 +-- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h index 733e7f93db66a7a29a4a8eba97e9ebf2c49da1f9..5f57128ef0c7d018341c15cc59288aa47edec646 100644 --- a/include/linux/ceph/libceph.h +++ b/include/linux/ceph/libceph.h @@ -72,15 +72,15 @@ struct ceph_options { /* * defaults */ -#define CEPH_MOUNT_TIMEOUT_DEFAULT msecs_to_jiffies(60 * 1000) -#define CEPH_OSD_KEEPALIVE_DEFAULT msecs_to_jiffies(5 * 1000) -#define CEPH_OSD_IDLE_TTL_DEFAULT msecs_to_jiffies(60 * 1000) +#define CEPH_MOUNT_TIMEOUT_DEFAULT secs_to_jiffies(60) +#define CEPH_OSD_KEEPALIVE_DEFAULT secs_to_jiffies(5) +#define CEPH_OSD_IDLE_TTL_DEFAULT secs_to_jiffies(60) #define CEPH_OSD_REQUEST_TIMEOUT_DEFAULT 0 /* no timeout */ #define CEPH_READ_FROM_REPLICA_DEFAULT 0 /* read from primary */ -#define CEPH_MONC_HUNT_INTERVAL msecs_to_jiffies(3 * 1000) -#define CEPH_MONC_PING_INTERVAL msecs_to_jiffies(10 * 1000) -#define CEPH_MONC_PING_TIMEOUT msecs_to_jiffies(30 * 1000) +#define CEPH_MONC_HUNT_INTERVAL secs_to_jiffies(3) +#define CEPH_MONC_PING_INTERVAL secs_to_jiffies(10) +#define CEPH_MONC_PING_TIMEOUT secs_to_jiffies(30) #define CEPH_MONC_HUNT_BACKOFF 2 #define CEPH_MONC_HUNT_MAX_MULT 10 diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 4c6441536d55b6323f4b9d93b5d4837cd4ec880c..c2a2c3bcc4e91a628c99bd1cef1211d54389efa2 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -527,29 +527,23 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt, case Opt_osdkeepalivetimeout: /* 0 isn't well defined right now, reject it */ - if (result.uint_32 < 1 || result.uint_32 > INT_MAX / 1000) + if (result.uint_32 < 1) goto out_of_range; - opt->osd_keepalive_timeout = - msecs_to_jiffies(result.uint_32 * 1000); + opt->osd_keepalive_timeout = secs_to_jiffies(result.uint_32); break; case Opt_osd_idle_ttl: /* 0 isn't well defined right now, reject it */ - if (result.uint_32 < 1 || result.uint_32 > INT_MAX / 1000) + if (result.uint_32 < 1) goto out_of_range; - opt->osd_idle_ttl = msecs_to_jiffies(result.uint_32 * 1000); + opt->osd_idle_ttl = secs_to_jiffies(result.uint_32); break; case Opt_mount_timeout: /* 0 is "wait forever" (i.e. infinite timeout) */ - if (result.uint_32 > INT_MAX / 1000) - goto out_of_range; - opt->mount_timeout = msecs_to_jiffies(result.uint_32 * 1000); + opt->mount_timeout = secs_to_jiffies(result.uint_32); break; case Opt_osd_request_timeout: /* 0 is "wait forever" (i.e. infinite timeout) */ - if (result.uint_32 > INT_MAX / 1000) - goto out_of_range; - opt->osd_request_timeout = - msecs_to_jiffies(result.uint_32 * 1000); + opt->osd_request_timeout = secs_to_jiffies(result.uint_32); break; case Opt_share: diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index b24afec241382b60d775dd12a6561fa23a7eca45..ba61a48b4388c2eceb5b7a299906e7f90191dd5d 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -4989,8 +4989,7 @@ int ceph_osdc_notify(struct ceph_osd_client *osdc, linger_submit(lreq); ret = linger_reg_commit_wait(lreq); if (!ret) - ret = linger_notify_finish_wait(lreq, - msecs_to_jiffies(2 * timeout * MSEC_PER_SEC)); + ret = linger_notify_finish_wait(lreq, secs_to_jiffies(2 * timeout)); else dout("lreq %p failed to initiate notify %d\n", lreq, ret);