From: Fengguang Wu <fengguang.wu@intel.com>
To: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Andi Kleen <andi.kleen@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Tony Luck <tony.luck@intel.com>, Rik van Riel <riel@redhat.com>,
Jun'ichi Nomura <j-nomura@ce.jp.nec.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] HWPOISON: prevent inode cache removal to keep AS_HWPOISON sticky
Date: Thu, 23 Aug 2012 17:11:25 +0800 [thread overview]
Message-ID: <20120823091125.GA12745@localhost> (raw)
In-Reply-To: <1345648655-4497-4-git-send-email-n-horiguchi@ah.jp.nec.com>
On Wed, Aug 22, 2012 at 11:17:35AM -0400, Naoya Horiguchi wrote:
> "HWPOISON: report sticky EIO for poisoned file" still has a corner case
> where we have possibilities of data lost. This is because in this fix
> AS_HWPOISON is cleared when the inode cache is dropped.
>
> For example, consider an application in which a process periodically
> (every 10 minutes) writes some logs on a file (and closes it after
> each writes,) and at the end of each day some batch programs run using
> the log file. If a memory error hits on dirty pagecache of this log file
> just after periodic write/close and the inode cache is cleared before the
> next write, then this application is not aware of the error and the batch
> programs will work wrongly.
>
> To avoid this, this patch makes us pin the hwpoisoned inode on memory
> until we remove or completely truncate the hwpoisoned file.
Good point!
> Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> ---
> fs/inode.c | 12 ++++++++++++
> include/linux/pagemap.h | 11 +++++++++++
> mm/memory-failure.c | 2 +-
> mm/truncate.c | 2 ++
> 4 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git v3.6-rc1.orig/fs/inode.c v3.6-rc1/fs/inode.c
> index ac8d904..8742397 100644
> --- v3.6-rc1.orig/fs/inode.c
> +++ v3.6-rc1/fs/inode.c
> @@ -717,6 +717,15 @@ void prune_icache_sb(struct super_block *sb, int nr_to_scan)
> }
>
> /*
> + * Keep inode caches on memory for user processes to certainly
> + * be aware of memory errors.
> + */
> + if (unlikely(mapping_hwpoison(inode->i_mapping))) {
> + spin_unlock(&inode->i_lock);
> + continue;
> + }
That chunk prevents reclaiming all the cached pages. However the intention
is only to keep the struct inode together with the hwpoison bit?
> + /*
> * Referenced or dirty inodes are still in use. Give them
> * another pass through the LRU as we canot reclaim them now.
> */
> @@ -1405,6 +1414,9 @@ static void iput_final(struct inode *inode)
> inode->i_state &= ~I_WILL_FREE;
> }
>
> + if (unlikely(mapping_hwpoison(inode->i_mapping) && drop))
> + mapping_clear_hwpoison(inode->i_mapping);
Is that clear necessary? Because the bit will be gone with the inode
struct: it's going to be de-allocated anyway.
> inode->i_state |= I_FREEING;
> if (!list_empty(&inode->i_lru))
> inode_lru_list_del(inode);
> diff --git v3.6-rc1.orig/include/linux/pagemap.h v3.6-rc1/include/linux/pagemap.h
> index 4d8d821..9fce4e4 100644
> --- v3.6-rc1.orig/include/linux/pagemap.h
> +++ v3.6-rc1/include/linux/pagemap.h
> @@ -59,11 +59,22 @@ static inline int mapping_hwpoison(struct address_space *mapping)
> {
> return test_bit(AS_HWPOISON, &mapping->flags);
> }
> +static inline void mapping_set_hwpoison(struct address_space *mapping)
> +{
> + set_bit(AS_HWPOISON, &mapping->flags);
> +}
> +static inline void mapping_clear_hwpoison(struct address_space *mapping)
> +{
> + clear_bit(AS_HWPOISON, &mapping->flags);
> +}
> #else
> static inline int mapping_hwpoison(struct address_space *mapping)
> {
> return 0;
> }
> +static inline void mapping_clear_hwpoison(struct address_space *mapping)
> +{
> +}
> #endif
>
> static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
> diff --git v3.6-rc1.orig/mm/memory-failure.c v3.6-rc1/mm/memory-failure.c
> index a1e7e00..ca064c6 100644
> --- v3.6-rc1.orig/mm/memory-failure.c
> +++ v3.6-rc1/mm/memory-failure.c
> @@ -652,7 +652,7 @@ static int me_pagecache_dirty(struct page *p, unsigned long pfn)
> * the first EIO, but we're not worse than other parts
> * of the kernel.
> */
> - set_bit(AS_HWPOISON, &mapping->flags);
> + mapping_set_hwpoison(mapping);
> }
>
> return me_pagecache_clean(p, pfn);
> diff --git v3.6-rc1.orig/mm/truncate.c v3.6-rc1/mm/truncate.c
> index 75801ac..82a994f 100644
> --- v3.6-rc1.orig/mm/truncate.c
> +++ v3.6-rc1/mm/truncate.c
> @@ -574,6 +574,8 @@ void truncate_setsize(struct inode *inode, loff_t newsize)
>
> oldsize = inode->i_size;
> i_size_write(inode, newsize);
> + if (unlikely(mapping_hwpoison(inode->i_mapping) && !newsize))
It might be a bit better to test !newsize first.
> + mapping_clear_hwpoison(inode->i_mapping);
>
> truncate_pagecache(inode, oldsize, newsize);
> }
> --
> 1.7.11.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Fengguang Wu <fengguang.wu@intel.com>
To: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Andi Kleen <andi.kleen@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Tony Luck <tony.luck@intel.com>, Rik van Riel <riel@redhat.com>,
"Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] HWPOISON: prevent inode cache removal to keep AS_HWPOISON sticky
Date: Thu, 23 Aug 2012 17:11:25 +0800 [thread overview]
Message-ID: <20120823091125.GA12745@localhost> (raw)
In-Reply-To: <1345648655-4497-4-git-send-email-n-horiguchi@ah.jp.nec.com>
On Wed, Aug 22, 2012 at 11:17:35AM -0400, Naoya Horiguchi wrote:
> "HWPOISON: report sticky EIO for poisoned file" still has a corner case
> where we have possibilities of data lost. This is because in this fix
> AS_HWPOISON is cleared when the inode cache is dropped.
>
> For example, consider an application in which a process periodically
> (every 10 minutes) writes some logs on a file (and closes it after
> each writes,) and at the end of each day some batch programs run using
> the log file. If a memory error hits on dirty pagecache of this log file
> just after periodic write/close and the inode cache is cleared before the
> next write, then this application is not aware of the error and the batch
> programs will work wrongly.
>
> To avoid this, this patch makes us pin the hwpoisoned inode on memory
> until we remove or completely truncate the hwpoisoned file.
Good point!
> Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> ---
> fs/inode.c | 12 ++++++++++++
> include/linux/pagemap.h | 11 +++++++++++
> mm/memory-failure.c | 2 +-
> mm/truncate.c | 2 ++
> 4 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git v3.6-rc1.orig/fs/inode.c v3.6-rc1/fs/inode.c
> index ac8d904..8742397 100644
> --- v3.6-rc1.orig/fs/inode.c
> +++ v3.6-rc1/fs/inode.c
> @@ -717,6 +717,15 @@ void prune_icache_sb(struct super_block *sb, int nr_to_scan)
> }
>
> /*
> + * Keep inode caches on memory for user processes to certainly
> + * be aware of memory errors.
> + */
> + if (unlikely(mapping_hwpoison(inode->i_mapping))) {
> + spin_unlock(&inode->i_lock);
> + continue;
> + }
That chunk prevents reclaiming all the cached pages. However the intention
is only to keep the struct inode together with the hwpoison bit?
> + /*
> * Referenced or dirty inodes are still in use. Give them
> * another pass through the LRU as we canot reclaim them now.
> */
> @@ -1405,6 +1414,9 @@ static void iput_final(struct inode *inode)
> inode->i_state &= ~I_WILL_FREE;
> }
>
> + if (unlikely(mapping_hwpoison(inode->i_mapping) && drop))
> + mapping_clear_hwpoison(inode->i_mapping);
Is that clear necessary? Because the bit will be gone with the inode
struct: it's going to be de-allocated anyway.
> inode->i_state |= I_FREEING;
> if (!list_empty(&inode->i_lru))
> inode_lru_list_del(inode);
> diff --git v3.6-rc1.orig/include/linux/pagemap.h v3.6-rc1/include/linux/pagemap.h
> index 4d8d821..9fce4e4 100644
> --- v3.6-rc1.orig/include/linux/pagemap.h
> +++ v3.6-rc1/include/linux/pagemap.h
> @@ -59,11 +59,22 @@ static inline int mapping_hwpoison(struct address_space *mapping)
> {
> return test_bit(AS_HWPOISON, &mapping->flags);
> }
> +static inline void mapping_set_hwpoison(struct address_space *mapping)
> +{
> + set_bit(AS_HWPOISON, &mapping->flags);
> +}
> +static inline void mapping_clear_hwpoison(struct address_space *mapping)
> +{
> + clear_bit(AS_HWPOISON, &mapping->flags);
> +}
> #else
> static inline int mapping_hwpoison(struct address_space *mapping)
> {
> return 0;
> }
> +static inline void mapping_clear_hwpoison(struct address_space *mapping)
> +{
> +}
> #endif
>
> static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
> diff --git v3.6-rc1.orig/mm/memory-failure.c v3.6-rc1/mm/memory-failure.c
> index a1e7e00..ca064c6 100644
> --- v3.6-rc1.orig/mm/memory-failure.c
> +++ v3.6-rc1/mm/memory-failure.c
> @@ -652,7 +652,7 @@ static int me_pagecache_dirty(struct page *p, unsigned long pfn)
> * the first EIO, but we're not worse than other parts
> * of the kernel.
> */
> - set_bit(AS_HWPOISON, &mapping->flags);
> + mapping_set_hwpoison(mapping);
> }
>
> return me_pagecache_clean(p, pfn);
> diff --git v3.6-rc1.orig/mm/truncate.c v3.6-rc1/mm/truncate.c
> index 75801ac..82a994f 100644
> --- v3.6-rc1.orig/mm/truncate.c
> +++ v3.6-rc1/mm/truncate.c
> @@ -574,6 +574,8 @@ void truncate_setsize(struct inode *inode, loff_t newsize)
>
> oldsize = inode->i_size;
> i_size_write(inode, newsize);
> + if (unlikely(mapping_hwpoison(inode->i_mapping) && !newsize))
It might be a bit better to test !newsize first.
> + mapping_clear_hwpoison(inode->i_mapping);
>
> truncate_pagecache(inode, oldsize, newsize);
> }
> --
> 1.7.11.4
next prev parent reply other threads:[~2012-08-23 9:11 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-22 15:17 [PATCH 0/3 v2] HWPOISON: improve dirty pagecache error reporting Naoya Horiguchi
2012-08-22 15:17 ` Naoya Horiguchi
2012-08-22 15:17 ` [PATCH 1/3] HWPOISON: fix action_result() to print out dirty/clean Naoya Horiguchi
2012-08-22 15:17 ` Naoya Horiguchi
2012-08-23 9:33 ` Fengguang Wu
2012-08-23 9:33 ` Fengguang Wu
2012-08-23 20:31 ` Naoya Horiguchi
2012-08-23 20:31 ` Naoya Horiguchi
2012-08-22 15:17 ` [PATCH 2/3] HWPOISON: report sticky EIO for poisoned file Naoya Horiguchi
2012-08-22 15:17 ` Naoya Horiguchi
2012-08-23 9:22 ` Fengguang Wu
2012-08-23 9:22 ` Fengguang Wu
2012-08-23 20:31 ` Naoya Horiguchi
2012-08-23 20:31 ` Naoya Horiguchi
2012-08-22 15:17 ` [PATCH 3/3] HWPOISON: prevent inode cache removal to keep AS_HWPOISON sticky Naoya Horiguchi
2012-08-22 15:17 ` Naoya Horiguchi
2012-08-23 9:11 ` Fengguang Wu [this message]
2012-08-23 9:11 ` Fengguang Wu
2012-08-23 20:31 ` Naoya Horiguchi
2012-08-23 20:31 ` Naoya Horiguchi
2012-08-24 21:52 ` Naoya Horiguchi
2012-08-24 21:52 ` Naoya Horiguchi
2012-08-24 1:31 ` Dave Chinner
2012-08-24 1:31 ` Dave Chinner
2012-08-24 2:39 ` Naoya Horiguchi
2012-08-24 2:39 ` Naoya Horiguchi
2012-08-24 4:39 ` Dave Chinner
2012-08-24 4:39 ` Dave Chinner
2012-08-24 17:24 ` Naoya Horiguchi
2012-08-24 17:24 ` Naoya Horiguchi
2012-08-26 22:26 ` Dave Chinner
2012-08-26 22:26 ` Dave Chinner
2012-08-27 22:05 ` Naoya Horiguchi
2012-08-27 22:05 ` Naoya Horiguchi
2012-08-29 2:59 ` Dave Chinner
2012-08-29 2:59 ` Dave Chinner
2012-08-29 5:32 ` Jun'ichi Nomura
2012-08-29 5:32 ` Jun'ichi Nomura
2012-09-03 0:39 ` Dave Chinner
2012-09-03 0:39 ` Dave Chinner
2012-08-22 20:22 ` [PATCH 0/3 v2] HWPOISON: improve dirty pagecache error reporting Andi Kleen
2012-08-22 20:22 ` Andi Kleen
2012-08-22 21:14 ` Naoya Horiguchi
2012-08-22 21:14 ` Naoya Horiguchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120823091125.GA12745@localhost \
--to=fengguang.wu@intel.com \
--cc=akpm@linux-foundation.org \
--cc=andi.kleen@intel.com \
--cc=j-nomura@ce.jp.nec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=riel@redhat.com \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.