All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 3/3] f2fs:use enum dentrt_ptr type to replace constant use
@ 2015-03-07 10:10 ` Yuan Zhong
  0 siblings, 0 replies; 3+ messages in thread
From: Yuan Zhong @ 2015-03-07 10:10 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel, linux-fsdevel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=windows-1252, Size: 3930 bytes --]

The function make_dentry_ptr has an argument 'int type'.
This argument is used to distinguish 'block dentry' and
'inline dentry'. We used 1 and 2 as the type. To make
code more readable, we use enum type to replace constant
use.
	
Signed-off-by: Yuan Zhong <yuan.mark.zhong@samsung.com>	
---
 fs/f2fs/dir.c    |    8 ++++----
 fs/f2fs/f2fs.h   |    8 +++++++-
 fs/f2fs/inline.c |    8 ++++----
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 590aeef..c39a18f 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -99,7 +99,7 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
 
 	dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page);
 
-	make_dentry_ptr(&d, (void *)dentry_blk, 1);
+	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
 	de = find_target_dentry(name, max_slots, &d);
 
 	if (de)
@@ -360,7 +360,7 @@ static int make_empty_dir(struct inode *inode,
 
 	dentry_blk = kmap_atomic(dentry_page);
 
-	make_dentry_ptr(&d, (void *)dentry_blk, 1);
+	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
 	do_make_empty_dir(inode, parent, &d);
 
 	kunmap_atomic(dentry_blk);
@@ -571,7 +571,7 @@ add_dentry:
 		goto fail;
 	}
 
-	make_dentry_ptr(&d, (void *)dentry_blk, 1);
+	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
 	f2fs_update_dentry(inode, &d, name, dentry_hash, bit_pos);
 
 	set_page_dirty(dentry_page);
@@ -782,7 +782,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
 
 		dentry_blk = kmap(dentry_page);
 
-		make_dentry_ptr(&d, (void *)dentry_blk, 1);
+		make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
 
 		if (f2fs_fill_dentries(ctx, &d, n * NR_DENTRY_IN_BLOCK))
 			goto stop;
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 511d6cd..31b440e 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -236,10 +236,16 @@ struct f2fs_dentry_ptr {
 	int max;
 };
 
+enum {
+	DENTRY_PTR_TYPE_BLOCK = 1,
+	DENTRY_PTR_TYPE_INLNE,
+	DENTRY_PTR_TYPE_MAX
+};
+
 static inline void make_dentry_ptr(struct f2fs_dentry_ptr *d,
 					void *src, int type)
 {
-	if (type == 1) {
+	if (type == DENTRY_PTR_TYPE_BLOCK) {
 		struct f2fs_dentry_block *t = (struct f2fs_dentry_block *)src;
 		d->max = NR_DENTRY_IN_BLOCK;
 		d->bitmap = &t->dentry_bitmap;
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 4ba9732..ee0984c 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -271,7 +271,7 @@ struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir,
 
 	inline_dentry = inline_data_addr(ipage);
 
-	make_dentry_ptr(&d, (void *)inline_dentry, 2);
+	make_dentry_ptr(&d, (void *)inline_dentry, DENTRY_PTR_TYPE_INLNE);
 	de = find_target_dentry(name, NULL, &d);
 
 	unlock_page(ipage);
@@ -315,7 +315,7 @@ int make_empty_inline_dir(struct inode *inode, struct inode *parent,
 
 	dentry_blk = inline_data_addr(ipage);
 
-	make_dentry_ptr(&d, (void *)dentry_blk, 2);
+	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_INLNE);
 	do_make_empty_dir(inode, parent, &d);
 
 	set_page_dirty(ipage);
@@ -417,7 +417,7 @@ int f2fs_add_inline_entry(struct inode *dir, const struct qstr *name,
 	f2fs_wait_on_page_writeback(ipage, NODE);
 
 	name_hash = f2fs_dentry_hash(name);
-	make_dentry_ptr(&d, (void *)dentry_blk, 2);
+	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_INLNE);
 	f2fs_update_dentry(inode, &d, name, name_hash, bit_pos);
 
 	set_page_dirty(ipage);
@@ -507,7 +507,7 @@ int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx)
 
 	inline_dentry = inline_data_addr(ipage);
 
-	make_dentry_ptr(&d, (void *)inline_dentry, 2);
+	make_dentry_ptr(&d, (void *)inline_dentry, DENTRY_PTR_TYPE_INLNE);
 
 	if (!f2fs_fill_dentries(ctx, &d, 0))
 		ctx->pos = NR_INLINE_DENTRY;
-- 
1.7.9.5ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* [f2fs-dev] [PATCH 3/3] f2fs:use enum dentrt_ptr type to replace constant use
@ 2015-03-07 10:10 ` Yuan Zhong
  0 siblings, 0 replies; 3+ messages in thread
From: Yuan Zhong @ 2015-03-07 10:10 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel, linux-fsdevel

The function make_dentry_ptr has an argument 'int type'.
This argument is used to distinguish 'block dentry' and
'inline dentry'. We used 1 and 2 as the type. To make
code more readable, we use enum type to replace constant
use.
	
Signed-off-by: Yuan Zhong <yuan.mark.zhong@samsung.com>	
---
 fs/f2fs/dir.c    |    8 ++++----
 fs/f2fs/f2fs.h   |    8 +++++++-
 fs/f2fs/inline.c |    8 ++++----
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 590aeef..c39a18f 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -99,7 +99,7 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
 
 	dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page);
 
-	make_dentry_ptr(&d, (void *)dentry_blk, 1);
+	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
 	de = find_target_dentry(name, max_slots, &d);
 
 	if (de)
@@ -360,7 +360,7 @@ static int make_empty_dir(struct inode *inode,
 
 	dentry_blk = kmap_atomic(dentry_page);
 
-	make_dentry_ptr(&d, (void *)dentry_blk, 1);
+	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
 	do_make_empty_dir(inode, parent, &d);
 
 	kunmap_atomic(dentry_blk);
@@ -571,7 +571,7 @@ add_dentry:
 		goto fail;
 	}
 
-	make_dentry_ptr(&d, (void *)dentry_blk, 1);
+	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
 	f2fs_update_dentry(inode, &d, name, dentry_hash, bit_pos);
 
 	set_page_dirty(dentry_page);
@@ -782,7 +782,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
 
 		dentry_blk = kmap(dentry_page);
 
-		make_dentry_ptr(&d, (void *)dentry_blk, 1);
+		make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
 
 		if (f2fs_fill_dentries(ctx, &d, n * NR_DENTRY_IN_BLOCK))
 			goto stop;
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 511d6cd..31b440e 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -236,10 +236,16 @@ struct f2fs_dentry_ptr {
 	int max;
 };
 
+enum {
+	DENTRY_PTR_TYPE_BLOCK = 1,
+	DENTRY_PTR_TYPE_INLNE,
+	DENTRY_PTR_TYPE_MAX
+};
+
 static inline void make_dentry_ptr(struct f2fs_dentry_ptr *d,
 					void *src, int type)
 {
-	if (type == 1) {
+	if (type == DENTRY_PTR_TYPE_BLOCK) {
 		struct f2fs_dentry_block *t = (struct f2fs_dentry_block *)src;
 		d->max = NR_DENTRY_IN_BLOCK;
 		d->bitmap = &t->dentry_bitmap;
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 4ba9732..ee0984c 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -271,7 +271,7 @@ struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir,
 
 	inline_dentry = inline_data_addr(ipage);
 
-	make_dentry_ptr(&d, (void *)inline_dentry, 2);
+	make_dentry_ptr(&d, (void *)inline_dentry, DENTRY_PTR_TYPE_INLNE);
 	de = find_target_dentry(name, NULL, &d);
 
 	unlock_page(ipage);
@@ -315,7 +315,7 @@ int make_empty_inline_dir(struct inode *inode, struct inode *parent,
 
 	dentry_blk = inline_data_addr(ipage);
 
-	make_dentry_ptr(&d, (void *)dentry_blk, 2);
+	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_INLNE);
 	do_make_empty_dir(inode, parent, &d);
 
 	set_page_dirty(ipage);
@@ -417,7 +417,7 @@ int f2fs_add_inline_entry(struct inode *dir, const struct qstr *name,
 	f2fs_wait_on_page_writeback(ipage, NODE);
 
 	name_hash = f2fs_dentry_hash(name);
-	make_dentry_ptr(&d, (void *)dentry_blk, 2);
+	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_INLNE);
 	f2fs_update_dentry(inode, &d, name, name_hash, bit_pos);
 
 	set_page_dirty(ipage);
@@ -507,7 +507,7 @@ int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx)
 
 	inline_dentry = inline_data_addr(ipage);
 
-	make_dentry_ptr(&d, (void *)inline_dentry, 2);
+	make_dentry_ptr(&d, (void *)inline_dentry, DENTRY_PTR_TYPE_INLNE);
 
 	if (!f2fs_fill_dentries(ctx, &d, 0))
 		ctx->pos = NR_INLINE_DENTRY;
-- 
1.7.9.5

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

* RE: [f2fs-dev] [PATCH 3/3] f2fs:use enum dentrt_ptr type to replace constant use
  2015-03-07 10:10 ` Yuan Zhong
  (?)
@ 2015-03-09  6:52 ` Chao Yu
  -1 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2015-03-09  6:52 UTC (permalink / raw)
  To: yuan.mark.zhong, 'Jaegeuk Kim'
  Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel

Hi Yuan,

> -----Original Message-----
> From: Yuan Zhong [mailto:yuan.mark.zhong@samsung.com]
> Sent: Saturday, March 07, 2015 6:10 PM
> To: Jaegeuk Kim
> Cc: linux-fsdevel@vger.kernel.org; linux-kernel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Subject: [f2fs-dev] [PATCH 3/3] f2fs:use enum dentrt_ptr type to replace constant use
> 
> The function make_dentry_ptr has an argument 'int type'.
> This argument is used to distinguish 'block dentry' and
> 'inline dentry'. We used 1 and 2 as the type. To make
> code more readable, we use enum type to replace constant
> use.
> 
> Signed-off-by: Yuan Zhong <yuan.mark.zhong@samsung.com>
> ---
>  fs/f2fs/dir.c    |    8 ++++----
>  fs/f2fs/f2fs.h   |    8 +++++++-
>  fs/f2fs/inline.c |    8 ++++----
>  3 files changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> index 590aeef..c39a18f 100644
> --- a/fs/f2fs/dir.c
> +++ b/fs/f2fs/dir.c
> @@ -99,7 +99,7 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
> 
>  	dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page);
> 
> -	make_dentry_ptr(&d, (void *)dentry_blk, 1);
> +	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
>  	de = find_target_dentry(name, max_slots, &d);
> 
>  	if (de)
> @@ -360,7 +360,7 @@ static int make_empty_dir(struct inode *inode,
> 
>  	dentry_blk = kmap_atomic(dentry_page);
> 
> -	make_dentry_ptr(&d, (void *)dentry_blk, 1);
> +	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
>  	do_make_empty_dir(inode, parent, &d);
> 
>  	kunmap_atomic(dentry_blk);
> @@ -571,7 +571,7 @@ add_dentry:
>  		goto fail;
>  	}
> 
> -	make_dentry_ptr(&d, (void *)dentry_blk, 1);
> +	make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
>  	f2fs_update_dentry(inode, &d, name, dentry_hash, bit_pos);
> 
>  	set_page_dirty(dentry_page);
> @@ -782,7 +782,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
> 
>  		dentry_blk = kmap(dentry_page);
> 
> -		make_dentry_ptr(&d, (void *)dentry_blk, 1);
> +		make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK);
> 
>  		if (f2fs_fill_dentries(ctx, &d, n * NR_DENTRY_IN_BLOCK))
>  			goto stop;
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 511d6cd..31b440e 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -236,10 +236,16 @@ struct f2fs_dentry_ptr {
>  	int max;
>  };
> 
> +enum {
> +	DENTRY_PTR_TYPE_BLOCK = 1,
> +	DENTRY_PTR_TYPE_INLNE,
> +	DENTRY_PTR_TYPE_MAX
> +};

How do you think of using below enum?

enum dentry_type {
	REGULAR_DENTRY = 1,
	INLINE_DENTRY,
};



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

end of thread, other threads:[~2015-03-09  6:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-07 10:10 [f2fs-dev] [PATCH 3/3] f2fs:use enum dentrt_ptr type to replace constant use Yuan Zhong
2015-03-07 10:10 ` Yuan Zhong
2015-03-09  6:52 ` 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.