* [PATCH 3.15 1/2] f2fs: adjust free mem size to flush dentry blocks
@ 2014-07-14 14:52 Jaegeuk Kim
2014-07-14 14:52 ` [PATCH 3.15 2/2] f2fs: check bdi->dirty_exceeded when trying to skip data writes Jaegeuk Kim
0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2014-07-14 14:52 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel, stable; +Cc: Jaegeuk Kim
From: Jaegeuk Kim <jaegeuk.kim@samsung.com>
commit 6fb03f3a40805a412c9b285010ffdc2e7563f81b upstream.
If so many dirty dentry blocks are cached, not reached to the flush condition,
we should fall into livelock in balance_dirty_pages.
So, let's consider the mem size for the condition.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Conflicts:
fs/f2fs/node.h
---
fs/f2fs/data.c | 3 ++-
fs/f2fs/f2fs.h | 1 +
fs/f2fs/node.c | 44 ++++++++++++++++++++++++++------------------
fs/f2fs/node.h | 5 +++--
4 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 45abd60..716645e 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -867,7 +867,8 @@ static int f2fs_write_data_pages(struct address_space *mapping,
return 0;
if (S_ISDIR(inode->i_mode) && wbc->sync_mode == WB_SYNC_NONE &&
- get_dirty_dents(inode) < nr_pages_to_skip(sbi, DATA))
+ get_dirty_dents(inode) < nr_pages_to_skip(sbi, DATA) &&
+ available_free_memory(sbi, DIRTY_DENTS))
goto skip_write;
diff = nr_pages_to_write(sbi, DATA, wbc);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 2ecac83..656523c 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1140,6 +1140,7 @@ f2fs_hash_t f2fs_dentry_hash(const char *, size_t);
struct dnode_of_data;
struct node_info;
+bool available_free_memory(struct f2fs_sb_info *, int);
int is_checkpointed_node(struct f2fs_sb_info *, nid_t);
bool fsync_mark_done(struct f2fs_sb_info *, nid_t);
void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index a161e95..a9c0495 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -26,20 +26,26 @@
static struct kmem_cache *nat_entry_slab;
static struct kmem_cache *free_nid_slab;
-static inline bool available_free_memory(struct f2fs_nm_info *nm_i, int type)
+bool available_free_memory(struct f2fs_sb_info *sbi, int type)
{
+ struct f2fs_nm_info *nm_i = NM_I(sbi);
struct sysinfo val;
unsigned long mem_size = 0;
+ bool res = false;
si_meminfo(&val);
- if (type == FREE_NIDS)
- mem_size = nm_i->fcnt * sizeof(struct free_nid);
- else if (type == NAT_ENTRIES)
- mem_size += nm_i->nat_cnt * sizeof(struct nat_entry);
- mem_size >>= 12;
-
- /* give 50:50 memory for free nids and nat caches respectively */
- return (mem_size < ((val.totalram * nm_i->ram_thresh) >> 11));
+ /* give 25%, 25%, 50% memory for each components respectively */
+ if (type == FREE_NIDS) {
+ mem_size = (nm_i->fcnt * sizeof(struct free_nid)) >> 12;
+ res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 2);
+ } else if (type == NAT_ENTRIES) {
+ mem_size = (nm_i->nat_cnt * sizeof(struct nat_entry)) >> 12;
+ res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 2);
+ } else if (type == DIRTY_DENTS) {
+ mem_size = get_pages(sbi, F2FS_DIRTY_DENTS);
+ res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 1);
+ }
+ return res;
}
static void clear_node_page_dirty(struct page *page)
@@ -243,7 +249,7 @@ int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink)
{
struct f2fs_nm_info *nm_i = NM_I(sbi);
- if (available_free_memory(nm_i, NAT_ENTRIES))
+ if (available_free_memory(sbi, NAT_ENTRIES))
return 0;
write_lock(&nm_i->nat_tree_lock);
@@ -1315,13 +1321,14 @@ static void __del_from_free_nid_list(struct f2fs_nm_info *nm_i,
radix_tree_delete(&nm_i->free_nid_root, i->nid);
}
-static int add_free_nid(struct f2fs_nm_info *nm_i, nid_t nid, bool build)
+static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
{
+ struct f2fs_nm_info *nm_i = NM_I(sbi);
struct free_nid *i;
struct nat_entry *ne;
bool allocated = false;
- if (!available_free_memory(nm_i, FREE_NIDS))
+ if (!available_free_memory(sbi, FREE_NIDS))
return -1;
/* 0 nid should not be used */
@@ -1374,9 +1381,10 @@ static void remove_free_nid(struct f2fs_nm_info *nm_i, nid_t nid)
kmem_cache_free(free_nid_slab, i);
}
-static void scan_nat_page(struct f2fs_nm_info *nm_i,
+static void scan_nat_page(struct f2fs_sb_info *sbi,
struct page *nat_page, nid_t start_nid)
{
+ struct f2fs_nm_info *nm_i = NM_I(sbi);
struct f2fs_nat_block *nat_blk = page_address(nat_page);
block_t blk_addr;
int i;
@@ -1391,7 +1399,7 @@ static void scan_nat_page(struct f2fs_nm_info *nm_i,
blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr);
f2fs_bug_on(blk_addr == NEW_ADDR);
if (blk_addr == NULL_ADDR) {
- if (add_free_nid(nm_i, start_nid, true) < 0)
+ if (add_free_nid(sbi, start_nid, true) < 0)
break;
}
}
@@ -1415,7 +1423,7 @@ static void build_free_nids(struct f2fs_sb_info *sbi)
while (1) {
struct page *page = get_current_nat_page(sbi, nid);
- scan_nat_page(nm_i, page, nid);
+ scan_nat_page(sbi, page, nid);
f2fs_put_page(page, 1);
nid += (NAT_ENTRY_PER_BLOCK - (nid % NAT_ENTRY_PER_BLOCK));
@@ -1435,7 +1443,7 @@ static void build_free_nids(struct f2fs_sb_info *sbi)
block_t addr = le32_to_cpu(nat_in_journal(sum, i).block_addr);
nid = le32_to_cpu(nid_in_journal(sum, i));
if (addr == NULL_ADDR)
- add_free_nid(nm_i, nid, true);
+ add_free_nid(sbi, nid, true);
else
remove_free_nid(nm_i, nid);
}
@@ -1512,7 +1520,7 @@ void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
spin_lock(&nm_i->free_nid_list_lock);
i = __lookup_free_nid_list(nm_i, nid);
f2fs_bug_on(!i || i->state != NID_ALLOC);
- if (!available_free_memory(nm_i, FREE_NIDS)) {
+ if (!available_free_memory(sbi, FREE_NIDS)) {
__del_from_free_nid_list(nm_i, i);
need_free = true;
} else {
@@ -1843,7 +1851,7 @@ flush_now:
}
if (nat_get_blkaddr(ne) == NULL_ADDR &&
- add_free_nid(NM_I(sbi), nid, false) <= 0) {
+ add_free_nid(sbi, nid, false) <= 0) {
write_lock(&nm_i->nat_tree_lock);
__del_from_nat_cache(nm_i, ne);
write_unlock(&nm_i->nat_tree_lock);
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 5decc1a..b517077 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -75,9 +75,10 @@ static inline void node_info_from_raw_nat(struct node_info *ni,
ni->version = raw_ne->version;
}
-enum nid_type {
+enum mem_type {
FREE_NIDS, /* indicates the free nid list */
- NAT_ENTRIES /* indicates the cached nat entry */
+ NAT_ENTRIES, /* indicates the cached nat entry */
+ DIRTY_DENTS /* indicates dirty dentry pages */
};
/*
--
2.0.1.472.g6f92e5f
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3.15 2/2] f2fs: check bdi->dirty_exceeded when trying to skip data writes
2014-07-14 14:52 [PATCH 3.15 1/2] f2fs: adjust free mem size to flush dentry blocks Jaegeuk Kim
@ 2014-07-14 14:52 ` Jaegeuk Kim
2014-07-15 0:53 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2014-07-14 14:52 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel, stable; +Cc: Jaegeuk Kim
commit dd6b9bf5883c3ca9c17bac80ccd8615fe5a452a3 upstream.
If we don't check the current backing device status, balance_dirty_pages can
fall into infinite pausing routine.
This can be occurred when a lot of directories make a small number of dirty
dentry pages including files.
Reported-by: Brian Chadwick <brianchad@westnet.com.au>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/node.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index a9c0495..5696bde 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -42,6 +42,8 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type)
mem_size = (nm_i->nat_cnt * sizeof(struct nat_entry)) >> 12;
res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 2);
} else if (type == DIRTY_DENTS) {
+ if (sbi->sb->s_bdi->dirty_exceeded)
+ return false;
mem_size = get_pages(sbi, F2FS_DIRTY_DENTS);
res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 1);
}
--
2.0.1.472.g6f92e5f
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck®
Code Sight™ - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 3.15 2/2] f2fs: check bdi->dirty_exceeded when trying to skip data writes
2014-07-14 14:52 ` [PATCH 3.15 2/2] f2fs: check bdi->dirty_exceeded when trying to skip data writes Jaegeuk Kim
@ 2014-07-15 0:53 ` Greg KH
2014-07-15 17:57 ` Jaegeuk Kim
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2014-07-15 0:53 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-fsdevel, linux-kernel, stable, linux-f2fs-devel
On Mon, Jul 14, 2014 at 07:52:51AM -0700, Jaegeuk Kim wrote:
> commit dd6b9bf5883c3ca9c17bac80ccd8615fe5a452a3 upstream.
You mean 2743f865543c0c4a5e12fc13edb2bf89a6e9687c, right?
thanks,
greg k-h
>
> If we don't check the current backing device status, balance_dirty_pages can
> fall into infinite pausing routine.
>
> This can be occurred when a lot of directories make a small number of dirty
> dentry pages including files.
>
> Reported-by: Brian Chadwick <brianchad@westnet.com.au>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
> fs/f2fs/node.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index a9c0495..5696bde 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -42,6 +42,8 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type)
> mem_size = (nm_i->nat_cnt * sizeof(struct nat_entry)) >> 12;
> res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 2);
> } else if (type == DIRTY_DENTS) {
> + if (sbi->sb->s_bdi->dirty_exceeded)
> + return false;
> mem_size = get_pages(sbi, F2FS_DIRTY_DENTS);
> res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 1);
> }
> --
> 2.0.1.472.g6f92e5f
>
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3.15 2/2] f2fs: check bdi->dirty_exceeded when trying to skip data writes
2014-07-15 0:53 ` Greg KH
@ 2014-07-15 17:57 ` Jaegeuk Kim
0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2014-07-15 17:57 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel, stable
On Mon, Jul 14, 2014 at 05:53:36PM -0700, Greg KH wrote:
> On Mon, Jul 14, 2014 at 07:52:51AM -0700, Jaegeuk Kim wrote:
> > commit dd6b9bf5883c3ca9c17bac80ccd8615fe5a452a3 upstream.
>
> You mean 2743f865543c0c4a5e12fc13edb2bf89a6e9687c, right?
Ah, correct.
Thank you. :)
>
> thanks,
>
> greg k-h
>
> >
> > If we don't check the current backing device status, balance_dirty_pages can
> > fall into infinite pausing routine.
> >
> > This can be occurred when a lot of directories make a small number of dirty
> > dentry pages including files.
> >
> > Reported-by: Brian Chadwick <brianchad@westnet.com.au>
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> > fs/f2fs/node.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> > index a9c0495..5696bde 100644
> > --- a/fs/f2fs/node.c
> > +++ b/fs/f2fs/node.c
> > @@ -42,6 +42,8 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type)
> > mem_size = (nm_i->nat_cnt * sizeof(struct nat_entry)) >> 12;
> > res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 2);
> > } else if (type == DIRTY_DENTS) {
> > + if (sbi->sb->s_bdi->dirty_exceeded)
> > + return false;
> > mem_size = get_pages(sbi, F2FS_DIRTY_DENTS);
> > res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 1);
> > }
> > --
> > 2.0.1.472.g6f92e5f
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe stable" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Jaegeuk Kim
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-15 17:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-14 14:52 [PATCH 3.15 1/2] f2fs: adjust free mem size to flush dentry blocks Jaegeuk Kim
2014-07-14 14:52 ` [PATCH 3.15 2/2] f2fs: check bdi->dirty_exceeded when trying to skip data writes Jaegeuk Kim
2014-07-15 0:53 ` Greg KH
2014-07-15 17:57 ` Jaegeuk Kim
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).