Re: [RFC PATCH v2 0/3] ceph: add support for snapshot names encryption

From: Xiubo Li
Date: Thu Mar 17 2022 - 07:02:48 EST



On 3/17/22 6:14 PM, Luís Henriques wrote:
Xiubo Li <xiubli@xxxxxxxxxx> writes:

Hi Luis,

There has another issue you need to handle at the same time.

Currently only the empty directory could be enabled the file encryption, such as
for the following command:

$ fscrypt encrypt mydir/

But should we also make sure that the mydir/.snap/ is empty ?

Here the 'empty' is not totally empty, which allows it should allow long snap
names exist.

Make sense ?
Right, actually I had came across that question in the past but completely
forgot about it.

Right now we simply check the dir stats to ensure a directory is empty.
We could add an extra check in ceph_crypt_empty_dir() to ensure that there
are no snapshots _above_ that directory (i.e. that there are no
"mydir/.snap/_name_xxxxx").

Unfortunately, I don't know enough of snapshots implementation details to
understand if it's a problem to consider a directory as being empty (in
the fscrypt context) when there are these '_name_xxx' directories. My
feeling is that this is not a problem but I really don't know.

Do you (or anyone) have any ideas/suggestions?

There is no need to care about the long snap names in .snap, because they are all from the parent snaprealms.

What you need to make sure is that there shouldn't have any local snapshot before encrypting the directory.

If we don't make sure about this then when encrypting/decrypting the snapshot names you will hit errors in theory.

But I didn't test this yet, you can try.

-- Xiubo

Cheers,