Received: by 10.223.185.116 with SMTP id b49csp1074579wrg; Sat, 3 Mar 2018 14:51:15 -0800 (PST) X-Google-Smtp-Source: AG47ELvtqOdpBxAYvgriFM2zsMdy8FlpN9cYxrTZR1ODBgGBS/XuecmLZf9ZLHNBxevbalk42RNG X-Received: by 10.98.69.196 with SMTP id n65mr10359353pfi.29.1520117475851; Sat, 03 Mar 2018 14:51:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520117475; cv=none; d=google.com; s=arc-20160816; b=bFu7XNhkYsvXSyP3OhEwMQM8ubj5h9qyjJzOZI3scVHKhLUygIwBP1rBFzRswLer/i c10qP79h2pnUyzBIpJh6sbaWjL8k+xhw2yq6YLnt73GKdw4bGUDkkBKoHUiyXwzG8R80 qUVsZn7YJeiFh3DeYhTacj9sK3uzOigLDvT55iAa2oWuBTXsDB+JEYDXrUTiCs6x/Nz/ DfK7sRo41JYi169QpeYCjrWo30HuIUdZO9mWjsJd3SFOM2UwqKYxSyMkHMCtY6Ju9Wag lXxT7IttPIykoqNSCKjI/Y03RjwG111JhC1E0OG+VGHl4gncNS6Zwx6t/whiGPvJV5AX N9wQ== 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=4Snu5BWBnPZw9arcAC5sibRVovYIKv+F83/7kUxtUnI=; b=R1sLkQE57RwFr5XQoCDK2nlfVd5DMitBNPhlrI2NRys/VboHxrV3Bpg/T8lIlVKzN9 rH1Pwo/zDVCHv1nyyfwTMe+4JD/aeQPNZ6U/8UQSECSc56OYxFH3DqIL+23kBK6AqOxr wblxhWEoeIHt1vEiswCfKr8smid1ZhqTXPoddpyVmYX4mCo9akQeJx2QvmZ3UWuPCjgo qjK+PO4D9+1AXeS/PtFIMIfBkUQRKVFOQqGGezFOMNN1fKsuqSGi1OWCLzBjfjbyweFZ CZjKGcgXCLty7rmT/LtM9GG167dFIcNbB0KDFnBGiQw9Qy2IP439mgaHSBc4vATjgF11 6ynQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=X2SjN6Ly; 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 k11-v6si6799885pls.58.2018.03.03.14.51.01; Sat, 03 Mar 2018 14:51:15 -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=X2SjN6Ly; 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 S934567AbeCCWuT (ORCPT + 99 others); Sat, 3 Mar 2018 17:50:19 -0500 Received: from mail-cys01nam02on0126.outbound.protection.outlook.com ([104.47.37.126]:64496 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935470AbeCCWlO (ORCPT ); Sat, 3 Mar 2018 17:41: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=4Snu5BWBnPZw9arcAC5sibRVovYIKv+F83/7kUxtUnI=; b=X2SjN6LybCTsJn8Mq8gE86apLBAjpgYMujNWdZEU6ko+Jv4T0ueTJ5QslxhY3706RIo3kme5xVCyEE0dqA049JCCm48qomjkclJHL96GqAVsZOICJUXOqz4x0O6qWvrHE82iWHG+BnaDJ0lQ4U1WG+jYrnXTxyqwsvLVgVZdSp4= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2SPR01MB06.namprd21.prod.outlook.com (52.132.152.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.3; Sat, 3 Mar 2018 22:41:11 +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:41:10 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Jan Kara , Sasha Levin Subject: [PATCH AUTOSEL for 3.18 30/63] reiserfs: Make cancel_old_flush() reliable Thread-Topic: [PATCH AUTOSEL for 3.18 30/63] reiserfs: Make cancel_old_flush() reliable Thread-Index: AQHTsz+mP/DYhJyksE+HmaCQcSjcOw== Date: Sat, 3 Mar 2018 22:33:27 +0000 Message-ID: <20180303223228.27323-30-alexander.levin@microsoft.com> References: <20180303223228.27323-1-alexander.levin@microsoft.com> In-Reply-To: <20180303223228.27323-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;MW2SPR01MB06;7:AK04SzPb2XbFYLJobO45cHPjcLg0aKMOg/ZMMTJ45sxCVEjwAhAfZR1EKzIhwoSsXICgVd5J0Ei/6LaJNtvYCNbspEGWwdenKc/5P2OkgwfbDXtO5R0TQKjNLtir8bDfMogJlNx22o2jzG7mwujFGSS0zbzZV1fXhvAhN4vtDOi7+rCs0nPzNqbhdjELJq7N4ceQLCAD0VCNyd2Bn3JhMzs4VhExYh6rovCNHLP9h1WVXkHVtPSamYn0/Vdfglum x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 25d90c8d-849f-4d61-fc9c-08d58157dcd2 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2SPR01MB06; x-ms-traffictypediagnostic: MW2SPR01MB06: 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)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:MW2SPR01MB06;BCL:0;PCL:0;RULEID:;SRVR:MW2SPR01MB06; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(396003)(39860400002)(39380400002)(366004)(376002)(189003)(199004)(3660700001)(8936002)(72206003)(5660300001)(14454004)(110136005)(6512007)(4326008)(6506007)(26005)(2501003)(66066001)(86362001)(7736002)(54906003)(305945005)(25786009)(10290500003)(53936002)(6436002)(2906002)(81156014)(59450400001)(551934003)(8676002)(478600001)(102836004)(106356001)(316002)(186003)(5250100002)(81166006)(6486002)(76176011)(86612001)(6666003)(2900100001)(3846002)(68736007)(97736004)(36756003)(1076002)(107886003)(2950100002)(105586002)(99286004)(6116002)(3280700002)(22452003)(10090500001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2SPR01MB06;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: 2UDmCc09x7yGvF0/PMQJghWXjsMlXVgqYKiOvgz6mnMe5JRy5zGilcT7dF3kEpxgdgfPuCNprXjRs9/oSfPzMRvwli8lftniteKLa+bJIqOgHTZBpVuS9ADYGdE78By1aiwdaBY6zvk+VOpYsVCvF199mf5LkX9YdmPUBZoFRWQ= 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: 25d90c8d-849f-4d61-fc9c-08d58157dcd2 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:33:27.9194 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2SPR01MB06 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 d571e173a990..e503effd284d 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c @@ -1961,7 +1961,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 1894d96ccb7c..8fb8107710f7 100644 --- a/fs/reiserfs/reiserfs.h +++ b/fs/reiserfs/reiserfs.h @@ -2946,6 +2946,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 b27ef3541490..5b8acce4f863 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -89,7 +89,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); @@ -116,21 +118,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)) { @@ -151,7 +154,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 @@ -2164,7 +2173,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