Skip to content

Commit 536ef6a

Browse files
committed
client, libcephfs: Expose fscrypt apis as low level
Add low level versions of fscrypt apis to support protocols such as NFS. Signed-off-by: Christopher Hoffman <[email protected]> (cherry picked from commit a3cba25)
1 parent a29aa59 commit 536ef6a

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

src/client/Client.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18207,7 +18207,11 @@ int Client::is_encrypted(int fd, UserPerm& perms, char* enctag)
1820718207
return -EBADF;
1820818208
}
1820918209

18210-
Inode *in = f->inode.get();
18210+
return ll_is_encrypted(f->inode.get(), perms, enctag);
18211+
}
18212+
18213+
int Client::ll_is_encrypted(Inode *in, UserPerm& perms, char *enctag)
18214+
{
1821118215
if (in->is_encrypted()) {
1821218216
int r = ll_getxattr(in, "user.ceph.subvolume.enctag", enctag, sizeof(enctag), perms);
1821318217
// dir can be encrypted and xattr DNE if it isn't setup via mgr subvolume

src/client/Client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ class Client : public Dispatcher, public md_config_obs_t {
711711

712712
int ll_set_fscrypt_policy_v2(Inode *in, const struct fscrypt_policy_v2& policy);
713713
int ll_get_fscrypt_policy_v2(Inode *in, struct fscrypt_policy_v2* policy);
714+
int ll_is_encrypted(Inode *in, UserPerm& perms, char* enctag);
714715

715716
int ll_get_stripe_osd(struct Inode *in, uint64_t blockno,
716717
file_layout_t* layout);

src/include/cephfs/libcephfs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,6 +2206,14 @@ int ceph_ll_setlk(struct ceph_mount_info *cmount,
22062206

22072207
int ceph_ll_lazyio(struct ceph_mount_info *cmount, Fh *fh, int enable);
22082208

2209+
int ceph_ll_set_fscrypt_policy_v2(struct ceph_mount_info *cmount,
2210+
Inode *in, const struct fscrypt_policy_v2 *policy);
2211+
2212+
int ceph_ll_get_fscrypt_policy_v2(struct ceph_mount_info *cmount,
2213+
Inode *in, struct fscrypt_policy_v2 *policy);
2214+
2215+
int ceph_ll_is_encrypted(struct ceph_mount_info *cmount, Inode *in, char* enctag);
2216+
22092217
/*
22102218
* Delegation support
22112219
*

src/libcephfs.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,6 +2746,32 @@ extern "C" int ceph_get_fscrypt_policy_v2(struct ceph_mount_info *cmount,
27462746
return cmount->get_client()->get_fscrypt_policy_v2(fd, policy);
27472747
}
27482748

2749+
extern "C" int ceph_ll_set_fscrypt_policy_v2(struct ceph_mount_info *cmount,
2750+
Inode *in, const struct fscrypt_policy_v2 *policy)
2751+
{
2752+
if (!cmount->is_mounted())
2753+
return -ENOTCONN;
2754+
2755+
return cmount->get_client()->ll_set_fscrypt_policy_v2(in, *policy);
2756+
}
2757+
2758+
extern "C" int ceph_ll_get_fscrypt_policy_v2(struct ceph_mount_info *cmount,
2759+
Inode *in, struct fscrypt_policy_v2 *policy)
2760+
{
2761+
if (!cmount->is_mounted())
2762+
return -ENOTCONN;
2763+
2764+
return cmount->get_client()->ll_get_fscrypt_policy_v2(in, policy);
2765+
}
2766+
2767+
extern "C" int ceph_ll_is_encrypted(struct ceph_mount_info *cmount,
2768+
Inode *in, char* enctag)
2769+
{
2770+
if (!cmount->is_mounted())
2771+
return -ENOTCONN;
2772+
2773+
return cmount->get_client()->ll_is_encrypted(in, cmount->default_perms, enctag);
2774+
}
27492775

27502776
// This is deprecated, use ceph_ll_register_callbacks2 instead.
27512777
extern "C" void ceph_ll_register_callbacks(class ceph_mount_info *cmount,

0 commit comments

Comments
 (0)