* [PATCH] fs: keep dio_warn_stale_pagecache() when CONFIG_BLOCK=n
@ 2019-10-30 8:11 Konstantin Khlebnikov
2019-10-30 12:49 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Konstantin Khlebnikov @ 2019-10-30 8:11 UTC (permalink / raw)
To: Jan Kara, linux-kernel, linux-mm, Alexander Viro, linux-fsdevel,
Andrew Morton
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 <khlebnikov@yandex-team.ru>
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)
{
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fs: keep dio_warn_stale_pagecache() when CONFIG_BLOCK=n
2019-10-30 8:11 [PATCH] fs: keep dio_warn_stale_pagecache() when CONFIG_BLOCK=n Konstantin Khlebnikov
@ 2019-10-30 12:49 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2019-10-30 12:49 UTC (permalink / raw)
To: Konstantin Khlebnikov
Cc: Jan Kara, linux-kernel, linux-mm, Alexander Viro, linux-fsdevel,
Andrew Morton
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 <khlebnikov@yandex-team.ru>
> 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 <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-30 12:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 8:11 [PATCH] fs: keep dio_warn_stale_pagecache() when CONFIG_BLOCK=n Konstantin Khlebnikov
2019-10-30 12:49 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).