* [PATCH v3] f2fs: check blkaddr more accuratly before issue a bio
@ 2018-03-08 8:29 Yunlei He
2018-03-08 9:12 ` Chao Yu
0 siblings, 1 reply; 5+ messages in thread
From: Yunlei He @ 2018-03-08 8:29 UTC (permalink / raw)
To: jaegeuk, yuchao0, linux-f2fs-devel; +Cc: heyunlei
This patch check blkaddr more accuratly before issue a
write or read bio.
Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
fs/f2fs/checkpoint.c | 2 ++
fs/f2fs/data.c | 5 +++--
fs/f2fs/f2fs.h | 1 +
fs/f2fs/segment.h | 25 +++++++++++++++++++------
4 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 5b2db75..bf77946 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -68,6 +68,7 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
.old_blkaddr = index,
.new_blkaddr = index,
.encrypted_page = NULL,
+ .is_meta = is_meta,
};
if (unlikely(!is_meta))
@@ -162,6 +163,7 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
.op_flags = sync ? (REQ_META | REQ_PRIO) : REQ_RAHEAD,
.encrypted_page = NULL,
.in_list = false,
+ .is_meta = (type != META_POR),
};
struct blk_plug plug;
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 6c3c978..de036e8 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -383,6 +383,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
struct page *page = fio->encrypted_page ?
fio->encrypted_page : fio->page;
+ verify_block_addr(fio, fio->new_blkaddr);
trace_f2fs_submit_page_bio(page, fio);
f2fs_trace_ios(fio, 0);
@@ -428,8 +429,8 @@ int f2fs_submit_page_write(struct f2fs_io_info *fio)
}
if (fio->old_blkaddr != NEW_ADDR)
- verify_block_addr(sbi, fio->old_blkaddr);
- verify_block_addr(sbi, fio->new_blkaddr);
+ verify_block_addr(fio, fio->old_blkaddr);
+ verify_block_addr(fio, fio->new_blkaddr);
bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f6dc706..842adea 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -980,6 +980,7 @@ struct f2fs_io_info {
bool submitted; /* indicate IO submission */
int need_lock; /* indicate we need to lock cp_rwsem */
bool in_list; /* indicate fio is in io_list */
+ bool is_meta; /* indicate borrow meta inode mapping or not */
enum iostat_type io_type; /* io type */
struct writeback_control *io_wbc; /* writeback control */
};
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index dbb774aa..3325d07 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -53,13 +53,19 @@
((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \
(sbi)->segs_per_sec)) \
-#define MAIN_BLKADDR(sbi) (SM_I(sbi)->main_blkaddr)
-#define SEG0_BLKADDR(sbi) (SM_I(sbi)->seg0_blkaddr)
+#define MAIN_BLKADDR(sbi) \
+ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \
+ le32_to_cpu(F2FS_RAW_SUPER(sbi)->main_blkaddr))
+#define SEG0_BLKADDR(sbi) \
+ (SM_I(sbi) ? SM_I(sbi)->seg0_blkaddr : \
+ le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment0_blkaddr))
#define MAIN_SEGS(sbi) (SM_I(sbi)->main_segments)
#define MAIN_SECS(sbi) ((sbi)->total_sections)
-#define TOTAL_SEGS(sbi) (SM_I(sbi)->segment_count)
+#define TOTAL_SEGS(sbi) \
+ (SM_I(sbi) ? SM_I(sbi)->segment_count : \
+ le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count))
#define TOTAL_BLKS(sbi) (TOTAL_SEGS(sbi) << (sbi)->log_blocks_per_seg)
#define MAX_BLKADDR(sbi) (SEG0_BLKADDR(sbi) + TOTAL_BLKS(sbi))
@@ -632,10 +638,17 @@ static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
}
-static inline void verify_block_addr(struct f2fs_sb_info *sbi, block_t blk_addr)
+static inline void verify_block_addr(struct f2fs_io_info *fio, block_t blk_addr)
{
- BUG_ON(blk_addr < SEG0_BLKADDR(sbi)
- || blk_addr >= MAX_BLKADDR(sbi));
+ struct f2fs_sb_info *sbi = fio->sbi;
+
+ if (PAGE_TYPE_OF_BIO(fio->type) == META &&
+ (!is_read_io(fio->op) || fio->is_meta))
+ BUG_ON(blk_addr < SEG0_BLKADDR(sbi) ||
+ blk_addr >= MAIN_BLKADDR(sbi));
+ else
+ BUG_ON(blk_addr < MAIN_BLKADDR(sbi) ||
+ blk_addr >= MAX_BLKADDR(sbi));
}
/*
--
1.9.1
------------------------------------------------------------------------------
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] 5+ messages in thread
* Re: [PATCH v3] f2fs: check blkaddr more accuratly before issue a bio
2018-03-08 8:29 [PATCH v3] f2fs: check blkaddr more accuratly before issue a bio Yunlei He
@ 2018-03-08 9:12 ` Chao Yu
2018-03-19 1:55 ` heyunlei
0 siblings, 1 reply; 5+ messages in thread
From: Chao Yu @ 2018-03-08 9:12 UTC (permalink / raw)
To: Yunlei He, jaegeuk, linux-f2fs-devel
On 2018/3/8 16:29, Yunlei He wrote:
> This patch check blkaddr more accuratly before issue a
> write or read bio.
>
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Thanks,
------------------------------------------------------------------------------
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 [flat|nested] 5+ messages in thread
* Re: [PATCH v3] f2fs: check blkaddr more accuratly before issue a bio
2018-03-08 9:12 ` Chao Yu
@ 2018-03-19 1:55 ` heyunlei
0 siblings, 0 replies; 5+ messages in thread
From: heyunlei @ 2018-03-19 1:55 UTC (permalink / raw)
To: Yuchao (T), jaegeuk, linux-f2fs-devel
ping
>-----Original Message-----
>From: Yuchao (T)
>Sent: Thursday, March 08, 2018 5:12 PM
>To: heyunlei; jaegeuk@kernel.org; linux-f2fs-devel@lists.sourceforge.net
>Cc: Wangbintian
>Subject: Re: [f2fs-dev][PATCH v3] f2fs: check blkaddr more accuratly before issue a bio
>
>On 2018/3/8 16:29, Yunlei He wrote:
>> This patch check blkaddr more accuratly before issue a
>> write or read bio.
>>
>> Signed-off-by: Yunlei He <heyunlei@huawei.com>
>
>Reviewed-by: Chao Yu <yuchao0@huawei.com>
>
>Thanks,
------------------------------------------------------------------------------
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 [flat|nested] 5+ messages in thread
* Re: [PATCH v3] f2fs: check blkaddr more accuratly before issue a bio
2018-03-09 9:52 Yunlei He
@ 2018-03-09 10:08 ` heyunlei
0 siblings, 0 replies; 5+ messages in thread
From: heyunlei @ 2018-03-09 10:08 UTC (permalink / raw)
To: heyunlei, jaegeuk, Yuchao (T), linux-f2fs-devel; +Cc: Zhangdianfang (Euler)
>-----Original Message-----
>From: heyunlei
>Sent: Friday, March 09, 2018 5:52 PM
>To: jaegeuk@kernel.org; Yuchao (T); linux-f2fs-devel@lists.sourceforge.net
>Cc: Wangbintian; Zhangdianfang (Euler); heyunlei
>Subject: [f2fs-dev][PATCH v3] f2fs: check blkaddr more accuratly before issue a bio
>
I'm sorry that resend this email, please ignore this!
Thanks.
>This patch check blkaddr more accuratly before issue a
>write or read bio.
>
>Signed-off-by: Yunlei He <heyunlei@huawei.com>
>---
> fs/f2fs/checkpoint.c | 2 ++
> fs/f2fs/data.c | 5 +++--
> fs/f2fs/f2fs.h | 1 +
> fs/f2fs/segment.h | 25 +++++++++++++++++++------
> 4 files changed, 25 insertions(+), 8 deletions(-)
>
>diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
>index 5b2db75..bf77946 100644
>--- a/fs/f2fs/checkpoint.c
>+++ b/fs/f2fs/checkpoint.c
>@@ -68,6 +68,7 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
> .old_blkaddr = index,
> .new_blkaddr = index,
> .encrypted_page = NULL,
>+ .is_meta = is_meta,
> };
>
> if (unlikely(!is_meta))
>@@ -162,6 +163,7 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
> .op_flags = sync ? (REQ_META | REQ_PRIO) : REQ_RAHEAD,
> .encrypted_page = NULL,
> .in_list = false,
>+ .is_meta = (type != META_POR),
> };
> struct blk_plug plug;
>
>diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
>index 6c3c978..de036e8 100644
>--- a/fs/f2fs/data.c
>+++ b/fs/f2fs/data.c
>@@ -383,6 +383,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
> struct page *page = fio->encrypted_page ?
> fio->encrypted_page : fio->page;
>
>+ verify_block_addr(fio, fio->new_blkaddr);
> trace_f2fs_submit_page_bio(page, fio);
> f2fs_trace_ios(fio, 0);
>
>@@ -428,8 +429,8 @@ int f2fs_submit_page_write(struct f2fs_io_info *fio)
> }
>
> if (fio->old_blkaddr != NEW_ADDR)
>- verify_block_addr(sbi, fio->old_blkaddr);
>- verify_block_addr(sbi, fio->new_blkaddr);
>+ verify_block_addr(fio, fio->old_blkaddr);
>+ verify_block_addr(fio, fio->new_blkaddr);
>
> bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
>
>diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>index f6dc706..842adea 100644
>--- a/fs/f2fs/f2fs.h
>+++ b/fs/f2fs/f2fs.h
>@@ -980,6 +980,7 @@ struct f2fs_io_info {
> bool submitted; /* indicate IO submission */
> int need_lock; /* indicate we need to lock cp_rwsem */
> bool in_list; /* indicate fio is in io_list */
>+ bool is_meta; /* indicate borrow meta inode mapping or not */
> enum iostat_type io_type; /* io type */
> struct writeback_control *io_wbc; /* writeback control */
> };
>diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
>index dbb774aa..3325d07 100644
>--- a/fs/f2fs/segment.h
>+++ b/fs/f2fs/segment.h
>@@ -53,13 +53,19 @@
> ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \
> (sbi)->segs_per_sec)) \
>
>-#define MAIN_BLKADDR(sbi) (SM_I(sbi)->main_blkaddr)
>-#define SEG0_BLKADDR(sbi) (SM_I(sbi)->seg0_blkaddr)
>+#define MAIN_BLKADDR(sbi) \
>+ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \
>+ le32_to_cpu(F2FS_RAW_SUPER(sbi)->main_blkaddr))
>+#define SEG0_BLKADDR(sbi) \
>+ (SM_I(sbi) ? SM_I(sbi)->seg0_blkaddr : \
>+ le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment0_blkaddr))
>
> #define MAIN_SEGS(sbi) (SM_I(sbi)->main_segments)
> #define MAIN_SECS(sbi) ((sbi)->total_sections)
>
>-#define TOTAL_SEGS(sbi) (SM_I(sbi)->segment_count)
>+#define TOTAL_SEGS(sbi) \
>+ (SM_I(sbi) ? SM_I(sbi)->segment_count : \
>+ le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count))
> #define TOTAL_BLKS(sbi) (TOTAL_SEGS(sbi) << (sbi)->log_blocks_per_seg)
>
> #define MAX_BLKADDR(sbi) (SEG0_BLKADDR(sbi) + TOTAL_BLKS(sbi))
>@@ -632,10 +638,17 @@ static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
> f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
> }
>
>-static inline void verify_block_addr(struct f2fs_sb_info *sbi, block_t blk_addr)
>+static inline void verify_block_addr(struct f2fs_io_info *fio, block_t blk_addr)
> {
>- BUG_ON(blk_addr < SEG0_BLKADDR(sbi)
>- || blk_addr >= MAX_BLKADDR(sbi));
>+ struct f2fs_sb_info *sbi = fio->sbi;
>+
>+ if (PAGE_TYPE_OF_BIO(fio->type) == META &&
>+ (!is_read_io(fio->op) || fio->is_meta))
>+ BUG_ON(blk_addr < SEG0_BLKADDR(sbi) ||
>+ blk_addr >= MAIN_BLKADDR(sbi));
>+ else
>+ BUG_ON(blk_addr < MAIN_BLKADDR(sbi) ||
>+ blk_addr >= MAX_BLKADDR(sbi));
> }
>
> /*
>--
>1.9.1
------------------------------------------------------------------------------
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 [flat|nested] 5+ messages in thread
* [PATCH v3] f2fs: check blkaddr more accuratly before issue a bio
@ 2018-03-09 9:52 Yunlei He
2018-03-09 10:08 ` heyunlei
0 siblings, 1 reply; 5+ messages in thread
From: Yunlei He @ 2018-03-09 9:52 UTC (permalink / raw)
To: jaegeuk, yuchao0, linux-f2fs-devel; +Cc: heyunlei, zhangdianfang
This patch check blkaddr more accuratly before issue a
write or read bio.
Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
fs/f2fs/checkpoint.c | 2 ++
fs/f2fs/data.c | 5 +++--
fs/f2fs/f2fs.h | 1 +
fs/f2fs/segment.h | 25 +++++++++++++++++++------
4 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 5b2db75..bf77946 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -68,6 +68,7 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
.old_blkaddr = index,
.new_blkaddr = index,
.encrypted_page = NULL,
+ .is_meta = is_meta,
};
if (unlikely(!is_meta))
@@ -162,6 +163,7 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
.op_flags = sync ? (REQ_META | REQ_PRIO) : REQ_RAHEAD,
.encrypted_page = NULL,
.in_list = false,
+ .is_meta = (type != META_POR),
};
struct blk_plug plug;
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 6c3c978..de036e8 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -383,6 +383,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
struct page *page = fio->encrypted_page ?
fio->encrypted_page : fio->page;
+ verify_block_addr(fio, fio->new_blkaddr);
trace_f2fs_submit_page_bio(page, fio);
f2fs_trace_ios(fio, 0);
@@ -428,8 +429,8 @@ int f2fs_submit_page_write(struct f2fs_io_info *fio)
}
if (fio->old_blkaddr != NEW_ADDR)
- verify_block_addr(sbi, fio->old_blkaddr);
- verify_block_addr(sbi, fio->new_blkaddr);
+ verify_block_addr(fio, fio->old_blkaddr);
+ verify_block_addr(fio, fio->new_blkaddr);
bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f6dc706..842adea 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -980,6 +980,7 @@ struct f2fs_io_info {
bool submitted; /* indicate IO submission */
int need_lock; /* indicate we need to lock cp_rwsem */
bool in_list; /* indicate fio is in io_list */
+ bool is_meta; /* indicate borrow meta inode mapping or not */
enum iostat_type io_type; /* io type */
struct writeback_control *io_wbc; /* writeback control */
};
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index dbb774aa..3325d07 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -53,13 +53,19 @@
((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \
(sbi)->segs_per_sec)) \
-#define MAIN_BLKADDR(sbi) (SM_I(sbi)->main_blkaddr)
-#define SEG0_BLKADDR(sbi) (SM_I(sbi)->seg0_blkaddr)
+#define MAIN_BLKADDR(sbi) \
+ (SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \
+ le32_to_cpu(F2FS_RAW_SUPER(sbi)->main_blkaddr))
+#define SEG0_BLKADDR(sbi) \
+ (SM_I(sbi) ? SM_I(sbi)->seg0_blkaddr : \
+ le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment0_blkaddr))
#define MAIN_SEGS(sbi) (SM_I(sbi)->main_segments)
#define MAIN_SECS(sbi) ((sbi)->total_sections)
-#define TOTAL_SEGS(sbi) (SM_I(sbi)->segment_count)
+#define TOTAL_SEGS(sbi) \
+ (SM_I(sbi) ? SM_I(sbi)->segment_count : \
+ le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count))
#define TOTAL_BLKS(sbi) (TOTAL_SEGS(sbi) << (sbi)->log_blocks_per_seg)
#define MAX_BLKADDR(sbi) (SEG0_BLKADDR(sbi) + TOTAL_BLKS(sbi))
@@ -632,10 +638,17 @@ static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
}
-static inline void verify_block_addr(struct f2fs_sb_info *sbi, block_t blk_addr)
+static inline void verify_block_addr(struct f2fs_io_info *fio, block_t blk_addr)
{
- BUG_ON(blk_addr < SEG0_BLKADDR(sbi)
- || blk_addr >= MAX_BLKADDR(sbi));
+ struct f2fs_sb_info *sbi = fio->sbi;
+
+ if (PAGE_TYPE_OF_BIO(fio->type) == META &&
+ (!is_read_io(fio->op) || fio->is_meta))
+ BUG_ON(blk_addr < SEG0_BLKADDR(sbi) ||
+ blk_addr >= MAIN_BLKADDR(sbi));
+ else
+ BUG_ON(blk_addr < MAIN_BLKADDR(sbi) ||
+ blk_addr >= MAX_BLKADDR(sbi));
}
/*
--
1.9.1
------------------------------------------------------------------------------
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] 5+ messages in thread
end of thread, other threads:[~2018-03-19 1:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-08 8:29 [PATCH v3] f2fs: check blkaddr more accuratly before issue a bio Yunlei He
2018-03-08 9:12 ` Chao Yu
2018-03-19 1:55 ` heyunlei
2018-03-09 9:52 Yunlei He
2018-03-09 10:08 ` heyunlei
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.