linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Huajun Li <huajun.li.lee@gmail.com>
To: jaegeuk.kim@samsung.com, linux-f2fs-devel@lists.sourceforge.net
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Huajun Li <huajun.li@intel.com>,
	Haicheng Li <haicheng.li@linux.intel.com>,
	Weihong Xu <weihong.xu@intel.com>
Subject: [f2fs-dev 3/5] f2fs: Add a new function: f2fs_reserve_block()
Date: Sat, 26 Oct 2013 00:01:57 +0800	[thread overview]
Message-ID: <1382716919-23345-4-git-send-email-huajun.li.lee@gmail.com> (raw)
In-Reply-To: <1382716919-23345-1-git-send-email-huajun.li.lee@gmail.com>

From: Huajun Li <huajun.li@intel.com>

Add the function f2fs_reserve_block() to easily reserve new blocks.

Signed-off-by: Huajun Li <huajun.li@intel.com>
Signed-off-by: Haicheng Li <haicheng.li@linux.intel.com>
Signed-off-by: Weihong Xu <weihong.xu@intel.com>
---
 fs/f2fs/data.c |   29 ++++++++++++++++++-----------
 fs/f2fs/f2fs.h |    1 +
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index c8887d8..7b31911 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -64,6 +64,23 @@ int reserve_new_block(struct dnode_of_data *dn)
 	return 0;
 }
 
+int f2fs_reserve_block(struct inode *inode,
+		       struct dnode_of_data *dn, pgoff_t index)
+{
+	int err;
+
+	set_new_dnode(dn, inode, NULL, NULL, 0);
+	err = get_dnode_of_data(dn, index, ALLOC_NODE);
+	if (err)
+		return err;
+	if (dn->data_blkaddr == NULL_ADDR)
+		err = reserve_new_block(dn);
+
+	f2fs_put_dnode(dn);
+
+	return err;
+}
+
 static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
 					struct buffer_head *bh_result)
 {
@@ -644,19 +661,9 @@ repeat:
 	*pagep = page;
 
 	f2fs_lock_op(sbi);
-
-	set_new_dnode(&dn, inode, NULL, NULL, 0);
-	err = get_dnode_of_data(&dn, index, ALLOC_NODE);
-	if (err)
-		goto err;
-
-	if (dn.data_blkaddr == NULL_ADDR)
-		err = reserve_new_block(&dn);
-
-	f2fs_put_dnode(&dn);
+	err = f2fs_reserve_block(inode, &dn, index);
 	if (err)
 		goto err;
-
 	f2fs_unlock_op(sbi);
 
 	if ((len == PAGE_CACHE_SIZE) || PageUptodate(page))
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e50a8b0..4f34330 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1112,6 +1112,7 @@ void destroy_checkpoint_caches(void);
  * data.c
  */
 int reserve_new_block(struct dnode_of_data *);
+int f2fs_reserve_block(struct inode *, struct dnode_of_data *, pgoff_t);
 void update_extent_cache(block_t, struct dnode_of_data *);
 struct page *find_data_page(struct inode *, pgoff_t, bool);
 struct page *get_lock_data_page(struct inode *, pgoff_t);
-- 
1.7.9.5

  parent reply	other threads:[~2013-10-25 16:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-25 16:01 [f2fs-dev 0/5] f2fs: Enable f2fs support inline data Huajun Li
2013-10-25 16:01 ` [f2fs-dev 1/5] f2fs: Add flags and helpers to " Huajun Li
2013-10-25 16:01 ` [f2fs-dev 2/5] f2fs: Add a new mount option: inline_data Huajun Li
2013-10-25 16:01 ` Huajun Li [this message]
     [not found]   ` <1382962607.992.104.camel@kjgkr>
2013-10-28 12:28     ` [f2fs-dev 3/5] f2fs: Add a new function: f2fs_reserve_block() Jaegeuk Kim
2013-10-28 16:53       ` Huajun Li
2013-10-29  0:56         ` Jaegeuk Kim
2013-10-29 15:27           ` Huajun Li
2013-10-25 16:01 ` [f2fs-dev 4/5] f2fs: Key functions to handle inline data Huajun Li
2013-10-28 12:43   ` Jaegeuk Kim
2013-10-28 17:20     ` Huajun Li
2013-10-29  1:06       ` Jaegeuk Kim
2013-10-29 15:33         ` Huajun Li
2013-10-25 16:01 ` [f2fs-dev 5/5] f2fs: Handle inline data operations Huajun Li
2013-10-28 12:44   ` Jaegeuk Kim
2013-10-28 16:56     ` Huajun Li

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=1382716919-23345-4-git-send-email-huajun.li.lee@gmail.com \
    --to=huajun.li.lee@gmail.com \
    --cc=haicheng.li@linux.intel.com \
    --cc=huajun.li@intel.com \
    --cc=jaegeuk.kim@samsung.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=weihong.xu@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 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).