Message ID | 8a27a999b81dc317ff9420f87288cf9fdd6da4b7.1710409033.git.wqu@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: scrub: refine the error messages | expand |
On Thu, Mar 14, 2024 at 9:51 AM Qu Wenruo <wqu@suse.com> wrote: > > The following two output are not really needed: > > - nlinks > Normally file inodes should have nlinks as 1, for those inodes have > multiple hard links, the inode/root number is still enough to pin it > down to certain inode. > > - size > The size is always fixed to sector size. > > By removing the nlinks output, we can reduce one inode item lookup. > > Signed-off-by: Qu Wenruo <wqu@suse.com> Seems reasonable, thanks. Reviewed-by: Filipe Manana <fdmanana@suse.com> > --- > fs/btrfs/scrub.c | 27 +-------------------------- > 1 file changed, 1 insertion(+), 26 deletions(-) > > diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c > index 277583464371..18b2ee3b1616 100644 > --- a/fs/btrfs/scrub.c > +++ b/fs/btrfs/scrub.c > @@ -388,17 +388,13 @@ static noinline_for_stack struct scrub_ctx *scrub_setup_ctx( > static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes, > u64 root, void *warn_ctx) > { > - u32 nlink; > int ret; > int i; > unsigned nofs_flag; > - struct extent_buffer *eb; > - struct btrfs_inode_item *inode_item; > struct scrub_warning *swarn = warn_ctx; > struct btrfs_fs_info *fs_info = swarn->dev->fs_info; > struct inode_fs_paths *ipath = NULL; > struct btrfs_root *local_root; > - struct btrfs_key key; > > local_root = btrfs_get_fs_root(fs_info, root, true); > if (IS_ERR(local_root)) { > @@ -406,26 +402,6 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes, > goto err; > } > > - /* > - * this makes the path point to (inum INODE_ITEM ioff) > - */ > - key.objectid = inum; > - key.type = BTRFS_INODE_ITEM_KEY; > - key.offset = 0; > - > - ret = btrfs_search_slot(NULL, local_root, &key, swarn->path, 0, 0); > - if (ret) { > - btrfs_put_root(local_root); > - btrfs_release_path(swarn->path); > - goto err; > - } > - > - eb = swarn->path->nodes[0]; > - inode_item = btrfs_item_ptr(eb, swarn->path->slots[0], > - struct btrfs_inode_item); > - nlink = btrfs_inode_nlink(eb, inode_item); > - btrfs_release_path(swarn->path); > - > /* > * init_path might indirectly call vmalloc, or use GFP_KERNEL. Scrub > * uses GFP_NOFS in this context, so we keep it consistent but it does > @@ -451,12 +427,11 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes, > */ > for (i = 0; i < ipath->fspath->elem_cnt; ++i) > btrfs_warn_in_rcu(fs_info, > -"%s at logical %llu on dev %s, physical %llu, root %llu, inode %llu, offset %llu, length %u, links %u (path: %s)", > +"%s at logical %llu on dev %s, physical %llu, root %llu, inode %llu, offset %llu, path: %s", > swarn->errstr, swarn->logical, > btrfs_dev_name(swarn->dev), > swarn->physical, > root, inum, offset, > - fs_info->sectorsize, nlink, > (char *)(unsigned long)ipath->fspath->val[i]); > > btrfs_put_root(local_root); > -- > 2.44.0 > >
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 277583464371..18b2ee3b1616 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -388,17 +388,13 @@ static noinline_for_stack struct scrub_ctx *scrub_setup_ctx( static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes, u64 root, void *warn_ctx) { - u32 nlink; int ret; int i; unsigned nofs_flag; - struct extent_buffer *eb; - struct btrfs_inode_item *inode_item; struct scrub_warning *swarn = warn_ctx; struct btrfs_fs_info *fs_info = swarn->dev->fs_info; struct inode_fs_paths *ipath = NULL; struct btrfs_root *local_root; - struct btrfs_key key; local_root = btrfs_get_fs_root(fs_info, root, true); if (IS_ERR(local_root)) { @@ -406,26 +402,6 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes, goto err; } - /* - * this makes the path point to (inum INODE_ITEM ioff) - */ - key.objectid = inum; - key.type = BTRFS_INODE_ITEM_KEY; - key.offset = 0; - - ret = btrfs_search_slot(NULL, local_root, &key, swarn->path, 0, 0); - if (ret) { - btrfs_put_root(local_root); - btrfs_release_path(swarn->path); - goto err; - } - - eb = swarn->path->nodes[0]; - inode_item = btrfs_item_ptr(eb, swarn->path->slots[0], - struct btrfs_inode_item); - nlink = btrfs_inode_nlink(eb, inode_item); - btrfs_release_path(swarn->path); - /* * init_path might indirectly call vmalloc, or use GFP_KERNEL. Scrub * uses GFP_NOFS in this context, so we keep it consistent but it does @@ -451,12 +427,11 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes, */ for (i = 0; i < ipath->fspath->elem_cnt; ++i) btrfs_warn_in_rcu(fs_info, -"%s at logical %llu on dev %s, physical %llu, root %llu, inode %llu, offset %llu, length %u, links %u (path: %s)", +"%s at logical %llu on dev %s, physical %llu, root %llu, inode %llu, offset %llu, path: %s", swarn->errstr, swarn->logical, btrfs_dev_name(swarn->dev), swarn->physical, root, inum, offset, - fs_info->sectorsize, nlink, (char *)(unsigned long)ipath->fspath->val[i]); btrfs_put_root(local_root);
The following two output are not really needed: - nlinks Normally file inodes should have nlinks as 1, for those inodes have multiple hard links, the inode/root number is still enough to pin it down to certain inode. - size The size is always fixed to sector size. By removing the nlinks output, we can reduce one inode item lookup. Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/btrfs/scrub.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-)