linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs: don't use erofs_map_blocks() any more
@ 2021-03-25  7:10 Yue Hu
  2021-03-25  8:29 ` Gao Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Yue Hu @ 2021-03-25  7:10 UTC (permalink / raw)
  To: xiang, chao; +Cc: huyue2, linux-erofs, zbestahu

From: Yue Hu <huyue2@yulong.com>

Currently, erofs_map_blocks() will be called only from
erofs_{bmap, read_raw_page} which are all for uncompressed files.
So, the compression branch in erofs_map_blocks() is pointless. Let's
remove it and use erofs_map_blocks_flatmode() directly. Also update
related comments.

Signed-off-by: Yue Hu <huyue2@yulong.com>
---
 fs/erofs/data.c     | 19 ++-----------------
 fs/erofs/internal.h |  6 ++----
 2 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 1249e74..ebac756 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -109,21 +109,6 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
 	return err;
 }
 
-int erofs_map_blocks(struct inode *inode,
-		     struct erofs_map_blocks *map, int flags)
-{
-	if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout)) {
-		int err = z_erofs_map_blocks_iter(inode, map, flags);
-
-		if (map->mpage) {
-			put_page(map->mpage);
-			map->mpage = NULL;
-		}
-		return err;
-	}
-	return erofs_map_blocks_flatmode(inode, map, flags);
-}
-
 static inline struct bio *erofs_read_raw_page(struct bio *bio,
 					      struct address_space *mapping,
 					      struct page *page,
@@ -159,7 +144,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
 		erofs_blk_t blknr;
 		unsigned int blkoff;
 
-		err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW);
+		err = erofs_map_blocks_flatmode(inode, &map, EROFS_GET_BLOCKS_RAW);
 		if (err)
 			goto err_out;
 
@@ -318,7 +303,7 @@ static sector_t erofs_bmap(struct address_space *mapping, sector_t block)
 			return 0;
 	}
 
-	if (!erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW))
+	if (!erofs_map_blocks_flatmode(inode, &map, EROFS_GET_BLOCKS_RAW))
 		return erofs_blknr(map.m_pa);
 
 	return 0;
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 30e63b7..db8c847 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -289,7 +289,7 @@ static inline unsigned int erofs_inode_datalayout(unsigned int value)
 extern const struct address_space_operations z_erofs_aops;
 
 /*
- * Logical to physical block mapping, used by erofs_map_blocks()
+ * Logical to physical block mapping
  *
  * Different with other file systems, it is used for 2 access modes:
  *
@@ -336,7 +336,7 @@ struct erofs_map_blocks {
 	struct page *mpage;
 };
 
-/* Flags used by erofs_map_blocks() */
+/* Flags used by erofs_map_blocks_flatmode() */
 #define EROFS_GET_BLOCKS_RAW    0x0001
 
 /* zmap.c */
@@ -358,8 +358,6 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,
 /* data.c */
 struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr);
 
-int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int);
-
 /* inode.c */
 static inline unsigned long erofs_inode_hash(erofs_nid_t nid)
 {
-- 
1.9.1


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

* Re: [PATCH] erofs: don't use erofs_map_blocks() any more
  2021-03-25  7:10 [PATCH] erofs: don't use erofs_map_blocks() any more Yue Hu
@ 2021-03-25  8:29 ` Gao Xiang
  2021-03-27  9:32   ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Gao Xiang @ 2021-03-25  8:29 UTC (permalink / raw)
  To: Yue Hu; +Cc: xiang, linux-erofs, huyue2, zbestahu

Hi Yue,

On Thu, Mar 25, 2021 at 03:10:08PM +0800, Yue Hu wrote:
> From: Yue Hu <huyue2@yulong.com>
> 
> Currently, erofs_map_blocks() will be called only from
> erofs_{bmap, read_raw_page} which are all for uncompressed files.
> So, the compression branch in erofs_map_blocks() is pointless. Let's
> remove it and use erofs_map_blocks_flatmode() directly. Also update
> related comments.
> 

You are right, since for compressed files, map_blocks_iter would be more
effective than erofs_map_blocks. Originally, such unique interface was
designed for fiemap (just for example), but I'm fine to get rid of it
until related interfaces are finally implemented.

Also, I'd like to hear opinions from Chao as well.

Thanks,
Gao Xiang

> Signed-off-by: Yue Hu <huyue2@yulong.com>
> ---
>  fs/erofs/data.c     | 19 ++-----------------
>  fs/erofs/internal.h |  6 ++----
>  2 files changed, 4 insertions(+), 21 deletions(-)
> 
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index 1249e74..ebac756 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -109,21 +109,6 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
>  	return err;
>  }
>  
> -int erofs_map_blocks(struct inode *inode,
> -		     struct erofs_map_blocks *map, int flags)
> -{
> -	if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout)) {
> -		int err = z_erofs_map_blocks_iter(inode, map, flags);
> -
> -		if (map->mpage) {
> -			put_page(map->mpage);
> -			map->mpage = NULL;
> -		}
> -		return err;
> -	}
> -	return erofs_map_blocks_flatmode(inode, map, flags);
> -}
> -
>  static inline struct bio *erofs_read_raw_page(struct bio *bio,
>  					      struct address_space *mapping,
>  					      struct page *page,
> @@ -159,7 +144,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
>  		erofs_blk_t blknr;
>  		unsigned int blkoff;
>  
> -		err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW);
> +		err = erofs_map_blocks_flatmode(inode, &map, EROFS_GET_BLOCKS_RAW);
>  		if (err)
>  			goto err_out;
>  
> @@ -318,7 +303,7 @@ static sector_t erofs_bmap(struct address_space *mapping, sector_t block)
>  			return 0;
>  	}
>  
> -	if (!erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW))
> +	if (!erofs_map_blocks_flatmode(inode, &map, EROFS_GET_BLOCKS_RAW))
>  		return erofs_blknr(map.m_pa);
>  
>  	return 0;
> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
> index 30e63b7..db8c847 100644
> --- a/fs/erofs/internal.h
> +++ b/fs/erofs/internal.h
> @@ -289,7 +289,7 @@ static inline unsigned int erofs_inode_datalayout(unsigned int value)
>  extern const struct address_space_operations z_erofs_aops;
>  
>  /*
> - * Logical to physical block mapping, used by erofs_map_blocks()
> + * Logical to physical block mapping
>   *
>   * Different with other file systems, it is used for 2 access modes:
>   *
> @@ -336,7 +336,7 @@ struct erofs_map_blocks {
>  	struct page *mpage;
>  };
>  
> -/* Flags used by erofs_map_blocks() */
> +/* Flags used by erofs_map_blocks_flatmode() */
>  #define EROFS_GET_BLOCKS_RAW    0x0001
>  
>  /* zmap.c */
> @@ -358,8 +358,6 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,
>  /* data.c */
>  struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr);
>  
> -int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int);
> -
>  /* inode.c */
>  static inline unsigned long erofs_inode_hash(erofs_nid_t nid)
>  {
> -- 
> 1.9.1
> 


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

* Re: [PATCH] erofs: don't use erofs_map_blocks() any more
  2021-03-25  8:29 ` Gao Xiang
@ 2021-03-27  9:32   ` Chao Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2021-03-27  9:32 UTC (permalink / raw)
  To: Gao Xiang, Yue Hu; +Cc: xiang, linux-erofs, huyue2, zbestahu

On 2021/3/25 16:29, Gao Xiang wrote:
> Hi Yue,
> 
> On Thu, Mar 25, 2021 at 03:10:08PM +0800, Yue Hu wrote:
>> From: Yue Hu <huyue2@yulong.com>
>>
>> Currently, erofs_map_blocks() will be called only from
>> erofs_{bmap, read_raw_page} which are all for uncompressed files.
>> So, the compression branch in erofs_map_blocks() is pointless. Let's
>> remove it and use erofs_map_blocks_flatmode() directly. Also update
>> related comments.
>>
> 
> You are right, since for compressed files, map_blocks_iter would be more
> effective than erofs_map_blocks. Originally, such unique interface was
> designed for fiemap (just for example), but I'm fine to get rid of it
> until related interfaces are finally implemented.
> 
> Also, I'd like to hear opinions from Chao as well.

Looks fine to me.

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> 
> Thanks,
> Gao Xiang
> 
>> Signed-off-by: Yue Hu <huyue2@yulong.com>
>> ---
>>   fs/erofs/data.c     | 19 ++-----------------
>>   fs/erofs/internal.h |  6 ++----
>>   2 files changed, 4 insertions(+), 21 deletions(-)
>>
>> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
>> index 1249e74..ebac756 100644
>> --- a/fs/erofs/data.c
>> +++ b/fs/erofs/data.c
>> @@ -109,21 +109,6 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
>>   	return err;
>>   }
>>   
>> -int erofs_map_blocks(struct inode *inode,
>> -		     struct erofs_map_blocks *map, int flags)
>> -{
>> -	if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout)) {
>> -		int err = z_erofs_map_blocks_iter(inode, map, flags);
>> -
>> -		if (map->mpage) {
>> -			put_page(map->mpage);
>> -			map->mpage = NULL;
>> -		}
>> -		return err;
>> -	}
>> -	return erofs_map_blocks_flatmode(inode, map, flags);
>> -}
>> -
>>   static inline struct bio *erofs_read_raw_page(struct bio *bio,
>>   					      struct address_space *mapping,
>>   					      struct page *page,
>> @@ -159,7 +144,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
>>   		erofs_blk_t blknr;
>>   		unsigned int blkoff;
>>   
>> -		err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW);
>> +		err = erofs_map_blocks_flatmode(inode, &map, EROFS_GET_BLOCKS_RAW);
>>   		if (err)
>>   			goto err_out;
>>   
>> @@ -318,7 +303,7 @@ static sector_t erofs_bmap(struct address_space *mapping, sector_t block)
>>   			return 0;
>>   	}
>>   
>> -	if (!erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW))
>> +	if (!erofs_map_blocks_flatmode(inode, &map, EROFS_GET_BLOCKS_RAW))
>>   		return erofs_blknr(map.m_pa);
>>   
>>   	return 0;
>> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
>> index 30e63b7..db8c847 100644
>> --- a/fs/erofs/internal.h
>> +++ b/fs/erofs/internal.h
>> @@ -289,7 +289,7 @@ static inline unsigned int erofs_inode_datalayout(unsigned int value)
>>   extern const struct address_space_operations z_erofs_aops;
>>   
>>   /*
>> - * Logical to physical block mapping, used by erofs_map_blocks()
>> + * Logical to physical block mapping
>>    *
>>    * Different with other file systems, it is used for 2 access modes:
>>    *
>> @@ -336,7 +336,7 @@ struct erofs_map_blocks {
>>   	struct page *mpage;
>>   };
>>   
>> -/* Flags used by erofs_map_blocks() */
>> +/* Flags used by erofs_map_blocks_flatmode() */
>>   #define EROFS_GET_BLOCKS_RAW    0x0001
>>   
>>   /* zmap.c */
>> @@ -358,8 +358,6 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,
>>   /* data.c */
>>   struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr);
>>   
>> -int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int);
>> -
>>   /* inode.c */
>>   static inline unsigned long erofs_inode_hash(erofs_nid_t nid)
>>   {
>> -- 
>> 1.9.1
>>
> 
> .
> 

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

end of thread, other threads:[~2021-03-27  9:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-25  7:10 [PATCH] erofs: don't use erofs_map_blocks() any more Yue Hu
2021-03-25  8:29 ` Gao Xiang
2021-03-27  9:32   ` Chao Yu

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