Re: [PATCH v2 5/7] btrfs-progs: check/lowmem mode: Check inline extent size

2018-03-13 Thread Qu Wenruo


On 2018年03月13日 16:39, Nikolay Borisov wrote:
> 
> 
> On 13.03.2018 03:56, Qu Wenruo wrote:
>> Signed-off-by: Qu Wenruo 
>> ---
>>  check/mode-lowmem.c | 28 
>>  1 file changed, 28 insertions(+)
>>
>> diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
>> index 62bcf3d2e126..0d19b373c7af 100644
>> --- a/check/mode-lowmem.c
>> +++ b/check/mode-lowmem.c
>> @@ -1417,6 +1417,8 @@ static int check_file_extent(struct btrfs_root *root, 
>> struct btrfs_key *fkey,
>>  u64 csum_found; /* In byte size, sectorsize aligned */
>>  u64 search_start;   /* Logical range start we search for csum */
>>  u64 search_len; /* Logical range len we search for csum */
>> +u32 max_inline_extent_size = min_t(u32, root->fs_info->sectorsize - 1,
>> +BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info));
>>  unsigned int extent_type;
>>  unsigned int is_hole;
>>  int compressed = 0;
>> @@ -1440,6 +1442,32 @@ static int check_file_extent(struct btrfs_root *root, 
>> struct btrfs_key *fkey,
>>  root->objectid, fkey->objectid, fkey->offset);
>>  err |= FILE_EXTENT_ERROR;
>>  }
>> +if (compressed) {
>> +if (extent_num_bytes > root->fs_info->sectorsize) {
>> +error(
>> +"root %llu EXTENT_DATA[%llu %llu] too large inline extent ram size, have 
>> %llu, max: %u",
>> +root->objectid, fkey->objectid,
>> +fkey->offset, extent_num_bytes,
>> +root->fs_info->sectorsize);
> nit: shouldn't this really be sectorsize - 1 ?

Yep.

I'd update the github branch.

Thanks,
Qu

>> +err |= FILE_EXTENT_ERROR;
>> +}
>> +if (item_inline_len > max_inline_extent_size) {
>> +error(
>> +"root %llu EXTENT_DATA[%llu %llu] too large inline extent on-disk size, 
>> have %u, max: %u",
>> +root->objectid, fkey->objectid,
>> +fkey->offset, item_inline_len,
>> +max_inline_extent_size);
>> +err |= FILE_EXTENT_ERROR;
>> +}
>> +} else {
>> +if (extent_num_bytes > max_inline_extent_size) {
>> +error(
>> + "root %llu EXTENT_DATA[%llu %llu] too large inline extent size, have %llu, 
>> max: %u",
>> +root->objectid, fkey->objectid, fkey->offset,
>> +extent_num_bytes, max_inline_extent_size);
>> +err |= FILE_EXTENT_ERROR;
>> +}
>> +}
>>  if (!compressed && extent_num_bytes != item_inline_len) {
>>  error(
>>  "root %llu EXTENT_DATA[%llu %llu] wrong inline size, have: 
>> %llu, expected: %u",
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v2 5/7] btrfs-progs: check/lowmem mode: Check inline extent size

2018-03-13 Thread Nikolay Borisov


On 13.03.2018 03:56, Qu Wenruo wrote:
> Signed-off-by: Qu Wenruo 
> ---
>  check/mode-lowmem.c | 28 
>  1 file changed, 28 insertions(+)
> 
> diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
> index 62bcf3d2e126..0d19b373c7af 100644
> --- a/check/mode-lowmem.c
> +++ b/check/mode-lowmem.c
> @@ -1417,6 +1417,8 @@ static int check_file_extent(struct btrfs_root *root, 
> struct btrfs_key *fkey,
>   u64 csum_found; /* In byte size, sectorsize aligned */
>   u64 search_start;   /* Logical range start we search for csum */
>   u64 search_len; /* Logical range len we search for csum */
> + u32 max_inline_extent_size = min_t(u32, root->fs_info->sectorsize - 1,
> + BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info));
>   unsigned int extent_type;
>   unsigned int is_hole;
>   int compressed = 0;
> @@ -1440,6 +1442,32 @@ static int check_file_extent(struct btrfs_root *root, 
> struct btrfs_key *fkey,
>   root->objectid, fkey->objectid, fkey->offset);
>   err |= FILE_EXTENT_ERROR;
>   }
> + if (compressed) {
> + if (extent_num_bytes > root->fs_info->sectorsize) {
> + error(
> +"root %llu EXTENT_DATA[%llu %llu] too large inline extent ram size, have 
> %llu, max: %u",
> + root->objectid, fkey->objectid,
> + fkey->offset, extent_num_bytes,
> + root->fs_info->sectorsize);
nit: shouldn't this really be sectorsize - 1 ?
> + err |= FILE_EXTENT_ERROR;
> + }
> + if (item_inline_len > max_inline_extent_size) {
> + error(
> +"root %llu EXTENT_DATA[%llu %llu] too large inline extent on-disk size, have 
> %u, max: %u",
> + root->objectid, fkey->objectid,
> + fkey->offset, item_inline_len,
> + max_inline_extent_size);
> + err |= FILE_EXTENT_ERROR;
> + }
> + } else {
> + if (extent_num_bytes > max_inline_extent_size) {
> + error(
> + "root %llu EXTENT_DATA[%llu %llu] too large inline extent size, have %llu, 
> max: %u",
> + root->objectid, fkey->objectid, fkey->offset,
> + extent_num_bytes, max_inline_extent_size);
> + err |= FILE_EXTENT_ERROR;
> + }
> + }
>   if (!compressed && extent_num_bytes != item_inline_len) {
>   error(
>   "root %llu EXTENT_DATA[%llu %llu] wrong inline size, have: 
> %llu, expected: %u",
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 5/7] btrfs-progs: check/lowmem mode: Check inline extent size

2018-03-12 Thread Qu Wenruo
Signed-off-by: Qu Wenruo 
---
 check/mode-lowmem.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 62bcf3d2e126..0d19b373c7af 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -1417,6 +1417,8 @@ static int check_file_extent(struct btrfs_root *root, 
struct btrfs_key *fkey,
u64 csum_found; /* In byte size, sectorsize aligned */
u64 search_start;   /* Logical range start we search for csum */
u64 search_len; /* Logical range len we search for csum */
+   u32 max_inline_extent_size = min_t(u32, root->fs_info->sectorsize - 1,
+   BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info));
unsigned int extent_type;
unsigned int is_hole;
int compressed = 0;
@@ -1440,6 +1442,32 @@ static int check_file_extent(struct btrfs_root *root, 
struct btrfs_key *fkey,
root->objectid, fkey->objectid, fkey->offset);
err |= FILE_EXTENT_ERROR;
}
+   if (compressed) {
+   if (extent_num_bytes > root->fs_info->sectorsize) {
+   error(
+"root %llu EXTENT_DATA[%llu %llu] too large inline extent ram size, have %llu, 
max: %u",
+   root->objectid, fkey->objectid,
+   fkey->offset, extent_num_bytes,
+   root->fs_info->sectorsize);
+   err |= FILE_EXTENT_ERROR;
+   }
+   if (item_inline_len > max_inline_extent_size) {
+   error(
+"root %llu EXTENT_DATA[%llu %llu] too large inline extent on-disk size, have 
%u, max: %u",
+   root->objectid, fkey->objectid,
+   fkey->offset, item_inline_len,
+   max_inline_extent_size);
+   err |= FILE_EXTENT_ERROR;
+   }
+   } else {
+   if (extent_num_bytes > max_inline_extent_size) {
+   error(
+ "root %llu EXTENT_DATA[%llu %llu] too large inline extent size, have %llu, 
max: %u",
+   root->objectid, fkey->objectid, fkey->offset,
+   extent_num_bytes, max_inline_extent_size);
+   err |= FILE_EXTENT_ERROR;
+   }
+   }
if (!compressed && extent_num_bytes != item_inline_len) {
error(
"root %llu EXTENT_DATA[%llu %llu] wrong inline size, have: 
%llu, expected: %u",
-- 
2.16.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html