From patchwork Tue Oct 17 00:01:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010303 X-Patchwork-Delegate: snitzer@redhat.com 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 BDF1260235 for ; Tue, 17 Oct 2017 00:02:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACC2E28716 for ; Tue, 17 Oct 2017 00:02:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A076628718; Tue, 17 Oct 2017 00:02:03 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D3A428716 for ; Tue, 17 Oct 2017 00:02:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 79C7F7E381; Tue, 17 Oct 2017 00:02:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 79C7F7E381 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 79C7F7E381 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iISrw4UZ" Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D91F60606; Tue, 17 Oct 2017 00:01:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BB7E81800C90; Tue, 17 Oct 2017 00:01:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9H01sHX031094 for ; Mon, 16 Oct 2017 20:01:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2E0475D974; Tue, 17 Oct 2017 00:01:54 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2712D5D976 for ; Tue, 17 Oct 2017 00:01:52 +0000 (UTC) Received: from mail-pf0-f181.google.com (mail-pf0-f181.google.com [209.85.192.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 243C181DF0 for ; Tue, 17 Oct 2017 00:01:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 243C181DF0 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=keescook@chromium.org DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 243C181DF0 Received: by mail-pf0-f181.google.com with SMTP id a8so8277pfc.0 for ; Mon, 16 Oct 2017 17:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=//cnCDLv/xA7lzbZijx0J8tkzsb953FxO2MCiO1rycQ=; b=iISrw4UZBoF4RwIQk4Olr8LqQm2bJAOne9aJP4odQMTK4hxhTeKrNMvBNWhbLp8Gic RLsClNbWXFF0iOhCan5hPtSg6/VrVXu+wnmmlXU4OnwqARXzwzyhMeFk31pKo+J964M4 RPtZ1eta1bH2llgjcYCWaCzzRcEFYGl2DW82E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=//cnCDLv/xA7lzbZijx0J8tkzsb953FxO2MCiO1rycQ=; b=pvachEdjooSRlRK4OGcHwr2w2LXgk56cf7/T6kfnDFpI4pl4mmKpY7K34uYqL8PHTM lQIGOI3SSf4WJEsi7R9Suh6zCnla27QhLKffH4Mk0Mh60HUtQquqrDhlW9ocT38K2G+j hclfoaFGKPBWHcGqJdAPkfJwQSvlVnGJewgUyRaAzVe9bSd19x1flEmyUFwrpnyUIgMs FA0FHyNnLtR2UIqQzxFozjR398od1WRK849u/RlI03BjLoWeu0TUN3suvCxOBlOGG0wc KNRN1l+q0T5jkFMhuS6zmz/X4WxfwC7VNpQjFdrGZpwmRktORCehRgc5gnVbb54y6l59 rThw== X-Gm-Message-State: AMCzsaXSiuFDEtY0sQiSAtyDy/1zWlhYpA9v/ftI3xUGtV1YAn9O+A+v LSnDZCvcMK3aC53ZyOeJ18lSow== X-Google-Smtp-Source: AOwi7QDMl0qsCuadvK5H1bgptnQiafO3mQv46uHL03o8sz/2AQ91XEg5Q2wXJl2k6L7XEJWyHtLkVg== X-Received: by 10.84.244.203 with SMTP id f11mr10253488plt.187.1508198510647; Mon, 16 Oct 2017 17:01:50 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id k3sm8348370pfc.44.2017.10.16.17.01.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 17:01:49 -0700 (PDT) Date: Mon, 16 Oct 2017 17:01:48 -0700 From: Kees Cook To: Shaohua Li Message-ID: <20171017000148.GA102867@beast> MIME-Version: 1.0 Content-Disposition: inline X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 17 Oct 2017 00:01:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 17 Oct 2017 00:01:51 +0000 (UTC) for IP:'209.85.192.181' DOMAIN:'mail-pf0-f181.google.com' HELO:'mail-pf0-f181.google.com' FROM:'keescook@chromium.org' RCPT:'' X-RedHat-Spam-Score: -2.411 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.192.181 mail-pf0-f181.google.com 209.85.192.181 mail-pf0-f181.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: Mike Snitzer , dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-bcache@vger.kernel.org, Kent Overstreet , Alasdair Kergon Subject: [dm-devel] [PATCH] md: Convert timers to use timer_setup() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 17 Oct 2017 00:02:02 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Cc: Kent Overstreet Cc: Shaohua Li Cc: Alasdair Kergon Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: linux-bcache@vger.kernel.org Cc: linux-raid@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Michael Lyle Reviewed-by: Mike Snitzer --- drivers/md/bcache/stats.c | 8 +++----- drivers/md/dm-delay.c | 6 +++--- drivers/md/dm-integrity.c | 6 +++--- drivers/md/dm-raid1.c | 8 +++----- drivers/md/md.c | 9 ++++----- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/md/bcache/stats.c b/drivers/md/bcache/stats.c index 0ca072c20d0d..93a89c528760 100644 --- a/drivers/md/bcache/stats.c +++ b/drivers/md/bcache/stats.c @@ -146,9 +146,9 @@ static void scale_stats(struct cache_stats *stats, unsigned long rescale_at) } } -static void scale_accounting(unsigned long data) +static void scale_accounting(struct timer_list *t) { - struct cache_accounting *acc = (struct cache_accounting *) data; + struct cache_accounting *acc = from_timer(acc, t, timer); #define move_stat(name) do { \ unsigned t = atomic_xchg(&acc->collector.name, 0); \ @@ -233,9 +233,7 @@ void bch_cache_accounting_init(struct cache_accounting *acc, kobject_init(&acc->day.kobj, &bch_stats_ktype); closure_init(&acc->cl, parent); - init_timer(&acc->timer); + timer_setup(&acc->timer, scale_accounting, 0); acc->timer.expires = jiffies + accounting_delay; - acc->timer.data = (unsigned long) acc; - acc->timer.function = scale_accounting; add_timer(&acc->timer); } diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c index 2209a9700acd..288386bfbfb5 100644 --- a/drivers/md/dm-delay.c +++ b/drivers/md/dm-delay.c @@ -44,9 +44,9 @@ struct dm_delay_info { static DEFINE_MUTEX(delayed_bios_lock); -static void handle_delayed_timer(unsigned long data) +static void handle_delayed_timer(struct timer_list *t) { - struct delay_c *dc = (struct delay_c *)data; + struct delay_c *dc = from_timer(dc, t, delay_timer); queue_work(dc->kdelayd_wq, &dc->flush_expired_bios); } @@ -195,7 +195,7 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv) goto bad_queue; } - setup_timer(&dc->delay_timer, handle_delayed_timer, (unsigned long)dc); + timer_setup(&dc->delay_timer, handle_delayed_timer, 0); INIT_WORK(&dc->flush_expired_bios, flush_expired_bios); INIT_LIST_HEAD(&dc->delayed_bios); diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 096fe9b66c50..98f0b645b839 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -1093,9 +1093,9 @@ static void sleep_on_endio_wait(struct dm_integrity_c *ic) __remove_wait_queue(&ic->endio_wait, &wait); } -static void autocommit_fn(unsigned long data) +static void autocommit_fn(struct timer_list *t) { - struct dm_integrity_c *ic = (struct dm_integrity_c *)data; + struct dm_integrity_c *ic = from_timer(ic, t, autocommit_timer); if (likely(!dm_integrity_failed(ic))) queue_work(ic->commit_wq, &ic->commit_work); @@ -2941,7 +2941,7 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv) ic->autocommit_jiffies = msecs_to_jiffies(sync_msec); ic->autocommit_msec = sync_msec; - setup_timer(&ic->autocommit_timer, autocommit_fn, (unsigned long)ic); + timer_setup(&ic->autocommit_timer, autocommit_fn, 0); ic->io = dm_io_client_create(); if (IS_ERR(ic->io)) { diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index c0b82136b2d1..580c49cc8079 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c @@ -94,9 +94,9 @@ static void wakeup_mirrord(void *context) queue_work(ms->kmirrord_wq, &ms->kmirrord_work); } -static void delayed_wake_fn(unsigned long data) +static void delayed_wake_fn(struct timer_list *t) { - struct mirror_set *ms = (struct mirror_set *) data; + struct mirror_set *ms = from_timer(ms, t, timer); clear_bit(0, &ms->timer_pending); wakeup_mirrord(ms); @@ -108,8 +108,6 @@ static void delayed_wake(struct mirror_set *ms) return; ms->timer.expires = jiffies + HZ / 5; - ms->timer.data = (unsigned long) ms; - ms->timer.function = delayed_wake_fn; add_timer(&ms->timer); } @@ -1133,7 +1131,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) goto err_free_context; } INIT_WORK(&ms->kmirrord_work, do_mirror); - init_timer(&ms->timer); + timer_setup(&ms->timer, delayed_wake_fn, 0); ms->timer_pending = 0; INIT_WORK(&ms->trigger_event, trigger_event); diff --git a/drivers/md/md.c b/drivers/md/md.c index 97afb28c6f51..873a20f44197 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -520,7 +520,7 @@ static void mddev_put(struct mddev *mddev) bioset_free(sync_bs); } -static void md_safemode_timeout(unsigned long data); +static void md_safemode_timeout(struct timer_list *t); void mddev_init(struct mddev *mddev) { @@ -529,8 +529,7 @@ void mddev_init(struct mddev *mddev) mutex_init(&mddev->bitmap_info.mutex); INIT_LIST_HEAD(&mddev->disks); INIT_LIST_HEAD(&mddev->all_mddevs); - setup_timer(&mddev->safemode_timer, md_safemode_timeout, - (unsigned long) mddev); + timer_setup(&mddev->safemode_timer, md_safemode_timeout, 0); atomic_set(&mddev->active, 1); atomic_set(&mddev->openers, 0); atomic_set(&mddev->active_io, 0); @@ -5386,9 +5385,9 @@ static int add_named_array(const char *val, struct kernel_param *kp) return -EINVAL; } -static void md_safemode_timeout(unsigned long data) +static void md_safemode_timeout(struct timer_list *t) { - struct mddev *mddev = (struct mddev *) data; + struct mddev *mddev = from_timer(mddev, t, safemode_timer); mddev->safemode = 1; if (mddev->external)