Re: [U-Boot] [PATCH 3/3] ext4: Only write journal entries for modified blocks in unlink_filename

2016-10-14 Thread Lukasz Majewski
Hi Stefan,

> Instead of creating a journal entry for each directory block, even
> if the block is unmodified, only log the modified block.
> 
> Signed-off-by: Stefan Brüns 
> ---
>  fs/ext4/ext4_common.c | 23 +--
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> index 11be0b7..ec02eec 100644
> --- a/fs/ext4/ext4_common.c
> +++ b/fs/ext4/ext4_common.c
> @@ -874,8 +874,6 @@ static int unlink_filename(char *filename,
> unsigned int blknr) if (status == 0)
>   goto fail;
>  
> - if (ext4fs_log_journal(block_buffer, blknr))
> - goto fail;
>   offset = 0;
>   do {
>   previous_dir = dir;
> @@ -889,14 +887,6 @@ static int unlink_filename(char *filename,
> unsigned int blknr) if (dir->inode && (strlen(filename) ==
> dir->namelen) && (strncmp(direntname, filename, dir->namelen) == 0)) {
>   inodeno = le32_to_cpu(dir->inode);
> - if (previous_dir) {
> - uint16_t new_len;
> - new_len =
> le16_to_cpu(previous_dir->direntlen);
> - new_len +=
> le16_to_cpu(dir->direntlen);
> - previous_dir->direntlen =
> cpu_to_le16(new_len);
> - } else {
> - dir->inode = 0;
> - }
>   break;
>   }
>  
> @@ -905,7 +895,20 @@ static int unlink_filename(char *filename,
> unsigned int blknr) } while (offset < fs->blksz);
>  
>   if (inodeno > 0) {
> + printf("file found, deleting\n");
> + if (ext4fs_log_journal(block_buffer, blknr))
> + goto fail;
>  
> + if (previous_dir) {
> + /* merge dir entry with predecessor */
> + uint16_t new_len;
> + new_len =
> le16_to_cpu(previous_dir->direntlen);
> + new_len += le16_to_cpu(dir->direntlen);
> + previous_dir->direntlen =
> cpu_to_le16(new_len);
> + } else {
> + /* invalidate dir entry */
> + dir->inode = 0;
> + }
>   if (ext4fs_put_metadata(block_buffer, blknr))
>   goto fail;
>   ret = inodeno;

Reviewed-by: Lukasz Majewski 

-- 
Best regards,

Lukasz Majewski

Samsung R Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 3/3] ext4: Only write journal entries for modified blocks in unlink_filename

2016-10-13 Thread Tom Rini
On Sun, Oct 09, 2016 at 08:15:28PM +0200, Stefan Brüns wrote:

> Instead of creating a journal entry for each directory block, even
> if the block is unmodified, only log the modified block.
> 
> Signed-off-by: Stefan Brüns 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 3/3] ext4: Only write journal entries for modified blocks in unlink_filename

2016-10-09 Thread Stefan Brüns
Instead of creating a journal entry for each directory block, even
if the block is unmodified, only log the modified block.

Signed-off-by: Stefan Brüns 
---
 fs/ext4/ext4_common.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 11be0b7..ec02eec 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -874,8 +874,6 @@ static int unlink_filename(char *filename, unsigned int 
blknr)
if (status == 0)
goto fail;
 
-   if (ext4fs_log_journal(block_buffer, blknr))
-   goto fail;
offset = 0;
do {
previous_dir = dir;
@@ -889,14 +887,6 @@ static int unlink_filename(char *filename, unsigned int 
blknr)
if (dir->inode && (strlen(filename) == dir->namelen) &&
(strncmp(direntname, filename, dir->namelen) == 0)) {
inodeno = le32_to_cpu(dir->inode);
-   if (previous_dir) {
-   uint16_t new_len;
-   new_len = le16_to_cpu(previous_dir->direntlen);
-   new_len += le16_to_cpu(dir->direntlen);
-   previous_dir->direntlen = cpu_to_le16(new_len);
-   } else {
-   dir->inode = 0;
-   }
break;
}
 
@@ -905,7 +895,20 @@ static int unlink_filename(char *filename, unsigned int 
blknr)
} while (offset < fs->blksz);
 
if (inodeno > 0) {
+   printf("file found, deleting\n");
+   if (ext4fs_log_journal(block_buffer, blknr))
+   goto fail;
 
+   if (previous_dir) {
+   /* merge dir entry with predecessor */
+   uint16_t new_len;
+   new_len = le16_to_cpu(previous_dir->direntlen);
+   new_len += le16_to_cpu(dir->direntlen);
+   previous_dir->direntlen = cpu_to_le16(new_len);
+   } else {
+   /* invalidate dir entry */
+   dir->inode = 0;
+   }
if (ext4fs_put_metadata(block_buffer, blknr))
goto fail;
ret = inodeno;
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot