Skip to contentSkip to conversation

ceph: don't allow setlease on cephfs

PATCH In review Jeff Layton 2 participants 6 messages Aug 20, 2020 – Aug 24, 2020 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: don't allow setlease on cephfs

Leases don't currently work correctly on kcephfs, as they are not broken when caps are revoked. They could eventually be implemented similarly to how we did them in libcephfs, but for now don't allow them.

---
 fs/ceph/dir.c  | 2 ++
 fs/ceph/file.c | 1 +
 2 files changed, 3 insertions(+)
fs/ceph/dir.c +2 -0
index 040eaad9d063..34f669220a8b 100644
@@ -1935,6 +1935,7 @@ const struct file_operations ceph_dir_fops = {
 	.compat_ioctl = compat_ptr_ioctl,
 	.fsync = ceph_fsync,
 	.lock = ceph_lock,
+	.setlease = simple_nosetlease,
 	.flock = ceph_flock,
 };
 
@@ -1943,6 +1944,7 @@ const struct file_operations ceph_snapdir_fops = {
 	.llseek = ceph_dir_llseek,
 	.open = ceph_open,
 	.release = ceph_release,
+	.setlease = simple_nosetlease,
 };
 
 const struct inode_operations ceph_dir_iops = {
fs/ceph/file.c +1 -0
index 27c7047c9383..fb3ea715a19d 100644
@@ -2505,6 +2505,7 @@ const struct file_operations ceph_file_fops = {
 	.mmap = ceph_mmap,
 	.fsync = ceph_fsync,
 	.lock = ceph_lock,
+	.setlease = simple_nosetlease,
 	.flock = ceph_flock,
 	.splice_read = generic_file_splice_read,
 	.splice_write = iter_file_splice_write,
Signature · 1 line
2.26.2
maintainer
#1 lore raw
Quoted 24 lines · Jeff Layton

Leases don't currently work correctly on kcephfs, as they are not broken when caps are revoked. They could eventually be implemented similarly to how we did them in libcephfs, but for now don't allow them.

---
 fs/ceph/dir.c  | 2 ++
 fs/ceph/file.c | 1 +
 2 files changed, 3 insertions(+)
fs/ceph/dir.c +1 -0
index 040eaad9d063..34f669220a8b 100644
@@ -1935,6 +1935,7 @@ const struct file_operations ceph_dir_fops = {
        .compat_ioctl = compat_ptr_ioctl,
        .fsync = ceph_fsync,
        .lock = ceph_lock,
+       .setlease = simple_nosetlease,
        .flock = ceph_flock,
 };
 

fs/ceph/dir.c const struct file_operations ceph_snapdir_fops = { · line 1947

Quoted 4 lines
fs/ceph/dir.c +1 -0
@@ -1943,6 +1944,7 @@ const struct file_operations ceph_snapdir_fops = {
        .llseek = ceph_dir_llseek,
        .open = ceph_open,
        .release = ceph_release,
+       .setlease = simple_nosetlease,

Hi Jeff,

Isn't this redundant for directories?

Thanks,

Ilya

#2 lore raw
Quoted 31 lines · Ilya Dryomov
Quoted 23 lines · Jeff Layton

Leases don't currently work correctly on kcephfs, as they are not broken when caps are revoked. They could eventually be implemented similarly to how we did them in libcephfs, but for now don't allow them.

---
 fs/ceph/dir.c  | 2 ++
 fs/ceph/file.c | 1 +
 2 files changed, 3 insertions(+)
fs/ceph/dir.c +1 -0
index 040eaad9d063..34f669220a8b 100644
@@ -1935,6 +1935,7 @@ const struct file_operations ceph_dir_fops = {
        .compat_ioctl = compat_ptr_ioctl,
        .fsync = ceph_fsync,
        .lock = ceph_lock,
+       .setlease = simple_nosetlease,
        .flock = ceph_flock,
 };
 

fs/ceph/dir.c const struct file_operations ceph_snapdir_fops = { · line 1947

Quoted 4 lines
fs/ceph/dir.c +1 -0
@@ -1943,6 +1944,7 @@ const struct file_operations ceph_snapdir_fops = {
        .llseek = ceph_dir_llseek,
        .open = ceph_open,
        .release = ceph_release,
+       .setlease = simple_nosetlease,

Hi Jeff,

Quoted 5 lines

Isn't this redundant for directories?

Thanks,

Ilya

generic_setlease does currently return -EINVAL if you try to set it on anything but a regular file. But, there is nothing that prevents that at a higher level. A filesystem can implement a ->setlease op that allows it.

So yeah, that doesn't really have of an effect since you'd likely get back -EINVAL anyway, but adding this line in it makes that explicit.

Signature · 1 line
Jeff Layton <[email protected]>
maintainer
#5 lore raw
In reply to Jeff Layton
Quoted 49 lines · Jeff Layton
Quoted 47 lines · Ilya Dryomov
Quoted 45 lines · Jeff Layton
Quoted 31 lines · Ilya Dryomov
Quoted 23 lines · Jeff Layton

Leases don't currently work correctly on kcephfs, as they are not broken when caps are revoked. They could eventually be implemented similarly to how we did them in libcephfs, but for now don't allow them.

---
 fs/ceph/dir.c  | 2 ++
 fs/ceph/file.c | 1 +
 2 files changed, 3 insertions(+)
fs/ceph/dir.c +1 -0
index 040eaad9d063..34f669220a8b 100644
@@ -1935,6 +1935,7 @@ const struct file_operations ceph_dir_fops = {
        .compat_ioctl = compat_ptr_ioctl,
        .fsync = ceph_fsync,
        .lock = ceph_lock,
+       .setlease = simple_nosetlease,
        .flock = ceph_flock,
 };
 

fs/ceph/dir.c const struct file_operations ceph_snapdir_fops = { · line 1947

Quoted 4 lines
fs/ceph/dir.c +1 -0
@@ -1943,6 +1944,7 @@ const struct file_operations ceph_snapdir_fops = {
        .llseek = ceph_dir_llseek,
        .open = ceph_open,
        .release = ceph_release,
+       .setlease = simple_nosetlease,

Hi Jeff,

Quoted 5 lines

Isn't this redundant for directories?

Thanks,

Ilya

generic_setlease does currently return -EINVAL if you try to set it on anything but a regular file. But, there is nothing that prevents that at a higher level. A filesystem can implement a ->setlease op that allows it.

So yeah, that doesn't really have of an effect since you'd likely get back -EINVAL anyway, but adding this line in it makes that explicit.

Quoted 6 lines
Quoted 4 lines

It looks like gfs2 and nfs only set simple_nosetlease for file fops, so it might be more consistent if we did this only for ceph_file_fops as well.

Fair enough. Do you want to just fix it up, or would you rather I send a v2?

I'll fix it up.

Thanks,

Ilya

#4 lore raw
In reply to Ilya Dryomov
Quoted 44 lines · Ilya Dryomov
Quoted 43 lines · Jeff Layton
Quoted 31 lines · Ilya Dryomov
Quoted 23 lines · Jeff Layton

Leases don't currently work correctly on kcephfs, as they are not broken when caps are revoked. They could eventually be implemented similarly to how we did them in libcephfs, but for now don't allow them.

---
 fs/ceph/dir.c  | 2 ++
 fs/ceph/file.c | 1 +
 2 files changed, 3 insertions(+)
fs/ceph/dir.c +1 -0
index 040eaad9d063..34f669220a8b 100644
@@ -1935,6 +1935,7 @@ const struct file_operations ceph_dir_fops = {
        .compat_ioctl = compat_ptr_ioctl,
        .fsync = ceph_fsync,
        .lock = ceph_lock,
+       .setlease = simple_nosetlease,
        .flock = ceph_flock,
 };
 

fs/ceph/dir.c const struct file_operations ceph_snapdir_fops = { · line 1947

Quoted 4 lines
fs/ceph/dir.c +1 -0
@@ -1943,6 +1944,7 @@ const struct file_operations ceph_snapdir_fops = {
        .llseek = ceph_dir_llseek,
        .open = ceph_open,
        .release = ceph_release,
+       .setlease = simple_nosetlease,

Hi Jeff,

Quoted 5 lines

Isn't this redundant for directories?

Thanks,

Ilya

generic_setlease does currently return -EINVAL if you try to set it on anything but a regular file. But, there is nothing that prevents that at a higher level. A filesystem can implement a ->setlease op that allows it.

Quoted 7 lines
Quoted 2 lines

So yeah, that doesn't really have of an effect since you'd likely get back -EINVAL anyway, but adding this line in it makes that explicit.

It looks like gfs2 and nfs only set simple_nosetlease for file fops, so it might be more consistent if we did this only for ceph_file_fops as well.

Fair enough. Do you want to just fix it up, or would you rather I send a v2?

Thanks,

Signature · 1 line
Jeff Layton <[email protected]>
maintainer
#3 lore raw
In reply to Jeff Layton
Quoted 39 lines · Jeff Layton
Quoted 31 lines · Ilya Dryomov
Quoted 23 lines · Jeff Layton

Leases don't currently work correctly on kcephfs, as they are not broken when caps are revoked. They could eventually be implemented similarly to how we did them in libcephfs, but for now don't allow them.

---
 fs/ceph/dir.c  | 2 ++
 fs/ceph/file.c | 1 +
 2 files changed, 3 insertions(+)
fs/ceph/dir.c +1 -0
index 040eaad9d063..34f669220a8b 100644
@@ -1935,6 +1935,7 @@ const struct file_operations ceph_dir_fops = {
        .compat_ioctl = compat_ptr_ioctl,
        .fsync = ceph_fsync,
        .lock = ceph_lock,
+       .setlease = simple_nosetlease,
        .flock = ceph_flock,
 };
 

fs/ceph/dir.c const struct file_operations ceph_snapdir_fops = { · line 1947

Quoted 4 lines
fs/ceph/dir.c +1 -0
@@ -1943,6 +1944,7 @@ const struct file_operations ceph_snapdir_fops = {
        .llseek = ceph_dir_llseek,
        .open = ceph_open,
        .release = ceph_release,
+       .setlease = simple_nosetlease,

Hi Jeff,

Quoted 5 lines

Isn't this redundant for directories?

Thanks,

Ilya

Quoted 7 lines

generic_setlease does currently return -EINVAL if you try to set it on anything but a regular file. But, there is nothing that prevents that at a higher level. A filesystem can implement a ->setlease op that allows it.

So yeah, that doesn't really have of an effect since you'd likely get back -EINVAL anyway, but adding this line in it makes that explicit.

It looks like gfs2 and nfs only set simple_nosetlease for file fops, so it might be more consistent if we did this only for ceph_file_fops as well.

Thanks,

Ilya