All of lore.kernel.org
 help / color / mirror / Atom feed
* why fscrypt_mergeable_bio use logical block number?
@ 2022-04-15  8:18 常凤楠
  2022-04-15 18:49 ` Eric Biggers
  0 siblings, 1 reply; 4+ messages in thread
From: 常凤楠 @ 2022-04-15  8:18 UTC (permalink / raw)
  To: tytso, jaegeuk, ebiggers, satyat; +Cc: linux-fscrypt

Hi:
	When I dig into a problem, I found: bio merge may reduce a lot when enable inlinecrypt, the root cause is fscrypt_mergeable_bio use logical block number rather than physical block number. I had read the UFSHCI, but not see any description about why data unit number shoud use logical block number. I want to know why, Is the anyone can explain this?

Thanks.
Fengnan Chang.

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

* Re: why fscrypt_mergeable_bio use logical block number?
  2022-04-15  8:18 why fscrypt_mergeable_bio use logical block number? 常凤楠
@ 2022-04-15 18:49 ` Eric Biggers
  2022-04-17  2:34   ` 常凤楠
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Biggers @ 2022-04-15 18:49 UTC (permalink / raw)
  To: 常凤楠; +Cc: tytso, jaegeuk, linux-fscrypt

On Fri, Apr 15, 2022 at 08:18:11AM +0000, 常凤楠 wrote:
> Hi:
> 	When I dig into a problem, I found: bio merge may reduce a lot when
> 	enable inlinecrypt, the root cause is fscrypt_mergeable_bio use logical
> 	block number rather than physical block number. I had read the UFSHCI,
> 	but not see any description about why data unit number shoud use logical
> 	block number. I want to know why, Is the anyone can explain this?
> 
> Thanks.
> Fengnan Chang.

The main reason that fscrypt generates IVs using the file logical block number
instead of the sector number is because f2fs needs to move data blocks around
without the key.  That would be impossible with sector number based encryption.

There are other reasons too.  Always using the file logical block number keeps
the various fscrypt options consistent, it works well with per-file keys, it
doesn't break filesystem resizing, and it avoids having the interpretation of
the filesystem depend on its on-disk location which would be a layering
violation.  But the need to support f2fs is the main one.

Note that by default, fscrypt uses a different key for every file, and in that
case the only way that using the file logical block number instead of the sector
number would prevent merging is if data was being read/written from a file that
is physically but not logically contiguous.  That's not a very common case.

- Eric

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

* RE: why fscrypt_mergeable_bio use logical block number?
  2022-04-15 18:49 ` Eric Biggers
@ 2022-04-17  2:34   ` 常凤楠
  2022-04-18  7:25     ` Eric Biggers
  0 siblings, 1 reply; 4+ messages in thread
From: 常凤楠 @ 2022-04-17  2:34 UTC (permalink / raw)
  To: Eric Biggers; +Cc: tytso, jaegeuk, linux-fscrypt



> -----Original Message-----
> From: Eric Biggers <ebiggers@kernel.org>
> Sent: Saturday, April 16, 2022 2:50 AM
> To: 常凤楠 <changfengnan@vivo.com>
> Cc: tytso@mit.edu; jaegeuk@kernel.org; linux-fscrypt@vger.kernel.org
> Subject: Re: why fscrypt_mergeable_bio use logical block number?
> 
> On Fri, Apr 15, 2022 at 08:18:11AM +0000, 常凤楠 wrote:
> > Hi:
> > 	When I dig into a problem, I found: bio merge may reduce a lot when
> > 	enable inlinecrypt, the root cause is fscrypt_mergeable_bio use logical
> > 	block number rather than physical block number. I had read the UFSHCI,
> > 	but not see any description about why data unit number shoud use
> logical
> > 	block number. I want to know why, Is the anyone can explain this?
> >
> > Thanks.
> > Fengnan Chang.
> 
> The main reason that fscrypt generates IVs using the file logical block number
> instead of the sector number is because f2fs needs to move data blocks
> around without the key.  That would be impossible with sector number
> based encryption.
So if use sector number to generate IVs, after f2fs move data blocks in gc, we can
not decrypt correctly, am I right ?
> 
> There are other reasons too.  Always using the file logical block number
> keeps the various fscrypt options consistent, it works well with per-file keys, it
> doesn't break filesystem resizing, and it avoids having the interpretation of
> the filesystem depend on its on-disk location which would be a layering
> violation.  But the need to support f2fs is the main one.
> 
> Note that by default, fscrypt uses a different key for every file, and in that case
> the only way that using the file logical block number instead of the sector
> number would prevent merging is if data was being read/written from a file
> that is physically but not logically contiguous.  That's not a very common
> case.
This is exactly the problem I have faced. We read/write a file in physically contiguous but not logically.
So I'm wander if we can keep physically contiguous always, can we skip check wheatear logical block 
number is contiguous when bio merge?
> 
> - Eric

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

* Re: why fscrypt_mergeable_bio use logical block number?
  2022-04-17  2:34   ` 常凤楠
@ 2022-04-18  7:25     ` Eric Biggers
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2022-04-18  7:25 UTC (permalink / raw)
  To: 常凤楠; +Cc: tytso, jaegeuk, linux-fscrypt

On Sun, Apr 17, 2022 at 02:34:17AM +0000, 常凤楠 wrote:
> 
> 
> > -----Original Message-----
> > From: Eric Biggers <ebiggers@kernel.org>
> > Sent: Saturday, April 16, 2022 2:50 AM
> > To: 常凤楠 <changfengnan@vivo.com>
> > Cc: tytso@mit.edu; jaegeuk@kernel.org; linux-fscrypt@vger.kernel.org
> > Subject: Re: why fscrypt_mergeable_bio use logical block number?
> > 
> > On Fri, Apr 15, 2022 at 08:18:11AM +0000, 常凤楠 wrote:
> > > Hi:
> > > 	When I dig into a problem, I found: bio merge may reduce a lot when
> > > 	enable inlinecrypt, the root cause is fscrypt_mergeable_bio use logical
> > > 	block number rather than physical block number. I had read the UFSHCI,
> > > 	but not see any description about why data unit number shoud use
> > logical
> > > 	block number. I want to know why, Is the anyone can explain this?
> > >
> > > Thanks.
> > > Fengnan Chang.
> > 
> > The main reason that fscrypt generates IVs using the file logical block number
> > instead of the sector number is because f2fs needs to move data blocks
> > around without the key.  That would be impossible with sector number
> > based encryption.
> So if use sector number to generate IVs, after f2fs move data blocks in gc, we can
> not decrypt correctly, am I right ?

Yes, that's correct.

> > 
> > There are other reasons too.  Always using the file logical block number
> > keeps the various fscrypt options consistent, it works well with per-file keys, it
> > doesn't break filesystem resizing, and it avoids having the interpretation of
> > the filesystem depend on its on-disk location which would be a layering
> > violation.  But the need to support f2fs is the main one.
> > 
> > Note that by default, fscrypt uses a different key for every file, and in that case
> > the only way that using the file logical block number instead of the sector
> > number would prevent merging is if data was being read/written from a file
> > that is physically but not logically contiguous.  That's not a very common
> > case.
> This is exactly the problem I have faced. We read/write a file in physically contiguous but not logically.
> So I'm wander if we can keep physically contiguous always, can we skip check wheatear logical block 
> number is contiguous when bio merge?

No, inline encryption requires contiguous DUNs.

- Eric

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

end of thread, other threads:[~2022-04-18  7:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15  8:18 why fscrypt_mergeable_bio use logical block number? 常凤楠
2022-04-15 18:49 ` Eric Biggers
2022-04-17  2:34   ` 常凤楠
2022-04-18  7:25     ` Eric Biggers

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.