Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3534821imu; Mon, 7 Jan 2019 05:14:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN4T8oiVEIhinkCD91Z+p9h6Ap6aTOMS5/fYIi3mkWcWKlm/+ryL5XyJJh2SPU+GDSAT4059 X-Received: by 2002:a65:6645:: with SMTP id z5mr58490048pgv.351.1546866860344; Mon, 07 Jan 2019 05:14:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546866860; cv=none; d=google.com; s=arc-20160816; b=SNG0JUG5Z+mPgvx5ZcsnDW3i0jZ0APWYmA8/AyiG+zIihmHyn0fRW3bYnJfn1RoYjt 0oh6XMGXMWU1DUcwrxtrkaeklxytNW5HQ8k5mM5vPGI5I+Bb50lpBvKT/p0ptTxsizqM AbwUvdPhnRgfQz/yY0e7TdarUBgi1Jxr9t1Q91TQ458jW+fRWQkSICJ0FQGrsDxp0BwV f28yN5Y8upn6y2LiVwYzs6Gv+UaL+8ESSyByapg1YlS2Px53pImz2F7sVtIXl8cpcP9t 3S5rIHwnpz1VfZL6g4BZR++pI5G7qyTc2L8bCL0Eu6CXr3yQbKPTTgQVNceXtX03YNRe MWLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Fm1KDEWRPdMu5jP/48W+No3NCbLLEb9QrbJYJeb0hyo=; b=UFj39rgeiYYe+BcmdjeLX7IcQxjWm6s3O6oNcdVFqvhwyHr1RNuORhEFJNKQGVaLqB tmGbbmufi0jHAxvV4h1zvhi3t7NBrFNLeK+23lpgUoILigThVz/J9HvlD1XJokqSntdQ Vlx52R6jjtdAFIfaIUpbjQuNs+tTTDT4icG3OA/M5cOplZlm9uoe2pYPES4YFb9XSgRY r0kMu7DJHTqrGae8yUqw+gcG11C3CKBbfJlDF2I68sz3LfcKZfVgqVQhBCVZw505yTEQ cnkNQhijhx2abyaNZK2gsG7qTwsaRCw1TwA1fZe6Wbg/hD+VqoCmMXYjnxqpH5s3XNqP XKHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ukQUAkiz; 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 l123si2779359pfc.187.2019.01.07.05.14.05; Mon, 07 Jan 2019 05:14:20 -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=@kernel.org header.s=default header.b=ukQUAkiz; 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 S1730136AbfAGNIX (ORCPT + 99 others); Mon, 7 Jan 2019 08:08:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:55404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730077AbfAGNIS (ORCPT ); Mon, 7 Jan 2019 08:08:18 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BC12C2147C; Mon, 7 Jan 2019 13:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866498; bh=t6EZQ2oP1A+rQijkXb/VbJhGEzfb0Agw/y0D7wvFlHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ukQUAkizFunppoLdqy21FG4YM9AxcsI+fND8kgTaVHdyFQkfg7uKaUg3kHfjndymS tyF8zROWo8OIpcE/i7nTaIfzWZcW6bDzvgya7E7Nit0sUxPk99VeHd95Zv3HsZ6RTr BDMOYjUYG5W4+iME+H1rVOP5lRAV9uYKFplndVvw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , stable@kernel.org Subject: [PATCH 4.9 50/71] ext4: force inode writes when nfsd calls commit_metadata() Date: Mon, 7 Jan 2019 13:33:19 +0100 Message-Id: <20190107105335.609542789@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.280153213@linuxfoundation.org> References: <20190107105330.280153213@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable 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 Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- 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 @@ -1076,6 +1076,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 @@ -1258,6 +1268,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 @@ -223,6 +223,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),