linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.de>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 5/7] btrfs: check/lowmem: Check and repair free space cache inode mode
Date: Fri, 29 Mar 2019 19:02:03 +0800	[thread overview]
Message-ID: <a608f9c1-e3e9-875a-e472-726e2c696eac@suse.de> (raw)
In-Reply-To: <6e9857a2-163e-27f4-8128-7af73e5d18b1@suse.com>

[snip]
>> +/*
>> + * For free space inodes, we can't call check_inode_item() as free space
>> + * cache inode doesn't have INODE_REF.
>> + * We just check its inode mode.
>> + */
>> +int check_repair_free_space_inode(struct btrfs_fs_info *fs_info,
>> +				  struct btrfs_path *path)
>> +{
>> +	struct btrfs_inode_item *iitem;
>> +	struct btrfs_key key;
>> +	u32 mode;
>> +	int ret = 0;
>> +
>> +	btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
>> +	ASSERT(key.type == BTRFS_INODE_ITEM_KEY && is_fstree(key.objectid));
>> +	iitem = btrfs_item_ptr(path->nodes[0], path->slots[0],
>> +			       struct btrfs_inode_item);
>> +	mode = btrfs_inode_mode(path->nodes[0], iitem);
>> +	if (mode != FREE_SPACE_CACHE_INODE_MODE) {
>> +		error(
>> +	"free space cache inode %llu has invalid mode: has 0%o expect 0%o",
>> +			key.objectid, mode, FREE_SPACE_CACHE_INODE_MODE);
>> +		ret = -EUCLEAN;
>> +		if (repair) {
>> +			ret = repair_imode_lowmem(fs_info->tree_root,
>> +						  path);
>> +			if (ret < 0)
>> +				return ret;
>> +			return ret;
>> +		}
>> +	}
>> +	return ret;
>> +}
> 
> You put this function in mode-lowmem, yet it's also used in the next
> patch to implement check/repair for original mode. Since you are oging
> to re-use function across the 2 modes it makes no sense to separate them
> in their names. Perhaps put them in mode-common.c
> 

The limitation is due to repair_imode_lowmem().

Thanks,
Qu

>> +
>>  /*
>>   * Check all fs/file tree in low_memory mode.
>>   *
>> @@ -5130,6 +5164,17 @@ int check_fs_roots_lowmem(struct btrfs_fs_info *fs_info)
>>  		btrfs_item_key_to_cpu(node, &key, slot);
>>  		if (key.objectid > BTRFS_LAST_FREE_OBJECTID)
>>  			goto out;
>> +		if (key.type == BTRFS_INODE_ITEM_KEY &&
>> +		    is_fstree(key.objectid)) {
>> +			ret = check_repair_free_space_inode(fs_info, &path);
>> +			/* Check if we still have a valid path to continue */
>> +			if (ret < 0 && path.nodes[0]) {
>> +				err |= ret;
>> +				goto next;
>> +			}
>> +			if (ret < 0 && !path.nodes[0])
>> +				goto out;
>> +		}
>>  		if (key.type == BTRFS_ROOT_ITEM_KEY &&
>>  		    fs_root_objectid(key.objectid)) {
>>  			if (key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
>> diff --git a/check/mode-lowmem.h b/check/mode-lowmem.h
>> index e0ab30b770d5..d2983fd12eb4 100644
>> --- a/check/mode-lowmem.h
>> +++ b/check/mode-lowmem.h
>> @@ -67,5 +67,7 @@
>>  
>>  int check_fs_roots_lowmem(struct btrfs_fs_info *fs_info);
>>  int check_chunks_and_extents_lowmem(struct btrfs_fs_info *fs_info);
>> +int check_repair_free_space_inode(struct btrfs_fs_info *fs_info,
>> +				  struct btrfs_path *path);
>>  
>>  #endif
>>

  reply	other threads:[~2019-03-29 11:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-25  8:22 [PATCH 0/7] btrfs: check: Check and repair invalid free space cahce inode mode Qu Wenruo
2019-03-25  8:22 ` [PATCH 1/7] btrfs-progs: check/lowmem: Add inode mode check Qu Wenruo
2019-03-25 15:40   ` Nikolay Borisov
2019-03-25  8:22 ` [PATCH 2/7] btrfs-progs: check/original: " Qu Wenruo
2019-03-25 15:43   ` Nikolay Borisov
2019-03-25 22:59     ` Qu Wenruo
2019-03-25  8:22 ` [PATCH 3/7] btrfs-progs: check/lowmem: Repair invalid inode mode in root tree Qu Wenruo
2019-03-29  9:36   ` Nikolay Borisov
2019-03-29 11:00     ` Qu Wenruo
2019-03-25  8:22 ` [PATCH 4/7] btrfs-progs: check/original: " Qu Wenruo
2019-03-25  8:22 ` [PATCH 5/7] btrfs: check/lowmem: Check and repair free space cache inode mode Qu Wenruo
2019-03-25 14:36   ` Su Yue
2019-03-25 14:39     ` Qu Wenruo
2019-03-29  9:40   ` Nikolay Borisov
2019-03-29 11:02     ` Qu Wenruo [this message]
2019-03-29 11:47       ` Nikolay Borisov
2019-03-25  8:22 ` [PATCH 6/7] btrfs: check/original: Check and repair free space cache inode item Qu Wenruo
2019-03-25  8:22 ` [PATCH 7/7] btrfs: tests/fsck: Add test image for free space cache mode repair Qu Wenruo
2019-03-29 12:05   ` Nikolay Borisov
2019-03-29 12:08     ` Qu Wenruo
2019-04-01  5:52     ` 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=a608f9c1-e3e9-875a-e472-726e2c696eac@suse.de \
    --to=wqu@suse.de \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).