Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1315556yba; Tue, 2 Apr 2019 06:44:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzB7NG2WgAaW77QaxHk17TYk36cXi4HKliuLrpxhHbcqpT+NA7nR2JgnOYtsqFLUF5LOrzm X-Received: by 2002:a17:902:241:: with SMTP id 59mr35331942plc.79.1554212668015; Tue, 02 Apr 2019 06:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554212668; cv=none; d=google.com; s=arc-20160816; b=JSaGcxj2U7FmKJE3wU4BpERVT/Lz6eL8FdHIYfO26ArDgK9mwPknv6VxM1Mra2VCqt 3J/xu9KI0Pw8frh8e3NyFESrQEIXGjqUhgnFBOqpp1vPfDWJ2KfCDnOQFsH+lTDRt8J5 2qQHVXfUxsrt6Ard0T82av9NUOSpKC7tXEgvM0UtrcoOxTntpfld74cbqLK1N6srwpyD Eb+W8ZDCNWzR4NJ9Bs5dkL0eqUNcP6EPX0ldpCwJb1zDC/mamu486yhm9xNGt3bk1Bov 7oJF5dAcGoSo/q5I7tmrfcxgXLCPHOCCQhGgb6vuOLs9EOAHbgINYEHUAnKcaH6NS0Sn yHfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=d/PBGqmXLMQ00D6UnRBnewwux9iAGoFDPd9Xyg/zoz0=; b=uP/JEBTiRlzRHKTukHAY1GfEnuJSQ5YRDtrGekpiMil3fjuGECfiP1RPIPeHDOtG+G ISxjD7FO9O6uxufRUMEBaOMucmMgNOJlsaphDm2aDo204+TmdK2tAjgbvN3LdqE0ssb/ GJSZyGLaLF4LJp1UpsguiKFRuEhiLnQN+5oa2JF1rYXrn4rm/CY5aIAKQPuxmzan4vpb mZiMBpNgkkt0gZkUm/ZaeXbQn1Q76RZyN6wNTW7I1sDVKV+k0OzjWhONCZzCHHw+7Y3V AfipSTRRiv7AoD04V7JdbU23wtDqINso2P5s08Jf0yQX98jUyuxXX3oQw4pXJs6G5cYB beyw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si11217175pfa.268.2019.04.02.06.44.12; Tue, 02 Apr 2019 06:44:28 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731898AbfDBNnM (ORCPT + 99 others); Tue, 2 Apr 2019 09:43:12 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43660 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731518AbfDBNkL (ORCPT ); Tue, 2 Apr 2019 09:40:11 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJe4-0002oc-7z; Tue, 02 Apr 2019 14:40:08 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdx-0004vW-3r; Tue, 02 Apr 2019 14:40:01 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Theodore Ts'o" Date: Tue, 02 Apr 2019 14:38:27 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 63/99] ext4: force inode writes when nfsd calls commit_metadata() In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o commit fde872682e175743e0c3ef939c89e3c6008a1529 upstream. Some time back, nfsd switched from calling vfs_fsync() to using a new commit_metadata() hook in export_operations(). If the file system did not provide a commit_metadata() hook, it fell back to using sync_inode_metadata(). Unfortunately doesn't work on all file systems. In particular, it doesn't work on ext4 due to how the inode gets journalled --- the VFS writeback code will not always call ext4_write_inode(). So we need to provide our own ext4_nfs_commit_metdata() method which calls ext4_write_inode() directly. Google-Bug-Id: 121195940 Signed-off-by: Theodore Ts'o Signed-off-by: Ben Hutchings --- fs/ext4/super.c | 11 +++++++++++ include/trace/events/ext4.h | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1042,6 +1042,16 @@ static struct dentry *ext4_fh_to_parent( ext4_nfs_get_inode); } +static int ext4_nfs_commit_metadata(struct inode *inode) +{ + struct writeback_control wbc = { + .sync_mode = WB_SYNC_ALL + }; + + trace_ext4_nfs_commit_metadata(inode); + return ext4_write_inode(inode, &wbc); +} + /* * Try to release metadata pages (indirect blocks, directories) which are * mapped via the block device. Since these pages could have journal heads @@ -1162,6 +1172,7 @@ static const struct export_operations ex .fh_to_dentry = ext4_fh_to_dentry, .fh_to_parent = ext4_fh_to_parent, .get_parent = ext4_get_parent, + .commit_metadata = ext4_nfs_commit_metadata, }; enum { --- a/include/trace/events/ext4.h +++ b/include/trace/events/ext4.h @@ -195,6 +195,26 @@ TRACE_EVENT(ext4_drop_inode, (unsigned long) __entry->ino, __entry->drop) ); +TRACE_EVENT(ext4_nfs_commit_metadata, + TP_PROTO(struct inode *inode), + + TP_ARGS(inode), + + TP_STRUCT__entry( + __field( dev_t, dev ) + __field( ino_t, ino ) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + ), + + TP_printk("dev %d,%d ino %lu", + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long) __entry->ino) +); + TRACE_EVENT(ext4_mark_inode_dirty, TP_PROTO(struct inode *inode, unsigned long IP),