From 30982583e4e57c4648fee4a4d6511e23b6e5db2b Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Sat, 23 Jul 2016 22:36:41 +1000 Subject: fs/befs/linuxvfs.c: move useless assignment Control is transfered to unacquire_none when sb->s_fs_info is equal to NULL, so the assignment to NULL is useless and it is moved above unacquire_none. Link: http://lkml.kernel.org/r/ed41da113fc693c7daa4e8813ca04cc766ddfc05.1464226521.git.salah.triki@acm.org Signed-off-by: Salah Triki Signed-off-by: Andrew Morton --- fs/befs/linuxvfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 7da05b159ade..75ec9a74d8ff 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -870,9 +870,9 @@ befs_fill_super(struct super_block *sb, void *data, int silent) unacquire_priv_sbp: kfree(befs_sb->mount_opts.iocharset); kfree(sb->s_fs_info); + sb->s_fs_info = NULL; unacquire_none: - sb->s_fs_info = NULL; return ret; } -- cgit v1.2.3 From dceee2e230e07d25e50478dde3f0621a1381da53 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Sat, 23 Jul 2016 22:36:41 +1000 Subject: fs/befs/linuxvfs.c: check silent flag before logging errors Log errors only when silent flag is not set. Link: http://lkml.kernel.org/r/d400aaf5a7430de79bd956e40ec075fb1cb08474.1464226521.git.salah.triki@acm.org Signed-off-by: Salah Triki Signed-off-by: Andrew Morton --- fs/befs/linuxvfs.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 75ec9a74d8ff..edee857c2b08 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -772,7 +772,8 @@ befs_fill_super(struct super_block *sb, void *data, int silent) befs_sb = BEFS_SB(sb); if (!parse_options((char *) data, &befs_sb->mount_opts)) { - befs_error(sb, "cannot parse mount options"); + if (!silent) + befs_error(sb, "cannot parse mount options"); goto unacquire_priv_sbp; } @@ -796,7 +797,8 @@ befs_fill_super(struct super_block *sb, void *data, int silent) sb_min_blocksize(sb, 1024); if (!(bh = sb_bread(sb, sb_block))) { - befs_error(sb, "unable to read superblock"); + if (!silent) + befs_error(sb, "unable to read superblock"); goto unacquire_priv_sbp; } @@ -820,9 +822,9 @@ befs_fill_super(struct super_block *sb, void *data, int silent) brelse(bh); if( befs_sb->num_blocks > ~((sector_t)0) ) { - befs_error(sb, "blocks count: %llu " - "is larger than the host can use", - befs_sb->num_blocks); + if (!silent) + befs_error(sb, "blocks count: %llu is larger than the host can use", + befs_sb->num_blocks); goto unacquire_priv_sbp; } @@ -841,7 +843,8 @@ befs_fill_super(struct super_block *sb, void *data, int silent) } sb->s_root = d_make_root(root); if (!sb->s_root) { - befs_error(sb, "get root inode failed"); + if (!silent) + befs_error(sb, "get root inode failed"); goto unacquire_priv_sbp; } -- cgit v1.2.3 From c625426fb61a64427f4e12b83a6710161fd9489b Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Sat, 23 Jul 2016 22:36:41 +1000 Subject: fs/befs/linuxvfs.c: remove useless pr_err in befs_fill_super() Remove pr_err since when kzalloc fails there is a generic out of memory and stack dump. Link: http://lkml.kernel.org/r/c5a7f2d42ec0fc8465c118248e88cd221c483391.1464226521.git.salah.triki@acm.org Signed-off-by: Salah Triki Signed-off-by: Andrew Morton --- fs/befs/linuxvfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index edee857c2b08..5b47b0fbffdd 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -764,11 +764,9 @@ befs_fill_super(struct super_block *sb, void *data, int silent) save_mount_options(sb, data); sb->s_fs_info = kzalloc(sizeof(*befs_sb), GFP_KERNEL); - if (sb->s_fs_info == NULL) { - pr_err("(%s): Unable to allocate memory for private " - "portion of superblock. Bailing.\n", sb->s_id); + if (sb->s_fs_info == NULL) goto unacquire_none; - } + befs_sb = BEFS_SB(sb); if (!parse_options((char *) data, &befs_sb->mount_opts)) { -- cgit v1.2.3 From e808792784e5a4f4532e660697385d3d370f8803 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Sat, 23 Jul 2016 22:36:41 +1000 Subject: fs/befs/linuxvfs.c: remove useless befs_error Remove befs_error since when kmalloc fails there is a generic out of memory and stack dump. Link: http://lkml.kernel.org/r/3de4d388d98bbb570462a5eb8e64623e17fb5d74.1464226521.git.salah.triki@acm.org Signed-off-by: Salah Triki Signed-off-by: Andrew Morton --- fs/befs/linuxvfs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 5b47b0fbffdd..04541f37fe83 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -524,7 +524,6 @@ befs_utf2nls(struct super_block *sb, const char *in, *out = result = kmalloc(maxlen, GFP_NOFS); if (!*out) { - befs_error(sb, "%s cannot allocate memory", __func__); *out_len = 0; return -ENOMEM; } @@ -604,7 +603,6 @@ befs_nls2utf(struct super_block *sb, const char *in, *out = result = kmalloc(maxlen, GFP_NOFS); if (!*out) { - befs_error(sb, "%s cannot allocate memory", __func__); *out_len = 0; return -ENOMEM; } -- cgit v1.2.3 From c08f1cb627c43d7b0a1d04a5a0efaf385f0391ad Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Sat, 23 Jul 2016 22:36:41 +1000 Subject: fs: befs: remove useless pr_err in befs_init_inodecache() Remove pr_err since kmem_cache_create log error and dump stack. Link: http://lkml.kernel.org/r/e6d03cbc9542495dc6174b59e32fcd41c1393cfc.1464226521.git.salah.triki@acm.org Signed-off-by: Salah Triki --- fs/befs/linuxvfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 04541f37fe83..c734f21fd581 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -436,10 +436,9 @@ befs_init_inodecache(void) 0, (SLAB_RECLAIM_ACCOUNT| SLAB_MEM_SPREAD|SLAB_ACCOUNT), init_once); - if (befs_inode_cachep == NULL) { - pr_err("%s: Couldn't initialize inode slabcache\n", __func__); + if (befs_inode_cachep == NULL) return -ENOMEM; - } + return 0; } @@ -524,7 +523,6 @@ befs_utf2nls(struct super_block *sb, const char *in, *out = result = kmalloc(maxlen, GFP_NOFS); if (!*out) { - *out_len = 0; return -ENOMEM; } -- cgit v1.2.3 From 173b066f5826e8eca9b67e8091cab67fcda74f2f Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Sat, 23 Jul 2016 22:36:42 +1000 Subject: befs: check return of sb_min_blocksize Confirm sb_min_blocksize() succeeded before continuing. Link: http://lkml.kernel.org/r/1465700235-22881-1-git-send-email-luisbg@osg.samsung.com Signed-off-by: Luis de Bethencourt Signed-off-by: Andrew Morton --- fs/befs/linuxvfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index c734f21fd581..453bb68da219 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -756,6 +756,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent) long ret = -EINVAL; const unsigned long sb_block = 0; const off_t x86_sb_off = 512; + int blocksize; save_mount_options(sb, data); @@ -788,7 +789,11 @@ befs_fill_super(struct super_block *sb, void *data, int silent) * least 1k to get the second 512 bytes of the volume. * -WD 10-26-01 */ - sb_min_blocksize(sb, 1024); + blocksize = sb_min_blocksize(sb, 1024); + if (!blocksize) { + befs_error(sb, "unable to set blocksize"); + goto unacquire_priv_sbp; + } if (!(bh = sb_bread(sb, sb_block))) { if (!silent) -- cgit v1.2.3 From 10145d6116325266728e423c42d84a89f8f129d2 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Sat, 23 Jul 2016 22:36:42 +1000 Subject: befs: fix function name in documentation Documentation of function befs_load_cb() lists it as load_befs_sb(). Fix the misnomer. Link: http://lkml.kernel.org/r/1465700235-22881-2-git-send-email-luisbg@osg.samsung.com Signed-off-by: Luis de Bethencourt Signed-off-by: Andrew Morton --- fs/befs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/befs/super.c b/fs/befs/super.c index aeafc4d84278..9d1b56cd6f19 100644 --- a/fs/befs/super.c +++ b/fs/befs/super.c @@ -14,7 +14,7 @@ #include "super.h" /** - * load_befs_sb -- Read from disk and properly byteswap all the fields + * befs_load_sb -- Read from disk and properly byteswap all the fields * of the befs superblock * * -- cgit v1.2.3 From f0f2536fe36671028209e0bd15a2940f2b61cdb5 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Sat, 23 Jul 2016 22:36:42 +1000 Subject: befs: remove unused functions befs_iaddr_is_empty() and befs_brun_size() are unused. Remove them. Link: http://lkml.kernel.org/r/1465700235-22881-3-git-send-email-luisbg@osg.samsung.com Signed-off-by: Luis de Bethencourt Signed-off-by: Andrew Morton --- fs/befs/befs.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/fs/befs/befs.h b/fs/befs/befs.h index e0f59263a96d..c5c6cd13709c 100644 --- a/fs/befs/befs.h +++ b/fs/befs/befs.h @@ -140,18 +140,6 @@ befs_iaddrs_per_block(struct super_block *sb) return BEFS_SB(sb)->block_size / sizeof (befs_disk_inode_addr); } -static inline int -befs_iaddr_is_empty(const befs_inode_addr *iaddr) -{ - return (!iaddr->allocation_group) && (!iaddr->start) && (!iaddr->len); -} - -static inline size_t -befs_brun_size(struct super_block *sb, befs_block_run run) -{ - return BEFS_SB(sb)->block_size * run.len; -} - #include "endian.h" #endif /* _LINUX_BEFS_H */ -- cgit v1.2.3 From f7f675406be6eb3736a8690217d7b41d60f6a1aa Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Sat, 23 Jul 2016 22:36:42 +1000 Subject: fs: befs: replace befs_bread by sb_bread Since befs_bread merely calls sb_bread, replace it by sb_bread. Link: http://lkml.kernel.org/r/1466800258-4542-1-git-send-email-salah.triki@gmail.com Signed-off-by: Salah Triki Acked-by: Luis de Bethencourt Signed-off-by: Andrew Morton --- fs/befs/datastream.c | 6 +++--- fs/befs/io.c | 24 ------------------------ fs/befs/io.h | 2 -- fs/befs/linuxvfs.c | 2 +- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c index af1bc19b7c85..26cc417cbdce 100644 --- a/fs/befs/datastream.c +++ b/fs/befs/datastream.c @@ -326,7 +326,7 @@ befs_find_brun_indirect(struct super_block *sb, /* Examine blocks of the indirect run one at a time */ for (i = 0; i < indirect.len; i++) { - indirblock = befs_bread(sb, indirblockno + i); + indirblock = sb_bread(sb, indirblockno + i); if (indirblock == NULL) { befs_debug(sb, "---> %s failed to read " "disk block %lu from the indirect brun", @@ -471,7 +471,7 @@ befs_find_brun_dblindirect(struct super_block *sb, } dbl_indir_block = - befs_bread(sb, iaddr2blockno(sb, &data->double_indirect) + + sb_bread(sb, iaddr2blockno(sb, &data->double_indirect) + dbl_which_block); if (dbl_indir_block == NULL) { befs_error(sb, "%s couldn't read the " @@ -499,7 +499,7 @@ befs_find_brun_dblindirect(struct super_block *sb, } indir_block = - befs_bread(sb, iaddr2blockno(sb, &indir_run) + which_block); + sb_bread(sb, iaddr2blockno(sb, &indir_run) + which_block); if (indir_block == NULL) { befs_error(sb, "%s couldn't read the indirect block " "at blockno %lu", __func__, (unsigned long) diff --git a/fs/befs/io.c b/fs/befs/io.c index 523c8af2d770..4223b779fcc4 100644 --- a/fs/befs/io.c +++ b/fs/befs/io.c @@ -59,27 +59,3 @@ befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr) befs_debug(sb, "<--- %s ERROR", __func__); return NULL; } - -struct buffer_head * -befs_bread(struct super_block *sb, befs_blocknr_t block) -{ - struct buffer_head *bh; - - befs_debug(sb, "---> Enter %s %lu", __func__, (unsigned long)block); - - bh = sb_bread(sb, block); - - if (bh == NULL) { - befs_error(sb, "Failed to read block %lu", - (unsigned long)block); - goto error; - } - - befs_debug(sb, "<--- %s", __func__); - - return bh; - - error: - befs_debug(sb, "<--- %s ERROR", __func__); - return NULL; -} diff --git a/fs/befs/io.h b/fs/befs/io.h index 9b78266b6aa5..78d7bc6e60de 100644 --- a/fs/befs/io.h +++ b/fs/befs/io.h @@ -5,5 +5,3 @@ struct buffer_head *befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr); -struct buffer_head *befs_bread(struct super_block *sb, befs_blocknr_t block); - diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 453bb68da219..619b998e9a1e 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -318,7 +318,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino) befs_ino->i_inode_num.allocation_group, befs_ino->i_inode_num.start, befs_ino->i_inode_num.len); - bh = befs_bread(sb, inode->i_ino); + bh = sb_bread(sb, inode->i_ino); if (!bh) { befs_error(sb, "unable to read inode block - " "inode = %lu", inode->i_ino); -- cgit v1.2.3 From a64998504ebd766f07cf77f41334ccd8a60297ae Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Wed, 29 Jun 2016 21:27:40 +0100 Subject: fs: befs: check silent flag before logging error Log error only when silent flag is not set. Fixes: dbe6460388bc ("fs/befs/linuxvfs.c: check silent flag before logging errors") Signed-off-by: Luis de Bethencourt Acked-by: Salah Triki --- fs/befs/linuxvfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 619b998e9a1e..9272f614d985 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -791,7 +791,8 @@ befs_fill_super(struct super_block *sb, void *data, int silent) */ blocksize = sb_min_blocksize(sb, 1024); if (!blocksize) { - befs_error(sb, "unable to set blocksize"); + if (!silent) + befs_error(sb, "unable to set blocksize"); goto unacquire_priv_sbp; } -- cgit v1.2.3 From 39dcfd3b3448e03a77cd918a918cdea5d84d6076 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Wed, 29 Jun 2016 21:27:41 +0100 Subject: fs: befs: remove comment that confuses kernel-doc This comment with a mysterious unfinished line confuses the kernel-doc system since, because it starts with /**, it thinks it is documenting a function. Signed-off-by: Luis de Bethencourt --- fs/befs/linuxvfs.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 9272f614d985..cf8f9206d4eb 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -633,10 +633,6 @@ befs_nls2utf(struct super_block *sb, const char *in, return -EILSEQ; } -/** - * Use the - * - */ enum { Opt_uid, Opt_gid, Opt_charset, Opt_debug, Opt_err, }; -- cgit v1.2.3 From f7769f9cf95fa1a63eea81f13126f8fe7f708dc1 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Fri, 1 Jul 2016 01:07:30 +0100 Subject: befs: avoid dereferencing dentry twice No need to dereference dentry twice to get the name when we already have it stored in a local variable. Signed-off-by: Luis de Bethencourt --- fs/befs/linuxvfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index cf8f9206d4eb..62889eb4a97e 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -179,7 +179,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) kfree(utfname); } else { - ret = befs_btree_find(sb, ds, dentry->d_name.name, &offset); + ret = befs_btree_find(sb, ds, name, &offset); } if (ret == BEFS_BT_NOT_FOUND) { -- cgit v1.2.3 From 50858ef96deeeeeb36b2113d49007f41d0410763 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Fri, 1 Jul 2016 01:07:31 +0100 Subject: befs: remove constant variable Use macro directly instead of via assigning it to an unchanging variable. Signed-off-by: Luis de Bethencourt Acked-by: Salah Triki --- fs/befs/linuxvfs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 62889eb4a97e..516a958ba50e 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -211,7 +211,6 @@ befs_readdir(struct file *file, struct dir_context *ctx) befs_off_t value; int result; size_t keysize; - unsigned char d_type; char keybuf[BEFS_NAME_LEN + 1]; befs_debug(sb, "---> %s name %pD, inode %ld, ctx->pos %lld", @@ -236,8 +235,6 @@ more: return 0; } - d_type = DT_UNKNOWN; - /* Convert to NLS */ if (BEFS_SB(sb)->nls) { char *nlsname; @@ -249,14 +246,14 @@ more: return result; } if (!dir_emit(ctx, nlsname, nlsnamelen, - (ino_t) value, d_type)) { + (ino_t) value, DT_UNKNOWN)) { kfree(nlsname); return 0; } kfree(nlsname); } else { if (!dir_emit(ctx, keybuf, keysize, - (ino_t) value, d_type)) + (ino_t) value, DT_UNKNOWN)) return 0; } ctx->pos++; -- cgit v1.2.3 From 9ae51a32b1a060d2db4340d853d989ae622d273f Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Fri, 1 Jul 2016 01:07:32 +0100 Subject: befs: use simpler while loop Replace goto with simpler while loop to make befs_readdir() more readable. Signed-off-by: Luis de Bethencourt --- fs/befs/linuxvfs.c | 74 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 516a958ba50e..e0979a471e84 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -216,48 +216,50 @@ befs_readdir(struct file *file, struct dir_context *ctx) befs_debug(sb, "---> %s name %pD, inode %ld, ctx->pos %lld", __func__, file, inode->i_ino, ctx->pos); -more: - result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1, - keybuf, &keysize, &value); - - if (result == BEFS_ERR) { - befs_debug(sb, "<--- %s ERROR", __func__); - befs_error(sb, "IO error reading %pD (inode %lu)", - file, inode->i_ino); - return -EIO; - - } else if (result == BEFS_BT_END) { - befs_debug(sb, "<--- %s END", __func__); - return 0; - - } else if (result == BEFS_BT_EMPTY) { - befs_debug(sb, "<--- %s Empty directory", __func__); - return 0; - } + while (1) { + result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1, + keybuf, &keysize, &value); - /* Convert to NLS */ - if (BEFS_SB(sb)->nls) { - char *nlsname; - int nlsnamelen; - result = - befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen); - if (result < 0) { + if (result == BEFS_ERR) { befs_debug(sb, "<--- %s ERROR", __func__); - return result; + befs_error(sb, "IO error reading %pD (inode %lu)", + file, inode->i_ino); + return -EIO; + + } else if (result == BEFS_BT_END) { + befs_debug(sb, "<--- %s END", __func__); + return 0; + + } else if (result == BEFS_BT_EMPTY) { + befs_debug(sb, "<--- %s Empty directory", __func__); + return 0; } - if (!dir_emit(ctx, nlsname, nlsnamelen, - (ino_t) value, DT_UNKNOWN)) { + + /* Convert to NLS */ + if (BEFS_SB(sb)->nls) { + char *nlsname; + int nlsnamelen; + + result = + befs_utf2nls(sb, keybuf, keysize, &nlsname, + &nlsnamelen); + if (result < 0) { + befs_debug(sb, "<--- %s ERROR", __func__); + return result; + } + if (!dir_emit(ctx, nlsname, nlsnamelen, + (ino_t) value, DT_UNKNOWN)) { + kfree(nlsname); + return 0; + } kfree(nlsname); - return 0; + } else { + if (!dir_emit(ctx, keybuf, keysize, + (ino_t) value, DT_UNKNOWN)) + return 0; } - kfree(nlsname); - } else { - if (!dir_emit(ctx, keybuf, keysize, - (ino_t) value, DT_UNKNOWN)) - return 0; + ctx->pos++; } - ctx->pos++; - goto more; } static struct inode * -- cgit v1.2.3 From 4c3897cce0774b6196f59f98a44eed7e011db5aa Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Sun, 3 Jul 2016 16:29:44 +0100 Subject: befs: make consistent use of befs_error() befs_error() is used in potential errors that could happen in befs to provide informational log messages. befs_debug() is silent when CONFIG_BEFS_DEBUG=no, and very verbose when switched on, which is why it is used for general debugging but not for errors. Fix a few cases where the befs debug utility usage isn't following the expected pattern. To make sure we have consistent information in the logs. Signed-off-by: Luis de Bethencourt --- fs/befs/btree.c | 6 ++++-- fs/befs/datastream.c | 5 ++++- fs/befs/linuxvfs.c | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/befs/btree.c b/fs/befs/btree.c index 307645f9e284..679f69df3817 100644 --- a/fs/befs/btree.c +++ b/fs/befs/btree.c @@ -301,7 +301,8 @@ befs_btree_find(struct super_block *sb, const befs_data_stream *ds, kfree(this_node); if (res != BEFS_BT_MATCH) { - befs_debug(sb, "<--- %s Key %s not found", __func__, key); + befs_error(sb, "<--- %s Key %s not found", __func__, key); + befs_debug(sb, "<--- %s ERROR", __func__); *value = 0; return BEFS_BT_NOT_FOUND; } @@ -358,7 +359,8 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node, eq = befs_compare_strings(thiskey, keylen, findkey, findkey_len); if (eq < 0) { - befs_debug(sb, "<--- %s %s not found", __func__, findkey); + befs_error(sb, "<--- %s %s not found", __func__, findkey); + befs_debug(sb, "<--- %s ERROR", __func__); return BEFS_BT_NOT_FOUND; } diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c index 26cc417cbdce..740fabcd57c0 100644 --- a/fs/befs/datastream.c +++ b/fs/befs/datastream.c @@ -275,6 +275,8 @@ befs_find_brun_direct(struct super_block *sb, const befs_data_stream *data, } } + befs_error(sb, "%s failed to find file block %lu", __func__, + (unsigned long)blockno); befs_debug(sb, "---> %s ERROR", __func__); return BEFS_ERR; } @@ -328,9 +330,10 @@ befs_find_brun_indirect(struct super_block *sb, for (i = 0; i < indirect.len; i++) { indirblock = sb_bread(sb, indirblockno + i); if (indirblock == NULL) { - befs_debug(sb, "---> %s failed to read " + befs_error(sb, "---> %s failed to read " "disk block %lu from the indirect brun", __func__, (unsigned long)indirblockno + i); + befs_debug(sb, "<--- %s ERROR", __func__); return BEFS_ERR; } diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index e0979a471e84..67669a81cfd1 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -187,7 +187,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) return ERR_PTR(-ENOENT); } else if (ret != BEFS_OK || offset == 0) { - befs_warning(sb, "<--- %s Error", __func__); + befs_error(sb, "<--- %s Error", __func__); return ERR_PTR(-ENODATA); } -- cgit v1.2.3 From cfe0cb20e6fa09becc5e6f7597c6e2d1ed9ab7dd Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Tue, 12 Jul 2016 00:02:49 +0100 Subject: befs: in memory free_node_ptr and max_size never read The only place the values of free_node_ptr and max_size are read is in befs_dump_index_entry(), which both times it is called, it is passed the on disk superblock. Removing assignment of unused values. Signed-off-by: Luis de Bethencourt --- fs/befs/btree.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/befs/btree.c b/fs/befs/btree.c index 679f69df3817..e8827af43dcd 100644 --- a/fs/befs/btree.c +++ b/fs/befs/btree.c @@ -156,8 +156,6 @@ befs_bt_read_super(struct super_block *sb, const befs_data_stream *ds, sup->max_depth = fs32_to_cpu(sb, od_sup->max_depth); sup->data_type = fs32_to_cpu(sb, od_sup->data_type); sup->root_node_ptr = fs64_to_cpu(sb, od_sup->root_node_ptr); - sup->free_node_ptr = fs64_to_cpu(sb, od_sup->free_node_ptr); - sup->max_size = fs64_to_cpu(sb, od_sup->max_size); brelse(bh); if (sup->magic != BEFS_BTREE_MAGIC) { -- cgit v1.2.3 From 2dfa8a6e56f63d2f6c479e7b65ef087e892280e9 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Tue, 12 Jul 2016 00:02:50 +0100 Subject: befs: fix typo in befs_bt_read_node documentation Fixing a grammatical error in the documentation. Signed-off-by: Luis de Bethencourt --- fs/befs/btree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/befs/btree.c b/fs/befs/btree.c index e8827af43dcd..97f5e242d3ab 100644 --- a/fs/befs/btree.c +++ b/fs/befs/btree.c @@ -181,8 +181,8 @@ befs_bt_read_super(struct super_block *sb, const befs_data_stream *ds, * Calls befs_read_datastream to read in the indicated btree node and * makes sure its header fields are in cpu byteorder, byteswapping if * necessary. - * Note: node->bh must be NULL when this function called first - * time. Don't forget brelse(node->bh) after last call. + * Note: node->bh must be NULL when this function is called the first time. + * Don't forget brelse(node->bh) after last call. * * On success, returns BEFS_OK and *@node contains the btree node that * starts at @node_off, with the node->head fields in cpu byte order. -- cgit v1.2.3 From d84e4a5a09c320e209789d263a26617f6f7324e3 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 27 Jul 2016 04:11:52 +0100 Subject: fs: befs: Remove redundant validation from befs_find_brun_direct The only caller of befs_find_brun_direct is befs_fblock2brun, which already validates that the block is within the range of direct blocks. So remove the duplicate validation. Signed-off-by: Salah Triki Acked-by: Luis de Bethencourt --- fs/befs/datastream.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c index 740fabcd57c0..41ce07766328 100644 --- a/fs/befs/datastream.c +++ b/fs/befs/datastream.c @@ -249,17 +249,9 @@ befs_find_brun_direct(struct super_block *sb, const befs_data_stream *data, int i; const befs_block_run *array = data->direct; befs_blocknr_t sum; - befs_blocknr_t max_block = - data->max_direct_range >> BEFS_SB(sb)->block_shift; befs_debug(sb, "---> %s, find %lu", __func__, (unsigned long)blockno); - if (blockno > max_block) { - befs_error(sb, "%s passed block outside of direct region", - __func__); - return BEFS_ERR; - } - for (i = 0, sum = 0; i < BEFS_NUM_DIRECT_BLOCKS; sum += array[i].len, i++) { if (blockno >= sum && blockno < sum + (array[i].len)) { -- cgit v1.2.3 From 4bb594329a35e90ed7ff38db24f54aef8680f346 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 27 Jul 2016 04:11:53 +0100 Subject: fs: befs: Coding style fix Constant has to be capitalized. Signed-off-by: Salah Triki Acked-by: Luis de Bethencourt --- fs/befs/btree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/befs/btree.c b/fs/befs/btree.c index 97f5e242d3ab..85453e50bc6e 100644 --- a/fs/befs/btree.c +++ b/fs/befs/btree.c @@ -85,7 +85,7 @@ struct befs_btree_node { }; /* local constants */ -static const befs_off_t befs_bt_inval = 0xffffffffffffffffULL; +static const befs_off_t BEFS_BT_INVAL = 0xffffffffffffffffULL; /* local functions */ static int befs_btree_seekleaf(struct super_block *sb, const befs_data_stream *ds, @@ -467,7 +467,7 @@ befs_btree_read(struct super_block *sb, const befs_data_stream *ds, while (key_sum + this_node->head.all_key_count <= key_no) { /* no more nodes to look in: key_no is too large */ - if (this_node->head.right == befs_bt_inval) { + if (this_node->head.right == BEFS_BT_INVAL) { *keysize = 0; *value = 0; befs_debug(sb, @@ -608,7 +608,7 @@ static int befs_leafnode(struct befs_btree_node *node) { /* all interior nodes (and only interior nodes) have an overflow node */ - if (node->head.overflow == befs_bt_inval) + if (node->head.overflow == BEFS_BT_INVAL) return 1; else return 0; -- cgit v1.2.3 From d70ee4f2de3de1f56f7b5d0837ad9d53320cf128 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 27 Jul 2016 04:11:54 +0100 Subject: fs: befs: Remove useless calls to brelse in befs_find_brun_dblindirect The calls to brelse are useless since dbl_indir_block and indir_block are NULL. Signed-off-by: Salah Triki Acked-by: Luis de Bethencourt --- fs/befs/datastream.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c index 41ce07766328..d7c4bb07e1e4 100644 --- a/fs/befs/datastream.c +++ b/fs/befs/datastream.c @@ -474,7 +474,6 @@ befs_find_brun_dblindirect(struct super_block *sb, (unsigned long) iaddr2blockno(sb, &data->double_indirect) + dbl_which_block); - brelse(dbl_indir_block); return BEFS_ERR; } @@ -499,7 +498,6 @@ befs_find_brun_dblindirect(struct super_block *sb, befs_error(sb, "%s couldn't read the indirect block " "at blockno %lu", __func__, (unsigned long) iaddr2blockno(sb, &indir_run) + which_block); - brelse(indir_block); return BEFS_ERR; } -- cgit v1.2.3 From a26bc1adc74063ec116159d45f305d2a1dd4a07b Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 27 Jul 2016 03:35:59 +0100 Subject: fs: befs: Insert NULL inode to dentry As VFS expects, lookup inserts NULL inode to dentry when the named inode does not exist. Signed-off-by: Salah Triki Acked-by: Luis de Bethencourt --- fs/befs/linuxvfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 67669a81cfd1..ebfc9f0b8a2d 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -184,6 +184,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) if (ret == BEFS_BT_NOT_FOUND) { befs_debug(sb, "<--- %s %pd not found", __func__, dentry); + d_add(dentry, NULL); return ERR_PTR(-ENOENT); } else if (ret != BEFS_OK || offset == 0) { -- cgit v1.2.3 From 88ff34446b33c15340c45888dbe325e2ef7ba8c8 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Sun, 31 Jul 2016 21:34:27 +0100 Subject: fs: befs: remove in vain variable assignment There is no need to set *value, it will be overwritten later. Signed-off-by: Salah Triki Acked-by: Luis de Bethencourt --- fs/befs/btree.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/befs/btree.c b/fs/befs/btree.c index 85453e50bc6e..d5641852c5ff 100644 --- a/fs/befs/btree.c +++ b/fs/befs/btree.c @@ -347,8 +347,6 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node, befs_debug(sb, "---> %s %s", __func__, findkey); - *value = 0; - findkey_len = strlen(findkey); /* if node can not contain key, just skeep this node */ -- cgit v1.2.3 From 143d2a615fe39dd972a6446d24b298f7544588e9 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Sun, 31 Jul 2016 21:34:28 +0100 Subject: fs: befs: remove useless initialization to zero node_off is unconditionally set to bt_super.root_node_ptr, so no need to init it to zero. Signed-off-by: Salah Triki Acked-by: Luis de Bethencourt --- fs/befs/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/befs/btree.c b/fs/befs/btree.c index d5641852c5ff..3f1a39166d89 100644 --- a/fs/befs/btree.c +++ b/fs/befs/btree.c @@ -420,7 +420,7 @@ befs_btree_read(struct super_block *sb, const befs_data_stream *ds, { struct befs_btree_node *this_node; befs_btree_super bt_super; - befs_off_t node_off = 0; + befs_off_t node_off; int cur_key; fs64 *valarray; char *keystart; -- cgit v1.2.3 From f30661035b01910c5da248b6e67fb66182e40f6f Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Sun, 31 Jul 2016 21:34:29 +0100 Subject: fs: befs: remove unnecessary *befs_sb variable Remove *befs_sb and just call BEFS_SB(sb) directly, since the returned value by this function is only used once. Signed-off-by: Salah Triki Acked-by: Luis de Bethencourt --- fs/befs/datastream.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c index d7c4bb07e1e4..6889644e65f8 100644 --- a/fs/befs/datastream.c +++ b/fs/befs/datastream.c @@ -425,10 +425,9 @@ befs_find_brun_dblindirect(struct super_block *sb, struct buffer_head *indir_block; befs_block_run indir_run; befs_disk_inode_addr *iaddr_array; - struct befs_sb_info *befs_sb = BEFS_SB(sb); befs_blocknr_t indir_start_blk = - data->max_indirect_range >> befs_sb->block_shift; + data->max_indirect_range >> BEFS_SB(sb)->block_shift; off_t dbl_indir_off = blockno - indir_start_blk; -- cgit v1.2.3 From abcf911691ee2a4e3fd8c71adc397f67c56565a2 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Sun, 31 Jul 2016 21:34:30 +0100 Subject: fs: befs: remove in vain variable assignment There is no need to init res, since it will be overwitten later by befs_fblock2brun(). Signed-off-by: Salah Triki Acked-by: Luis de Bethencourt --- fs/befs/linuxvfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index ebfc9f0b8a2d..c3909a6a24a3 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -120,7 +120,7 @@ befs_get_block(struct inode *inode, sector_t block, struct super_block *sb = inode->i_sb; befs_data_stream *ds = &BEFS_I(inode)->i_data.ds; befs_block_run run = BAD_IADDR; - int res = 0; + int res; ulong disk_off; befs_debug(sb, "---> befs_get_block() for inode %lu, block %ld", -- cgit v1.2.3 From 33c712b4fcf23fba57cb9a8d947d9ab41e363b08 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Sun, 31 Jul 2016 21:34:31 +0100 Subject: fs: befs: remove ret variable ret is initialized to -EIO and is never modified, so remove ret and use -EIO directly. Signed-off-by: Salah Triki Acked-by: Luis de Bethencourt --- fs/befs/linuxvfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index c3909a6a24a3..d307c1e44f49 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -299,7 +299,6 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino) struct befs_sb_info *befs_sb = BEFS_SB(sb); struct befs_inode_info *befs_ino; struct inode *inode; - long ret = -EIO; befs_debug(sb, "---> %s inode = %lu", __func__, ino); @@ -421,7 +420,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino) unacquire_none: iget_failed(inode); befs_debug(sb, "<--- %s - Bad inode", __func__); - return ERR_PTR(ret); + return ERR_PTR(-EIO); } /* Initialize the inode cache. Called at fs setup. -- cgit v1.2.3 From 672a8515ee7ce3931daba8ed24f43de476d8e29a Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Mon, 8 Aug 2016 15:21:20 +0100 Subject: befs: remove unused BEFS_BT_PARMATCH befs_btree_find(), the only caller of befs_find_key(), only cares about if the return from that function is BEFS_BT_MATCH or not. It never uses the partial match given with BEFS_BT_PARMATCH. Make the overflow return clearer by having BEFS_BT_OVERFLOW instead of BEFS_BT_PARMATCH. Signed-off-by: Luis de Bethencourt Signed-off-by: Salah Triki --- fs/befs/befs.h | 2 +- fs/befs/btree.c | 33 +++++++++++++++------------------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/fs/befs/befs.h b/fs/befs/befs.h index c5c6cd13709c..a8ca7fcf0795 100644 --- a/fs/befs/befs.h +++ b/fs/befs/befs.h @@ -79,7 +79,7 @@ enum befs_err { BEFS_BT_END, BEFS_BT_EMPTY, BEFS_BT_MATCH, - BEFS_BT_PARMATCH, + BEFS_BT_OVERFLOW, BEFS_BT_NOT_FOUND }; diff --git a/fs/befs/btree.c b/fs/befs/btree.c index 3f1a39166d89..5670d845b2ef 100644 --- a/fs/befs/btree.c +++ b/fs/befs/btree.c @@ -281,9 +281,9 @@ befs_btree_find(struct super_block *sb, const befs_data_stream *ds, while (!befs_leafnode(this_node)) { res = befs_find_key(sb, this_node, key, &node_off); - if (res == BEFS_BT_NOT_FOUND) + /* if no key set, try the overflow node */ + if (res == BEFS_BT_OVERFLOW) node_off = this_node->head.overflow; - /* if no match, go to overflow node */ if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) { befs_error(sb, "befs_btree_find() failed to read " "node at %llu", node_off); @@ -291,8 +291,7 @@ befs_btree_find(struct super_block *sb, const befs_data_stream *ds, } } - /* at the correct leaf node now */ - + /* at a leaf node now, check if it is correct */ res = befs_find_key(sb, this_node, key, value); brelse(this_node->bh); @@ -323,16 +322,12 @@ befs_btree_find(struct super_block *sb, const befs_data_stream *ds, * @findkey: Keystring to search for * @value: If key is found, the value stored with the key is put here * - * finds exact match if one exists, and returns BEFS_BT_MATCH - * If no exact match, finds first key in node that is greater - * (alphabetically) than the search key and returns BEFS_BT_PARMATCH - * (for partial match, I guess). Can you think of something better to - * call it? - * - * If no key was a match or greater than the search key, return - * BEFS_BT_NOT_FOUND. + * Finds exact match if one exists, and returns BEFS_BT_MATCH. + * If there is no match and node's value array is too small for key, return + * BEFS_BT_OVERFLOW. + * If no match and node should countain this key, return BEFS_BT_NOT_FOUND. * - * Use binary search instead of a linear. + * Uses binary search instead of a linear. */ static int befs_find_key(struct super_block *sb, struct befs_btree_node *node, @@ -355,9 +350,8 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node, eq = befs_compare_strings(thiskey, keylen, findkey, findkey_len); if (eq < 0) { - befs_error(sb, "<--- %s %s not found", __func__, findkey); - befs_debug(sb, "<--- %s ERROR", __func__); - return BEFS_BT_NOT_FOUND; + befs_debug(sb, "<--- node can't contain %s", findkey); + return BEFS_BT_OVERFLOW; } valarray = befs_bt_valarray(node); @@ -385,12 +379,15 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node, else first = mid + 1; } + + /* return an existing value so caller can arrive to a leaf node */ if (eq < 0) *value = fs64_to_cpu(sb, valarray[mid + 1]); else *value = fs64_to_cpu(sb, valarray[mid]); - befs_debug(sb, "<--- %s found %s at %d", __func__, thiskey, mid); - return BEFS_BT_PARMATCH; + befs_error(sb, "<--- %s %s not found", __func__, findkey); + befs_debug(sb, "<--- %s ERROR", __func__); + return BEFS_BT_NOT_FOUND; } /** -- cgit v1.2.3 From bb75e66627b28816f472183d5dce0784d5edb87f Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Mon, 8 Aug 2016 15:21:21 +0100 Subject: befs: fix typo in befs_find_key Fixing skeep to skip. Signed-off-by: Luis de Bethencourt Signed-off-by: Salah Triki --- fs/befs/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/befs/btree.c b/fs/befs/btree.c index 5670d845b2ef..0807766d8ba8 100644 --- a/fs/befs/btree.c +++ b/fs/befs/btree.c @@ -344,7 +344,7 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node, findkey_len = strlen(findkey); - /* if node can not contain key, just skeep this node */ + /* if node can not contain key, just skip this node */ last = node->head.all_key_count - 1; thiskey = befs_bt_get_key(sb, node, last, &keylen); -- cgit v1.2.3 From 6ea4558f9b373b588162e5d3523bc65fcf669b06 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Tue, 9 Aug 2016 14:46:04 +0100 Subject: befs: add flags field to validate superblock state For validating superblock state, add flags field to befs_sb_info, read the state from the disk and check if it is equal to BEFS_DIRTY. Signed-off-by: Salah Triki Signed-off-by: Luis de Bethencourt --- fs/befs/befs.h | 3 +++ fs/befs/super.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/befs/befs.h b/fs/befs/befs.h index a8ca7fcf0795..af8ea961e88f 100644 --- a/fs/befs/befs.h +++ b/fs/befs/befs.h @@ -43,6 +43,9 @@ struct befs_sb_info { u32 ag_shift; u32 num_ags; + /* State of the superblock */ + u32 flags; + /* jornal log entry */ befs_block_run log_blocks; befs_off_t log_start; diff --git a/fs/befs/super.c b/fs/befs/super.c index 9d1b56cd6f19..dc13df8de3e8 100644 --- a/fs/befs/super.c +++ b/fs/befs/super.c @@ -45,6 +45,8 @@ befs_load_sb(struct super_block *sb, befs_super_block * disk_sb) befs_sb->ag_shift = fs32_to_cpu(sb, disk_sb->ag_shift); befs_sb->num_ags = fs32_to_cpu(sb, disk_sb->num_ags); + befs_sb->flags = fs32_to_cpu(sb, disk_sb->flags); + befs_sb->log_blocks = fsrun_to_cpu(sb, disk_sb->log_blocks); befs_sb->log_start = fs64_to_cpu(sb, disk_sb->log_start); befs_sb->log_end = fs64_to_cpu(sb, disk_sb->log_end); @@ -101,7 +103,7 @@ befs_check_sb(struct super_block *sb) return BEFS_ERR; } - if (befs_sb->log_start != befs_sb->log_end) { + if (befs_sb->log_start != befs_sb->log_end || befs_sb->flags == BEFS_DIRTY) { befs_error(sb, "Filesystem not clean! There are blocks in the " "journal. You must boot into BeOS and mount this volume " "to make it clean."); -- cgit v1.2.3 From 2ac636b4d04702e26421598949fc30c7a9e38988 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Tue, 9 Aug 2016 14:46:05 +0100 Subject: befs: fix typo in befs_sb_info Fixing jornal to Journal. Signed-off-by: Salah Triki Signed-off-by: Luis de Bethencourt --- fs/befs/befs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/befs/befs.h b/fs/befs/befs.h index af8ea961e88f..c6bad51d8ec7 100644 --- a/fs/befs/befs.h +++ b/fs/befs/befs.h @@ -46,7 +46,7 @@ struct befs_sb_info { /* State of the superblock */ u32 flags; - /* jornal log entry */ + /* Journal log entry */ befs_block_run log_blocks; befs_off_t log_start; befs_off_t log_end; -- cgit v1.2.3 From 78f647c27f17b10bd7e1ce5d66a3755b1848efa5 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Thu, 11 Aug 2016 12:04:52 +0100 Subject: befs: remove unnecessary initialization There is no need to init block, since it will be overwitten later by iaddr2blockno(). Signed-off-by: Salah Triki Signed-off-by: Luis de Bethencourt --- fs/befs/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/befs/io.c b/fs/befs/io.c index 4223b779fcc4..b4a558126ee1 100644 --- a/fs/befs/io.c +++ b/fs/befs/io.c @@ -27,7 +27,7 @@ struct buffer_head * befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr) { struct buffer_head *bh; - befs_blocknr_t block = 0; + befs_blocknr_t block; struct befs_sb_info *befs_sb = BEFS_SB(sb); befs_debug(sb, "---> Enter %s " -- cgit v1.2.3 From d1a8c70676c7e2cd4b80f494aed17b5813f2be44 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Tue, 9 Aug 2016 22:20:23 +0100 Subject: befs: dump inode_size superblock information befs_dump_super_block() wasn't giving the inode_size information when dumping all elements of the superblock. Add this element to have complete information of the superblock. Signed-off-by: Luis de Bethencourt Signed-off-by: Salah Triki --- fs/befs/debug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/befs/debug.c b/fs/befs/debug.c index 4de7cffcd662..85c13392e9e8 100644 --- a/fs/befs/debug.c +++ b/fs/befs/debug.c @@ -169,6 +169,7 @@ befs_dump_super_block(const struct super_block *sb, befs_super_block * sup) befs_debug(sb, " num_blocks %llu", fs64_to_cpu(sb, sup->num_blocks)); befs_debug(sb, " used_blocks %llu", fs64_to_cpu(sb, sup->used_blocks)); + befs_debug(sb, " inode_size %u", fs32_to_cpu(sb, sup->inode_size)); befs_debug(sb, " magic2 %08x", fs32_to_cpu(sb, sup->magic2)); befs_debug(sb, " blocks_per_ag %u", -- cgit v1.2.3 From bbe1bd0b6bba138eaf441c6c964bde9866da8808 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Tue, 9 Aug 2016 22:23:36 +0100 Subject: befs: add check for ag_shift in superblock ag_shift and blocks_per_ag contain the same information in different ways, same as block_shift and block_size do. It is worth checking this two are consistent, but since blocks_per_ag isn't documented as mandatory to use some implementations of befs don't enforce this, so making it non-fatal if they don't match and just having it as a warning. Signed-off-by: Luis de Bethencourt Signed-off-by: Salah Triki --- fs/befs/super.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/befs/super.c b/fs/befs/super.c index dc13df8de3e8..c36745d2b45f 100644 --- a/fs/befs/super.c +++ b/fs/befs/super.c @@ -103,6 +103,13 @@ befs_check_sb(struct super_block *sb) return BEFS_ERR; } + + /* ag_shift also encodes the same information as blocks_per_ag in a + * different way, non-fatal consistency check + */ + if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag) + befs_error(sb, "ag_shift disagrees with blocks_per_ag."); + if (befs_sb->log_start != befs_sb->log_end || befs_sb->flags == BEFS_DIRTY) { befs_error(sb, "Filesystem not clean! There are blocks in the " "journal. You must boot into BeOS and mount this volume " -- cgit v1.2.3 From 11674239f927c900bc50f8f2f5a4ec3e4a3df89b Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Tue, 9 Aug 2016 22:24:09 +0100 Subject: befs: fix comment style The description of befs_load_sb was confusing the kernel-doc system since, because it starts with /**, it thinks it will document the function with kernel-doc formatting. Which it isn't. Fix other comment style issues in the file while we are at it. Signed-off-by: Luis de Bethencourt Signed-off-by: Salah Triki --- fs/befs/super.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/befs/super.c b/fs/befs/super.c index c36745d2b45f..80b93c0a1a7b 100644 --- a/fs/befs/super.c +++ b/fs/befs/super.c @@ -13,13 +13,9 @@ #include "befs.h" #include "super.h" -/** +/* * befs_load_sb -- Read from disk and properly byteswap all the fields * of the befs superblock - * - * - * - * */ int befs_load_sb(struct super_block *sb, befs_super_block * disk_sb) @@ -93,8 +89,8 @@ befs_check_sb(struct super_block *sb) } /* - * block_shift and block_size encode the same information - * in different ways as a consistency check. + * block_shift and block_size encode the same information + * in different ways as a consistency check. */ if ((1 << befs_sb->block_shift) != befs_sb->block_size) { -- cgit v1.2.3 From 103c0fb3400b3efc74c806db2fd18e9eedc510d5 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Tue, 9 Aug 2016 22:51:44 +0100 Subject: befs: fix style issues in super.c Fixing the following checkpatch.pl error: ERROR: "foo * bar" should be "foo *bar" +befs_load_sb(struct super_block *sb, befs_super_block * disk_sb) And the following warnings: WARNING: suspect code indent for conditional statements (8, 12) + if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_LE) + befs_sb->byte_order = BEFS_BYTESEX_LE; WARNING: suspect code indent for conditional statements (8, 12) + else if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_BE) + befs_sb->byte_order = BEFS_BYTESEX_BE; WARNING: break quoted strings at a space character + befs_error(sb, "blocksize(%u) cannot be larger" + "than system pagesize(%lu)", befs_sb->block_size, WARNING: line over 80 characters + if (befs_sb->log_start != befs_sb->log_end || befs_sb->flags == BEFS_DIRTY) { Signed-off-by: Luis de Bethencourt Signed-off-by: Salah Triki --- fs/befs/super.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/befs/super.c b/fs/befs/super.c index 80b93c0a1a7b..7c50025c99d8 100644 --- a/fs/befs/super.c +++ b/fs/befs/super.c @@ -18,15 +18,15 @@ * of the befs superblock */ int -befs_load_sb(struct super_block *sb, befs_super_block * disk_sb) +befs_load_sb(struct super_block *sb, befs_super_block *disk_sb) { struct befs_sb_info *befs_sb = BEFS_SB(sb); /* Check the byte order of the filesystem */ if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_LE) - befs_sb->byte_order = BEFS_BYTESEX_LE; + befs_sb->byte_order = BEFS_BYTESEX_LE; else if (disk_sb->fs_byte_order == BEFS_BYTEORDER_NATIVE_BE) - befs_sb->byte_order = BEFS_BYTESEX_BE; + befs_sb->byte_order = BEFS_BYTESEX_BE; befs_sb->magic1 = fs32_to_cpu(sb, disk_sb->magic1); befs_sb->magic2 = fs32_to_cpu(sb, disk_sb->magic2); @@ -82,7 +82,7 @@ befs_check_sb(struct super_block *sb) } if (befs_sb->block_size > PAGE_SIZE) { - befs_error(sb, "blocksize(%u) cannot be larger" + befs_error(sb, "blocksize(%u) cannot be larger " "than system pagesize(%lu)", befs_sb->block_size, PAGE_SIZE); return BEFS_ERR; @@ -106,10 +106,11 @@ befs_check_sb(struct super_block *sb) if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag) befs_error(sb, "ag_shift disagrees with blocks_per_ag."); - if (befs_sb->log_start != befs_sb->log_end || befs_sb->flags == BEFS_DIRTY) { + if (befs_sb->log_start != befs_sb->log_end || + befs_sb->flags == BEFS_DIRTY) { befs_error(sb, "Filesystem not clean! There are blocks in the " - "journal. You must boot into BeOS and mount this volume " - "to make it clean."); + "journal. You must boot into BeOS and mount this " + "volume to make it clean."); return BEFS_ERR; } -- cgit v1.2.3 From 02d91f97fdd62e1d01191e3bb1c42092bd807951 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 Aug 2016 22:15:16 +0100 Subject: befs: fix typos in btree.c Fixing typos in kernel-doc function descriptions in fs/befs/btree.c. Signed-off-by: Luis de Bethencourt Signed-off-by: Salah Triki --- fs/befs/btree.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/befs/btree.c b/fs/befs/btree.c index 0807766d8ba8..7e135ea73fdd 100644 --- a/fs/befs/btree.c +++ b/fs/befs/btree.c @@ -242,7 +242,7 @@ befs_bt_read_node(struct super_block *sb, const befs_data_stream *ds, * Read the superblock and rootnode of the b+tree. * Drill down through the interior nodes using befs_find_key(). * Once at the correct leaf node, use befs_find_key() again to get the - * actuall value stored with the key. + * actual value stored with the key. */ int befs_btree_find(struct super_block *sb, const befs_data_stream *ds, @@ -400,7 +400,7 @@ befs_find_key(struct super_block *sb, struct befs_btree_node *node, * @keysize: Length of the returned key * @value: Value stored with the returned key * - * Heres how it works: Key_no is the index of the key/value pair to + * Here's how it works: Key_no is the index of the key/value pair to * return in keybuf/value. * Bufsize is the size of keybuf (BEFS_NAME_LEN+1 is a good size). Keysize is * the number of characters in the key (just a convenience). @@ -536,7 +536,6 @@ befs_btree_read(struct super_block *sb, const befs_data_stream *ds, * @node_off: Pointer to offset of current node within datastream. Modified * by the function. * - * * Helper function for btree traverse. Moves the current position to the * start of the first leaf node. * @@ -710,7 +709,7 @@ befs_bt_get_key(struct super_block *sb, struct befs_btree_node *node, * * Returns 0 if @key1 and @key2 are equal. * Returns >0 if @key1 is greater. - * Returns <0 if @key2 is greater.. + * Returns <0 if @key2 is greater. */ static int befs_compare_strings(const void *key1, int keylen1, -- cgit v1.2.3 From d327e612bd1f854f08bc4c419122a41440455cbe Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Sat, 13 Aug 2016 18:11:19 +0100 Subject: befs: fix typos in datastream.c Signed-off-by: Luis de Bethencourt Signed-off-by: Salah Triki --- fs/befs/datastream.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c index 6889644e65f8..b2eb5b5cdff2 100644 --- a/fs/befs/datastream.c +++ b/fs/befs/datastream.c @@ -37,7 +37,7 @@ static int befs_find_brun_dblindirect(struct super_block *sb, /** * befs_read_datastream - get buffer_head containing data, starting from pos. * @sb: Filesystem superblock - * @ds: datastrem to find data with + * @ds: datastream to find data with * @pos: start of data * @off: offset of data in buffer_head->b_data * @@ -115,7 +115,7 @@ befs_fblock2brun(struct super_block *sb, const befs_data_stream *data, /** * befs_read_lsmylink - read long symlink from datastream. * @sb: Filesystem superblock - * @ds: Datastrem to read from + * @ds: Datastream to read from * @buff: Buffer in which to place long symlink data * @len: Length of the long symlink in bytes * @@ -183,7 +183,7 @@ befs_count_blocks(struct super_block *sb, const befs_data_stream *ds) metablocks += ds->indirect.len; /* - Double indir block, plus all the indirect blocks it mapps + Double indir block, plus all the indirect blocks it maps. In the double-indirect range, all block runs of data are BEFS_DBLINDIR_BRUN_LEN blocks long. Therefore, we know how many data block runs are in the double-indirect region, @@ -397,7 +397,7 @@ befs_find_brun_indirect(struct super_block *sb, though the double-indirect run may be several blocks long, we can calculate which of those blocks will contain the index we are after and only read that one. We then follow it to - the indirect block and perform a similar process to find + the indirect block and perform a similar process to find the actual block run that maps the data block we are interested in. -- cgit v1.2.3 From a20af5f9eaac083e2865e94f37e47af74d70f187 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Sat, 13 Aug 2016 18:11:20 +0100 Subject: befs: improve documentation in datastream.c Convert function descriptions to kernel-doc style. Signed-off-by: Luis de Bethencourt Signed-off-by: Salah Triki --- fs/befs/datastream.c | 193 ++++++++++++++++++++++++++------------------------- 1 file changed, 98 insertions(+), 95 deletions(-) diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c index b2eb5b5cdff2..5ce85cfd8ae1 100644 --- a/fs/befs/datastream.c +++ b/fs/befs/datastream.c @@ -75,7 +75,13 @@ befs_read_datastream(struct super_block *sb, const befs_data_stream *ds, return bh; } -/* +/** + * befs_fblock2brun - give back block run for fblock + * @sb: the superblock + * @data: datastream to read from + * @fblock: the blocknumber with the file position to find + * @run: The found run is passed back through this pointer + * * Takes a file position and gives back a brun who's starting block * is block number fblock of the file. * @@ -212,36 +218,35 @@ befs_count_blocks(struct super_block *sb, const befs_data_stream *ds) return blocks; } -/* - Finds the block run that starts at file block number blockno - in the file represented by the datastream data, if that - blockno is in the direct region of the datastream. - - sb: the superblock - data: the datastream - blockno: the blocknumber to find - run: The found run is passed back through this pointer - - Return value is BEFS_OK if the blockrun is found, BEFS_ERR - otherwise. - - Algorithm: - Linear search. Checks each element of array[] to see if it - contains the blockno-th filesystem block. This is necessary - because the block runs map variable amounts of data. Simply - keeps a count of the number of blocks searched so far (sum), - incrementing this by the length of each block run as we come - across it. Adds sum to *count before returning (this is so - you can search multiple arrays that are logicaly one array, - as in the indirect region code). - - When/if blockno is found, if blockno is inside of a block - run as stored on disk, we offset the start and length members - of the block run, so that blockno is the start and len is - still valid (the run ends in the same place). - - 2001-11-15 Will Dyson -*/ +/** + * befs_find_brun_direct - find a direct block run in the datastream + * @sb: the superblock + * @data: the datastream + * @blockno: the blocknumber to find + * @run: The found run is passed back through this pointer + * + * Finds the block run that starts at file block number blockno + * in the file represented by the datastream data, if that + * blockno is in the direct region of the datastream. + * + * Return value is BEFS_OK if the blockrun is found, BEFS_ERR + * otherwise. + * + * Algorithm: + * Linear search. Checks each element of array[] to see if it + * contains the blockno-th filesystem block. This is necessary + * because the block runs map variable amounts of data. Simply + * keeps a count of the number of blocks searched so far (sum), + * incrementing this by the length of each block run as we come + * across it. Adds sum to *count before returning (this is so + * you can search multiple arrays that are logicaly one array, + * as in the indirect region code). + * + * When/if blockno is found, if blockno is inside of a block + * run as stored on disk, we offset the start and length members + * of the block run, so that blockno is the start and len is + * still valid (the run ends in the same place). + */ static int befs_find_brun_direct(struct super_block *sb, const befs_data_stream *data, befs_blocknr_t blockno, befs_block_run * run) @@ -273,29 +278,28 @@ befs_find_brun_direct(struct super_block *sb, const befs_data_stream *data, return BEFS_ERR; } -/* - Finds the block run that starts at file block number blockno - in the file represented by the datastream data, if that - blockno is in the indirect region of the datastream. - - sb: the superblock - data: the datastream - blockno: the blocknumber to find - run: The found run is passed back through this pointer - - Return value is BEFS_OK if the blockrun is found, BEFS_ERR - otherwise. - - Algorithm: - For each block in the indirect run of the datastream, read - it in and search through it for search_blk. - - XXX: - Really should check to make sure blockno is inside indirect - region. - - 2001-11-15 Will Dyson -*/ +/** + * befs_find_brun_indirect - find a block run in the datastream + * @sb: the superblock + * @data: the datastream + * @blockno: the blocknumber to find + * @run: The found run is passed back through this pointer + * + * Finds the block run that starts at file block number blockno + * in the file represented by the datastream data, if that + * blockno is in the indirect region of the datastream. + * + * Return value is BEFS_OK if the blockrun is found, BEFS_ERR + * otherwise. + * + * Algorithm: + * For each block in the indirect run of the datastream, read + * it in and search through it for search_blk. + * + * XXX: + * Really should check to make sure blockno is inside indirect + * region. + */ static int befs_find_brun_indirect(struct super_block *sb, const befs_data_stream *data, @@ -365,47 +369,46 @@ befs_find_brun_indirect(struct super_block *sb, return BEFS_ERR; } -/* - Finds the block run that starts at file block number blockno - in the file represented by the datastream data, if that - blockno is in the double-indirect region of the datastream. - - sb: the superblock - data: the datastream - blockno: the blocknumber to find - run: The found run is passed back through this pointer - - Return value is BEFS_OK if the blockrun is found, BEFS_ERR - otherwise. - - Algorithm: - The block runs in the double-indirect region are different. - They are always allocated 4 fs blocks at a time, so each - block run maps a constant amount of file data. This means - that we can directly calculate how many block runs into the - double-indirect region we need to go to get to the one that - maps a particular filesystem block. - - We do this in two stages. First we calculate which of the - inode addresses in the double-indirect block will point us - to the indirect block that contains the mapping for the data, - then we calculate which of the inode addresses in that - indirect block maps the data block we are after. - - Oh, and once we've done that, we actually read in the blocks - that contain the inode addresses we calculated above. Even - though the double-indirect run may be several blocks long, - we can calculate which of those blocks will contain the index - we are after and only read that one. We then follow it to - the indirect block and perform a similar process to find - the actual block run that maps the data block we are interested - in. - - Then we offset the run as in befs_find_brun_array() and we are - done. - - 2001-11-15 Will Dyson -*/ +/** + * befs_find_brun_dblindirect - find a block run in the datastream + * @sb: the superblock + * @data: the datastream + * @blockno: the blocknumber to find + * @run: The found run is passed back through this pointer + * + * Finds the block run that starts at file block number blockno + * in the file represented by the datastream data, if that + * blockno is in the double-indirect region of the datastream. + * + * Return value is BEFS_OK if the blockrun is found, BEFS_ERR + * otherwise. + * + * Algorithm: + * The block runs in the double-indirect region are different. + * They are always allocated 4 fs blocks at a time, so each + * block run maps a constant amount of file data. This means + * that we can directly calculate how many block runs into the + * double-indirect region we need to go to get to the one that + * maps a particular filesystem block. + * + * We do this in two stages. First we calculate which of the + * inode addresses in the double-indirect block will point us + * to the indirect block that contains the mapping for the data, + * then we calculate which of the inode addresses in that + * indirect block maps the data block we are after. + * + * Oh, and once we've done that, we actually read in the blocks + * that contain the inode addresses we calculated above. Even + * though the double-indirect run may be several blocks long, + * we can calculate which of those blocks will contain the index + * we are after and only read that one. We then follow it to + * the indirect block and perform a similar process to find + * the actual block run that maps the data block we are interested + * in. + * + * Then we offset the run as in befs_find_brun_array() and we are + * done. + */ static int befs_find_brun_dblindirect(struct super_block *sb, const befs_data_stream *data, -- cgit v1.2.3 From a17e7d2010b44103e3b8e00d0c8c510606457bc6 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Sat, 13 Aug 2016 18:11:21 +0100 Subject: befs: befs: fix style issues in datastream.c Fixing the following checkpatch.pl errors: ERROR: "foo * bar" should be "foo *bar" + befs_blocknr_t blockno, befs_block_run * run); WARNING: Missing a blank line after declarations + struct buffer_head *bh; + befs_debug(sb, "---> %s length: %llu", __func__, len); WARNING: Block comments use * on subsequent lines + /* + Double indir block, plus all the indirect blocks it maps. (and other instances of these) Signed-off-by: Luis de Bethencourt Signed-off-by: Salah Triki --- fs/befs/datastream.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c index 5ce85cfd8ae1..b4c7ba013c0d 100644 --- a/fs/befs/datastream.c +++ b/fs/befs/datastream.c @@ -22,17 +22,17 @@ const befs_inode_addr BAD_IADDR = { 0, 0, 0 }; static int befs_find_brun_direct(struct super_block *sb, const befs_data_stream *data, - befs_blocknr_t blockno, befs_block_run * run); + befs_blocknr_t blockno, befs_block_run *run); static int befs_find_brun_indirect(struct super_block *sb, const befs_data_stream *data, befs_blocknr_t blockno, - befs_block_run * run); + befs_block_run *run); static int befs_find_brun_dblindirect(struct super_block *sb, const befs_data_stream *data, befs_blocknr_t blockno, - befs_block_run * run); + befs_block_run *run); /** * befs_read_datastream - get buffer_head containing data, starting from pos. @@ -46,7 +46,7 @@ static int befs_find_brun_dblindirect(struct super_block *sb, */ struct buffer_head * befs_read_datastream(struct super_block *sb, const befs_data_stream *ds, - befs_off_t pos, uint * off) + befs_off_t pos, uint *off) { struct buffer_head *bh; befs_block_run run; @@ -94,7 +94,7 @@ befs_read_datastream(struct super_block *sb, const befs_data_stream *ds, */ int befs_fblock2brun(struct super_block *sb, const befs_data_stream *data, - befs_blocknr_t fblock, befs_block_run * run) + befs_blocknr_t fblock, befs_block_run *run) { int err; befs_off_t pos = fblock << BEFS_SB(sb)->block_shift; @@ -134,6 +134,7 @@ befs_read_lsymlink(struct super_block *sb, const befs_data_stream *ds, befs_off_t bytes_read = 0; /* bytes readed */ u16 plen; struct buffer_head *bh; + befs_debug(sb, "---> %s length: %llu", __func__, len); while (bytes_read < len) { @@ -189,13 +190,13 @@ befs_count_blocks(struct super_block *sb, const befs_data_stream *ds) metablocks += ds->indirect.len; /* - Double indir block, plus all the indirect blocks it maps. - In the double-indirect range, all block runs of data are - BEFS_DBLINDIR_BRUN_LEN blocks long. Therefore, we know - how many data block runs are in the double-indirect region, - and from that we know how many indirect blocks it takes to - map them. We assume that the indirect blocks are also - BEFS_DBLINDIR_BRUN_LEN blocks long. + * Double indir block, plus all the indirect blocks it maps. + * In the double-indirect range, all block runs of data are + * BEFS_DBLINDIR_BRUN_LEN blocks long. Therefore, we know + * how many data block runs are in the double-indirect region, + * and from that we know how many indirect blocks it takes to + * map them. We assume that the indirect blocks are also + * BEFS_DBLINDIR_BRUN_LEN blocks long. */ if (ds->size > ds->max_indirect_range && ds->max_indirect_range != 0) { uint dbl_bytes; @@ -249,7 +250,7 @@ befs_count_blocks(struct super_block *sb, const befs_data_stream *ds) */ static int befs_find_brun_direct(struct super_block *sb, const befs_data_stream *data, - befs_blocknr_t blockno, befs_block_run * run) + befs_blocknr_t blockno, befs_block_run *run) { int i; const befs_block_run *array = data->direct; @@ -261,6 +262,7 @@ befs_find_brun_direct(struct super_block *sb, const befs_data_stream *data, sum += array[i].len, i++) { if (blockno >= sum && blockno < sum + (array[i].len)) { int offset = blockno - sum; + run->allocation_group = array[i].allocation_group; run->start = array[i].start + offset; run->len = array[i].len - offset; @@ -304,7 +306,7 @@ static int befs_find_brun_indirect(struct super_block *sb, const befs_data_stream *data, befs_blocknr_t blockno, - befs_block_run * run) + befs_block_run *run) { int i, j; befs_blocknr_t sum = 0; @@ -413,7 +415,7 @@ static int befs_find_brun_dblindirect(struct super_block *sb, const befs_data_stream *data, befs_blocknr_t blockno, - befs_block_run * run) + befs_block_run *run) { int dblindir_indx; int indir_indx; -- cgit v1.2.3