All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fb.com>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>, <linux-btrfs@vger.kernel.org>
Cc: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Subject: Re: [PATCH RFC v1.1 02/16] btrfs-progs: fsck: Introduce function to check data backref in extent tree
Date: Thu, 28 Apr 2016 10:08:41 -0400	[thread overview]
Message-ID: <26f85b88-d499-d236-43bf-4505d526b0a0@fb.com> (raw)
In-Reply-To: <1461807819-29771-1-git-send-email-quwenruo@cn.fujitsu.com>

On 04/27/2016 09:43 PM, Qu Wenruo wrote:
> From: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
>
> Introduce a new function check_data_extent_item() to check if the
> corresponding data backref exists in extent tree.
>
> Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
> ---
> Changelog:
> v1.1:
>    Fix a typo which passed wrong parameter for hash_extent_data_ref()
>    Fix a generation mismatch condition, as for inband dedupe or reflink
>    case, file extent generation can be larger than extent item generation.
> ---
>  cmds-check.c  | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  ctree.h       |   2 +
>  extent-tree.c |   2 +-
>  3 files changed, 155 insertions(+), 1 deletion(-)
>
> diff --git a/cmds-check.c b/cmds-check.c
> index 27fc26f..a6ea0fd 100644
> --- a/cmds-check.c
> +++ b/cmds-check.c
> @@ -322,6 +322,7 @@ struct root_item_info {
>   */
>  #define MISSING_BACKREF	(1 << 0) /* Completely no backref in extent tree */
>  #define BAD_BACKREF	(1 << 1) /* Backref mismatch */
> +#define UNALIGNED_BYTES	(1 << 2) /* Some bytes are not aligned */
>
>  static void *print_status_check(void *p)
>  {
> @@ -8565,6 +8566,157 @@ out:
>  	return -err;
>  }
>
> +/*
> + * Check EXTENT_DATA item, mainly for its dbackref in extent tree
> + *
> + * Return <0 any error found and output error message
> + * Return 0 for no error found
> + */
> +static int check_extent_data_item(struct btrfs_root *root,
> +				  struct extent_buffer *eb, int slot)
> +{
> +	struct btrfs_file_extent_item *fi;
> +	struct btrfs_path path;
> +	struct btrfs_root *extent_root = root->fs_info->extent_root;
> +	struct btrfs_key key;
> +	struct btrfs_key orig_key;
> +	struct btrfs_key found_key;
> +	struct extent_buffer *leaf;
> +	struct btrfs_extent_item *ei;
> +	struct btrfs_extent_inline_ref *iref;
> +	struct btrfs_extent_data_ref *dref;
> +	u64 owner;
> +	u64 file_extent_gen;
> +	u64 disk_bytenr;
> +	u64 disk_num_bytes;
> +	u64 extent_num_bytes;
> +	u64 extent_flags;
> +	u64 extent_gen;
> +	u32 item_size;
> +	unsigned long end;
> +	unsigned long ptr;
> +	int type;
> +	u64 ref_root;
> +	int found_dbackref = 0;
> +	int err = 0;
> +	int ret;
> +
> +	btrfs_item_key_to_cpu(eb, &orig_key, slot);
> +	fi = btrfs_item_ptr(eb, slot, struct btrfs_file_extent_item);
> +	file_extent_gen = btrfs_file_extent_generation(eb, fi);
> +
> +	/* Nothing to check for hole and inline data extents */
> +	if (btrfs_file_extent_type(eb, fi) == BTRFS_FILE_EXTENT_INLINE ||
> +	    btrfs_file_extent_disk_bytenr(eb, fi) == 0)
> +		return 0;
> +
> +	disk_bytenr = btrfs_file_extent_disk_bytenr(eb, fi);
> +	disk_num_bytes = btrfs_file_extent_disk_num_bytes(eb, fi);
> +	extent_num_bytes = btrfs_file_extent_num_bytes(eb, fi);
> +	/* Check unaligned disk_num_bytes and num_bytes */
> +	if (!IS_ALIGNED(disk_num_bytes, root->sectorsize)) {
> +		error("File extent [%llu, %llu] has unaligned disk num bytes: %llu, should be aligned to %u",
> +		      key.objectid, key.offset, disk_num_bytes,
> +		      root->sectorsize);
> +		err |= UNALIGNED_BYTES;
> +	} else
> +		data_bytes_allocated += disk_num_bytes;

Please use the standard kernel format of having

} else {
	//blah
}

for single lined else's combined with multi-line if's.  Once that is 
fixed you can add

Reviewed-by: Josef Bacik <jbacik@fb.com>

Thanks,

Josef

  reply	other threads:[~2016-04-28 14:08 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26  3:48 [PATCH RFC 00/16] Introduce low memory usage btrfsck mode Qu Wenruo
2016-04-26  3:48 ` [PATCH RFC 01/16] btrfs-progs: fsck: Introduce function to check tree block backref in extent tree Qu Wenruo
2016-04-28 14:03   ` Josef Bacik
2016-04-26  3:48 ` [PATCH RFC 02/16] btrfs-progs: fsck: Introduce function to check data " Qu Wenruo
2016-04-28  1:43   ` [PATCH RFC v1.1 " Qu Wenruo
2016-04-28 14:08     ` Josef Bacik [this message]
2016-04-26  3:48 ` [PATCH RFC 03/16] btrfs-progs: fsck: Introduce function to query tree block level Qu Wenruo
2016-04-28 14:13   ` Josef Bacik
2016-04-29  3:35     ` Qu Wenruo
2016-04-29 13:51       ` Josef Bacik
2016-04-26  3:48 ` [PATCH RFC 04/16] btrfs-progs: fsck: Introduce function to check referencer of a backref Qu Wenruo
2016-04-28 14:17   ` Josef Bacik
2016-04-29  5:31     ` Qu Wenruo
2016-04-29 13:52       ` Josef Bacik
2016-05-03  0:56         ` Qu Wenruo
2016-04-28 14:31   ` Josef Bacik
2016-04-26  3:48 ` [PATCH RFC 05/16] btrfs-progs: fsck: Introduce function to check shared block ref Qu Wenruo
2016-04-28 14:19   ` Josef Bacik
2016-04-26  3:48 ` [PATCH RFC 06/16] btrfs-progs: fsck: Introduce function to check referencer for data backref Qu Wenruo
2016-04-28 14:22   ` Josef Bacik
2016-04-26  3:48 ` [PATCH RFC 07/16] btrfs-progs: fsck: Introduce function to check shared " Qu Wenruo
2016-04-28 14:23   ` Josef Bacik
2016-04-26  3:48 ` [PATCH RFC 08/16] btrfs-progs: fsck: Introduce function to check an extent Qu Wenruo
2016-04-28 14:26   ` Josef Bacik
2016-04-26  3:48 ` [PATCH RFC 09/16] btrfs-progs: fsck: Introduce function to check dev extent item Qu Wenruo
2016-04-28 14:27   ` Josef Bacik
2016-04-26  3:48 ` [PATCH RFC 10/16] btrfs-progs: fsck: Introduce function to check dev used space Qu Wenruo
2016-04-28 14:29   ` Josef Bacik
2016-04-26  3:48 ` [PATCH RFC 11/16] btrfs-progs: fsck: Introduce function to check block group item Qu Wenruo
2016-04-26  3:48 ` [PATCH RFC 12/16] btrfs-progs: fsck: Introduce function to check chunk item Qu Wenruo
2016-04-26  3:49 ` [PATCH RFC 13/16] btrfs-progs: fsck: Introduce hub function for later fsck Qu Wenruo
2016-04-26  3:49 ` [PATCH RFC 14/16] btrfs-progs: fsck: Introduce function to speed up fs tree check Qu Wenruo
2016-04-26  3:49 ` [PATCH RFC 15/16] btrfs-progs: fsck: Introduce traversal function for fsck Qu Wenruo
2016-04-26  3:49 ` [PATCH RFC 16/16] btrfs-progs: fsck: Introduce low memory mode Qu Wenruo
2016-04-26 13:38 ` [PATCH RFC 00/16] Introduce low memory usage btrfsck mode Austin S. Hemmelgarn
2016-04-28 14:32 ` Josef Bacik
2016-04-29  0:25   ` Qu Wenruo

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=26f85b88-d499-d236-43bf-4505d526b0a0@fb.com \
    --to=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lufq.fnst@cn.fujitsu.com \
    --cc=quwenruo@cn.fujitsu.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.