From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 09/13] ext4: After completely filled group, scan next group from the beginning
Date: Mon, 29 Aug 2016 16:06:29 +0200 [thread overview]
Message-ID: <20160829160629.69de011d@amdc2363> (raw)
In-Reply-To: <f5754761054b4b6f9ecc5219c9c45bf7@rwthex-w2-b.rwth-ad.de>
Hi Stefan,
> The last free block of a block group may be in its middle. After it
> has been allocated, the next block group should be scanned from its
> beginning.
>
> The following command triggers the bad behaviour (on a blocksize 1024
> fs):
>
> ./sandbox/u-boot -c 'i=0; host bind 0 ./disk.raw ;
> while test $i -lt 260 ; do echo $i; setexpr i $i + 1;
> ext4write host 0:2 0 /X${i} 0x1450; done ;
> ext4write host 0:2 0 /X240 0x2000 ; '
>
> When 'X240' is extended from 5200 byte to 8192 byte, the new blocks
> should start from the first free block (8811), but it uses the blocks
> 8098-8103 and 16296-16297 -- 8103 + 1 + 8192 = 16296. This can be
> shown with debugfs, commands 'ffb' and 'stat X240'.
>
> Signed-off-by: Stefan Br?ns <stefan.bruens@rwth-aachen.de>
> ---
> fs/ext4/ext4_common.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> v3: Patch added to series
>
> diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> index 1ebdbe6..362668b 100644
> --- a/fs/ext4/ext4_common.c
> +++ b/fs/ext4/ext4_common.c
> @@ -895,8 +895,8 @@ uint32_t ext4fs_get_new_blk_no(void)
>
> goto fail;
> } else {
> -restart:
> fs->curr_blkno++;
> +restart:
> /* get the blockbitmap index respective to blockno */
> bg_idx = fs->curr_blkno / blk_per_grp;
> if (fs->blksz == 1024) {
> @@ -914,8 +914,9 @@ restart:
>
> if (bgd[bg_idx].free_blocks == 0) {
> debug("block group %u is full. Skipping\n",
> bg_idx);
> - fs->curr_blkno = fs->curr_blkno +
> blk_per_grp;
> - fs->curr_blkno--;
> + fs->curr_blkno = (bg_idx + 1) * blk_per_grp;
> + if (fs->blksz == 1024)
> + fs->curr_blkno += 1;
> goto restart;
> }
>
> @@ -932,6 +933,7 @@ restart:
> bg_idx) != 0) {
> debug("going for restart for the block no
> %ld %u\n", fs->curr_blkno, bg_idx);
> + fs->curr_blkno++;
> goto restart;
> }
>
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
next prev parent reply other threads:[~2016-08-29 14:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20160828204238.10809-1-stefan.bruens@rwth-aachen.de>
2016-08-28 20:42 ` [U-Boot] [PATCH v3 01/13] ext4: fix possible crash on directory traversal, ignore deleted entries Stefan Brüns
2016-08-28 20:42 ` [U-Boot] [PATCH v3 02/13] ext4: propagate error if creation of directory entry fails Stefan Brüns
2016-08-28 20:42 ` [U-Boot] [PATCH v3 03/13] ext4: Do not crash when trying to grow a directory using extents Stefan Brüns
2016-08-28 20:42 ` [U-Boot] [PATCH v3 04/13] ext4: Scan all directory blocks for space when inserting a new entry Stefan Brüns
2016-08-29 13:56 ` Lukasz Majewski
2016-08-28 20:42 ` [U-Boot] [PATCH v3 05/13] ext4: Avoid corruption of directories with hash tree indexes Stefan Brüns
2016-08-28 20:42 ` [U-Boot] [PATCH v3 06/13] ext4: scan all directory blocks when looking up an entry Stefan Brüns
2016-08-28 20:42 ` [U-Boot] [PATCH v3 07/13] ext4: only update number of of unused inodes if GDT_CSUM feature is set Stefan Brüns
2016-08-29 14:03 ` Lukasz Majewski
2016-08-28 20:42 ` [U-Boot] [PATCH v3 08/13] ext4: do not clear zalloc'ed buffers a second time Stefan Brüns
2016-08-29 14:04 ` Lukasz Majewski
2016-08-28 20:42 ` [U-Boot] [PATCH v3 09/13] ext4: After completely filled group, scan next group from the beginning Stefan Brüns
2016-08-29 14:06 ` Lukasz Majewski [this message]
2016-08-28 20:42 ` [U-Boot] [PATCH v3 10/13] ext4: Avoid out-of-bounds access of block bitmap Stefan Brüns
2016-08-29 14:08 ` Lukasz Majewski
2016-08-28 20:42 ` [U-Boot] [PATCH v3 11/13] ext4: Fix memory leak in case of failure Stefan Brüns
2016-08-29 14:09 ` Lukasz Majewski
2016-08-28 20:42 ` [U-Boot] [PATCH v3 12/13] ext4: Use correct value for inode size even on revision 0 filesystems Stefan Brüns
2016-08-29 14:09 ` Lukasz Majewski
2016-08-28 20:42 ` [U-Boot] [PATCH v3 13/13] ext4: initialize full inode for inodes bigger than 128 bytes Stefan Brüns
2016-08-29 14:11 ` Lukasz Majewski
[not found] ` <20160828204238.10809-14-stefan.bruens@rwth-aachen.de>
2016-09-05 23:56 ` Stefan Bruens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160829160629.69de011d@amdc2363 \
--to=l.majewski@samsung.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox