* [PATCH 1/2] f2fs: add braces for macro variables more
@ 2017-04-21 0:49 Jaegeuk Kim
2017-04-21 0:49 ` [PATCH 2/2] f2fs: fix out-of free segments Jaegeuk Kim
2017-04-22 0:30 ` [PATCH 1/2] f2fs: add braces for macro variables more Chao Yu
0 siblings, 2 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2017-04-21 0:49 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
This patch adds braces for macro variables more in include/linux/f2fs_fs.h.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/f2fs.h | 1 +
include/linux/f2fs_fs.h | 10 +++++-----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e2d9a8d9101e..ca647d264b61 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -16,6 +16,7 @@
#include <linux/buffer_head.h>
#include <linux/slab.h>
#include <linux/crc32.h>
+#include <linux/quota.h>
#include <linux/magic.h>
#include <linux/kobject.h>
#include <linux/sched.h>
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index e2d239ed4c60..639cbdf65e2b 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -32,9 +32,9 @@
/* 0, 1(node nid), 2(meta nid) are reserved node id */
#define F2FS_RESERVED_NODE_NUM 3
-#define F2FS_ROOT_INO(sbi) (sbi->root_ino_num)
-#define F2FS_NODE_INO(sbi) (sbi->node_ino_num)
-#define F2FS_META_INO(sbi) (sbi->meta_ino_num)
+#define F2FS_ROOT_INO(sbi) ((sbi)->root_ino_num)
+#define F2FS_NODE_INO(sbi) ((sbi)->node_ino_num)
+#define F2FS_META_INO(sbi) ((sbi)->meta_ino_num)
#define F2FS_IO_SIZE(sbi) (1 << (sbi)->write_io_size_bits) /* Blocks */
#define F2FS_IO_SIZE_KB(sbi) (1 << ((sbi)->write_io_size_bits + 2)) /* KB */
@@ -161,7 +161,7 @@ struct f2fs_checkpoint {
*/
#define F2FS_ORPHANS_PER_BLOCK 1020
-#define GET_ORPHAN_BLOCKS(n) ((n + F2FS_ORPHANS_PER_BLOCK - 1) / \
+#define GET_ORPHAN_BLOCKS(n) (((n) + F2FS_ORPHANS_PER_BLOCK - 1) / \
F2FS_ORPHANS_PER_BLOCK)
struct f2fs_orphan_block {
@@ -449,7 +449,7 @@ typedef __le32 f2fs_hash_t;
#define F2FS_SLOT_LEN 8
#define F2FS_SLOT_LEN_BITS 3
-#define GET_DENTRY_SLOTS(x) ((x + F2FS_SLOT_LEN - 1) >> F2FS_SLOT_LEN_BITS)
+#define GET_DENTRY_SLOTS(x) (((x) + F2FS_SLOT_LEN - 1) >> F2FS_SLOT_LEN_BITS)
/* MAX level for dir lookup */
#define MAX_DIR_HASH_DEPTH 63
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] f2fs: fix out-of free segments
2017-04-21 0:49 [PATCH 1/2] f2fs: add braces for macro variables more Jaegeuk Kim
@ 2017-04-21 0:49 ` Jaegeuk Kim
2017-04-22 0:30 ` [PATCH 1/2] f2fs: add braces for macro variables more Chao Yu
1 sibling, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2017-04-21 0:49 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim, stable
This patch also reverts d0db7703ac1 ("f2fs: do SSR in higher priority").
This patch fixes out of free segments caused by many small file creation by
1) mkfs -s 1 2G
2) mount
3) untar
- preoduce 60000 small files burstly
4) sync
- flush node pages
- flush imeta
Here, when we do f2fs_balance_fs, we missed # of imeta blocks, resulting in
skipping to check has_not_enough_free_secs.
Another test is done by
1) mkfs -s 12 2G
2) mount
3) untar
- preoduce 60000 small files burstly
4) sync
- flush node pages
- flush imeta
In this case, this patch also fixes wrong block allocation under large section
size.
Reported-by: William Brana <wbrana@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/data.c | 3 ++-
fs/f2fs/inode.c | 3 ++-
fs/f2fs/segment.c | 26 +++++++++++++++++++++-----
3 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7d46a8e6d350..b8dcd1e224e8 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1472,7 +1472,8 @@ static int __write_data_page(struct page *page, bool *submitted,
}
unlock_page(page);
- f2fs_balance_fs(sbi, need_balance_fs);
+ if (!S_ISDIR(inode->i_mode))
+ f2fs_balance_fs(sbi, need_balance_fs);
if (unlikely(f2fs_cp_error(sbi))) {
f2fs_submit_merged_bio(sbi, DATA, WRITE);
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 0900814485c7..518f49643092 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -338,7 +338,8 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
* We need to balance fs here to prevent from producing dirty node pages
* during the urgent cleaning time when runing out of free sections.
*/
- if (update_inode_page(inode) && wbc && wbc->nr_to_write)
+ update_inode_page(inode);
+ if (wbc && wbc->nr_to_write)
f2fs_balance_fs(sbi, true);
return 0;
}
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index d4bda1e54475..2a95535794ca 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -388,11 +388,8 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
}
#endif
- if (!need)
- return;
-
/* balance_fs_bg is able to be pending */
- if (excess_cached_nats(sbi))
+ if (need && excess_cached_nats(sbi))
f2fs_balance_fs_bg(sbi);
/*
@@ -1639,6 +1636,17 @@ static void write_current_sum_page(struct f2fs_sb_info *sbi,
f2fs_put_page(page, 1);
}
+static int is_next_segment_free(struct f2fs_sb_info *sbi, int type)
+{
+ struct curseg_info *curseg = CURSEG_I(sbi, type);
+ unsigned int segno = curseg->segno + 1;
+ struct free_segmap_info *free_i = FREE_I(sbi);
+
+ if (segno < MAIN_SEGS(sbi) && segno % sbi->segs_per_sec)
+ return !test_bit(segno, free_i->free_segmap);
+ return 0;
+}
+
/*
* Find a new segment from the free segments bitmap to right order
* This function should be returned with success, otherwise BUG
@@ -1752,6 +1760,10 @@ static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)
static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)
{
+ /* if segs_per_sec is large than 1, we need to keep original policy. */
+ if (sbi->segs_per_sec != 1)
+ return CURSEG_I(sbi, type)->segno;
+
if (type == CURSEG_HOT_DATA || IS_NODESEG(type))
return 0;
@@ -1901,17 +1913,21 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type)
static void allocate_segment_by_default(struct f2fs_sb_info *sbi,
int type, bool force)
{
+ struct curseg_info *curseg = CURSEG_I(sbi, type);
+
if (force)
new_curseg(sbi, type, true);
else if (!is_set_ckpt_flags(sbi, CP_CRC_RECOVERY_FLAG) &&
type == CURSEG_WARM_NODE)
new_curseg(sbi, type, false);
+ else if (curseg->alloc_type == LFS && is_next_segment_free(sbi, type))
+ new_curseg(sbi, type, false);
else if (need_SSR(sbi) && get_ssr_segment(sbi, type))
change_curseg(sbi, type, true);
else
new_curseg(sbi, type, false);
- stat_inc_seg_type(sbi, CURSEG_I(sbi, type));
+ stat_inc_seg_type(sbi, curseg);
}
void allocate_new_segments(struct f2fs_sb_info *sbi)
--
2.11.0
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] f2fs: add braces for macro variables more
2017-04-21 0:49 [PATCH 1/2] f2fs: add braces for macro variables more Jaegeuk Kim
2017-04-21 0:49 ` [PATCH 2/2] f2fs: fix out-of free segments Jaegeuk Kim
@ 2017-04-22 0:30 ` Chao Yu
2017-04-24 17:38 ` Jaegeuk Kim
1 sibling, 1 reply; 4+ messages in thread
From: Chao Yu @ 2017-04-22 0:30 UTC (permalink / raw)
To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel
On 2017/4/21 8:49, Jaegeuk Kim wrote:
> This patch adds braces for macro variables more in include/linux/f2fs_fs.h.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
> fs/f2fs/f2fs.h | 1 +
> include/linux/f2fs_fs.h | 10 +++++-----
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index e2d9a8d9101e..ca647d264b61 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -16,6 +16,7 @@
> #include <linux/buffer_head.h>
> #include <linux/slab.h>
> #include <linux/crc32.h>
> +#include <linux/quota.h>
This is no needed. ;)
Thanks,
> #include <linux/magic.h>
> #include <linux/kobject.h>
> #include <linux/sched.h>
> diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
> index e2d239ed4c60..639cbdf65e2b 100644
> --- a/include/linux/f2fs_fs.h
> +++ b/include/linux/f2fs_fs.h
> @@ -32,9 +32,9 @@
> /* 0, 1(node nid), 2(meta nid) are reserved node id */
> #define F2FS_RESERVED_NODE_NUM 3
>
> -#define F2FS_ROOT_INO(sbi) (sbi->root_ino_num)
> -#define F2FS_NODE_INO(sbi) (sbi->node_ino_num)
> -#define F2FS_META_INO(sbi) (sbi->meta_ino_num)
> +#define F2FS_ROOT_INO(sbi) ((sbi)->root_ino_num)
> +#define F2FS_NODE_INO(sbi) ((sbi)->node_ino_num)
> +#define F2FS_META_INO(sbi) ((sbi)->meta_ino_num)
>
> #define F2FS_IO_SIZE(sbi) (1 << (sbi)->write_io_size_bits) /* Blocks */
> #define F2FS_IO_SIZE_KB(sbi) (1 << ((sbi)->write_io_size_bits + 2)) /* KB */
> @@ -161,7 +161,7 @@ struct f2fs_checkpoint {
> */
> #define F2FS_ORPHANS_PER_BLOCK 1020
>
> -#define GET_ORPHAN_BLOCKS(n) ((n + F2FS_ORPHANS_PER_BLOCK - 1) / \
> +#define GET_ORPHAN_BLOCKS(n) (((n) + F2FS_ORPHANS_PER_BLOCK - 1) / \
> F2FS_ORPHANS_PER_BLOCK)
>
> struct f2fs_orphan_block {
> @@ -449,7 +449,7 @@ typedef __le32 f2fs_hash_t;
> #define F2FS_SLOT_LEN 8
> #define F2FS_SLOT_LEN_BITS 3
>
> -#define GET_DENTRY_SLOTS(x) ((x + F2FS_SLOT_LEN - 1) >> F2FS_SLOT_LEN_BITS)
> +#define GET_DENTRY_SLOTS(x) (((x) + F2FS_SLOT_LEN - 1) >> F2FS_SLOT_LEN_BITS)
>
> /* MAX level for dir lookup */
> #define MAX_DIR_HASH_DEPTH 63
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] f2fs: add braces for macro variables more
2017-04-22 0:30 ` [PATCH 1/2] f2fs: add braces for macro variables more Chao Yu
@ 2017-04-24 17:38 ` Jaegeuk Kim
0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2017-04-24 17:38 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel
On 04/22, Chao Yu wrote:
> On 2017/4/21 8:49, Jaegeuk Kim wrote:
> > This patch adds braces for macro variables more in include/linux/f2fs_fs.h.
> >
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> > fs/f2fs/f2fs.h | 1 +
> > include/linux/f2fs_fs.h | 10 +++++-----
> > 2 files changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index e2d9a8d9101e..ca647d264b61 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -16,6 +16,7 @@
> > #include <linux/buffer_head.h>
> > #include <linux/slab.h>
> > #include <linux/crc32.h>
> > +#include <linux/quota.h>
>
> This is no needed. ;)
Yup. :)
>
> Thanks,
>
> > #include <linux/magic.h>
> > #include <linux/kobject.h>
> > #include <linux/sched.h>
> > diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
> > index e2d239ed4c60..639cbdf65e2b 100644
> > --- a/include/linux/f2fs_fs.h
> > +++ b/include/linux/f2fs_fs.h
> > @@ -32,9 +32,9 @@
> > /* 0, 1(node nid), 2(meta nid) are reserved node id */
> > #define F2FS_RESERVED_NODE_NUM 3
> >
> > -#define F2FS_ROOT_INO(sbi) (sbi->root_ino_num)
> > -#define F2FS_NODE_INO(sbi) (sbi->node_ino_num)
> > -#define F2FS_META_INO(sbi) (sbi->meta_ino_num)
> > +#define F2FS_ROOT_INO(sbi) ((sbi)->root_ino_num)
> > +#define F2FS_NODE_INO(sbi) ((sbi)->node_ino_num)
> > +#define F2FS_META_INO(sbi) ((sbi)->meta_ino_num)
> >
> > #define F2FS_IO_SIZE(sbi) (1 << (sbi)->write_io_size_bits) /* Blocks */
> > #define F2FS_IO_SIZE_KB(sbi) (1 << ((sbi)->write_io_size_bits + 2)) /* KB */
> > @@ -161,7 +161,7 @@ struct f2fs_checkpoint {
> > */
> > #define F2FS_ORPHANS_PER_BLOCK 1020
> >
> > -#define GET_ORPHAN_BLOCKS(n) ((n + F2FS_ORPHANS_PER_BLOCK - 1) / \
> > +#define GET_ORPHAN_BLOCKS(n) (((n) + F2FS_ORPHANS_PER_BLOCK - 1) / \
> > F2FS_ORPHANS_PER_BLOCK)
> >
> > struct f2fs_orphan_block {
> > @@ -449,7 +449,7 @@ typedef __le32 f2fs_hash_t;
> > #define F2FS_SLOT_LEN 8
> > #define F2FS_SLOT_LEN_BITS 3
> >
> > -#define GET_DENTRY_SLOTS(x) ((x + F2FS_SLOT_LEN - 1) >> F2FS_SLOT_LEN_BITS)
> > +#define GET_DENTRY_SLOTS(x) (((x) + F2FS_SLOT_LEN - 1) >> F2FS_SLOT_LEN_BITS)
> >
> > /* MAX level for dir lookup */
> > #define MAX_DIR_HASH_DEPTH 63
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-24 17:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-21 0:49 [PATCH 1/2] f2fs: add braces for macro variables more Jaegeuk Kim
2017-04-21 0:49 ` [PATCH 2/2] f2fs: fix out-of free segments Jaegeuk Kim
2017-04-22 0:30 ` [PATCH 1/2] f2fs: add braces for macro variables more Chao Yu
2017-04-24 17:38 ` 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).