Received: by 10.223.185.116 with SMTP id b49csp1106129wrg; Sat, 3 Mar 2018 15:44:25 -0800 (PST) X-Google-Smtp-Source: AG47ELv+lgD+NCWKlLuk8kc5HAgPYrB7Z2Bci68BR1Jh2QxaQ0jzmqw4tVD/ge5LoONL6FlUySS9 X-Received: by 10.101.83.194 with SMTP id z2mr8349727pgr.133.1520120665098; Sat, 03 Mar 2018 15:44:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520120665; cv=none; d=google.com; s=arc-20160816; b=Jd+54ew8sQk8/LgCw3MuGs+xacCAuuRenquqCfyAJRf/WY5B0K0oiftamATslkEG5j padbCITImACtm1jyILy8BgweWV7Y4f7KO9vOoWE6/vprlJgTAlRPb1E3GZuvzId7WpAP 6pmM9n56Lf5hVQfSgpcOJOj/JkshDdpPzilbwJQCnZd0jxvXAEZG/+ikfh2GSWCfhp+t IdRcSp1U0k5h49qOC9jjoPQVwEPnMh31Rxdps4U27GuAiPk5XbB8P48O8vV2PWReLmK/ /JJ00wrLAWisSkLwThq1tSZdAmXKIhsGLobRphXVh46qefBYx8DT+M4qI3WBtu/opseI iRlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=vHwxV293KrEbYuXMmc+cusnkkZt7IK3EwReDQEMawT0=; b=VNHmzQfwlRX++WRQy7lYB0JekoY8md7f4Ifm5gLBXEUJisdUtaNKwR2ioORvsLuXAj vUcKS7FVbY9WTdaUotM8bzUQFJhe0E8OB79gjopOW/l5m4YXy+2g0xRLNaCVMHCpW/aK PGau6Qhojil5+ZBmyacYFV5Nu9GE5Igo61a30RTg4xZhoM8XWgyGeBU1MQ5LkdivPaH3 +GLD5PBkjfNj+zcVKwI6bKfOM5+o0EVpUZj6pUKq9p9mVGBR0N/2/E5O55Uzwd12eoYM y0QnhsVJ/4d25ohGs7mm7dOvkzvA300D/ZFAy7Qh3XaM53TxU48ezp4e3GaoUZMVVS9I bv2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=FGU8Y5es; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7-v6si6972529plz.119.2018.03.03.15.44.11; Sat, 03 Mar 2018 15:44:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=FGU8Y5es; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934260AbeCCWek (ORCPT + 99 others); Sat, 3 Mar 2018 17:34:40 -0500 Received: from mail-bn3nam01on0104.outbound.protection.outlook.com ([104.47.33.104]:36491 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934080AbeCCWeO (ORCPT ); Sat, 3 Mar 2018 17:34:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=vHwxV293KrEbYuXMmc+cusnkkZt7IK3EwReDQEMawT0=; b=FGU8Y5esjN59/xJcXG9QXm9aEMAkXX6UchXUi7wRn369WilsSiK4K3ZOIl0w3P5JXT7BSfvZ9PKzR5DYE0KXKst0i79BFbjPUk2tYLa6AN1KR9NdI3y9sIRVCLN6dE2ZjRvOWQcjEWzIt90geqbd+BHZYDCs0H/fCff8eccnTsE= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB1065.namprd21.prod.outlook.com (52.132.149.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.2; Sat, 3 Mar 2018 22:34:05 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:34:05 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Jan Kara , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 110/219] reiserfs: Make cancel_old_flush() reliable Thread-Topic: [PATCH AUTOSEL for 4.9 110/219] reiserfs: Make cancel_old_flush() reliable Thread-Index: AQHTsz8G9mjfzgUXKEGKOfaCUwcmbQ== Date: Sat, 3 Mar 2018 22:28:59 +0000 Message-ID: <20180303222716.26640-110-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB1065;7:UdShUaOC1izOZnZehnmkXreCE8B/XhXi0F3DbgGoFBVb6zf+ng99SIcex6bnifiBSqo/aCQpBiYkOPudoCbn01uyWfayU+kaR52JuCLEn4cYydkyDZ4nRek/NKtbtTeDJx99cqFj/A1kWXksbzu9muXElc04eBkPiepmVhTPSYhc+kDuq5O73mf9WrHuZy4ilgY9a/MslMylFos9nhtth7sS2KJa+QWwaaUVV10cb4sDLF4uax/4youessnj7QCb x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 184e69be-4859-41a3-737b-08d58156df63 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2PR2101MB1065; x-ms-traffictypediagnostic: MW2PR2101MB1065: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231220)(944501244)(52105095)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB1065;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB1065; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(346002)(376002)(396003)(39380400002)(39860400002)(189003)(199004)(6506007)(22452003)(54906003)(25786009)(6666003)(186003)(2950100002)(102836004)(5250100002)(2501003)(110136005)(97736004)(316002)(2900100001)(36756003)(76176011)(6436002)(59450400001)(6486002)(26005)(4326008)(99286004)(551934003)(68736007)(6512007)(6116002)(10090500001)(106356001)(105586002)(478600001)(66066001)(107886003)(3660700001)(305945005)(86612001)(14454004)(81166006)(7736002)(86362001)(1076002)(72206003)(2906002)(10290500003)(8676002)(8936002)(81156014)(3846002)(5660300001)(3280700002)(53936002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB1065;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: PZLQuFHtQe/HSJQ/cSQOeoPbpYuA8rkKejMwtfVcY9KGIAY4wiDyilS+yUi9bT8v/Lk6WJjnntvtpyzHxOavN4/wOp1huiWddVnoMNPhfA/VwcNJP/vxQUuv0PzMfS5tni9JxS1MFLMA9ncQJdzKowlFn9945ynbSuPHs/pdV2I= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 184e69be-4859-41a3-737b-08d58156df63 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:28:59.6350 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB1065 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara [ Upstream commit 71b0576bdb862e964a82c73327cdd1a249c53e67 ] Currently canceling of delayed work that flushes old data using cancel_old_flush() does not prevent work from being requeued. Thus in theory new work can be queued after cancel_old_flush() from reiserfs_freeze() has run. This will become larger problem once flush_old_commits() can requeue the work itself. Fix the problem by recording in sbi->work_queue that flushing work is canceled and should not be requeued. Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/reiserfs/journal.c | 2 +- fs/reiserfs/reiserfs.h | 1 + fs/reiserfs/super.c | 21 +++++++++++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index bc2dde2423c2..76108185854e 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c @@ -1959,7 +1959,7 @@ static int do_journal_release(struct reiserfs_transac= tion_handle *th, * will be requeued because superblock is being shutdown and doesn't * have MS_ACTIVE set. */ - cancel_delayed_work_sync(&REISERFS_SB(sb)->old_work); + reiserfs_cancel_old_flush(sb); /* wait for all commits to finish */ cancel_delayed_work_sync(&SB_JOURNAL(sb)->j_work); =20 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h index 5dcf3ab83886..6ca00471afbf 100644 --- a/fs/reiserfs/reiserfs.h +++ b/fs/reiserfs/reiserfs.h @@ -2948,6 +2948,7 @@ int reiserfs_allocate_list_bitmaps(struct super_block= *s, struct reiserfs_list_bitmap *, unsigned int); =20 void reiserfs_schedule_old_flush(struct super_block *s); +void reiserfs_cancel_old_flush(struct super_block *s); void add_save_link(struct reiserfs_transaction_handle *th, struct inode *inode, int truncate); int remove_save_link(struct inode *inode, int truncate); diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index e101d70d2327..dec6c93044fa 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -90,7 +90,9 @@ static void flush_old_commits(struct work_struct *work) s =3D sbi->s_journal->j_work_sb; =20 spin_lock(&sbi->old_work_lock); - sbi->work_queued =3D 0; + /* Avoid clobbering the cancel state... */ + if (sbi->work_queued =3D=3D 1) + sbi->work_queued =3D 0; spin_unlock(&sbi->old_work_lock); =20 reiserfs_sync_fs(s, 1); @@ -117,21 +119,22 @@ void reiserfs_schedule_old_flush(struct super_block *= s) spin_unlock(&sbi->old_work_lock); } =20 -static void cancel_old_flush(struct super_block *s) +void reiserfs_cancel_old_flush(struct super_block *s) { struct reiserfs_sb_info *sbi =3D REISERFS_SB(s); =20 - cancel_delayed_work_sync(&REISERFS_SB(s)->old_work); spin_lock(&sbi->old_work_lock); - sbi->work_queued =3D 0; + /* Make sure no new flushes will be queued */ + sbi->work_queued =3D 2; spin_unlock(&sbi->old_work_lock); + cancel_delayed_work_sync(&REISERFS_SB(s)->old_work); } =20 static int reiserfs_freeze(struct super_block *s) { struct reiserfs_transaction_handle th; =20 - cancel_old_flush(s); + reiserfs_cancel_old_flush(s); =20 reiserfs_write_lock(s); if (!(s->s_flags & MS_RDONLY)) { @@ -152,7 +155,13 @@ static int reiserfs_freeze(struct super_block *s) =20 static int reiserfs_unfreeze(struct super_block *s) { + struct reiserfs_sb_info *sbi =3D REISERFS_SB(s); + reiserfs_allow_writes(s); + spin_lock(&sbi->old_work_lock); + /* Allow old_work to run again */ + sbi->work_queued =3D 0; + spin_unlock(&sbi->old_work_lock); return 0; } =20 @@ -2194,7 +2203,7 @@ error_unlocked: if (sbi->commit_wq) destroy_workqueue(sbi->commit_wq); =20 - cancel_delayed_work_sync(&REISERFS_SB(s)->old_work); + reiserfs_cancel_old_flush(s); =20 reiserfs_free_bitmap_cache(s); if (SB_BUFFER_WITH_SB(s)) --=20 2.14.1