From patchwork Wed Oct 30 08:11:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 11219159 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AECDA139A for ; Wed, 30 Oct 2019 08:11:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7A73E208E3 for ; Wed, 30 Oct 2019 08:11:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yandex-team.ru header.i=@yandex-team.ru header.b="E0YaAQv0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A73E208E3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=yandex-team.ru Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B63D76B0003; Wed, 30 Oct 2019 04:11:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B3A726B0006; Wed, 30 Oct 2019 04:11:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2B6F6B0007; Wed, 30 Oct 2019 04:11:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id 812B46B0003 for ; Wed, 30 Oct 2019 04:11:18 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 3A4376D9D for ; Wed, 30 Oct 2019 08:11:18 +0000 (UTC) X-FDA: 76099731036.08.frogs82_b4400e418a50 X-Spam-Summary: 2,0,0,ed21c06c824c5ad5,d41d8cd98f00b204,khlebnikov@yandex-team.ru,:jack@suse.cz:linux-kernel@vger.kernel.org::viro@zeniv.linux.org.uk:linux-fsdevel@vger.kernel.org:akpm@linux-foundation.org,RULES_HIT:41:69:152:355:379:800:960:967:973:988:989:1260:1277:1311:1313:1314:1345:1381:1437:1515:1516:1518:1535:1543:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2525:2559:2563:2682:2685:2859:2899:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3354:3867:3871:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4605:5007:6261:6653:7875:7903:9025:9207:9592:10004:10400:11026:11473:11658:11914:12043:12048:12114:12291:12296:12297:12438:12517:12519:12555:12679:12760:12986:14181:14394:14687:14721:14922:21080:21451:21627:21811:21939:30054:30056:30090,0,RBL:5.45.199.163:@yandex-team.ru:.lbl8.mailshell.net-62.2.3.100 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0 :0,LFtim X-HE-Tag: frogs82_b4400e418a50 X-Filterd-Recvd-Size: 5403 Received: from forwardcorp1j.mail.yandex.net (forwardcorp1j.mail.yandex.net [5.45.199.163]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Wed, 30 Oct 2019 08:11:17 +0000 (UTC) Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id DA8332E154E; Wed, 30 Oct 2019 11:11:13 +0300 (MSK) Received: from vla1-5826f599457c.qloud-c.yandex.net (vla1-5826f599457c.qloud-c.yandex.net [2a02:6b8:c0d:35a1:0:640:5826:f599]) by mxbackcorp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id OlQEp3d1hj-BDeW5lL2; Wed, 30 Oct 2019 11:11:13 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1572423073; bh=quyBFSBUxZLyiOh/Pn2ut7NnhKb8kTc5N+3Wo+3KAUE=; h=Message-ID:Date:To:From:Subject; b=E0YaAQv09VZ6bMh3jIKqlt38V6yindX2nS8vnODKXOzEUm8lDewK7liAn69aBYbTB r6oTVNuG3Wtmn8pjYsRL/zpRo1hJpXlA289v39ul140pV9BiZKoa7moJaJtKOCxkeK mY8K0W/FbDqmCUF6vaP7wEEJKjoJ8DkoA4sgORFY= Authentication-Results: mxbackcorp2j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:148a:8f3:5b61:9f4]) by vla1-5826f599457c.qloud-c.yandex.net (nwsmtp/Yandex) with ESMTPSA id WammiHiM15-BDVSWk1b; Wed, 30 Oct 2019 11:11:13 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: [PATCH] fs: keep dio_warn_stale_pagecache() when CONFIG_BLOCK=n From: Konstantin Khlebnikov To: Jan Kara , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Viro , linux-fsdevel@vger.kernel.org, Andrew Morton Date: Wed, 30 Oct 2019 11:11:13 +0300 Message-ID: <157242307298.5840.14949889649221596095.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This helper prints warning if direct I/O write failed to invalidate cache. Direct I/O is supported by non-disk filesystems, for example NFS. Signed-off-by: Konstantin Khlebnikov Link: https://lore.kernel.org/lkml/201910300824.UIo56oC7%25lkp@intel.com/ --- fs/direct-io.c | 21 --------------------- include/linux/fs.h | 6 +++++- mm/filemap.c | 21 +++++++++++++++++++++ 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index 9329ced91f1d..0ec4f270139f 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -220,27 +220,6 @@ static inline struct page *dio_get_page(struct dio *dio, return dio->pages[sdio->head]; } -/* - * Warn about a page cache invalidation failure during a direct io write. - */ -void dio_warn_stale_pagecache(struct file *filp) -{ - static DEFINE_RATELIMIT_STATE(_rs, 86400 * HZ, DEFAULT_RATELIMIT_BURST); - char pathname[128]; - struct inode *inode = file_inode(filp); - char *path; - - errseq_set(&inode->i_mapping->wb_err, -EIO); - if (__ratelimit(&_rs)) { - path = file_path(filp, pathname, sizeof(pathname)); - if (IS_ERR(path)) - path = "(unknown)"; - pr_crit("Page cache invalidation failure on direct I/O. Possible data corruption due to collision with buffered I/O!\n"); - pr_crit("File: %s PID: %d Comm: %.20s\n", path, current->pid, - current->comm); - } -} - /* * dio_complete() - called when all DIO BIO I/O has been completed * diff --git a/include/linux/fs.h b/include/linux/fs.h index e0d909d35763..b4e4560d1c38 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3153,7 +3153,6 @@ enum { }; void dio_end_io(struct bio *bio); -void dio_warn_stale_pagecache(struct file *filp); ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode, struct block_device *bdev, struct iov_iter *iter, @@ -3198,6 +3197,11 @@ static inline void inode_dio_end(struct inode *inode) wake_up_bit(&inode->i_state, __I_DIO_WAKEUP); } +/* + * Warn about a page cache invalidation failure diring a direct I/O write. + */ +void dio_warn_stale_pagecache(struct file *filp); + extern void inode_set_flags(struct inode *inode, unsigned int flags, unsigned int mask); diff --git a/mm/filemap.c b/mm/filemap.c index cdb8780a0758..d7394226f5ab 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3161,6 +3161,27 @@ int pagecache_write_end(struct file *file, struct address_space *mapping, } EXPORT_SYMBOL(pagecache_write_end); +/* + * Warn about a page cache invalidation failure during a direct I/O write. + */ +void dio_warn_stale_pagecache(struct file *filp) +{ + static DEFINE_RATELIMIT_STATE(_rs, 86400 * HZ, DEFAULT_RATELIMIT_BURST); + char pathname[128]; + struct inode *inode = file_inode(filp); + char *path; + + errseq_set(&inode->i_mapping->wb_err, -EIO); + if (__ratelimit(&_rs)) { + path = file_path(filp, pathname, sizeof(pathname)); + if (IS_ERR(path)) + path = "(unknown)"; + pr_crit("Page cache invalidation failure on direct I/O. Possible data corruption due to collision with buffered I/O!\n"); + pr_crit("File: %s PID: %d Comm: %.20s\n", path, current->pid, + current->comm); + } +} + ssize_t generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from) {