diff mbox

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

Message ID 201307111004467716774@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

majianpeng July 11, 2013, 2:04 a.m. UTC
Cephfs don't change the layout which has been written.So add this check
before do.

Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>

---
 fs/ceph/ioctl.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
1.8.1.2

Comments

Sage Weil July 11, 2013, 6:54 p.m. UTC | #1
On Thu, 11 Jul 2013, majianpeng wrote:
> 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

> 
> Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
> ---
>  fs/ceph/ioctl.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
> index e0b4ef3..cbea896 100644
> --- a/fs/ceph/ioctl.c
> +++ b/fs/ceph/ioctl.c
> @@ -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;
>  
> -- 
> 1.8.1.2
> N????y????b?????v?????{.n??????z??ay????????j???f????????????????:+v??????????zZ+??????"?!?
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
majianpeng July 12, 2013, 12:51 a.m. UTC | #2
>On Thu, 11 Jul 2013, majianpeng wrote:

>> 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]
Sage Weil July 12, 2013, 9 p.m. UTC | #3
On Fri, 12 Jul 2013, majianpeng wrote:
> >On Thu, 11 Jul 2013, majianpeng wrote:
> >> 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
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
majianpeng July 15, 2013, 2:31 a.m. UTC | #4
Pk9uIEZyaSwgMTIgSnVsIDIwMTMsIG1hamlhbnBlbmcgd3JvdGU6DQo+PiA+T24gVGh1LCAxMSBK
dWwgMjAxMywgbWFqaWFucGVuZyB3cm90ZToNCj4+ID4+IENlcGhmcyBkb24ndCBjaGFuZ2UgdGhl
IGxheW91dCB3aGljaCBoYXMgYmVlbiB3cml0dGVuLlNvIGFkZCB0aGlzIGNoZWNrDQo+PiA+PiBi
ZWZvcmUgZG8uDQo+PiA+DQo+PiA+VGhpcyBjb3VsZCBjb25jZWl2YWFibHkgY2hhbmdlIGluIHRo
ZSBmdXR1cmUsIGFuZCBJJ20gbm90IHN1cmUgdGhlcmUgaXMgDQo+PiA+aGFybSBpcyB0aGUgTURT
IHJvdW5kIHRyaXAgdG8gZ2V0IHRoZSBlcnJvciBjb2RlIGhlcmUuLi4/DQo+PiA+DQo+PiBTb3Jy
eSwgaSBjYW4ndCB1bmRlcnN0YW5kIHdoYXQncyB5b3VyIHNhaWQuIENhbiB5b3UgZXhwbGFpbiBp
biBkZXRhaWw/DQo+DQo+U29ycnkuICBJIG1lYW4gdGhhdCBzb21lZGF5IHRoZSBNRFMgbWlnaHQg
YmUgYWJsZSB0byBhZGp1c3QgdGhlIGxheW91dCBvZiANCj5hbiBleGlzdGluZyBmaWxlLiAgVGhh
dCBpcyBwcm9iYWJseSBub3Qgc29tZXRoaW5nIHRoYXQgd2lsbCBoYXBwZW4gYW55IA0KPnRpbWUg
c29vbiwgdGhvdWdoLiAgSXQgaXMgcHJvYmFibHkgd29ydGggbWVyZ2luZyB0aGlzIChhbG9uZyB3
aXRoIHRoZSANCj5HRVRMQVlPVVQgaGFsZikgZm9yIG5vdy4NCj4NCk9LLCBJIHNlZS4gVGhhbmtz
IHlvdXIgdGltZSENCg0KSmlhbnBlbmcNCj5zYWdl

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index e0b4ef3..cbea896 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -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;