From patchwork Mon Dec 31 19:48:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 1019706 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mit.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mit.edu header.i=@mit.edu header.b="SXvsg/sf"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43T7D32bcwz9sLw for ; Tue, 1 Jan 2019 06:48:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727495AbeLaTsr (ORCPT ); Mon, 31 Dec 2018 14:48:47 -0500 Received: from mail-eopbgr810107.outbound.protection.outlook.com ([40.107.81.107]:16128 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727392AbeLaTsq (ORCPT ); Mon, 31 Dec 2018 14:48:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gi5My60Ro39yuKVArOEuY8JPynHO2j53/VU0S24HU5c=; b=SXvsg/sfFghQm0V/jEb/hHRHa27Ap6RrSDWSoMF1vy7uxpR+0eE3iGl6VbT+BqskLzgTEx1wQhaeBL92ZgZ5WwRRkDjQx9EDT0qUBuXuw0mzjqPp2jw/5WwH9jZsb3o1bh4RGQzrcz4pTYETPCnQgHHErnmiNh4q5EUN9cNxf4E= Received: from BL0PR0102CA0042.prod.exchangelabs.com (2603:10b6:208:25::19) by CY4PR0101MB2951.prod.exchangelabs.com (2603:10b6:910:3f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1471.20; Mon, 31 Dec 2018 19:48:43 +0000 Received: from BY2NAM03FT047.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::206) by BL0PR0102CA0042.outlook.office365.com (2603:10b6:208:25::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1471.20 via Frontend Transport; Mon, 31 Dec 2018 19:48:42 +0000 Authentication-Results: spf=pass (sender IP is 18.9.28.11) smtp.mailfrom=mit.edu; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=mit.edu; Received-SPF: Pass (protection.outlook.com: domain of mit.edu designates 18.9.28.11 as permitted sender) receiver=protection.outlook.com; client-ip=18.9.28.11; helo=outgoing.mit.edu; Received: from outgoing.mit.edu (18.9.28.11) by BY2NAM03FT047.mail.protection.outlook.com (10.152.85.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1471.13 via Frontend Transport; Mon, 31 Dec 2018 19:48:41 +0000 Received: from callcc.thunk.org ([104.200.153.98]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id wBVJmdV4006846 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Dec 2018 14:48:40 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id A65CA7A018D; Mon, 31 Dec 2018 14:48:38 -0500 (EST) From: Theodore Ts'o To: Ext4 Developers List CC: Theodore Ts'o , Subject: [PATCH 2/3] ext4: use ext4_write_inode() when fsyncing w/o a journal Date: Mon, 31 Dec 2018 14:48:35 -0500 Message-ID: <20181231194836.3761-2-tytso@mit.edu> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181231194836.3761-1-tytso@mit.edu> References: <20181231194836.3761-1-tytso@mit.edu> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:18.9.28.11; IPV:CAL; SCL:-1; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(346002)(39860400002)(376002)(396003)(136003)(2980300002)(199004)(189003)(6266002)(52956003)(106466001)(356004)(6666004)(336012)(4326008)(5660300001)(2616005)(478600001)(476003)(11346002)(486006)(103686004)(14444005)(1076003)(126002)(26826003)(446003)(106002)(86362001)(90966002)(42186006)(316002)(786003)(54906003)(75432002)(246002)(76176011)(36756003)(51416003)(305945005)(8936002)(48376002)(50466002)(50226002)(186003)(26005)(47776003)(2906002)(36906005)(88552002)(6916009)(2870700001)(8676002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR0101MB2951; H:outgoing.mit.edu; FPR:; SPF:Pass; LANG:en; PTR:outgoing-auth-1.mit.edu; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT047; 1:NMfx1rMrbwrAPVZJKYi+0Ydzz9+dXVzMe6WcLoc5x/F/mTV9OXL5kZnRfPSwOhByUUYJ3S7AHGK+iM3WCvfM3pOzfqFiInITgC+g28GBNP1tTX+p45th6GyIfeiBTx3x X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c3399440-6df2-47bd-b3f0-08d66f58f7b4 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4608076)(4709027)(2017052603328)(7153060); SRVR:CY4PR0101MB2951; X-Microsoft-Exchange-Diagnostics: 1; CY4PR0101MB2951; 3:1OTv5QW6jIwG+0IvY0oLft8aQNElXwSexgO865MVF/9+eWWk2x6VfHdTQ4HusYs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lMemjS8snLyY3bHckRQVN1EwxNP/CZZCc6ShQRR9+soPfoDCdJin+/0nfRLMAE2V5aeKxeSCslqyO7clDUG81pdeSqHhmzhFE9TQlhGeQUVS45Jr5jDaZwCWUCXb+5jzpUDEPFjUYrnjJ83kq43QujDsK90mvymYT9aQnuOlYa2XVKLY+i9+FSeH3bfmYBtZ5M5oEUzro73H8xblglbcODRQgKwwFRnxUgaXzrw/PF7eU41z7ZqGOBZnyJ0VZIbuyt9gEYa0JLC6Dt0lqe3i40GJy9JLykJ9X9N9/4Nh0NnKx3aC4JD4xMNMiCvI8RHg/sIA+DWiAnzyBzB1+fFKsAt8ZI2Pq6yIqGmmwgV5iI2hne50ZIwIVxZlcnNpm8lidnxvOFjXp1RSvaNBxkBVIaZ1Uc08owDP3SDqHZ8Fw7H; 4:QH6Pu0VsRjBZAaTijhgNbqED7jVlhC2Ka09abNws0I2Rjo5X4mglc/Ao4oBMxqKGg+0WqABpS42fD0s186gBdsCDKRWr9J4I9mfSY7f16GhHRapBUU5hkpqU7rru0XEArOaxoyvRwkrqIVJXYVkrXa/qkR/i9q8ml4HsOmoVajsqmVil5hevT7Rd8rLqkGZsnFDA+jonVULG2DexqxmMTDzOjFYa8VgcWmObSrj3oOFI6C5KvYdUJhQSqa2s0fCflO60T6CtcepW1kQIqOtufA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(8220055)(2401047)(8121501046)(3002001)(3231475)(944501520)(52105112)(10201501046)(93006095)(93004095)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(201702281529075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:CY4PR0101MB2951; BCL:0; PCL:0; RULEID:; SRVR:CY4PR0101MB2951; X-Forefront-PRVS: 0903DD1D85 X-Microsoft-Exchange-Diagnostics: 1; CY4PR0101MB2951; 23:zi2fM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JFzQ9yujDHRk45mbLJqaAiLOoroGJ5+sF8SqmE8dHdbOdVcNW+mw89iQGfqpIHY4Y9ME2EXWc3mkw== X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: rb3KEopYG/Bf/Fi6bAaee9ITou9GRkWu0KgobwKaeXEvoey7YuHFZLbrhiFFh44fkTa0zOVEcIEPIIwbIjRHU4grNdaRBWDBtERWUM/XiFnJOsQ2ZRSYfSTT78XhFDh8z9U8NsCKp9r2a2Ky75srv+N0T065zTj04z82oIwti4lj2hXOoO9wui265oGZmYMqO0dN3EvkPCm3ScFEDzjYw+qEDxn1rrsNNBxOM09TJLoDp35KwCpwcxwZsG5ZsrgSouLRvi7Ua9E4zIQLmQN1vYw+9HdV3R3LCC35hioL8YEFrR0jDK6m3ONvnUOuDEGb X-Microsoft-Exchange-Diagnostics: 1; CY4PR0101MB2951; 6:b9j7OqumA5GC03nNwitVIenBSM5r7IUEUqgp23TMVJ1Y1drMshP29yaJfCbFquxGinZxTopHUzHuL6jQ6zCWkmkWUJO2d+AnVH8XUUy114MCbc8wA4N3UHinGpNNYkctC5R7i+yK/Jsi9ScQyD/lTk/pqUhavowiBrDp+5xr1zCbbyz5BQXPaeIerNWSfwOfo5Dgt5FKf1kAmniXHYCWJ88eGfDyKHXVW3xoiU9ubV1HbIJsIWkJBbxS72emhfn9+NAIjYVGozGY67u3RTqumMw1f3knUCc+5oqeyIQTwvoDXKxragz6O8gGVeoA5qmiJjzruZOsIwVIHdoCYfjCaxVptYJFex2fz7MtnBz4MvkdUQP0B1bTwJqXvGpzsyxsmaMcb9cGifNwXPwFvxRplGe69cJ0daSQmKYvepMHBk6Gf6tpUkBE+c6DBiDrXVVOB3Vacm4N7fQqIss25V2OLA==; 5:3SZUkENQvom929H4MAW+a+JARoGJ00CXk7myiR9gcsYD2kcpAdolMTYJ8QQn4XSYv4xPrhwTkcK9CvmEnxJKl2wHyZPD+srpJPiJNd/3EorRJ+kHrGuhB+7vn9yhzMCJO39KHjMd8h1OC5fQfYMNmso3sgFoi4IvmJ4yqaupuJ8=; 7:mEIruvWBaL3ZZoAzGbl4Eewkclgie07qcfYfqVI+AL/E3D3CgT6AmWb09GmcwdzP/Vp5biiK19fzaQ6er6Y5EvEuNLmoAv2nUjbjEQQV38ri7VilCFesXz1d3WjKZd3qezO0Amb+qClHZ9WCG013HQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: mit.edu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Dec 2018 19:48:41.9998 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3399440-6df2-47bd-b3f0-08d66f58f7b4 X-MS-Exchange-CrossTenant-Id: 64afd9ba-0ecf-4acf-bc36-935f6235ba8b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=64afd9ba-0ecf-4acf-bc36-935f6235ba8b; Ip=[18.9.28.11]; Helo=[outgoing.mit.edu] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0101MB2951 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In no-journal mode, we previously used __generic_file_fsync() in no-journal mode. This triggers a lockdep warning, and in addition, it's not safe to depend on the inode writeback mechanism in the case ext4. We can solve both problems by calling ext4_write_inode() directly. Signed-off-by: Theodore Ts'o Cc: stable@kernel.org --- fs/ext4/fsync.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c index 26a7fe5c4fd3..87a7ff00ef62 100644 --- a/fs/ext4/fsync.c +++ b/fs/ext4/fsync.c @@ -116,8 +116,16 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) goto out; } + ret = file_write_and_wait_range(file, start, end); + if (ret) + return ret; + if (!journal) { - ret = __generic_file_fsync(file, start, end, datasync); + struct writeback_control wbc = { + .sync_mode = WB_SYNC_ALL + }; + + ret = ext4_write_inode(inode, &wbc); if (!ret) ret = ext4_sync_parent(inode); if (test_opt(inode->i_sb, BARRIER)) @@ -125,9 +133,6 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) goto out; } - ret = file_write_and_wait_range(file, start, end); - if (ret) - return ret; /* * data=writeback,ordered: * The caller's filemap_fdatawrite()/wait will sync the data.