linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: make ext4_add_dirent_to_inline function return 0
@ 2013-07-09  0:11 Zheng Liu
  2013-07-09  1:47 ` Tao Ma
  0 siblings, 1 reply; 3+ messages in thread
From: Zheng Liu @ 2013-07-09  0:11 UTC (permalink / raw)
  To: linux-ext4; +Cc: Zheng Liu, Tao Ma, Theodore Ts'o

From: Zheng Liu <wenqing.lz@taobao.com>

Currently ext4_add_dirent_to_inline() function returns 1 to indicate
that a new directory entry has been added.  But it sounds reasonable
to return 0 in this function.  Meanwhile we also can eliminate a if
statement in ext4_add_entry() function when a directory entry has added
correctly.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Cc: Tao Ma <tm@tao.ma>
Cc: "Theodore Ts'o" <tytso@mit.edu>
---
 fs/ext4/inline.c |    2 +-
 fs/ext4/namei.c  |    6 +-----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index b8a0746..5a27d32 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1027,7 +1027,7 @@ static int ext4_add_dirent_to_inline(handle_t *handle,
 	ext4_update_dx_flag(dir);
 	dir->i_version++;
 	ext4_mark_inode_dirty(handle, dir);
-	return 1;
+	return 0;
 }
 
 static void *ext4_get_inline_xattr_pos(struct inode *inode,
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index ab2f6dc..2a6a736 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1901,12 +1901,8 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
 
 	if (ext4_has_inline_data(dir)) {
 		retval = ext4_try_add_inline_entry(handle, dentry, inode);
-		if (retval < 0)
+		if (retval <= 0)
 			return retval;
-		if (retval == 1) {
-			retval = 0;
-			return retval;
-		}
 	}
 
 	if (is_dx(dir)) {
-- 
1.7.9.7


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

* Re: [PATCH] ext4: make ext4_add_dirent_to_inline function return 0
  2013-07-09  0:11 [PATCH] ext4: make ext4_add_dirent_to_inline function return 0 Zheng Liu
@ 2013-07-09  1:47 ` Tao Ma
  2013-07-09 12:15   ` Zheng Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Tao Ma @ 2013-07-09  1:47 UTC (permalink / raw)
  To: Zheng Liu; +Cc: linux-ext4, Theodore Ts'o

On 07/09/2013 08:11 AM, Zheng Liu wrote:
> From: Zheng Liu <wenqing.lz@taobao.com>
> 
> Currently ext4_add_dirent_to_inline() function returns 1 to indicate
> that a new directory entry has been added.  But it sounds reasonable
> to return 0 in this function.  Meanwhile we also can eliminate a if
> statement in ext4_add_entry() function when a directory entry has added
> correctly.
> 
> Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
> Cc: Tao Ma <tm@tao.ma>
> Cc: "Theodore Ts'o" <tytso@mit.edu>
> ---
>  fs/ext4/inline.c |    2 +-
>  fs/ext4/namei.c  |    6 +-----
>  2 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
> index b8a0746..5a27d32 100644
> --- a/fs/ext4/inline.c
> +++ b/fs/ext4/inline.c
> @@ -1027,7 +1027,7 @@ static int ext4_add_dirent_to_inline(handle_t *handle,
>  	ext4_update_dx_flag(dir);
>  	dir->i_version++;
>  	ext4_mark_inode_dirty(handle, dir);
> -	return 1;
> +	return 0;
>  }
>  
>  static void *ext4_get_inline_xattr_pos(struct inode *inode,
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index ab2f6dc..2a6a736 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -1901,12 +1901,8 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
>  
>  	if (ext4_has_inline_data(dir)) {
>  		retval = ext4_try_add_inline_entry(handle, dentry, inode);
> -		if (retval < 0)
> +		if (retval <= 0)
Sorry, I guess you misread the codes here. If we get 0 here, it means
that ext4_try_add_inline_entry can't add this entry into the inline
data, but there is no error, so please go on with the normal case. "1"
means we have successfully done the work. So your change is wrong.

Thanks,
Tao
>  			return retval;
> -		if (retval == 1) {
> -			retval = 0;
> -			return retval;
> -		}
>  	}
>  
>  	if (is_dx(dir)) {
> 


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

* Re: [PATCH] ext4: make ext4_add_dirent_to_inline function return 0
  2013-07-09  1:47 ` Tao Ma
@ 2013-07-09 12:15   ` Zheng Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Zheng Liu @ 2013-07-09 12:15 UTC (permalink / raw)
  To: Tao Ma; +Cc: linux-ext4, Theodore Ts'o

On Tue, Jul 09, 2013 at 09:47:12AM +0800, Tao Ma wrote:
> On 07/09/2013 08:11 AM, Zheng Liu wrote:
> > From: Zheng Liu <wenqing.lz@taobao.com>
> > 
> > Currently ext4_add_dirent_to_inline() function returns 1 to indicate
> > that a new directory entry has been added.  But it sounds reasonable
> > to return 0 in this function.  Meanwhile we also can eliminate a if
> > statement in ext4_add_entry() function when a directory entry has added
> > correctly.
> > 
> > Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
> > Cc: Tao Ma <tm@tao.ma>
> > Cc: "Theodore Ts'o" <tytso@mit.edu>
> > ---
> >  fs/ext4/inline.c |    2 +-
> >  fs/ext4/namei.c  |    6 +-----
> >  2 files changed, 2 insertions(+), 6 deletions(-)
> > 
> > diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
> > index b8a0746..5a27d32 100644
> > --- a/fs/ext4/inline.c
> > +++ b/fs/ext4/inline.c
> > @@ -1027,7 +1027,7 @@ static int ext4_add_dirent_to_inline(handle_t *handle,
> >  	ext4_update_dx_flag(dir);
> >  	dir->i_version++;
> >  	ext4_mark_inode_dirty(handle, dir);
> > -	return 1;
> > +	return 0;
> >  }
> >  
> >  static void *ext4_get_inline_xattr_pos(struct inode *inode,
> > diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> > index ab2f6dc..2a6a736 100644
> > --- a/fs/ext4/namei.c
> > +++ b/fs/ext4/namei.c
> > @@ -1901,12 +1901,8 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
> >  
> >  	if (ext4_has_inline_data(dir)) {
> >  		retval = ext4_try_add_inline_entry(handle, dentry, inode);
> > -		if (retval < 0)
> > +		if (retval <= 0)
> Sorry, I guess you misread the codes here. If we get 0 here, it means
> that ext4_try_add_inline_entry can't add this entry into the inline
> data, but there is no error, so please go on with the normal case. "1"
> means we have successfully done the work. So your change is wrong.

Ah, you are right.  Thanks for pointing it out.

                                                - Zheng

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

end of thread, other threads:[~2013-07-09 11:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-09  0:11 [PATCH] ext4: make ext4_add_dirent_to_inline function return 0 Zheng Liu
2013-07-09  1:47 ` Tao Ma
2013-07-09 12:15   ` Zheng Liu

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