From: Chao Yu <chao2.yu@samsung.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Changman Lee <cm224.lee@samsung.com>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH v2 1/3] f2fs: introduce replace_block() for reuse
Date: Thu, 30 Apr 2015 18:11:35 +0800 [thread overview]
Message-ID: <025501d0832e$24f33fc0$6ed9bf40$@samsung.com> (raw)
Introduce a generic function replace_block base on recover_data_page,
and export it. So wit it we can operate file's meta data which is in
CP/SSA area when we invoke fallocate with FALLOC_FL_COLLAPSE_RANGE flag.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
fs/f2fs/f2fs.h | 4 ++--
fs/f2fs/recovery.c | 2 +-
fs/f2fs/segment.c | 33 ++++++++++++++++++++++++++-------
3 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 8be6cab..7ab06e8 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1560,8 +1560,8 @@ void write_node_page(struct f2fs_sb_info *, struct page *,
void write_data_page(struct page *, struct dnode_of_data *,
struct f2fs_io_info *);
void rewrite_data_page(struct page *, struct f2fs_io_info *);
-void recover_data_page(struct f2fs_sb_info *, struct page *,
- struct f2fs_summary *, block_t, block_t);
+void replace_block(struct f2fs_sb_info *, struct f2fs_summary *,
+ block_t, block_t, bool);
void allocate_data_block(struct f2fs_sb_info *, struct page *,
block_t, block_t *, struct f2fs_summary *, int);
void f2fs_wait_on_page_writeback(struct page *, enum page_type);
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index b80d9d4..703ab2f 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -412,7 +412,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version);
/* write dummy data page */
- recover_data_page(sbi, NULL, &sum, src, dest);
+ replace_block(sbi, &sum, src, dest, true);
dn.data_blkaddr = dest;
set_data_blkaddr(&dn);
f2fs_update_extent_cache(&dn);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index f939660..3db92fe 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1258,26 +1258,34 @@ void rewrite_data_page(struct page *page, struct f2fs_io_info *fio)
f2fs_submit_page_mbio(F2FS_P_SB(page), page, fio);
}
-void recover_data_page(struct f2fs_sb_info *sbi,
- struct page *page, struct f2fs_summary *sum,
- block_t old_blkaddr, block_t new_blkaddr)
+void replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
+ block_t old_blkaddr, block_t new_blkaddr,
+ bool recover_curseg)
{
struct sit_info *sit_i = SIT_I(sbi);
struct curseg_info *curseg;
unsigned int segno, old_cursegno;
struct seg_entry *se;
int type;
+ unsigned short old_blkoff;
segno = GET_SEGNO(sbi, new_blkaddr);
se = get_seg_entry(sbi, segno);
type = se->type;
- if (se->valid_blocks == 0 && !IS_CURSEG(sbi, segno)) {
- if (old_blkaddr == NULL_ADDR)
- type = CURSEG_COLD_DATA;
- else
+ if (recover_curseg) {
+ /* for recovery flow */
+ if (se->valid_blocks == 0 && !IS_CURSEG(sbi, segno)) {
+ if (old_blkaddr == NULL_ADDR)
+ type = CURSEG_COLD_DATA;
+ else
+ type = CURSEG_WARM_DATA;
+ }
+ } else {
+ if (!IS_CURSEG(sbi, segno))
type = CURSEG_WARM_DATA;
}
+
curseg = CURSEG_I(sbi, type);
mutex_lock(&curseg->curseg_mutex);
@@ -1289,6 +1297,10 @@ void recover_data_page(struct f2fs_sb_info *sbi,
if (segno != curseg->segno) {
curseg->next_segno = segno;
change_curseg(sbi, type, true);
+ recover_curseg = true;
+ } else {
+ old_blkoff = curseg->next_blkoff;
+ recover_curseg = false;
}
curseg->next_blkoff = GET_BLKOFF_FROM_SEG0(sbi, new_blkaddr);
@@ -1297,6 +1309,13 @@ void recover_data_page(struct f2fs_sb_info *sbi,
refresh_sit_entry(sbi, old_blkaddr, new_blkaddr);
locate_dirty_segment(sbi, old_cursegno);
+ if (recover_curseg) {
+ curseg->next_segno = old_cursegno;
+ change_curseg(sbi, type, true);
+ } else {
+ curseg->next_blkoff = old_blkoff;
+ }
+
mutex_unlock(&sit_i->sentry_lock);
mutex_unlock(&curseg->curseg_mutex);
}
--
2.3.3
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu <chao2.yu@samsung.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Changman Lee <cm224.lee@samsung.com>
Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/3] f2fs: introduce replace_block() for reuse
Date: Thu, 30 Apr 2015 18:11:35 +0800 [thread overview]
Message-ID: <025501d0832e$24f33fc0$6ed9bf40$@samsung.com> (raw)
Introduce a generic function replace_block base on recover_data_page,
and export it. So wit it we can operate file's meta data which is in
CP/SSA area when we invoke fallocate with FALLOC_FL_COLLAPSE_RANGE flag.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
fs/f2fs/f2fs.h | 4 ++--
fs/f2fs/recovery.c | 2 +-
fs/f2fs/segment.c | 33 ++++++++++++++++++++++++++-------
3 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 8be6cab..7ab06e8 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1560,8 +1560,8 @@ void write_node_page(struct f2fs_sb_info *, struct page *,
void write_data_page(struct page *, struct dnode_of_data *,
struct f2fs_io_info *);
void rewrite_data_page(struct page *, struct f2fs_io_info *);
-void recover_data_page(struct f2fs_sb_info *, struct page *,
- struct f2fs_summary *, block_t, block_t);
+void replace_block(struct f2fs_sb_info *, struct f2fs_summary *,
+ block_t, block_t, bool);
void allocate_data_block(struct f2fs_sb_info *, struct page *,
block_t, block_t *, struct f2fs_summary *, int);
void f2fs_wait_on_page_writeback(struct page *, enum page_type);
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index b80d9d4..703ab2f 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -412,7 +412,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version);
/* write dummy data page */
- recover_data_page(sbi, NULL, &sum, src, dest);
+ replace_block(sbi, &sum, src, dest, true);
dn.data_blkaddr = dest;
set_data_blkaddr(&dn);
f2fs_update_extent_cache(&dn);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index f939660..3db92fe 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1258,26 +1258,34 @@ void rewrite_data_page(struct page *page, struct f2fs_io_info *fio)
f2fs_submit_page_mbio(F2FS_P_SB(page), page, fio);
}
-void recover_data_page(struct f2fs_sb_info *sbi,
- struct page *page, struct f2fs_summary *sum,
- block_t old_blkaddr, block_t new_blkaddr)
+void replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
+ block_t old_blkaddr, block_t new_blkaddr,
+ bool recover_curseg)
{
struct sit_info *sit_i = SIT_I(sbi);
struct curseg_info *curseg;
unsigned int segno, old_cursegno;
struct seg_entry *se;
int type;
+ unsigned short old_blkoff;
segno = GET_SEGNO(sbi, new_blkaddr);
se = get_seg_entry(sbi, segno);
type = se->type;
- if (se->valid_blocks == 0 && !IS_CURSEG(sbi, segno)) {
- if (old_blkaddr == NULL_ADDR)
- type = CURSEG_COLD_DATA;
- else
+ if (recover_curseg) {
+ /* for recovery flow */
+ if (se->valid_blocks == 0 && !IS_CURSEG(sbi, segno)) {
+ if (old_blkaddr == NULL_ADDR)
+ type = CURSEG_COLD_DATA;
+ else
+ type = CURSEG_WARM_DATA;
+ }
+ } else {
+ if (!IS_CURSEG(sbi, segno))
type = CURSEG_WARM_DATA;
}
+
curseg = CURSEG_I(sbi, type);
mutex_lock(&curseg->curseg_mutex);
@@ -1289,6 +1297,10 @@ void recover_data_page(struct f2fs_sb_info *sbi,
if (segno != curseg->segno) {
curseg->next_segno = segno;
change_curseg(sbi, type, true);
+ recover_curseg = true;
+ } else {
+ old_blkoff = curseg->next_blkoff;
+ recover_curseg = false;
}
curseg->next_blkoff = GET_BLKOFF_FROM_SEG0(sbi, new_blkaddr);
@@ -1297,6 +1309,13 @@ void recover_data_page(struct f2fs_sb_info *sbi,
refresh_sit_entry(sbi, old_blkaddr, new_blkaddr);
locate_dirty_segment(sbi, old_cursegno);
+ if (recover_curseg) {
+ curseg->next_segno = old_cursegno;
+ change_curseg(sbi, type, true);
+ } else {
+ curseg->next_blkoff = old_blkoff;
+ }
+
mutex_unlock(&sit_i->sentry_lock);
mutex_unlock(&curseg->curseg_mutex);
}
--
2.3.3
next reply other threads:[~2015-04-30 10:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-30 10:11 Chao Yu [this message]
2015-04-30 10:11 ` [PATCH v2 1/3] f2fs: introduce replace_block() for reuse Chao Yu
2015-04-30 18:03 ` Jaegeuk Kim
2015-05-06 5:05 ` Chao Yu
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='025501d0832e$24f33fc0$6ed9bf40$@samsung.com' \
--to=chao2.yu@samsung.com \
--cc=cm224.lee@samsung.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/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.