Skip to contentSkip to conversation

ceph: Don't do set_layout for file which has been written.

PATCH In review majianpeng 2 participants 5 messages Jul 11, 2013 – Jul 15, 2013 Ceph client

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 1/1 ceph: Don't do set_layout for file which has been written.

Cephfs don't change the layout which has been written.So add this check before do.

---
 fs/ceph/ioctl.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ceph/ioctl.c +3 -0
index e0b4ef3..cbea896 100644
@@ -72,6 +72,9 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
 	struct ceph_ioctl_layout nl;
 	int err;
 
+	/*Only for file which has never been written*/
+	if (i_size_read(inode) > 0 || ci->i_truncate_seq > 1)
+		return -ENOTEMPTY;
 	if (copy_from_user(&l, arg, sizeof(l)))
 		return -EFAULT;
 
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 2 lines · majianpeng

Cephfs don't change the layout which has been written.So add this check before do.

This could conceivaably change in the future, and I'm not sure there is harm is the MDS round trip to get the error code here...?

sage

Quoted 23 lines
---
 fs/ceph/ioctl.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ceph/ioctl.c +3 -0
index e0b4ef3..cbea896 100644
@@ -72,6 +72,9 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
 	struct ceph_ioctl_layout nl;
 	int err;
 
+	/*Only for file which has never been written*/
+	if (i_size_read(inode) > 0 || ci->i_truncate_seq > 1)
+		return -ENOTEMPTY;
 	if (copy_from_user(&l, arg, sizeof(l)))
 		return -EFAULT;
 
Signature · 2 lines
1.8.1.2
N????y????b?????v?????{.n??????z??ay????????j???f????????????????:+v??????????zZ+??????"?!?
author
#2 lore raw
Quoted 7 lines · majianpeng
Quoted 2 lines

Cephfs don't change the layout which has been written.So add this check before do.

This could conceivaably change in the future, and I'm not sure there is harm is the MDS round trip to get the error code here...?

Sorry, i can't understand what's your said. Can you explain in detail?

Thanks
Jianpeng Ma
[snip]

#3 lore raw
Quoted 8 lines · majianpeng
Quoted 7 lines · majianpeng
Quoted 2 lines

Cephfs don't change the layout which has been written.So add this check before do.

This could conceivaably change in the future, and I'm not sure there is harm is the MDS round trip to get the error code here...?

Sorry, i can't understand what's your said. Can you explain in detail?

Sorry. I mean that someday the MDS might be able to adjust the layout of an existing file. That is probably not something that will happen any time soon, though. It is probably worth merging this (along with the GETLAYOUT half) for now.

sage

author
#4 lore raw
Quoted 8 lines · majianpeng
Quoted 7 lines
Quoted 7 lines · majianpeng
Quoted 2 lines

Cephfs don't change the layout which has been written.So add this check before do.

This could conceivaably change in the future, and I'm not sure there is harm is the MDS round trip to get the error code here...?

Quoted 7 lines
Quoted 1 line

Sorry, i can't understand what's your said. Can you explain in detail?

Sorry. I mean that someday the MDS might be able to adjust the layout of an existing file. That is probably not something that will happen any time soon, though. It is probably worth merging this (along with the GETLAYOUT half) for now.

OK, I see. Thanks your time!

Jianpeng

Quoted 1 line

sage