From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8F9CCA9EC5 for ; Wed, 30 Oct 2019 12:49:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7906C2080F for ; Wed, 30 Oct 2019 12:49:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7906C2080F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DED016B0003; Wed, 30 Oct 2019 08:49:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D9D596B0006; Wed, 30 Oct 2019 08:49:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB3B86B0007; Wed, 30 Oct 2019 08:49:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id AA6A66B0003 for ; Wed, 30 Oct 2019 08:49:40 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 56D91180AD83E for ; Wed, 30 Oct 2019 12:49:40 +0000 (UTC) X-FDA: 76100432520.26.sack22_7175f20113a01 X-HE-Tag: sack22_7175f20113a01 X-Filterd-Recvd-Size: 5132 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Wed, 30 Oct 2019 12:49:39 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B00F5B3F5; Wed, 30 Oct 2019 12:49:37 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id B313A1E485C; Wed, 30 Oct 2019 13:49:35 +0100 (CET) Date: Wed, 30 Oct 2019 13:49:35 +0100 From: Jan Kara To: Konstantin Khlebnikov Cc: Jan Kara , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Viro , linux-fsdevel@vger.kernel.org, Andrew Morton Subject: Re: [PATCH] fs: keep dio_warn_stale_pagecache() when CONFIG_BLOCK=n Message-ID: <20191030124935.GL28525@quack2.suse.cz> References: <157242307298.5840.14949889649221596095.stgit@buzz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <157242307298.5840.14949889649221596095.stgit@buzz> User-Agent: Mutt/1.10.1 (2018-07-13) 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: On Wed 30-10-19 11:11:13, Konstantin Khlebnikov wrote: > 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/ Well, but this patch doesn't quite make sense without your other patch so it would make sense to explain that in the changelog and make this patch 1/2 while the other patch will be 2/2? Otherwise those changes make sense to me. Honza > --- > 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) > { > -- Jan Kara SUSE Labs, CR