linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: make fibmap consistent with fiemap for compression chunk
@ 2020-08-28  3:49 Daeho Jeong
  2020-08-29 23:44 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Daeho Jeong @ 2020-08-28  3:49 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

From: Daeho Jeong <daehojeong@google.com>

Currently fibmap returns zero address for compression chunk. But it
is not consistent with the output of fiemap, since fiemap returns
real pysical block address related to the compression chunk. Therefore
I suggest fibmap returns the same output with fiemap.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
 fs/f2fs/data.c | 33 ---------------------------------
 1 file changed, 33 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index c1b676be67b9..8c26c5d0c778 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3708,36 +3708,6 @@ static int f2fs_set_data_page_dirty(struct page *page)
 	return 0;
 }
 
-
-static sector_t f2fs_bmap_compress(struct inode *inode, sector_t block)
-{
-#ifdef CONFIG_F2FS_FS_COMPRESSION
-	struct dnode_of_data dn;
-	sector_t start_idx, blknr = 0;
-	int ret;
-
-	start_idx = round_down(block, F2FS_I(inode)->i_cluster_size);
-
-	set_new_dnode(&dn, inode, NULL, NULL, 0);
-	ret = f2fs_get_dnode_of_data(&dn, start_idx, LOOKUP_NODE);
-	if (ret)
-		return 0;
-
-	if (dn.data_blkaddr != COMPRESS_ADDR) {
-		dn.ofs_in_node += block - start_idx;
-		blknr = f2fs_data_blkaddr(&dn);
-		if (!__is_valid_data_blkaddr(blknr))
-			blknr = 0;
-	}
-
-	f2fs_put_dnode(&dn);
-	return blknr;
-#else
-	return 0;
-#endif
-}
-
-
 static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
 {
 	struct inode *inode = mapping->host;
@@ -3753,9 +3723,6 @@ static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
 	if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
 		filemap_write_and_wait(mapping);
 
-	if (f2fs_compressed_file(inode))
-		blknr = f2fs_bmap_compress(inode, block);
-
 	if (!get_data_block_bmap(inode, block, &tmp, 0))
 		blknr = tmp.b_blocknr;
 out:
-- 
2.28.0.402.g5ffc5be6b7-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: make fibmap consistent with fiemap for compression chunk
  2020-08-28  3:49 [f2fs-dev] [PATCH] f2fs: make fibmap consistent with fiemap for compression chunk Daeho Jeong
@ 2020-08-29 23:44 ` Chao Yu
  2020-08-30 23:36   ` Daeho Jeong
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2020-08-29 23:44 UTC (permalink / raw)
  To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

On 2020-8-28 11:49, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
>
> Currently fibmap returns zero address for compression chunk. But it
> is not consistent with the output of fiemap, since fiemap returns
> real pysical block address related to the compression chunk. Therefore
> I suggest fibmap returns the same output with fiemap.

We can return real physical block address in fiemap, because we have set
FIEMAP_EXTENT_ENCODED flag in extent.fe_flags, then user can be noticed that he 
can not just read/write that block address for access/update in-there data.

Quoted from Documentation/filesystems/fiemap.rst
"
FIEMAP_EXTENT_ENCODED
   This extent does not consist of plain filesystem blocks but is
   encoded (e.g. encrypted or compressed).  Reading the data in this
   extent via I/O to the block device will have undefined results.
"

However, there is no such flag in fibmap interface, so I just return block 
address for those logical pages in non-compressed cluster.

Thanks,

>
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
> ---
>  fs/f2fs/data.c | 33 ---------------------------------
>  1 file changed, 33 deletions(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index c1b676be67b9..8c26c5d0c778 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -3708,36 +3708,6 @@ static int f2fs_set_data_page_dirty(struct page *page)
>  	return 0;
>  }
>
> -
> -static sector_t f2fs_bmap_compress(struct inode *inode, sector_t block)
> -{
> -#ifdef CONFIG_F2FS_FS_COMPRESSION
> -	struct dnode_of_data dn;
> -	sector_t start_idx, blknr = 0;
> -	int ret;
> -
> -	start_idx = round_down(block, F2FS_I(inode)->i_cluster_size);
> -
> -	set_new_dnode(&dn, inode, NULL, NULL, 0);
> -	ret = f2fs_get_dnode_of_data(&dn, start_idx, LOOKUP_NODE);
> -	if (ret)
> -		return 0;
> -
> -	if (dn.data_blkaddr != COMPRESS_ADDR) {
> -		dn.ofs_in_node += block - start_idx;
> -		blknr = f2fs_data_blkaddr(&dn);
> -		if (!__is_valid_data_blkaddr(blknr))
> -			blknr = 0;
> -	}
> -
> -	f2fs_put_dnode(&dn);
> -	return blknr;
> -#else
> -	return 0;
> -#endif
> -}
> -
> -
>  static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
>  {
>  	struct inode *inode = mapping->host;
> @@ -3753,9 +3723,6 @@ static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
>  	if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
>  		filemap_write_and_wait(mapping);
>
> -	if (f2fs_compressed_file(inode))
> -		blknr = f2fs_bmap_compress(inode, block);
> -
>  	if (!get_data_block_bmap(inode, block, &tmp, 0))
>  		blknr = tmp.b_blocknr;
>  out:
>


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: make fibmap consistent with fiemap for compression chunk
  2020-08-29 23:44 ` Chao Yu
@ 2020-08-30 23:36   ` Daeho Jeong
  0 siblings, 0 replies; 3+ messages in thread
From: Daeho Jeong @ 2020-08-30 23:36 UTC (permalink / raw)
  To: Chao Yu; +Cc: Daeho Jeong, kernel-team, linux-kernel, linux-f2fs-devel

I got it. Thanks~ :)

2020년 8월 30일 (일) 오전 8:44, Chao Yu <chao@kernel.org>님이 작성:
>
> On 2020-8-28 11:49, Daeho Jeong wrote:
> > From: Daeho Jeong <daehojeong@google.com>
> >
> > Currently fibmap returns zero address for compression chunk. But it
> > is not consistent with the output of fiemap, since fiemap returns
> > real pysical block address related to the compression chunk. Therefore
> > I suggest fibmap returns the same output with fiemap.
>
> We can return real physical block address in fiemap, because we have set
> FIEMAP_EXTENT_ENCODED flag in extent.fe_flags, then user can be noticed that he
> can not just read/write that block address for access/update in-there data.
>
> Quoted from Documentation/filesystems/fiemap.rst
> "
> FIEMAP_EXTENT_ENCODED
>    This extent does not consist of plain filesystem blocks but is
>    encoded (e.g. encrypted or compressed).  Reading the data in this
>    extent via I/O to the block device will have undefined results.
> "
>
> However, there is no such flag in fibmap interface, so I just return block
> address for those logical pages in non-compressed cluster.
>
> Thanks,
>
> >
> > Signed-off-by: Daeho Jeong <daehojeong@google.com>
> > ---
> >  fs/f2fs/data.c | 33 ---------------------------------
> >  1 file changed, 33 deletions(-)
> >
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index c1b676be67b9..8c26c5d0c778 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -3708,36 +3708,6 @@ static int f2fs_set_data_page_dirty(struct page *page)
> >       return 0;
> >  }
> >
> > -
> > -static sector_t f2fs_bmap_compress(struct inode *inode, sector_t block)
> > -{
> > -#ifdef CONFIG_F2FS_FS_COMPRESSION
> > -     struct dnode_of_data dn;
> > -     sector_t start_idx, blknr = 0;
> > -     int ret;
> > -
> > -     start_idx = round_down(block, F2FS_I(inode)->i_cluster_size);
> > -
> > -     set_new_dnode(&dn, inode, NULL, NULL, 0);
> > -     ret = f2fs_get_dnode_of_data(&dn, start_idx, LOOKUP_NODE);
> > -     if (ret)
> > -             return 0;
> > -
> > -     if (dn.data_blkaddr != COMPRESS_ADDR) {
> > -             dn.ofs_in_node += block - start_idx;
> > -             blknr = f2fs_data_blkaddr(&dn);
> > -             if (!__is_valid_data_blkaddr(blknr))
> > -                     blknr = 0;
> > -     }
> > -
> > -     f2fs_put_dnode(&dn);
> > -     return blknr;
> > -#else
> > -     return 0;
> > -#endif
> > -}
> > -
> > -
> >  static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
> >  {
> >       struct inode *inode = mapping->host;
> > @@ -3753,9 +3723,6 @@ static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
> >       if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
> >               filemap_write_and_wait(mapping);
> >
> > -     if (f2fs_compressed_file(inode))
> > -             blknr = f2fs_bmap_compress(inode, block);
> > -
> >       if (!get_data_block_bmap(inode, block, &tmp, 0))
> >               blknr = tmp.b_blocknr;
> >  out:
> >


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-30 23:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28  3:49 [f2fs-dev] [PATCH] f2fs: make fibmap consistent with fiemap for compression chunk Daeho Jeong
2020-08-29 23:44 ` Chao Yu
2020-08-30 23:36   ` Daeho Jeong

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).