* [f2fs-dev][RFC PATCH 03/10] f2fs: introduce f2fs_map_bh to clean codes of check_extent_cache
@ 2015-01-12 7:11 Chao Yu
2015-01-23 0:24 ` [RFC " Jaegeuk Kim
0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2015-01-12 7:11 UTC (permalink / raw)
To: Jaegeuk Kim, Changman Lee; +Cc: linux-f2fs-devel, linux-kernel
This patch introduces f2fs_map_bh to clean codes of check_extent_cache.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
fs/f2fs/data.c | 42 ++++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 935a23b..5a3e489 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -248,8 +248,30 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
return err;
}
+static void f2fs_map_bh(struct inode *inode, pgoff_t pgofs,
+ struct extent_info *ei, struct buffer_head *bh_result)
+{
+ unsigned int blkbits = inode->i_sb->s_blocksize_bits;
+ pgoff_t start_fofs, end_fofs;
+ block_t start_blkaddr;
+ size_t count;
+
+ start_fofs = ei->fofs;
+ end_fofs = ei->fofs + ei->len - 1;
+ start_blkaddr = ei->blk;
+
+ clear_buffer_new(bh_result);
+ map_bh(bh_result, inode->i_sb,
+ start_blkaddr + pgofs - start_fofs);
+ count = end_fofs - pgofs + 1;
+ if (count < (UINT_MAX >> blkbits))
+ bh_result->b_size = (count << blkbits);
+ else
+ bh_result->b_size = UINT_MAX;
+}
+
static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
- struct buffer_head *bh_result)
+ struct extent_info *ei)
{
struct f2fs_inode_info *fi = F2FS_I(inode);
pgoff_t start_fofs, end_fofs;
@@ -271,18 +293,7 @@ static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
start_blkaddr = fi->ext.blk;
if (pgofs >= start_fofs && pgofs <= end_fofs) {
- unsigned int blkbits = inode->i_sb->s_blocksize_bits;
- size_t count;
-
- clear_buffer_new(bh_result);
- map_bh(bh_result, inode->i_sb,
- start_blkaddr + pgofs - start_fofs);
- count = end_fofs - pgofs + 1;
- if (count < (UINT_MAX >> blkbits))
- bh_result->b_size = (count << blkbits);
- else
- bh_result->b_size = UINT_MAX;
-
+ *ei = fi->ext;
stat_inc_read_hit(inode->i_sb);
read_unlock(&fi->ext_lock);
return 1;
@@ -608,13 +619,16 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
int mode = create ? ALLOC_NODE : LOOKUP_NODE_RA;
pgoff_t pgofs, end_offset;
int err = 0, ofs = 1;
+ struct extent_info ei;
bool allocated = false;
/* Get the page offset from the block offset(iblock) */
pgofs = (pgoff_t)(iblock >> (PAGE_CACHE_SHIFT - blkbits));
- if (check_extent_cache(inode, pgofs, bh_result))
+ if (check_extent_cache(inode, pgofs, &ei)) {
+ f2fs_map_bh(inode, pgofs, &ei, bh_result);
goto out;
+ }
if (create) {
f2fs_balance_fs(F2FS_I_SB(inode));
--
2.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [f2fs-dev][RFC PATCH 03/10] f2fs: introduce f2fs_map_bh to clean codes of check_extent_cache
2015-01-12 7:11 [f2fs-dev][RFC PATCH 03/10] f2fs: introduce f2fs_map_bh to clean codes of check_extent_cache Chao Yu
@ 2015-01-23 0:24 ` Jaegeuk Kim
0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2015-01-23 0:24 UTC (permalink / raw)
To: Chao Yu; +Cc: Changman Lee, linux-f2fs-devel, linux-kernel
Hi Chao,
On Mon, Jan 12, 2015 at 03:11:04PM +0800, Chao Yu wrote:
> This patch introduces f2fs_map_bh to clean codes of check_extent_cache.
>
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
> fs/f2fs/data.c | 42 ++++++++++++++++++++++++++++--------------
> 1 file changed, 28 insertions(+), 14 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 935a23b..5a3e489 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -248,8 +248,30 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
> return err;
> }
>
> +static void f2fs_map_bh(struct inode *inode, pgoff_t pgofs,
> + struct extent_info *ei, struct buffer_head *bh_result)
> +{
> + unsigned int blkbits = inode->i_sb->s_blocksize_bits;
> + pgoff_t start_fofs, end_fofs;
> + block_t start_blkaddr;
> + size_t count;
> +
> + start_fofs = ei->fofs;
> + end_fofs = ei->fofs + ei->len - 1;
> + start_blkaddr = ei->blk;
> +
> + clear_buffer_new(bh_result);
> + map_bh(bh_result, inode->i_sb,
> + start_blkaddr + pgofs - start_fofs);
> + count = end_fofs - pgofs + 1;
How about cleaning this codes like this?
static void f2fs_map_bh(struct super_block *sb, pgoff_t pgofs,
struct extent_info *ei, struct buffer_head *bh_result)
{
unsigned int blkbits = sb->s_blocksize_bits;
size_t count;
clear_buffer_new(bh_result);
map_bh(bh_result, sb, ei->blk + pgofs - ei->fofs);
count = ei->fofs + ei->len - pgofs;
if (count < (UINT_MAX >> blkbits))
bh_result->b_size = (count << blkbits);
else
bh_result->b_size = UINT_MAX;
}
> + if (count < (UINT_MAX >> blkbits))
> + bh_result->b_size = (count << blkbits);
> + else
> + bh_result->b_size = UINT_MAX;
> +}
> +
> static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
> - struct buffer_head *bh_result)
> + struct extent_info *ei)
> {
> struct f2fs_inode_info *fi = F2FS_I(inode);
> pgoff_t start_fofs, end_fofs;
> @@ -271,18 +293,7 @@ static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
> start_blkaddr = fi->ext.blk;
>
> if (pgofs >= start_fofs && pgofs <= end_fofs) {
> - unsigned int blkbits = inode->i_sb->s_blocksize_bits;
> - size_t count;
> -
> - clear_buffer_new(bh_result);
> - map_bh(bh_result, inode->i_sb,
> - start_blkaddr + pgofs - start_fofs);
> - count = end_fofs - pgofs + 1;
> - if (count < (UINT_MAX >> blkbits))
> - bh_result->b_size = (count << blkbits);
> - else
> - bh_result->b_size = UINT_MAX;
> -
> + *ei = fi->ext;
> stat_inc_read_hit(inode->i_sb);
> read_unlock(&fi->ext_lock);
> return 1;
> @@ -608,13 +619,16 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
> int mode = create ? ALLOC_NODE : LOOKUP_NODE_RA;
> pgoff_t pgofs, end_offset;
> int err = 0, ofs = 1;
> + struct extent_info ei;
> bool allocated = false;
>
> /* Get the page offset from the block offset(iblock) */
> pgofs = (pgoff_t)(iblock >> (PAGE_CACHE_SHIFT - blkbits));
>
> - if (check_extent_cache(inode, pgofs, bh_result))
> + if (check_extent_cache(inode, pgofs, &ei)) {
> + f2fs_map_bh(inode, pgofs, &ei, bh_result);
> goto out;
> + }
>
> if (create) {
> f2fs_balance_fs(F2FS_I_SB(inode));
> --
> 2.2.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH 03/10] f2fs: introduce f2fs_map_bh to clean codes of check_extent_cache
@ 2015-01-23 0:24 ` Jaegeuk Kim
0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2015-01-23 0:24 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel
Hi Chao,
On Mon, Jan 12, 2015 at 03:11:04PM +0800, Chao Yu wrote:
> This patch introduces f2fs_map_bh to clean codes of check_extent_cache.
>
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
> fs/f2fs/data.c | 42 ++++++++++++++++++++++++++++--------------
> 1 file changed, 28 insertions(+), 14 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 935a23b..5a3e489 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -248,8 +248,30 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
> return err;
> }
>
> +static void f2fs_map_bh(struct inode *inode, pgoff_t pgofs,
> + struct extent_info *ei, struct buffer_head *bh_result)
> +{
> + unsigned int blkbits = inode->i_sb->s_blocksize_bits;
> + pgoff_t start_fofs, end_fofs;
> + block_t start_blkaddr;
> + size_t count;
> +
> + start_fofs = ei->fofs;
> + end_fofs = ei->fofs + ei->len - 1;
> + start_blkaddr = ei->blk;
> +
> + clear_buffer_new(bh_result);
> + map_bh(bh_result, inode->i_sb,
> + start_blkaddr + pgofs - start_fofs);
> + count = end_fofs - pgofs + 1;
How about cleaning this codes like this?
static void f2fs_map_bh(struct super_block *sb, pgoff_t pgofs,
struct extent_info *ei, struct buffer_head *bh_result)
{
unsigned int blkbits = sb->s_blocksize_bits;
size_t count;
clear_buffer_new(bh_result);
map_bh(bh_result, sb, ei->blk + pgofs - ei->fofs);
count = ei->fofs + ei->len - pgofs;
if (count < (UINT_MAX >> blkbits))
bh_result->b_size = (count << blkbits);
else
bh_result->b_size = UINT_MAX;
}
> + if (count < (UINT_MAX >> blkbits))
> + bh_result->b_size = (count << blkbits);
> + else
> + bh_result->b_size = UINT_MAX;
> +}
> +
> static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
> - struct buffer_head *bh_result)
> + struct extent_info *ei)
> {
> struct f2fs_inode_info *fi = F2FS_I(inode);
> pgoff_t start_fofs, end_fofs;
> @@ -271,18 +293,7 @@ static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
> start_blkaddr = fi->ext.blk;
>
> if (pgofs >= start_fofs && pgofs <= end_fofs) {
> - unsigned int blkbits = inode->i_sb->s_blocksize_bits;
> - size_t count;
> -
> - clear_buffer_new(bh_result);
> - map_bh(bh_result, inode->i_sb,
> - start_blkaddr + pgofs - start_fofs);
> - count = end_fofs - pgofs + 1;
> - if (count < (UINT_MAX >> blkbits))
> - bh_result->b_size = (count << blkbits);
> - else
> - bh_result->b_size = UINT_MAX;
> -
> + *ei = fi->ext;
> stat_inc_read_hit(inode->i_sb);
> read_unlock(&fi->ext_lock);
> return 1;
> @@ -608,13 +619,16 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
> int mode = create ? ALLOC_NODE : LOOKUP_NODE_RA;
> pgoff_t pgofs, end_offset;
> int err = 0, ofs = 1;
> + struct extent_info ei;
> bool allocated = false;
>
> /* Get the page offset from the block offset(iblock) */
> pgofs = (pgoff_t)(iblock >> (PAGE_CACHE_SHIFT - blkbits));
>
> - if (check_extent_cache(inode, pgofs, bh_result))
> + if (check_extent_cache(inode, pgofs, &ei)) {
> + f2fs_map_bh(inode, pgofs, &ei, bh_result);
> goto out;
> + }
>
> if (create) {
> f2fs_balance_fs(F2FS_I_SB(inode));
> --
> 2.2.1
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [f2fs-dev][RFC PATCH 03/10] f2fs: introduce f2fs_map_bh to clean codes of check_extent_cache
2015-01-23 0:24 ` [RFC " Jaegeuk Kim
(?)
@ 2015-01-23 1:52 ` Chao Yu
-1 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2015-01-23 1:52 UTC (permalink / raw)
To: 'Jaegeuk Kim'
Cc: 'Changman Lee', linux-f2fs-devel, linux-kernel
Hi Jaegeuk,
> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Friday, January 23, 2015 8:25 AM
> To: Chao Yu
> Cc: Changman Lee; linux-f2fs-devel@lists.sourceforge.net; linux-kernel@vger.kernel.org
> Subject: Re: [f2fs-dev][RFC PATCH 03/10] f2fs: introduce f2fs_map_bh to clean codes of
> check_extent_cache
>
> Hi Chao,
>
> On Mon, Jan 12, 2015 at 03:11:04PM +0800, Chao Yu wrote:
> > This patch introduces f2fs_map_bh to clean codes of check_extent_cache.
> >
> > Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> > ---
> > fs/f2fs/data.c | 42 ++++++++++++++++++++++++++++--------------
> > 1 file changed, 28 insertions(+), 14 deletions(-)
> >
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index 935a23b..5a3e489 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -248,8 +248,30 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
> > return err;
> > }
> >
> > +static void f2fs_map_bh(struct inode *inode, pgoff_t pgofs,
> > + struct extent_info *ei, struct buffer_head *bh_result)
> > +{
> > + unsigned int blkbits = inode->i_sb->s_blocksize_bits;
> > + pgoff_t start_fofs, end_fofs;
> > + block_t start_blkaddr;
> > + size_t count;
> > +
> > + start_fofs = ei->fofs;
> > + end_fofs = ei->fofs + ei->len - 1;
> > + start_blkaddr = ei->blk;
> > +
> > + clear_buffer_new(bh_result);
> > + map_bh(bh_result, inode->i_sb,
> > + start_blkaddr + pgofs - start_fofs);
> > + count = end_fofs - pgofs + 1;
>
> How about cleaning this codes like this?
Nice! I will use it.
Thanks,
Yu
>
> static void f2fs_map_bh(struct super_block *sb, pgoff_t pgofs,
> struct extent_info *ei, struct buffer_head *bh_result)
> {
> unsigned int blkbits = sb->s_blocksize_bits;
> size_t count;
>
> clear_buffer_new(bh_result);
> map_bh(bh_result, sb, ei->blk + pgofs - ei->fofs);
> count = ei->fofs + ei->len - pgofs;
> if (count < (UINT_MAX >> blkbits))
> bh_result->b_size = (count << blkbits);
> else
> bh_result->b_size = UINT_MAX;
> }
>
> > + if (count < (UINT_MAX >> blkbits))
> > + bh_result->b_size = (count << blkbits);
> > + else
> > + bh_result->b_size = UINT_MAX;
> > +}
> > +
> > static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
> > - struct buffer_head *bh_result)
> > + struct extent_info *ei)
> > {
> > struct f2fs_inode_info *fi = F2FS_I(inode);
> > pgoff_t start_fofs, end_fofs;
> > @@ -271,18 +293,7 @@ static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
> > start_blkaddr = fi->ext.blk;
> >
> > if (pgofs >= start_fofs && pgofs <= end_fofs) {
> > - unsigned int blkbits = inode->i_sb->s_blocksize_bits;
> > - size_t count;
> > -
> > - clear_buffer_new(bh_result);
> > - map_bh(bh_result, inode->i_sb,
> > - start_blkaddr + pgofs - start_fofs);
> > - count = end_fofs - pgofs + 1;
> > - if (count < (UINT_MAX >> blkbits))
> > - bh_result->b_size = (count << blkbits);
> > - else
> > - bh_result->b_size = UINT_MAX;
> > -
> > + *ei = fi->ext;
> > stat_inc_read_hit(inode->i_sb);
> > read_unlock(&fi->ext_lock);
> > return 1;
> > @@ -608,13 +619,16 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
> > int mode = create ? ALLOC_NODE : LOOKUP_NODE_RA;
> > pgoff_t pgofs, end_offset;
> > int err = 0, ofs = 1;
> > + struct extent_info ei;
> > bool allocated = false;
> >
> > /* Get the page offset from the block offset(iblock) */
> > pgofs = (pgoff_t)(iblock >> (PAGE_CACHE_SHIFT - blkbits));
> >
> > - if (check_extent_cache(inode, pgofs, bh_result))
> > + if (check_extent_cache(inode, pgofs, &ei)) {
> > + f2fs_map_bh(inode, pgofs, &ei, bh_result);
> > goto out;
> > + }
> >
> > if (create) {
> > f2fs_balance_fs(F2FS_I_SB(inode));
> > --
> > 2.2.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-23 1:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-12 7:11 [f2fs-dev][RFC PATCH 03/10] f2fs: introduce f2fs_map_bh to clean codes of check_extent_cache Chao Yu
2015-01-23 0:24 ` Jaegeuk Kim
2015-01-23 0:24 ` [RFC " Jaegeuk Kim
2015-01-23 1:52 ` [f2fs-dev][RFC " Chao Yu
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.