All of lore.kernel.org
 help / color / mirror / Atom feed
* Decompression success/failure dependent on PAGE_SIZE?
@ 2017-08-29 16:43 Marek Behún
  2017-08-29 17:13 ` Austin S. Hemmelgarn
  2017-08-29 17:44 ` Nikolay Borisov
  0 siblings, 2 replies; 3+ messages in thread
From: Marek Behún @ 2017-08-29 16:43 UTC (permalink / raw)
  To: linux-btrfs

Hello,

so I've been studying the linux btrfs code and have come across this:

in inode.c function uncompress_inline the max_size size variable is set
to min(max_size, PAGE_SIZE) and only max_size of output data are
decompressed.

The code for compression (in lzo.c for example) uses PAGE_SIZEd chunks
to compress an inline extent.

If I understand it correctly, then if the filesystem is created and used
on a computer with PAGE_SIZE for example 16KB, and an extent of size
16KB is compressed to (for example 9KB) and stored as inline extent,
and then the filesystem is mounted on a computer with PAGE_SIZE = 4KB,
reading the extent will result in a failure or incomplete read.

Is this a bug, or is this behaviour a feature?

Thank you.

Marek

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Decompression success/failure dependent on PAGE_SIZE?
  2017-08-29 16:43 Decompression success/failure dependent on PAGE_SIZE? Marek Behún
@ 2017-08-29 17:13 ` Austin S. Hemmelgarn
  2017-08-29 17:44 ` Nikolay Borisov
  1 sibling, 0 replies; 3+ messages in thread
From: Austin S. Hemmelgarn @ 2017-08-29 17:13 UTC (permalink / raw)
  To: Marek Behún, linux-btrfs

On 2017-08-29 12:43, Marek Behún wrote:
> Hello,
> 
> so I've been studying the linux btrfs code and have come across this:
> 
> in inode.c function uncompress_inline the max_size size variable is set
> to min(max_size, PAGE_SIZE) and only max_size of output data are
> decompressed.
> 
> The code for compression (in lzo.c for example) uses PAGE_SIZEd chunks
> to compress an inline extent.
> 
> If I understand it correctly, then if the filesystem is created and used
> on a computer with PAGE_SIZE for example 16KB, and an extent of size
> 16KB is compressed to (for example 9KB) and stored as inline extent,
> and then the filesystem is mounted on a computer with PAGE_SIZE = 4KB,
> reading the extent will result in a failure or incomplete read.
> 
> Is this a bug, or is this behaviour a feature?
It's absolutely not a feature.  I've not actually seen this issue 
mentioned anywhere myself, but I'm willing to bet that the consensus 
among developers will be that its an unintentional limitation of the 
current design.  There are in fact issues when trying to use a 
filesystem with a block size smaller than PAGE_SIZE as well, so the 
general consensus is to not mix filesystems from different architectures 
unless you know the page size matches.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Decompression success/failure dependent on PAGE_SIZE?
  2017-08-29 16:43 Decompression success/failure dependent on PAGE_SIZE? Marek Behún
  2017-08-29 17:13 ` Austin S. Hemmelgarn
@ 2017-08-29 17:44 ` Nikolay Borisov
  1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2017-08-29 17:44 UTC (permalink / raw)
  To: Marek Behún, linux-btrfs



On 29.08.2017 19:43, Marek Behún wrote:
> Hello,
> 
> so I've been studying the linux btrfs code and have come across this:
> 
> in inode.c function uncompress_inline the max_size size variable is set
> to min(max_size, PAGE_SIZE) and only max_size of output data are
> decompressed.
> 
> The code for compression (in lzo.c for example) uses PAGE_SIZEd chunks
> to compress an inline extent.
> 
> If I understand it correctly, then if the filesystem is created and used
> on a computer with PAGE_SIZE for example 16KB, and an extent of size
> 16KB is compressed to (for example 9KB) and stored as inline extent,
> and then the filesystem is mounted on a computer with PAGE_SIZE = 4KB,
> reading the extent will result in a failure or incomplete read.
> 
> Is this a bug, or is this behaviour a feature?

Please have a look in btrfs_check_super_valid(), which is being called
from open_ctree, which in turn is called when a filesystem is mounted.

Currently btrfs supports a single blocksize value - PAGE_SIZE, also it's
forbidden to mount a filesystem on systems with different page_sizes.
When the sub-page blocksizes patch is merged this might be have to be
taken into consideration but certainly not at present times.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-29 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-29 16:43 Decompression success/failure dependent on PAGE_SIZE? Marek Behún
2017-08-29 17:13 ` Austin S. Hemmelgarn
2017-08-29 17:44 ` Nikolay Borisov

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.