From: Jaegeuk Kim <jaegeuk.kim@samsung.com>
To: Huajun Li <huajun.li.lee@gmail.com>
Cc: linux-f2fs-devel@lists.sourceforge.net,
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: Re: [f2fs-dev][PATCH V2 3/6] f2fs: Add a new function: f2fs_reserve_block()
Date: Mon, 25 Nov 2013 20:05:06 +0900 [thread overview]
Message-ID: <1385377506.26319.159.camel@kjgkr> (raw)
In-Reply-To: <1384096401-25169-4-git-send-email-huajun.li.lee@gmail.com>
Hi Huajun,
I think this clean-up is not related to inline_data series, so I merged
this patch earlier.
Thanks,
2013-11-10 (일), 23:13 +0800, Huajun Li:
> From: Huajun Li <huajun.li@intel.com>
>
> Add the function f2fs_reserve_block() to easily reserve new blocks, and
> use it to clean up more codes.
>
> 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 | 50 +++++++++++++++++++++++---------------------------
> fs/f2fs/f2fs.h | 1 +
> fs/f2fs/file.c | 38 ++++++--------------------------------
> 3 files changed, 30 insertions(+), 59 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index aa3438c..92d0724 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -64,6 +64,22 @@ int reserve_new_block(struct dnode_of_data *dn)
> return 0;
> }
>
> +int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
> +{
> + bool need_put = dn->inode_page ? false : true;
> + int err;
> +
> + err = get_dnode_of_data(dn, index, ALLOC_NODE);
> + if (err)
> + return err;
> + if (dn->data_blkaddr == NULL_ADDR)
> + err = reserve_new_block(dn);
> +
> + if (need_put)
> + f2fs_put_dnode(dn);
> + return err;
> +}
> +
> static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
> struct buffer_head *bh_result)
> {
> @@ -300,19 +316,10 @@ struct page *get_new_data_page(struct inode *inode,
> int err;
>
> set_new_dnode(&dn, inode, npage, npage, 0);
> - err = get_dnode_of_data(&dn, index, ALLOC_NODE);
> + err = f2fs_reserve_block(&dn, index);
> if (err)
> return ERR_PTR(err);
>
> - if (dn.data_blkaddr == NULL_ADDR) {
> - if (reserve_new_block(&dn)) {
> - if (!npage)
> - f2fs_put_dnode(&dn);
> - return ERR_PTR(-ENOSPC);
> - }
> - }
> - if (!npage)
> - f2fs_put_dnode(&dn);
> repeat:
> page = grab_cache_page(mapping, index);
> if (!page)
> @@ -644,21 +651,15 @@ 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);
> - if (err)
> - goto err;
> -
> + err = f2fs_reserve_block(&dn, index);
> f2fs_unlock_op(sbi);
>
> + if (err) {
> + f2fs_put_page(page, 1);
> + return err;
> + }
> +
> if ((len == PAGE_CACHE_SIZE) || PageUptodate(page))
> return 0;
>
> @@ -691,11 +692,6 @@ out:
> SetPageUptodate(page);
> clear_cold_data(page);
> return 0;
> -
> -err:
> - f2fs_unlock_op(sbi);
> - f2fs_put_page(page, 1);
> - return err;
> }
>
> static int f2fs_write_end(struct file *file,
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index cd7d2f9..de84f52 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1119,6 +1119,7 @@ void destroy_checkpoint_caches(void);
> * data.c
> */
> int reserve_new_block(struct dnode_of_data *);
> +int f2fs_reserve_block(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);
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 7d714f4..1cd8e44 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -33,7 +33,6 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma,
> struct page *page = vmf->page;
> struct inode *inode = file_inode(vma->vm_file);
> struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
> - block_t old_blk_addr;
> struct dnode_of_data dn;
> int err;
>
> @@ -44,24 +43,10 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma,
> /* block allocation */
> f2fs_lock_op(sbi);
> set_new_dnode(&dn, inode, NULL, NULL, 0);
> - err = get_dnode_of_data(&dn, page->index, ALLOC_NODE);
> - if (err) {
> - f2fs_unlock_op(sbi);
> - goto out;
> - }
> -
> - old_blk_addr = dn.data_blkaddr;
> -
> - if (old_blk_addr == NULL_ADDR) {
> - err = reserve_new_block(&dn);
> - if (err) {
> - f2fs_put_dnode(&dn);
> - f2fs_unlock_op(sbi);
> - goto out;
> - }
> - }
> - f2fs_put_dnode(&dn);
> + err = f2fs_reserve_block(&dn, page->index);
> f2fs_unlock_op(sbi);
> + if (err)
> + goto out;
>
> file_update_time(vma->vm_file);
> lock_page(page);
> @@ -532,22 +517,11 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
>
> f2fs_lock_op(sbi);
> set_new_dnode(&dn, inode, NULL, NULL, 0);
> - ret = get_dnode_of_data(&dn, index, ALLOC_NODE);
> - if (ret) {
> - f2fs_unlock_op(sbi);
> + ret = f2fs_reserve_block(&dn, index);
> + f2fs_unlock_op(sbi);
> + if (ret)
> break;
> - }
>
> - if (dn.data_blkaddr == NULL_ADDR) {
> - ret = reserve_new_block(&dn);
> - if (ret) {
> - f2fs_put_dnode(&dn);
> - f2fs_unlock_op(sbi);
> - break;
> - }
> - }
> - f2fs_put_dnode(&dn);
> - f2fs_unlock_op(sbi);
>
> if (pg_start == pg_end)
> new_size = offset + len;
--
Jaegeuk Kim
Samsung
next prev parent reply other threads:[~2013-11-25 11:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-10 15:13 [f2fs-dev][PATCH V2 0/6] f2fs: Enable f2fs support inline data Huajun Li
2013-11-10 15:13 ` [f2fs-dev][PATCH V2 1/6] f2fs: Add flags and helpers to " Huajun Li
2013-11-10 15:13 ` [f2fs-dev][PATCH V2 2/6] f2fs: Add a new mount option: inline_data Huajun Li
2013-11-10 15:13 ` [f2fs-dev][PATCH V2 3/6] f2fs: Add a new function: f2fs_reserve_block() Huajun Li
2013-11-25 11:05 ` Jaegeuk Kim [this message]
2013-11-10 15:13 ` [f2fs-dev][PATCH V2 4/6] f2fs: Key functions to handle inline data Huajun Li
2013-11-15 7:49 ` Jaegeuk Kim
2013-11-20 12:51 ` Huajun Li
2013-11-25 11:01 ` Jaegeuk Kim
2013-11-10 15:13 ` [f2fs-dev][PATCH V2 5/6] f2fs: Handle inline data operations Huajun Li
2013-11-10 15:13 ` [f2fs-dev][PATCH V2 6/6] f2fs: update f2fs Documentation Huajun Li
2013-11-26 7:45 ` [f2fs-dev][PATCH V2 0/6] f2fs: Enable f2fs support inline data Jaegeuk Kim
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=1385377506.26319.159.camel@kjgkr \
--to=jaegeuk.kim@samsung.com \
--cc=haicheng.li@linux.intel.com \
--cc=huajun.li.lee@gmail.com \
--cc=huajun.li@intel.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