diff mbox

[U-Boot,1/2] fs:ext4:cleanup: Remove superfluous code

Message ID 1398854380-10778-2-git-send-email-l.majewski@samsung.com
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Łukasz Majewski April 30, 2014, 10:39 a.m. UTC
Code responsible for handling situation when ext4 has block size of 1024B
can be ordered to take less space.

This patch does that for ext4 common and write files.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 fs/ext4/ext4_common.c |    6 ++----
 fs/ext4/ext4_write.c  |   50 ++++++++++++++++---------------------------------
 2 files changed, 18 insertions(+), 38 deletions(-)

Comments

Simon Glass April 30, 2014, 7:15 p.m. UTC | #1
On 30 April 2014 03:39, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Code responsible for handling situation when ext4 has block size of 1024B
> can be ordered to take less space.
>
> This patch does that for ext4 common and write files.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>

Reviewed-by: Simon Glass <sjg@chromium.org>

> ---
>  fs/ext4/ext4_common.c |    6 ++----
>  fs/ext4/ext4_write.c  |   50 ++++++++++++++++---------------------------------
>  2 files changed, 18 insertions(+), 38 deletions(-)
>
> diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> index 02da75c..62e2e80 100644
> --- a/fs/ext4/ext4_common.c
> +++ b/fs/ext4/ext4_common.c
[snip]

> @@ -181,10 +179,8 @@ static void delete_double_indirect_block(struct ext2_inode *inode)
>                                 break;
>
>                         debug("DICB releasing %u\n", *di_buffer);
> -                       if (fs->blksz != 1024) {
> -                               bg_idx = (*di_buffer) / blk_per_grp;
> -                       } else {
> -                               bg_idx = (*di_buffer) / blk_per_grp;
> +                       bg_idx = (*di_buffer) / blk_per_grp;

You don't need the brackets here (or below).

> +                       if (fs->blksz == 1024) {
>                                 remainder = (*di_buffer) % blk_per_grp;
>                                 if (!remainder)
>                                         bg_idx--;
> @@ -213,10 +209,8 @@ static void delete_double_indirect_block(struct ext2_inode *inode)
>
>                 /* removing the parent double indirect block */
>                 blknr = inode->b.blocks.double_indir_block;
> -               if (fs->blksz != 1024) {
> -                       bg_idx = blknr / blk_per_grp;
> -               } else {
> -                       bg_idx = blknr / blk_per_grp;
> +               bg_idx = blknr / blk_per_grp;
> +               if (fs->blksz == 1024) {
>                         remainder = blknr % blk_per_grp;
>                         if (!remainder)
>                                 bg_idx--;
> @@ -293,11 +287,8 @@ static void delete_triple_indirect_block(struct ext2_inode *inode)
>                         for (j = 0; j < fs->blksz / sizeof(int); j++) {
>                                 if (*tip_buffer == 0)
>                                         break;
> -                               if (fs->blksz != 1024) {
> -                                       bg_idx = (*tip_buffer) / blk_per_grp;
> -                               } else {
> -                                       bg_idx = (*tip_buffer) / blk_per_grp;
> -
> +                               bg_idx = (*tip_buffer) / blk_per_grp;
> +                               if (fs->blksz == 1024) {
>                                         remainder = (*tip_buffer) % blk_per_grp;
>                                         if (!remainder)
>                                                 bg_idx--;
> @@ -336,11 +327,8 @@ static void delete_triple_indirect_block(struct ext2_inode *inode)
>                          * removing the grand parent blocks
>                          * which is connected to inode
>                          */
> -                       if (fs->blksz != 1024) {
> -                               bg_idx = (*tigp_buffer) / blk_per_grp;
> -                       } else {
> -                               bg_idx = (*tigp_buffer) / blk_per_grp;
> -
> +                       bg_idx = (*tigp_buffer) / blk_per_grp;
> +                       if (fs->blksz == 1024) {
>                                 remainder = (*tigp_buffer) % blk_per_grp;
>                                 if (!remainder)
>                                         bg_idx--;
> @@ -371,10 +359,8 @@ static void delete_triple_indirect_block(struct ext2_inode *inode)
>
>                 /* removing the grand parent triple indirect block */
>                 blknr = inode->b.blocks.triple_indir_block;
> -               if (fs->blksz != 1024) {
> -                       bg_idx = blknr / blk_per_grp;
> -               } else {
> -                       bg_idx = blknr / blk_per_grp;
> +               bg_idx = blknr / blk_per_grp;
> +               if (fs->blksz == 1024) {
>                         remainder = blknr % blk_per_grp;
>                         if (!remainder)
>                                 bg_idx--;
> @@ -452,10 +438,8 @@ static int ext4fs_delete_file(int inodeno)
>
>                 for (i = 0; i < no_blocks; i++) {
>                         blknr = read_allocated_block(&(node_inode->inode), i);
> -                       if (fs->blksz != 1024) {
> -                               bg_idx = blknr / blk_per_grp;
> -                       } else {
> -                               bg_idx = blknr / blk_per_grp;
> +                       bg_idx = blknr / blk_per_grp;
> +                       if (fs->blksz == 1024) {
>                                 remainder = blknr % blk_per_grp;
>                                 if (!remainder)
>                                         bg_idx--;
> @@ -499,10 +483,8 @@ static int ext4fs_delete_file(int inodeno)
>                         no_blocks++;
>                 for (i = 0; i < no_blocks; i++) {
>                         blknr = read_allocated_block(&inode, i);
> -                       if (fs->blksz != 1024) {
> -                               bg_idx = blknr / blk_per_grp;
> -                       } else {
> -                               bg_idx = blknr / blk_per_grp;
> +                       bg_idx = blknr / blk_per_grp;
> +                       if (fs->blksz == 1024) {
>                                 remainder = blknr % blk_per_grp;
>                                 if (!remainder)
>                                         bg_idx--;
> --
> 1.7.10.4
>
Łukasz Majewski May 5, 2014, 5:20 a.m. UTC | #2
Hi Simon,

> On 30 April 2014 03:39, Lukasz Majewski <l.majewski@samsung.com>
> wrote:
> > Code responsible for handling situation when ext4 has block size of
> > 1024B can be ordered to take less space.
> >
> > This patch does that for ext4 common and write files.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> > ---
> >  fs/ext4/ext4_common.c |    6 ++----
> >  fs/ext4/ext4_write.c  |   50
> > ++++++++++++++++--------------------------------- 2 files changed,
> > 18 insertions(+), 38 deletions(-)
> >
> > diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> > index 02da75c..62e2e80 100644
> > --- a/fs/ext4/ext4_common.c
> > +++ b/fs/ext4/ext4_common.c
> [snip]
> 
> > @@ -181,10 +179,8 @@ static void
> > delete_double_indirect_block(struct ext2_inode *inode) break;
> >
> >                         debug("DICB releasing %u\n", *di_buffer);
> > -                       if (fs->blksz != 1024) {
> > -                               bg_idx = (*di_buffer) / blk_per_grp;
> > -                       } else {
> > -                               bg_idx = (*di_buffer) / blk_per_grp;
> > +                       bg_idx = (*di_buffer) / blk_per_grp;
> 
> You don't need the brackets here (or below).

Maybe the GIT formatting is a bit misleading, but I've double checked
and it seems that those parenthesis are necessary here.

> 
> > +                       if (fs->blksz == 1024) {
> >                                 remainder = (*di_buffer) %
> > blk_per_grp; if (!remainder)
> >                                         bg_idx--;
> > @@ -213,10 +209,8 @@ static void
> > delete_double_indirect_block(struct ext2_inode *inode)
> >
> >                 /* removing the parent double indirect block */
> >                 blknr = inode->b.blocks.double_indir_block;
> > -               if (fs->blksz != 1024) {
> > -                       bg_idx = blknr / blk_per_grp;
> > -               } else {
> > -                       bg_idx = blknr / blk_per_grp;
> > +               bg_idx = blknr / blk_per_grp;
> > +               if (fs->blksz == 1024) {
> >                         remainder = blknr % blk_per_grp;
> >                         if (!remainder)
> >                                 bg_idx--;
> > @@ -293,11 +287,8 @@ static void
> > delete_triple_indirect_block(struct ext2_inode *inode) for (j = 0;
> > j < fs->blksz / sizeof(int); j++) { if (*tip_buffer == 0)
> >                                         break;
> > -                               if (fs->blksz != 1024) {
> > -                                       bg_idx = (*tip_buffer) /
> > blk_per_grp;
> > -                               } else {
> > -                                       bg_idx = (*tip_buffer) /
> > blk_per_grp; -
> > +                               bg_idx = (*tip_buffer) /
> > blk_per_grp;
> > +                               if (fs->blksz == 1024) {
> >                                         remainder = (*tip_buffer) %
> > blk_per_grp; if (!remainder)
> >                                                 bg_idx--;
> > @@ -336,11 +327,8 @@ static void
> > delete_triple_indirect_block(struct ext2_inode *inode)
> >                          * removing the grand parent blocks
> >                          * which is connected to inode
> >                          */
> > -                       if (fs->blksz != 1024) {
> > -                               bg_idx = (*tigp_buffer) /
> > blk_per_grp;
> > -                       } else {
> > -                               bg_idx = (*tigp_buffer) /
> > blk_per_grp; -
> > +                       bg_idx = (*tigp_buffer) / blk_per_grp;
> > +                       if (fs->blksz == 1024) {
> >                                 remainder = (*tigp_buffer) %
> > blk_per_grp; if (!remainder)
> >                                         bg_idx--;
> > @@ -371,10 +359,8 @@ static void
> > delete_triple_indirect_block(struct ext2_inode *inode)
> >
> >                 /* removing the grand parent triple indirect block
> > */ blknr = inode->b.blocks.triple_indir_block;
> > -               if (fs->blksz != 1024) {
> > -                       bg_idx = blknr / blk_per_grp;
> > -               } else {
> > -                       bg_idx = blknr / blk_per_grp;
> > +               bg_idx = blknr / blk_per_grp;
> > +               if (fs->blksz == 1024) {
> >                         remainder = blknr % blk_per_grp;
> >                         if (!remainder)
> >                                 bg_idx--;
> > @@ -452,10 +438,8 @@ static int ext4fs_delete_file(int inodeno)
> >
> >                 for (i = 0; i < no_blocks; i++) {
> >                         blknr =
> > read_allocated_block(&(node_inode->inode), i);
> > -                       if (fs->blksz != 1024) {
> > -                               bg_idx = blknr / blk_per_grp;
> > -                       } else {
> > -                               bg_idx = blknr / blk_per_grp;
> > +                       bg_idx = blknr / blk_per_grp;
> > +                       if (fs->blksz == 1024) {
> >                                 remainder = blknr % blk_per_grp;
> >                                 if (!remainder)
> >                                         bg_idx--;
> > @@ -499,10 +483,8 @@ static int ext4fs_delete_file(int inodeno)
> >                         no_blocks++;
> >                 for (i = 0; i < no_blocks; i++) {
> >                         blknr = read_allocated_block(&inode, i);
> > -                       if (fs->blksz != 1024) {
> > -                               bg_idx = blknr / blk_per_grp;
> > -                       } else {
> > -                               bg_idx = blknr / blk_per_grp;
> > +                       bg_idx = blknr / blk_per_grp;
> > +                       if (fs->blksz == 1024) {
> >                                 remainder = blknr % blk_per_grp;
> >                                 if (!remainder)
> >                                         bg_idx--;
> > --
> > 1.7.10.4
> >
Simon Glass May 5, 2014, 2:24 p.m. UTC | #3
Hi Lukasz,

On 4 May 2014 23:20, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Hi Simon,
>
>> On 30 April 2014 03:39, Lukasz Majewski <l.majewski@samsung.com>
>> wrote:
>> > Code responsible for handling situation when ext4 has block size of
>> > 1024B can be ordered to take less space.
>> >
>> > This patch does that for ext4 common and write files.
>> >
>> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>
>> > ---
>> >  fs/ext4/ext4_common.c |    6 ++----
>> >  fs/ext4/ext4_write.c  |   50
>> > ++++++++++++++++--------------------------------- 2 files changed,
>> > 18 insertions(+), 38 deletions(-)
>> >
>> > diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
>> > index 02da75c..62e2e80 100644
>> > --- a/fs/ext4/ext4_common.c
>> > +++ b/fs/ext4/ext4_common.c
>> [snip]
>>
>> > @@ -181,10 +179,8 @@ static void
>> > delete_double_indirect_block(struct ext2_inode *inode) break;
>> >
>> >                         debug("DICB releasing %u\n", *di_buffer);
>> > -                       if (fs->blksz != 1024) {
>> > -                               bg_idx = (*di_buffer) / blk_per_grp;
>> > -                       } else {
>> > -                               bg_idx = (*di_buffer) / blk_per_grp;
>> > +                       bg_idx = (*di_buffer) / blk_per_grp;
>>
>> You don't need the brackets here (or below).
>
> Maybe the GIT formatting is a bit misleading, but I've double checked
> and it seems that those parenthesis are necessary here.

OK. What is di_buffer such that (*di_buffer) works but *di_buffer doesn't?

Regards,
Simon
Lukasz Majewski May 5, 2014, 9:10 p.m. UTC | #4
On Mon, 5 May 2014 08:24:22 -0600
Simon Glass <sjg@chromium.org> wrote:

> 
> Hi Lukasz,
> 
> On 4 May 2014 23:20, Lukasz Majewski <l.majewski@samsung.com> wrote:
> > Hi Simon,
> >
> >> On 30 April 2014 03:39, Lukasz Majewski <l.majewski@samsung.com>
> >> wrote:
> >> > Code responsible for handling situation when ext4 has block size
> >> > of 1024B can be ordered to take less space.
> >> >
> >> > This patch does that for ext4 common and write files.
> >> >
> >> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> >>
> >> Reviewed-by: Simon Glass <sjg@chromium.org>
> >>
> >> > ---
> >> >  fs/ext4/ext4_common.c |    6 ++----
> >> >  fs/ext4/ext4_write.c  |   50
> >> > ++++++++++++++++--------------------------------- 2 files
> >> > changed, 18 insertions(+), 38 deletions(-)
> >> >
> >> > diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> >> > index 02da75c..62e2e80 100644
> >> > --- a/fs/ext4/ext4_common.c
> >> > +++ b/fs/ext4/ext4_common.c
> >> [snip]
> >>
> >> > @@ -181,10 +179,8 @@ static void
> >> > delete_double_indirect_block(struct ext2_inode *inode) break;
> >> >
> >> >                         debug("DICB releasing %u\n", *di_buffer);
> >> > -                       if (fs->blksz != 1024) {
> >> > -                               bg_idx = (*di_buffer) /
> >> > blk_per_grp;
> >> > -                       } else {
> >> > -                               bg_idx = (*di_buffer) /
> >> > blk_per_grp;
> >> > +                       bg_idx = (*di_buffer) / blk_per_grp;
> >>
> >> You don't need the brackets here (or below).
> >
> > Maybe the GIT formatting is a bit misleading, but I've double
> > checked and it seems that those parenthesis are necessary here.
> 
> OK. What is di_buffer such that (*di_buffer) works but *di_buffer
> doesn't?

It is hard to admit :-), but I've misunderstood you. I thought that you
are talking about the {} parentheses.

I will check the code tomorrow and prepare proper patch.

> 
> Regards,
> Simon

Best regards,
Lukasz Majewski
Simon Glass May 5, 2014, 9:12 p.m. UTC | #5
Hi Lukasz,

On 5 May 2014 15:10, Lukasz Majewski <l.majewski@majess.pl> wrote:
> On Mon, 5 May 2014 08:24:22 -0600
> Simon Glass <sjg@chromium.org> wrote:
>
>>
>> Hi Lukasz,
>>
>> On 4 May 2014 23:20, Lukasz Majewski <l.majewski@samsung.com> wrote:
>> > Hi Simon,
>> >
>> >> On 30 April 2014 03:39, Lukasz Majewski <l.majewski@samsung.com>
>> >> wrote:
>> >> > Code responsible for handling situation when ext4 has block size
>> >> > of 1024B can be ordered to take less space.
>> >> >
>> >> > This patch does that for ext4 common and write files.
>> >> >
>> >> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>> >>
>> >> Reviewed-by: Simon Glass <sjg@chromium.org>
>> >>
>> >> > ---
>> >> >  fs/ext4/ext4_common.c |    6 ++----
>> >> >  fs/ext4/ext4_write.c  |   50
>> >> > ++++++++++++++++--------------------------------- 2 files
>> >> > changed, 18 insertions(+), 38 deletions(-)
>> >> >
>> >> > diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
>> >> > index 02da75c..62e2e80 100644
>> >> > --- a/fs/ext4/ext4_common.c
>> >> > +++ b/fs/ext4/ext4_common.c
>> >> [snip]
>> >>
>> >> > @@ -181,10 +179,8 @@ static void
>> >> > delete_double_indirect_block(struct ext2_inode *inode) break;
>> >> >
>> >> >                         debug("DICB releasing %u\n", *di_buffer);
>> >> > -                       if (fs->blksz != 1024) {
>> >> > -                               bg_idx = (*di_buffer) /
>> >> > blk_per_grp;
>> >> > -                       } else {
>> >> > -                               bg_idx = (*di_buffer) /
>> >> > blk_per_grp;
>> >> > +                       bg_idx = (*di_buffer) / blk_per_grp;
>> >>
>> >> You don't need the brackets here (or below).
>> >
>> > Maybe the GIT formatting is a bit misleading, but I've double
>> > checked and it seems that those parenthesis are necessary here.
>>
>> OK. What is di_buffer such that (*di_buffer) works but *di_buffer
>> doesn't?
>
> It is hard to admit :-), but I've misunderstood you. I thought that you
> are talking about the {} parentheses.
>
> I will check the code tomorrow and prepare proper patch.

Ah, sorry I wasn't at all clear on that.

Regards,
Simon
diff mbox

Patch

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 02da75c..62e2e80 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -904,10 +904,8 @@  long int ext4fs_get_new_blk_no(void)
 restart:
 		fs->curr_blkno++;
 		/* get the blockbitmap index respective to blockno */
-		if (fs->blksz != 1024) {
-			bg_idx = fs->curr_blkno / blk_per_grp;
-		} else {
-			bg_idx = fs->curr_blkno / blk_per_grp;
+		bg_idx = fs->curr_blkno / blk_per_grp;
+		if (fs->blksz == 1024) {
 			remainder = fs->curr_blkno % blk_per_grp;
 			if (!remainder)
 				bg_idx--;
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index b674b6f..46c573b 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -116,10 +116,8 @@  static void delete_single_indirect_block(struct ext2_inode *inode)
 	if (inode->b.blocks.indir_block != 0) {
 		debug("SIPB releasing %u\n", inode->b.blocks.indir_block);
 		blknr = inode->b.blocks.indir_block;
-		if (fs->blksz != 1024) {
-			bg_idx = blknr / blk_per_grp;
-		} else {
-			bg_idx = blknr / blk_per_grp;
+		bg_idx = blknr / blk_per_grp;
+		if (fs->blksz == 1024) {
 			remainder = blknr % blk_per_grp;
 			if (!remainder)
 				bg_idx--;
@@ -181,10 +179,8 @@  static void delete_double_indirect_block(struct ext2_inode *inode)
 				break;
 
 			debug("DICB releasing %u\n", *di_buffer);
-			if (fs->blksz != 1024) {
-				bg_idx = (*di_buffer) / blk_per_grp;
-			} else {
-				bg_idx = (*di_buffer) / blk_per_grp;
+			bg_idx = (*di_buffer) / blk_per_grp;
+			if (fs->blksz == 1024) {
 				remainder = (*di_buffer) % blk_per_grp;
 				if (!remainder)
 					bg_idx--;
@@ -213,10 +209,8 @@  static void delete_double_indirect_block(struct ext2_inode *inode)
 
 		/* removing the parent double indirect block */
 		blknr = inode->b.blocks.double_indir_block;
-		if (fs->blksz != 1024) {
-			bg_idx = blknr / blk_per_grp;
-		} else {
-			bg_idx = blknr / blk_per_grp;
+		bg_idx = blknr / blk_per_grp;
+		if (fs->blksz == 1024) {
 			remainder = blknr % blk_per_grp;
 			if (!remainder)
 				bg_idx--;
@@ -293,11 +287,8 @@  static void delete_triple_indirect_block(struct ext2_inode *inode)
 			for (j = 0; j < fs->blksz / sizeof(int); j++) {
 				if (*tip_buffer == 0)
 					break;
-				if (fs->blksz != 1024) {
-					bg_idx = (*tip_buffer) / blk_per_grp;
-				} else {
-					bg_idx = (*tip_buffer) / blk_per_grp;
-
+				bg_idx = (*tip_buffer) / blk_per_grp;
+				if (fs->blksz == 1024) {
 					remainder = (*tip_buffer) % blk_per_grp;
 					if (!remainder)
 						bg_idx--;
@@ -336,11 +327,8 @@  static void delete_triple_indirect_block(struct ext2_inode *inode)
 			 * removing the grand parent blocks
 			 * which is connected to inode
 			 */
-			if (fs->blksz != 1024) {
-				bg_idx = (*tigp_buffer) / blk_per_grp;
-			} else {
-				bg_idx = (*tigp_buffer) / blk_per_grp;
-
+			bg_idx = (*tigp_buffer) / blk_per_grp;
+			if (fs->blksz == 1024) {
 				remainder = (*tigp_buffer) % blk_per_grp;
 				if (!remainder)
 					bg_idx--;
@@ -371,10 +359,8 @@  static void delete_triple_indirect_block(struct ext2_inode *inode)
 
 		/* removing the grand parent triple indirect block */
 		blknr = inode->b.blocks.triple_indir_block;
-		if (fs->blksz != 1024) {
-			bg_idx = blknr / blk_per_grp;
-		} else {
-			bg_idx = blknr / blk_per_grp;
+		bg_idx = blknr / blk_per_grp;
+		if (fs->blksz == 1024) {
 			remainder = blknr % blk_per_grp;
 			if (!remainder)
 				bg_idx--;
@@ -452,10 +438,8 @@  static int ext4fs_delete_file(int inodeno)
 
 		for (i = 0; i < no_blocks; i++) {
 			blknr = read_allocated_block(&(node_inode->inode), i);
-			if (fs->blksz != 1024) {
-				bg_idx = blknr / blk_per_grp;
-			} else {
-				bg_idx = blknr / blk_per_grp;
+			bg_idx = blknr / blk_per_grp;
+			if (fs->blksz == 1024) {
 				remainder = blknr % blk_per_grp;
 				if (!remainder)
 					bg_idx--;
@@ -499,10 +483,8 @@  static int ext4fs_delete_file(int inodeno)
 			no_blocks++;
 		for (i = 0; i < no_blocks; i++) {
 			blknr = read_allocated_block(&inode, i);
-			if (fs->blksz != 1024) {
-				bg_idx = blknr / blk_per_grp;
-			} else {
-				bg_idx = blknr / blk_per_grp;
+			bg_idx = blknr / blk_per_grp;
+			if (fs->blksz == 1024) {
 				remainder = blknr % blk_per_grp;
 				if (!remainder)
 					bg_idx--;