ceph: read/modify inline data support
Subsystems (2)
cover ceph: read/modify inline data support
Hi,
This patch series allows cephfs client kernel to read/modify inline data. When modifying a inode with inline data, inline data are always converted to normal object first. This patch series does not support storing new data as inline.
Regards
Yan, Zheng
PATCH 1/12 libceph: add SETXATTR/CMPXATTR osd operations support
--- include/linux/ceph/osd_client.h | 10 ++++++++++ net/ceph/osd_client.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+)
include/linux/ceph/osd_client.h +10 -0
@@ -87,6 +87,13 @@ struct ceph_osd_req_op {struct ceph_osd_data osd_data; } extent;struct { +__le32 name_len; +__le32 value_len; +__u8 cmp_op;/* CEPH_OSD_CMPXATTR_OP_* */ +__u8 cmp_mode;/* CEPH_OSD_CMPXATTR_MODE_* */ +struct ceph_osd_data osd_data; + } xattr; +struct {const char *class_name;const char *method_name;struct ceph_osd_data request_info;
@@ -295,6 +302,9 @@ extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,extern void osd_req_op_cls_init (struct ceph_osd_request *osd_req,unsigned int which,u16 opcode,const char *class,const char *method); +extern void osd_req_op_xattr_init (struct ceph_osd_request *osd_req,unsigned int which, +u16 opcode,const char *name,const void *value, +size_t size,u8 cmp_op,u8 cmp_mode);extern void osd_req_op_watch_init (struct ceph_osd_request *osd_req,unsigned int which,u16 opcode,u64 cookie,u64 version,int flag);
net/ceph/osd_client.c +38 -0
@@ -545,6 +545,34 @@ void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which, }EXPORT_SYMBOL (osd_req_op_cls_init); +void osd_req_op_xattr_init (struct ceph_osd_request *osd_req,unsigned int which, +u16 opcode,const char *name,const void *value, +size_t size,u8 cmp_op,u8 cmp_mode) +{ +struct ceph_osd_req_op *op =_osd_req_op_init (osd_req, which, opcode); +struct ceph_pagelist *pagelist; +size_t payload_len; + + pagelist =kmalloc (sizeof (*pagelist),GFP_NOFS ); +BUG_ON (!pagelist); +ceph_pagelist_init (pagelist); + + payload_len =strlen (name); + op->xattr.name_len = payload_len; +ceph_pagelist_append (pagelist, name, payload_len); + + op->xattr.value_len = size; +ceph_pagelist_append (pagelist, value, size); + payload_len += size; + + op->xattr.cmp_op = cmp_op; + op->xattr.cmp_mode = cmp_mode; + +ceph_osd_data_pagelist_init (&op->xattr.osd_data, pagelist); + op->payload_len = payload_len; +} +EXPORT_SYMBOL (osd_req_op_xattr_init); +void osd_req_op_watch_init (struct ceph_osd_request *osd_req,unsigned int which,u16 opcode,u64 cookie,u64 version,int flag)
@@ -676,6 +704,16 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, dst->alloc_hint.expected_write_size =cpu_to_le64 (src->alloc_hint.expected_write_size);break ; +case CEPH_OSD_OP_SETXATTR : +case CEPH_OSD_OP_CMPXATTR : + dst->xattr.name_len =cpu_to_le32 (src->xattr.name_len); + dst->xattr.value_len =cpu_to_le32 (src->xattr.value_len); + dst->xattr.cmp_op = src->xattr.cmp_op; + dst->xattr.cmp_mode = src->xattr.cmp_mode; + osd_data = &src->xattr.osd_data; +ceph_osdc_msg_data_add (req->r_request, osd_data); + request_data_len = osd_data->pagelist->length; +break ;default :pr_err ("unsupported osd opcode %s\n" ,ceph_osd_op_name (src->op));
Signature · 1 line
1.9.3
Re: [PATCH 01/12] libceph: add SETXATTR/CMPXATTR osd operations support
Quoted 39 lines · Zheng
Signed-off-by Yan, Zheng <[email protected]>--- include/linux/ceph/osd_client.h | 10 ++++++++++ net/ceph/osd_client.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+)include/linux/ceph/osd_client.h +10
-0@@ -87,6 +87,13 @@ struct ceph_osd_req_op {struct ceph_osd_data osd_data; } extent;struct { +__le32 name_len; +__le32 value_len; +__u8 cmp_op;/* CEPH_OSD_CMPXATTR_OP_* */ +__u8 cmp_mode;/* CEPH_OSD_CMPXATTR_MODE_* */ +struct ceph_osd_data osd_data; + } xattr; +struct {const char *class_name;const char *method_name;struct ceph_osd_data request_info;@@ -295,6 +302,9 @@ extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,extern void osd_req_op_cls_init (struct ceph_osd_request *osd_req,unsigned int which,u16 opcode,const char *class,const char *method); +extern void osd_req_op_xattr_init (struct ceph_osd_request *osd_req,unsigned int which, +u16 opcode,const char *name,const void *value, +size_t size,u8 cmp_op,u8 cmp_mode);extern void osd_req_op_watch_init (struct ceph_osd_request *osd_req,unsigned int which,u16 opcode,u64 cookie,u64 version,int flag);net/ceph/osd_client.c +0
-0
net/ceph/osd_client.c void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which, · line 554
Quoted 10 lines
net/ceph/osd_client.c +7
-0@@ -545,6 +545,34 @@ void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which, }EXPORT_SYMBOL (osd_req_op_cls_init); +void osd_req_op_xattr_init (struct ceph_osd_request *osd_req,unsigned int which, +u16 opcode,const char *name,const void *value, +size_t size,u8 cmp_op,u8 cmp_mode) +{ +struct ceph_osd_req_op *op =_osd_req_op_init (osd_req, which, opcode); +struct ceph_pagelist *pagelist; +size_t payload_len;
Add
BUG_ON(opcode != CEPH_OSD_OP_SETXATTR && opcode != CEPH_OSD_OP_CMPXATTR);
These asserts in osd_req_op_*_init() proved to be useful and some day we will change from BUG_ONs to something nicer throughout.
net/ceph/osd_client.c void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which, · line 557
Quoted 3 lines
net/ceph/osd_client.c +3
-0+ + pagelist =kmalloc (sizeof (*pagelist),GFP_NOFS ); +BUG_ON (!pagelist);
This BUG_ON OTOH is not useful ;) Can you make osd_req_op_xattr_init() return an error and get rid of it? I know you just pasted this from osd_req_op_cls_init(), but ceph_uninline_data() is perfectly capable of handling -ENOMEM so no reason to spread this any further.
Also drop the space after sizeof.
Thanks,
Ilya
Re: [PATCH 01/12] libceph: add SETXATTR/CMPXATTR osd operations support
updated patch
—
From 1f7963731ccbd2cd0f19d4f357c915e23d702d60 Mon Sep 17 00:00:00 2001
From: "Yan, Zheng" <[email protected]>
Date: Wed, 12 Nov 2014 14:00:43 +0800
Subject: [PATCH 01/12] libceph: add SETXATTR/CMPXATTR osd operations support
--- include/linux/ceph/osd_client.h | 10 +++++++++ net/ceph/osd_client.c | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+)
include/linux/ceph/osd_client.h +10 -0
@@ -87,6 +87,13 @@ struct ceph_osd_req_op {struct ceph_osd_data osd_data; } extent;struct { +__le32 name_len; +__le32 value_len; +__u8 cmp_op;/* CEPH_OSD_CMPXATTR_OP_* */ +__u8 cmp_mode;/* CEPH_OSD_CMPXATTR_MODE_* */ +struct ceph_osd_data osd_data; + } xattr; +struct {const char *class_name;const char *method_name;struct ceph_osd_data request_info;
@@ -295,6 +302,9 @@ extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,extern void osd_req_op_cls_init (struct ceph_osd_request *osd_req,unsigned int which,u16 opcode,const char *class,const char *method); +extern int osd_req_op_xattr_init (struct ceph_osd_request *osd_req,unsigned int which, +u16 opcode,const char *name,const void *value, +size_t size,u8 cmp_op,u8 cmp_mode);extern void osd_req_op_watch_init (struct ceph_osd_request *osd_req,unsigned int which,u16 opcode,u64 cookie,u64 version,int flag);
net/ceph/osd_client.c +47 -0
65 lines not on this page · raw message
Signature · 6 lines
1.9.3 -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Ilya Dryomov
Reviewed-byRe: [PATCH 01/12] libceph: add SETXATTR/CMPXATTR osd operations support
Quoted 104 lines · 严正
updated patch
—
From1f7963731ccbd2cd0f19d4f357c915e23d702d60Mon Sep 17 00:00:00 2001
From: "Yan, Zheng" <[email protected]>
Date: Wed, 12 Nov 2014 14:00:43 +0800
Subject: [PATCH 01/12] libceph: add SETXATTR/CMPXATTR osd operations supportSigned-off-by Yan, Zheng <[email protected]>--- include/linux/ceph/osd_client.h | 10 +++++++++ net/ceph/osd_client.c | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+)include/linux/ceph/osd_client.h +10
-0@@ -87,6 +87,13 @@ struct ceph_osd_req_op {struct ceph_osd_data osd_data; } extent;struct { +__le32 name_len; +__le32 value_len; +__u8 cmp_op;/* CEPH_OSD_CMPXATTR_OP_* */ +__u8 cmp_mode;/* CEPH_OSD_CMPXATTR_MODE_* */ +struct ceph_osd_data osd_data; + } xattr; +struct {const char *class_name;const char *method_name;struct ceph_osd_data request_info;@@ -295,6 +302,9 @@ extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,extern void osd_req_op_cls_init (struct ceph_osd_request *osd_req,unsigned int which,u16 opcode,const char *class,const char *method); +extern int osd_req_op_xattr_init (struct ceph_osd_request *osd_req,unsigned int which, +u16 opcode,const char *name,const void *value, +size_t size,u8 cmp_op,u8 cmp_mode);extern void osd_req_op_watch_init (struct ceph_osd_request *osd_req,unsigned int which,u16 opcode,u64 cookie,u64 version,int flag);net/ceph/osd_client.c +40
-0@@ -292,6 +292,10 @@ static void osd_req_op_data_release(struct ceph_osd_request *osd_req,ceph_osd_data_release (&op->cls.request_data);ceph_osd_data_release (&op->cls.response_data);break ; +case CEPH_OSD_OP_SETXATTR : +case CEPH_OSD_OP_CMPXATTR : +ceph_osd_data_release (&op->xattr.osd_data); +break ;default :break ; }@@ -545,6 +549,39 @@ void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which, }EXPORT_SYMBOL (osd_req_op_cls_init); +int osd_req_op_xattr_init (struct ceph_osd_request *osd_req,unsigned int which, +u16 opcode,const char *name,const void *value, +size_t size,u8 cmp_op,u8 cmp_mode) +{ +struct ceph_osd_req_op *op =_osd_req_op_init (osd_req, which, opcode); +struct ceph_pagelist *pagelist; +size_t payload_len; + +BUG_ON (opcode !=CEPH_OSD_OP_SETXATTR && opcode !=CEPH_OSD_OP_CMPXATTR ); + + pagelist =kmalloc (sizeof (*pagelist),GFP_NOFS ); +if (!pagelist) +return -ENOMEM ; + +ceph_pagelist_init (pagelist); + + payload_len =strlen (name); + op->xattr.name_len = payload_len; +ceph_pagelist_append (pagelist, name, payload_len); + + op->xattr.value_len = size; +ceph_pagelist_append (pagelist, value, size); + payload_len += size; + + op->xattr.cmp_op = cmp_op; + op->xattr.cmp_mode = cmp_mode; + +ceph_osd_data_pagelist_init (&op->xattr.osd_data, pagelist); + op->payload_len = payload_len; +return 0 ; +} +EXPORT_SYMBOL (osd_req_op_xattr_init); +void osd_req_op_watch_init (struct ceph_osd_request *osd_req,unsigned int which,u16 opcode,u64 cookie,u64 version,int flag)@@ -676,6 +713,16 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, dst->alloc_hint.expected_write_size =cpu_to_le64 (src->alloc_hint.expected_write_size);break ; +case CEPH_OSD_OP_SETXATTR : +case CEPH_OSD_OP_CMPXATTR : + dst->xattr.name_len =cpu_to_le32 (src->xattr.name_len);
net/ceph/osd_client.c static u64 osd_req_encode_op(struct ceph_osd_request *req, · line 728
Quoted 10 lines
net/ceph/osd_client.c +7
-0+ dst->xattr.value_len =cpu_to_le32 (src->xattr.value_len); + dst->xattr.cmp_op = src->xattr.cmp_op; + dst->xattr.cmp_mode = src->xattr.cmp_mode; + osd_data = &src->xattr.osd_data; +ceph_osdc_msg_data_add (req->r_request, osd_data); + request_data_len = osd_data->pagelist->length; +break ;default :pr_err ("unsupported osd opcode %s\n" ,ceph_osd_op_name (src->op));
I see you've also added osd_req_op_data_release() hunk.
Thanks,
Ilya
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/12 libceph: add CREATE osd operation support
In reply to Yan, Zheng--- net/ceph/osd_client.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-)
net/ceph/osd_client.c +22 -20
@@ -476,8 +476,7 @@ void osd_req_op_extent_init(struct ceph_osd_request *osd_req,size_t payload_len =0 ;BUG_ON (opcode !=CEPH_OSD_OP_READ && opcode !=CEPH_OSD_OP_WRITE && - opcode !=CEPH_OSD_OP_DELETE && opcode !=CEPH_OSD_OP_ZERO && - opcode !=CEPH_OSD_OP_TRUNCATE ); + opcode !=CEPH_OSD_OP_ZERO && opcode !=CEPH_OSD_OP_TRUNCATE ); op->extent.offset = offset; op->extent.length = length;
@@ -654,7 +653,6 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req,case CEPH_OSD_OP_READ :case CEPH_OSD_OP_WRITE :case CEPH_OSD_OP_ZERO : -case CEPH_OSD_OP_DELETE :case CEPH_OSD_OP_TRUNCATE :if (src->op ==CEPH_OSD_OP_WRITE ) request_data_len = src->extent.length;
@@ -714,6 +712,9 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req,ceph_osdc_msg_data_add (req->r_request, osd_data); request_data_len = osd_data->pagelist->length;break ; +case CEPH_OSD_OP_CREATE : +case CEPH_OSD_OP_DELETE : +break ;default :pr_err ("unsupported osd opcode %s\n" ,ceph_osd_op_name (src->op));
@@ -754,13 +755,11 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,u64 objnum =0 ;u64 objoff =0 ;u64 objlen =0 ; -u32 object_size; -u64 object_base;int r;BUG_ON (opcode !=CEPH_OSD_OP_READ && opcode !=CEPH_OSD_OP_WRITE && - opcode !=CEPH_OSD_OP_DELETE && opcode !=CEPH_OSD_OP_ZERO && - opcode !=CEPH_OSD_OP_TRUNCATE ); + opcode !=CEPH_OSD_OP_ZERO && opcode !=CEPH_OSD_OP_TRUNCATE && + opcode !=CEPH_OSD_OP_CREATE && opcode !=CEPH_OSD_OP_DELETE ); req =ceph_osdc_alloc_request (osdc, snapc, num_ops, use_mempool,GFP_NOFS );
@@ -776,21 +775,24 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,return ERR_PTR (r); } - object_size =le32_to_cpu (layout->fl_object_size); - object_base = off - objoff; -if (!(truncate_seq ==1 && truncate_size ==-1ULL )) { -if (truncate_size <= object_base) { - truncate_size =0 ; - }else { - truncate_size -= object_base; -if (truncate_size > object_size) - truncate_size = object_size; +if (opcode ==CEPH_OSD_OP_CREATE || opcode ==CEPH_OSD_OP_DELETE ) { +osd_req_op_init (req,0 , opcode); + }else { +u32 object_size =le32_to_cpu (layout->fl_object_size); +u32 object_base = off - objoff; +if (!(truncate_seq ==1 && truncate_size ==-1ULL )) { +if (truncate_size <= object_base) { + truncate_size =0 ; + }else { + truncate_size -= object_base; +if (truncate_size > object_size) + truncate_size = object_size; + } } - } - -osd_req_op_extent_init (req,0 , opcode, objoff, objlen, - truncate_size, truncate_seq); +osd_req_op_extent_init (req,0 , opcode, objoff, objlen, + truncate_size, truncate_seq); + }/* * A second op in the ops array means the caller wants to * also issue a include a 'startsync' command so that the
Signature · 1 line
1.9.3
Re: [PATCH 02/12] libceph: add CREATE osd operation support
Quoted 81 lines · Zheng
Signed-off-by Yan, Zheng <[email protected]>--- net/ceph/osd_client.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-)net/ceph/osd_client.c +19
-17@@ -476,8 +476,7 @@ void osd_req_op_extent_init(struct ceph_osd_request *osd_req,size_t payload_len =0 ;BUG_ON (opcode !=CEPH_OSD_OP_READ && opcode !=CEPH_OSD_OP_WRITE && - opcode !=CEPH_OSD_OP_DELETE && opcode !=CEPH_OSD_OP_ZERO && - opcode !=CEPH_OSD_OP_TRUNCATE ); + opcode !=CEPH_OSD_OP_ZERO && opcode !=CEPH_OSD_OP_TRUNCATE ); op->extent.offset = offset; op->extent.length = length;@@ -654,7 +653,6 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req,case CEPH_OSD_OP_READ :case CEPH_OSD_OP_WRITE :case CEPH_OSD_OP_ZERO : -case CEPH_OSD_OP_DELETE :case CEPH_OSD_OP_TRUNCATE :if (src->op ==CEPH_OSD_OP_WRITE ) request_data_len = src->extent.length;@@ -714,6 +712,9 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req,ceph_osdc_msg_data_add (req->r_request, osd_data); request_data_len = osd_data->pagelist->length;break ; +case CEPH_OSD_OP_CREATE : +case CEPH_OSD_OP_DELETE : +break ;default :pr_err ("unsupported osd opcode %s\n" ,ceph_osd_op_name (src->op));@@ -754,13 +755,11 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,u64 objnum =0 ;u64 objoff =0 ;u64 objlen =0 ; -u32 object_size; -u64 object_base;int r;BUG_ON (opcode !=CEPH_OSD_OP_READ && opcode !=CEPH_OSD_OP_WRITE && - opcode !=CEPH_OSD_OP_DELETE && opcode !=CEPH_OSD_OP_ZERO && - opcode !=CEPH_OSD_OP_TRUNCATE ); + opcode !=CEPH_OSD_OP_ZERO && opcode !=CEPH_OSD_OP_TRUNCATE && + opcode !=CEPH_OSD_OP_CREATE && opcode !=CEPH_OSD_OP_DELETE ); req =ceph_osdc_alloc_request (osdc, snapc, num_ops, use_mempool,GFP_NOFS );@@ -776,21 +775,24 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,return ERR_PTR (r); } - object_size =le32_to_cpu (layout->fl_object_size); - object_base = off - objoff; -if (!(truncate_seq ==1 && truncate_size ==-1ULL )) { -if (truncate_size <= object_base) { - truncate_size =0 ; - }else { - truncate_size -= object_base; -if (truncate_size > object_size) - truncate_size = object_size; +if (opcode ==CEPH_OSD_OP_CREATE || opcode ==CEPH_OSD_OP_DELETE ) { +osd_req_op_init (req,0 , opcode); + }else { +u32 object_size =le32_to_cpu (layout->fl_object_size); +u32 object_base = off - objoff; +if (!(truncate_seq ==1 && truncate_size ==-1ULL )) { +if (truncate_size <= object_base) { + truncate_size =0 ; + }else { + truncate_size -= object_base; +if (truncate_size > object_size) + truncate_size = object_size; + } } - }
net/ceph/osd_client.c struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, · line 798
Quoted 10 lines
net/ceph/osd_client.c +3
-3- -osd_req_op_extent_init (req,0 , opcode, objoff, objlen, - truncate_size, truncate_seq); +osd_req_op_extent_init (req,0 , opcode, objoff, objlen, + truncate_size, truncate_seq); + }/* * A second op in the ops array means the caller wants to * also issue a include a 'startsync' command so that the
Amended changelog to also mention CEPH_OSD_OP_DELETE change:
"Add CEPH_OSD_OP_CREATE support. Also change libceph to not treat
CEPH_OSD_OP_DELETE as an extent op and add an assert to that end."
Thanks,
Ilya
PATCH 3/12 libceph: specify position of extent operation
In reply to Yan, Zhengallow specifying position of extent operation in multi-operations osd request. This is required for cephfs to convert inline data to normal data (compare xattr, then write object).
--- fs/ceph/addr.c | 9 ++++++--- fs/ceph/file.c | 8 +++++--- include/linux/ceph/osd_client.h | 3 ++- net/ceph/osd_client.c | 19 ++++++------------- 4 files changed, 19 insertions(+), 20 deletions(-)
fs/ceph/addr.c +6 -3
@@ -319,7 +319,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max) off, len); vino =ceph_vino (inode); req =ceph_osdc_new_request (osdc, &ci->i_layout, vino, off, &len, -1 ,CEPH_OSD_OP_READ , +0 ,1 ,CEPH_OSD_OP_READ ,CEPH_OSD_FLAG_READ ,NULL , ci->i_truncate_seq, ci->i_truncate_size, false);
@@ -750,7 +750,6 @@ retry: last_snapc = snapc;while (!done && index <= end) { -int num_ops = do_sync ?2 :1 ;unsigned i;int first;pgoff_t next;
@@ -850,7 +849,8 @@ get_more_pages: len = wsize; req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, vino, - offset, &len, num_ops, + offset, &len, 0, + do_sync ? 2 : 1, CEPH_OSD_OP_WRITE, CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
@@ -862,6 +862,9 @@ get_more_pages:break ; } +if (do_sync) +osd_req_op_init (req,1 ,CEPH_OSD_OP_STARTSYNC ); + req->r_callback = writepages_finish; req->r_inode = inode;
fs/ceph/file.c +5 -3
@@ -598,7 +598,7 @@ ceph_sync_direct_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos) snapc = ci->i_snap_realm->cached_context; vino =ceph_vino (inode); req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, - vino, pos, &len, + vino, pos, &len, 0, 2,/*include a 'startsync' command*/ CEPH_OSD_OP_WRITE, flags, snapc, ci->i_truncate_seq,
@@ -609,6 +609,8 @@ ceph_sync_direct_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos)break ; } +osd_req_op_init (req,1 ,CEPH_OSD_OP_STARTSYNC ); + n =iov_iter_get_pages_alloc (from, &pages, len, &start);if (unlikely (n <0 )) { ret = n;
@@ -713,7 +715,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos) snapc = ci->i_snap_realm->cached_context; vino =ceph_vino (inode); req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, - vino, pos, &len, 1, + vino, pos, &len, 0, 1, CEPH_OSD_OP_WRITE, flags, snapc, ci->i_truncate_seq, ci->i_truncate_size,
@@ -1111,7 +1113,7 @@ static int ceph_zero_partial_object(struct inode *inode, req =ceph_osdc_new_request (&fsc->client->osdc, &ci->i_layout,ceph_vino (inode), offset, length, -1 , op, +0 ,1 , op,CEPH_OSD_FLAG_WRITE |CEPH_OSD_FLAG_ONDISK ,NULL ,0 ,0 , false);
include/linux/ceph/osd_client.h +2 -1
@@ -328,7 +328,8 @@ extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,struct ceph_file_layout *layout, struct ceph_vino vino, u64 offset, u64 *len, - int num_ops, int opcode, int flags, + unsigned int which, int num_ops, + int opcode, int flags, struct ceph_snap_context *snapc, u32 truncate_seq, u64 truncate_size, bool use_mempool);
net/ceph/osd_client.c +6 -13
@@ -744,7 +744,8 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, struct ceph_file_layout *layout, struct ceph_vino vino, - u64 off, u64 *plen, int num_ops, + u64 off, u64 *plen, + unsigned int which, int num_ops, int opcode, int flags, struct ceph_snap_context *snapc, u32 truncate_seq,
@@ -776,7 +777,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, }if (opcode ==CEPH_OSD_OP_CREATE || opcode ==CEPH_OSD_OP_DELETE ) { -osd_req_op_init (req,0 , opcode); +osd_req_op_init (req, which, opcode); }else {u32 object_size =le32_to_cpu (layout->fl_object_size);u32 object_base = off - objoff;
@@ -789,17 +790,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, truncate_size = object_size; } } - -osd_req_op_extent_init (req,0 , opcode, objoff, objlen, +osd_req_op_extent_init (req, which, opcode, objoff, objlen, truncate_size, truncate_seq); } -/* -* A second op in the ops array means the caller wants to -* also issue a include a 'startsync' command so that the -* osd will flush data quickly. -*/ -if (num_ops >1 ) -osd_req_op_init (req,1 ,CEPH_OSD_OP_STARTSYNC ); req->r_base_oloc.pool =ceph_file_layout_pg_pool (*layout);
@@ -2666,7 +2659,7 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,dout ("readpages on ino %llx.%llx on %llu~%llu\n" , vino.ino, vino.snap, off, *plen); - req =ceph_osdc_new_request (osdc, layout, vino, off, plen,1 , + req =ceph_osdc_new_request (osdc, layout, vino, off, plen,0 ,1 ,CEPH_OSD_OP_READ ,CEPH_OSD_FLAG_READ ,NULL , truncate_seq, truncate_size, false);
@@ -2709,7 +2702,7 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,int page_align = off & ~PAGE_MASK ;BUG_ON (vino.snap !=CEPH_NOSNAP );/* snapshots aren't writeable */ - req = ceph_osdc_new_request(osdc, layout, vino, off, &len, 1, + req = ceph_osdc_new_request(osdc, layout, vino, off, &len, 0, 1, CEPH_OSD_OP_WRITE, CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE, snapc, truncate_seq, truncate_size,
Signature · 1 line
1.9.3
Re: [PATCH 03/12] libceph: specify position of extent operation
Quoted 159 lines · Zheng
allow specifying position of extent operation in multi-operations osd request. This is required for cephfs to convert inline data to normal data (compare xattr, then write object).
Signed-off-by Yan, Zheng <[email protected]>--- fs/ceph/addr.c | 9 ++++++--- fs/ceph/file.c | 8 +++++--- include/linux/ceph/osd_client.h | 3 ++- net/ceph/osd_client.c | 19 ++++++------------- 4 files changed, 19 insertions(+), 20 deletions(-)fs/ceph/addr.c +6
-3@@ -319,7 +319,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max) off, len); vino =ceph_vino (inode); req =ceph_osdc_new_request (osdc, &ci->i_layout, vino, off, &len, -1 ,CEPH_OSD_OP_READ , +0 ,1 ,CEPH_OSD_OP_READ ,CEPH_OSD_FLAG_READ ,NULL , ci->i_truncate_seq, ci->i_truncate_size, false);@@ -750,7 +750,6 @@ retry: last_snapc = snapc;while (!done && index <= end) { -int num_ops = do_sync ?2 :1 ;unsigned i;int first;pgoff_t next;@@ -850,7 +849,8 @@ get_more_pages: len = wsize; req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, vino, - offset, &len, num_ops, + offset, &len, 0, + do_sync ? 2 : 1, CEPH_OSD_OP_WRITE, CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,@@ -862,6 +862,9 @@ get_more_pages:break ; } +if (do_sync) +osd_req_op_init (req,1 ,CEPH_OSD_OP_STARTSYNC ); + req->r_callback = writepages_finish; req->r_inode = inode;fs/ceph/file.c +5
-3@@ -598,7 +598,7 @@ ceph_sync_direct_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos) snapc = ci->i_snap_realm->cached_context; vino =ceph_vino (inode); req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, - vino, pos, &len, + vino, pos, &len, 0, 2,/*include a 'startsync' command*/ CEPH_OSD_OP_WRITE, flags, snapc, ci->i_truncate_seq,@@ -609,6 +609,8 @@ ceph_sync_direct_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos)break ; } +osd_req_op_init (req,1 ,CEPH_OSD_OP_STARTSYNC ); + n =iov_iter_get_pages_alloc (from, &pages, len, &start);if (unlikely (n <0 )) { ret = n;@@ -713,7 +715,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos) snapc = ci->i_snap_realm->cached_context; vino =ceph_vino (inode); req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, - vino, pos, &len, 1, + vino, pos, &len, 0, 1, CEPH_OSD_OP_WRITE, flags, snapc, ci->i_truncate_seq, ci->i_truncate_size,@@ -1111,7 +1113,7 @@ static int ceph_zero_partial_object(struct inode *inode, req =ceph_osdc_new_request (&fsc->client->osdc, &ci->i_layout,ceph_vino (inode), offset, length, -1 , op, +0 ,1 , op,CEPH_OSD_FLAG_WRITE |CEPH_OSD_FLAG_ONDISK ,NULL ,0 ,0 , false);include/linux/ceph/osd_client.h +2
-1@@ -328,7 +328,8 @@ extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,struct ceph_file_layout *layout, struct ceph_vino vino, u64 offset, u64 *len, - int num_ops, int opcode, int flags, + unsigned int which, int num_ops, + int opcode, int flags, struct ceph_snap_context *snapc, u32 truncate_seq, u64 truncate_size, bool use_mempool);net/ceph/osd_client.c +5
-12@@ -744,7 +744,8 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, struct ceph_file_layout *layout, struct ceph_vino vino, - u64 off, u64 *plen, int num_ops, + u64 off, u64 *plen, + unsigned int which, int num_ops, int opcode, int flags, struct ceph_snap_context *snapc, u32 truncate_seq,@@ -776,7 +777,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, }if (opcode ==CEPH_OSD_OP_CREATE || opcode ==CEPH_OSD_OP_DELETE ) { -osd_req_op_init (req,0 , opcode); +osd_req_op_init (req, which, opcode); }else {u32 object_size =le32_to_cpu (layout->fl_object_size);u32 object_base = off - objoff;@@ -789,17 +790,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, truncate_size = object_size; } } - -osd_req_op_extent_init (req,0 , opcode, objoff, objlen, +osd_req_op_extent_init (req, which, opcode, objoff, objlen, truncate_size, truncate_seq); } -/* -* A second op in the ops array means the caller wants to -* also issue a include a 'startsync' command so that the -* osd will flush data quickly. -*/ -if (num_ops >1 ) -osd_req_op_init (req,1 ,CEPH_OSD_OP_STARTSYNC ); req->r_base_oloc.pool =ceph_file_layout_pg_pool (*layout);@@ -2666,7 +2659,7 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,dout ("readpages on ino %llx.%llx on %llu~%llu\n" , vino.ino, vino.snap, off, *plen); - req =ceph_osdc_new_request (osdc, layout, vino, off, plen,1 , + req =ceph_osdc_new_request (osdc, layout, vino, off, plen,0 ,1 ,CEPH_OSD_OP_READ ,CEPH_OSD_FLAG_READ ,NULL , truncate_seq, truncate_size, false);
net/ceph/osd_client.c int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino, · line 2708
Quoted 8 lines
net/ceph/osd_client.c +1
-1@@ -2709,7 +2702,7 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,int page_align = off & ~PAGE_MASK ;BUG_ON (vino.snap !=CEPH_NOSNAP );/* snapshots aren't writeable */ - req = ceph_osdc_new_request(osdc, layout, vino, off, &len, 1, + req = ceph_osdc_new_request(osdc, layout, vino, off, &len, 0, 1, CEPH_OSD_OP_WRITE, CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE, snapc, truncate_seq, truncate_size,
Thanks,
Ilya
PATCH 4/12 ceph: parse inline data in MClientReply and MClientCaps
In reply to Yan, Zheng--- fs/ceph/caps.c | 34 +++++++++++++++++++++++----------- fs/ceph/mds_client.c | 10 ++++++++++ fs/ceph/mds_client.h | 3 +++ 3 files changed, 36 insertions(+), 11 deletions(-)
fs/ceph/caps.c +23 -11
@@ -2383,6 +2383,8 @@ static void invalidate_aliases(struct inode *inode)static void handle_cap_grant (struct ceph_mds_client *mdsc,struct inode *inode,struct ceph_mds_caps *grant,void *snaptrace,int snaptrace_len, +u64 inline_version, +void *inline_data,int inline_len,struct ceph_buffer *xattr_buf,struct ceph_mds_session *session,struct ceph_cap *cap,int issued)
@@ -2996,11 +2998,12 @@ void ceph_handle_caps(struct ceph_mds_session *session,u64 cap_id;u64 size, max_size;u64 tid; +u64 inline_version =0 ; +void *inline_data =NULL ; +u32 inline_len =0 ;void *snaptrace;size_t snaptrace_len; -void *flock; -void *end; -u32 flock_len; +void *p, *end;dout ("handle_caps from mds%d\n" , mds);
@@ -3021,30 +3024,37 @@ void ceph_handle_caps(struct ceph_mds_session *session, snaptrace = h +1 ; snaptrace_len =le32_to_cpu (h->snap_trace_len); + p = snaptrace + snaptrace_len;if (le16_to_cpu (msg->hdr.version) >=2 ) { -void *p = snaptrace + snaptrace_len; +u32 flock_len;ceph_decode_32_safe (&p, end, flock_len, bad);if (p + flock_len > end) goto bad; - flock = p; - }else { - flock =NULL ; - flock_len =0 ; + p += flock_len; }if (le16_to_cpu (msg->hdr.version) >=3 ) {if (op ==CEPH_CAP_OP_IMPORT ) { -void *p = flock + flock_len;if (p +sizeof (*peer) > end) goto bad; peer = p; + p +=sizeof (*peer); }else if (op ==CEPH_CAP_OP_EXPORT ) {/* recorded in unused fields */ peer = (void *)&h->size; } } +if (le16_to_cpu (msg->hdr.version) >=4 ) { +ceph_decode_64_safe (&p, end, inline_version, bad); +ceph_decode_32_safe (&p, end, inline_len, bad); +if (p + inline_len > end) + goto bad; + inline_data = p; + p += inline_len; + } +/* lookup ino */ inode =ceph_find_inode (sb, vino); ci =ceph_inode (inode);
@@ -3085,6 +3095,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,handle_cap_import (mdsc, inode, h, peer, session, &cap, &issued);handle_cap_grant (mdsc, inode, h, snaptrace, snaptrace_len, + inline_version, inline_data, inline_len, msg->middle, session, cap, issued); goto done_unlocked; }
@@ -3105,8 +3116,9 @@ void ceph_handle_caps(struct ceph_mds_session *session,case CEPH_CAP_OP_GRANT :__ceph_caps_issued (ci, &issued); issued |=__ceph_caps_dirty (ci); -handle_cap_grant (mdsc, inode, h,NULL ,0 , msg->middle, - session, cap, issued); +handle_cap_grant (mdsc, inode, h,NULL ,0 , + inline_version, inline_data, inline_len, + msg->middle, session, cap, issued); goto done_unlocked;case CEPH_CAP_OP_FLUSH_ACK :
fs/ceph/mds_client.c +10 -0
@@ -89,6 +89,16 @@ static int parse_reply_info_in(void **p, void *end,ceph_decode_need (p, end, info->xattr_len, bad); info->xattr_data = *p; *p += info->xattr_len; + +if (features &CEPH_FEATURE_MDS_INLINE_DATA ) { +ceph_decode_64_safe (p, end, info->inline_version, bad); +ceph_decode_32_safe (p, end, info->inline_len, bad); +ceph_decode_need (p, end, info->inline_len, bad); + info->inline_data = *p; + *p += info->inline_len; + }else + info->inline_version =CEPH_INLINE_NONE ; +return 0 ; bad:return err;
fs/ceph/mds_client.h +3 -0
@@ -41,6 +41,9 @@ struct ceph_mds_reply_info_in {char *symlink;u32 xattr_len;char *xattr_data; +u64 inline_version; +u32 inline_len; +char *inline_data; };/*
Signature · 1 line
1.9.3
PATCH 5/12 ceph: add inline data to pagecache
In reply to Yan, ZhengRequest reply and cap message can contain inline data. add inline data to the page cache if there is Fc cap.
--- fs/ceph/addr.c | 42 ++++++++++++++++++++++++++++++++++++++++++ fs/ceph/caps.c | 11 +++++++++++ fs/ceph/inode.c | 16 ++++++++++++++++ fs/ceph/inode.c.rej | 21 +++++++++++++++++++++ fs/ceph/mds_client.c.rej | 10 ++++++++++ fs/ceph/super.h | 5 ++++- fs/ceph/super.h.rej | 10 ++++++++++ include/linux/ceph/ceph_fs.h | 1 + 8 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 fs/ceph/inode.c.rej create mode 100644 fs/ceph/mds_client.c.rej create mode 100644 fs/ceph/super.h.rej
fs/ceph/addr.c +42 -0
@@ -1318,6 +1318,48 @@ out:return ret; } +void ceph_fill_inline_data (struct inode *inode,struct page *locked_page, +char *data,size_t len) +{ +struct address_space *mapping = inode->i_mapping; +struct page *page; + +if (locked_page) { + page = locked_page; + }else { +if (i_size_read (inode) ==0 ) +return ; + page =find_or_create_page (mapping,0 ,GFP_NOFS ); +if (!page) +return ; +if (PageUptodate (page)) { +unlock_page (page); +page_cache_release (page); +return ; + } + } + +dout ("fill_inline_data %p %llx.%llx len %lu locked_page %p\n" , + inode,ceph_vinop (inode), len, locked_page); + +if (len >0 ) { +void *kaddr =kmap_atomic (page); +memcpy (kaddr, data, len); +kunmap_atomic (kaddr); + } + +if (page != locked_page) { +if (len <PAGE_CACHE_SIZE ) +zero_user_segment (page, len,PAGE_CACHE_SIZE ); +else +flush_dcache_page (page); + +SetPageUptodate (page); +unlock_page (page); +page_cache_release (page); + } +} +static struct vm_operations_struct ceph_vmops = { .fault = ceph_filemap_fault, .page_mkwrite = ceph_page_mkwrite,
fs/ceph/caps.c +11 -0
@@ -2405,6 +2405,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,bool queue_invalidate = false;bool queue_revalidate = false;bool deleted_inode = false; +bool fill_inline = false;dout ("handle_cap_grant inode %p cap %p mds%d seq %d %s\n" , inode, cap, mds, seq,ceph_cap_string (newcaps));
@@ -2578,6 +2579,13 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc, }BUG_ON (cap->issued & ~cap->implemented); +if (inline_version >0 && inline_version >= ci->i_inline_version) { + ci->i_inline_version = inline_version; +if (ci->i_inline_version !=CEPH_INLINE_NONE && + (newcaps & (CEPH_CAP_FILE_CACHE |CEPH_CAP_FILE_LAZYIO ))) + fill_inline = true; + } +spin_unlock (&ci->i_ceph_lock);if (le32_to_cpu (grant->op) ==CEPH_CAP_OP_IMPORT ) {
@@ -2591,6 +2599,9 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc, wake = true; } +if (fill_inline) +ceph_fill_inline_data (inode,NULL , inline_data, inline_len); +if (queue_trunc) {ceph_queue_vmtruncate (inode);ceph_queue_revalidate (inode);
fs/ceph/inode.c +16 -0
@@ -387,6 +387,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)spin_lock_init (&ci->i_ceph_lock); ci->i_version =0 ; + ci->i_inline_version =0 ; ci->i_time_warp_seq =0 ; ci->i_ceph_flags =0 ; ci->i_ordered_count =0 ;
@@ -676,6 +677,7 @@ static int fill_inode(struct inode *inode,bool wake = false;bool queue_trunc = false;bool new_version = false; +bool fill_inline = false; dout("fill_inode %p ino %llx.%llx v %llu had %llu\n", inode, ceph_vinop(inode), le64_to_cpu(info->version),
@@ -875,8 +877,22 @@ static int fill_inode(struct inode *inode, ceph_vinop(inode));__ceph_get_fmode (ci, cap_fmode); } + +if (iinfo->inline_version >0 && + iinfo->inline_version >= ci->i_inline_version) { +int cache_caps =CEPH_CAP_FILE_CACHE |CEPH_CAP_FILE_LAZYIO ; + ci->i_inline_version = iinfo->inline_version; +if (ci->i_inline_version !=CEPH_INLINE_NONE && + (le32_to_cpu (info->cap.caps) & cache_caps)) + fill_inline = true; + } +spin_unlock (&ci->i_ceph_lock); +if (fill_inline) +ceph_fill_inline_data (inode,NULL , + iinfo->inline_data, iinfo->inline_len); +if (wake)wake_up_all (&ci->i_cap_wq);
fs/ceph/inode.c.rej new file +21 -0
@@ -0,0 +1,21 @@ +--- fs/ceph/inode.c ++++ fs/ceph/inode.c +@@ -1960,7 +2016,8 @@ + * Verify that we have a lease on the given mask. If not, + * do a getattr against an mds. + */ +-int ceph_do_getattr(struct inode *inode, int mask, bool force) ++int __ceph_do_getattr(struct inode *inode, struct page *locked_page, ++ int mask, bool force) + { + struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb); + struct ceph_mds_client *mdsc = fsc->mdsc; +@@ -1972,7 +2029,8 @@ + return 0; + } + +- dout("do_getattr inode %p mask %s mode 0%o\n", inode, ceph_cap_string(mask), inode->i_mode); ++ dout("do_getattr inode %p mask %s mode 0%o\n", ++ inode, ceph_cap_string(mask), inode->i_mode); + if (!force && ceph_caps_issued_mask(ceph_inode(inode), mask, 1)) + return 0;
fs/ceph/mds_client.c.rej new file +10 -0
@@ -0,0 +1,10 @@ +--- fs/ceph/mds_client.c ++++ fs/ceph/mds_client.c +@@ -1848,7 +1848,6 @@ + msg->hdr.front_len = cpu_to_le32(msg->front.iov_len); + + if (req->r_data_len) { +- /* outbound data set only by ceph_sync_setxattr() */ + BUG_ON(!req->r_pages); + ceph_msg_data_add_pages(msg, req->r_pages, req->r_data_len, 0); + }
fs/ceph/super.h +4 -1
@@ -253,6 +253,7 @@ struct ceph_inode_info {spinlock_t i_ceph_lock;u64 i_version; +u64 i_inline_version;u32 i_time_warp_seq;unsigned i_ceph_flags;
@@ -858,7 +859,7 @@ extern int ceph_encode_dentry_release(void **p, struct dentry *dn, int mds, int drop, int unless);extern int ceph_get_caps (struct ceph_inode_info *ci,int need,int want, -int *got,loff_t endoff); +loff_t endoff,int *got,struct page **pinned_page);/* for counting open files by mode */ static inline void __ceph_get_fmode (struct ceph_inode_info *ci,int mode)
@@ -880,6 +881,8 @@ extern int ceph_atomic_open(struct inode *dir, struct dentry *dentry, struct file *file, unsigned flags, umode_t mode, int *opened);extern int ceph_release (struct inode *inode,struct file *filp); +extern void ceph_fill_inline_data (struct inode *inode,struct page *locked_page, +char *data,size_t len);/* dir.c */ extern const struct file_operations ceph_dir_fops;
fs/ceph/super.h.rej new file +10 -0
@@ -0,0 +1,10 @@ +--- fs/ceph/super.h ++++ fs/ceph/super.h +@@ -254,6 +255,7 @@ + spinlock_t i_ceph_lock; + + u64 i_version; ++ u64 i_inline_version; + u32 i_time_warp_seq; + + unsigned i_ceph_flags;
include/linux/ceph/ceph_fs.h +1 -0
@@ -552,6 +552,7 @@ struct ceph_filelock {int ceph_flags_to_mode (int flags); +#define CEPH_INLINE_NONE ((__u64)-1)/* capability bits */ #define CEPH_CAP_PIN 1/* no specific capabilities beyond the pin */
Signature · 1 line
1.9.3
PATCH 6/12 ceph: use getattr request to fetch inline data
In reply to Yan, ZhengAdd a new parameter 'locked_page' to ceph_do_getattr(). If inline data in getattr reply will be copied to the page.
--- fs/ceph/inode.c | 34 +++++++++++++++++++++++++--------- fs/ceph/mds_client.h | 1 + fs/ceph/super.h | 7 ++++++- include/linux/ceph/ceph_fs.h | 2 ++ 4 files changed, 34 insertions(+), 10 deletions(-)
fs/ceph/inode.c +25 -9
@@ -659,7 +659,7 @@ void ceph_fill_file_time(struct inode *inode, int issued,* Populate an inode based on info from mds. May be called on new or * existing inodes. */ -static int fill_inode(struct inode *inode, +static int fill_inode(struct inode *inode, struct page *locked_page, struct ceph_mds_reply_info_in *iinfo, struct ceph_mds_reply_dirfrag *dirinfo, struct ceph_mds_session *session,
@@ -883,14 +883,15 @@ static int fill_inode(struct inode *inode,int cache_caps =CEPH_CAP_FILE_CACHE |CEPH_CAP_FILE_LAZYIO ; ci->i_inline_version = iinfo->inline_version;if (ci->i_inline_version !=CEPH_INLINE_NONE && - (le32_to_cpu (info->cap.caps) & cache_caps)) + (locked_page || + (le32_to_cpu (info->cap.caps) & cache_caps))) fill_inline = true; }spin_unlock (&ci->i_ceph_lock);if (fill_inline) -ceph_fill_inline_data (inode,NULL , +ceph_fill_inline_data (inode, locked_page, iinfo->inline_data, iinfo->inline_len);if (wake)
@@ -1080,7 +1081,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,struct inode *dir = req->r_locked_dir;if (dir) { - err =fill_inode (dir, &rinfo->diri, rinfo->dirfrag, + err =fill_inode (dir,NULL , + &rinfo->diri, rinfo->dirfrag, session, req->r_request_started,-1 , &req->r_caps_reservation);if (err <0 )
@@ -1150,7 +1152,7 @@ retry_lookup: } req->r_target_inode = in; - err = fill_inode(in, &rinfo->targeti, NULL, + err = fill_inode(in, req->r_locked_page, &rinfo->targeti, NULL, session, req->r_request_started, (!req->r_aborted && rinfo->head->result == 0) ? req->r_fmode : -1,
@@ -1321,7 +1323,7 @@ static int readdir_prepopulate_inodes_only(struct ceph_mds_request *req,dout ("new_inode badness got %d\n" , err);continue ; } - rc =fill_inode (in, &rinfo->dir_in[i],NULL , session, + rc =fill_inode (in,NULL , &rinfo->dir_in[i],NULL , session, req->r_request_started,-1 , &req->r_caps_reservation);if (rc <0 ) {
@@ -1437,7 +1439,7 @@ retry_lookup: } } -if (fill_inode (in, &rinfo->dir_in[i],NULL , session, +if (fill_inode (in,NULL , &rinfo->dir_in[i],NULL , session, req->r_request_started,-1 , &req->r_caps_reservation) <0 ) {pr_err ("fill_inode badness on %p\n" , in);
@@ -1920,7 +1922,8 @@ out_put:* Verify that we have a lease on the given mask. If not, * do a getattr against an mds. */ -int ceph_do_getattr (struct inode *inode,int mask,bool force) +int __ceph_do_getattr (struct inode *inode,struct page *locked_page, +int mask,bool force) {struct ceph_fs_client *fsc =ceph_sb_to_client (inode->i_sb);struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -1932,7 +1935,8 @@ int ceph_do_getattr(struct inode *inode, int mask, bool force)return 0 ; } -dout ("do_getattr inode %p mask %s mode 0%o\n" , inode,ceph_cap_string (mask), inode->i_mode); +dout ("do_getattr inode %p mask %s mode 0%o\n" , + inode,ceph_cap_string (mask), inode->i_mode);if (!force &&ceph_caps_issued_mask (ceph_inode (inode), mask,1 ))return 0 ;
@@ -1943,7 +1947,19 @@ int ceph_do_getattr(struct inode *inode, int mask, bool force)ihold (inode); req->r_num_caps =1 ; req->r_args.getattr.mask =cpu_to_le32 (mask); + req->r_locked_page = locked_page; err =ceph_mdsc_do_request (mdsc,NULL , req); +if (locked_page && err ==0 ) { +u64 inline_version = req->r_reply_info.targeti.inline_version; +if (inline_version ==0 ) { +/* the reply is supposed to contain inline data */ + err = -EINVAL ; + }else if (inline_version ==CEPH_INLINE_NONE ) { + err = -ENODATA ; + }else { + err = req->r_reply_info.targeti.inline_len; + } + }ceph_mdsc_put_request (req);dout ("do_getattr result=%d\n" , err);return err;
fs/ceph/mds_client.h +1 -0
@@ -223,6 +223,7 @@ struct ceph_mds_request {int r_request_release_offset;struct ceph_msg *r_reply;struct ceph_mds_reply_info_parsed r_reply_info; +struct page *r_locked_page;int r_err;bool r_aborted;
fs/ceph/super.h +6 -1
@@ -744,7 +744,12 @@ extern void ceph_queue_vmtruncate(struct inode *inode);extern void ceph_queue_invalidate (struct inode *inode);extern void ceph_queue_writeback (struct inode *inode); -extern int ceph_do_getattr (struct inode *inode,int mask,bool force); +extern int __ceph_do_getattr (struct inode *inode,struct page *locked_page, +int mask,bool force); +static inline int ceph_do_getattr (struct inode *inode,int mask,bool force) +{ +return __ceph_do_getattr (inode,NULL , mask, force); +}extern int ceph_permission (struct inode *inode,int mask);extern int ceph_setattr (struct dentry *dentry,struct iattr *attr); extern int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry,
include/linux/ceph/ceph_fs.h +2 -0
@@ -617,6 +617,8 @@ int ceph_flags_to_mode(int flags); CEPH_CAP_LINK_SHARED | \ CEPH_CAP_FILE_SHARED | \ CEPH_CAP_XATTR_SHARED) +#define CEPH_STAT_CAP_INLINE_DATA (CEPH_CAP_FILE_SHARED | \ + CEPH_CAP_FILE_RD)#define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \ CEPH_CAP_LINK_SHARED | \
Signature · 1 line
1.9.3
PATCH 7/12 ceph: fetch inline data while getting Fcr cap refs
In reply to Yan, Zhengwe can't use getattr to fetch inline data after getting Fcr caps, because it can cause deadlock. The solution is try bringing inline data to page cache when not holding any cap, and hope the inline data page is still there after getting the Fcr caps. If the page is still there, pin it in page cache for later IO.
--- fs/ceph/addr.c | 9 +++++++-- fs/ceph/caps.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- fs/ceph/file.c | 12 +++++++++--- 3 files changed, 62 insertions(+), 14 deletions(-)
fs/ceph/addr.c +7 -2
@@ -1207,6 +1207,7 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)struct inode *inode =file_inode (vma->vm_file);struct ceph_inode_info *ci =ceph_inode (inode);struct ceph_file_info *fi = vma->vm_file->private_data; +struct page *pinned_page =NULL ;loff_t off = vmf->pgoff <<PAGE_CACHE_SHIFT ;int want, got, ret;
@@ -1218,7 +1219,8 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) want =CEPH_CAP_FILE_CACHE ;while (1 ) { got =0 ; - ret =ceph_get_caps (ci,CEPH_CAP_FILE_RD , want, &got,-1 ); + ret =ceph_get_caps (ci,CEPH_CAP_FILE_RD , want,-1 , + &got, &pinned_page);if (ret ==0 )break ;if (ret != -ERESTARTSYS ) {
@@ -1233,6 +1235,8 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)dout ("filemap_fault %p %llu~%zd dropping cap refs on %s ret %d\n" , inode, off, (size_t )PAGE_CACHE_SIZE ,ceph_cap_string (got), ret); +if (pinned_page) +page_cache_release (pinned_page);ceph_put_cap_refs (ci, got);return ret;
@@ -1266,7 +1270,8 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) want =CEPH_CAP_FILE_BUFFER ;while (1 ) { got =0 ; - ret =ceph_get_caps (ci,CEPH_CAP_FILE_WR , want, &got, off + len); + ret =ceph_get_caps (ci,CEPH_CAP_FILE_WR , want, off + len, + &got,NULL );if (ret ==0 )break ;if (ret != -ERESTARTSYS ) {
fs/ceph/caps.c +46 -9
93 lines not on this page · raw message
fs/ceph/file.c +9 -3
@@ -805,6 +805,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)size_t len = iocb->ki_nbytes;struct inode *inode =file_inode (filp);struct ceph_inode_info *ci =ceph_inode (inode); +struct page *pinned_page =NULL ;ssize_t ret;int want, got =0 ;int checkeof =0 , read =0 ;
@@ -817,7 +818,7 @@ again: want =CEPH_CAP_FILE_CACHE |CEPH_CAP_FILE_LAZYIO ; else want =CEPH_CAP_FILE_CACHE ; - ret =ceph_get_caps (ci,CEPH_CAP_FILE_RD , want, &got,-1 ); + ret =ceph_get_caps (ci,CEPH_CAP_FILE_RD , want,-1 , &got, &pinned_page);if (ret <0 )return ret;
@@ -840,6 +841,10 @@ again: }dout ("aio_read %p %llx.%llx dropping cap refs on %s = %d\n" , inode,ceph_vinop (inode),ceph_cap_string (got), (int )ret); +if (pinned_page) { +page_cache_release (pinned_page); + pinned_page =NULL ; + }ceph_put_cap_refs (ci, got);if (checkeof && ret >=0 ) {
@@ -924,7 +929,8 @@ retry_snap:else want =CEPH_CAP_FILE_BUFFER ; got =0 ; - err =ceph_get_caps (ci,CEPH_CAP_FILE_WR , want, &got, pos + count); + err =ceph_get_caps (ci,CEPH_CAP_FILE_WR , want, pos + count, + &got,NULL );if (err <0 ) goto out;
@@ -1225,7 +1231,7 @@ static long ceph_fallocate(struct file *file, int mode,else want =CEPH_CAP_FILE_BUFFER ; - ret =ceph_get_caps (ci,CEPH_CAP_FILE_WR , want, &got, endoff); + ret =ceph_get_caps (ci,CEPH_CAP_FILE_WR , want, endoff, &got,NULL );if (ret <0 ) goto unlock;
Signature · 1 line
1.9.3
PATCH 8/12 ceph: sync read inline data
In reply to Yan, Zhengwe can't use getattr to fetch inline data while holding Fr cap, because it can cause deadlock. If we need to sync read inline data, drop cap refs first, then use getattr to fetch inline data.
--- fs/ceph/addr.c | 7 ++++++- fs/ceph/file.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 61 insertions(+), 9 deletions(-)
fs/ceph/addr.c +6 -1
@@ -194,8 +194,10 @@ static int readpage_nounlock(struct file *filp, struct page *page)int err =0 ;u64 len =PAGE_CACHE_SIZE ; - err =ceph_readpage_from_fscache (inode, page); +if (ci->i_inline_version !=CEPH_INLINE_NONE ) +return -EINVAL ; + err =ceph_readpage_from_fscache (inode, page);if (err ==0 ) goto out;
@@ -384,6 +386,9 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,int rc =0 ;int max =0 ; +if (ceph_inode (inode)->i_inline_version !=CEPH_INLINE_NONE ) +return -EINVAL ; + rc =ceph_readpages_from_fscache (mapping->host, mapping, page_list, &nr_pages);
fs/ceph/file.c +55 -8
102 lines not on this page · raw message
Signature · 1 line
1.9.3
PATCH 9/12 ceph: convert inline data to normal data before data write
In reply to Yan, ZhengBefore any data write, convert inline data to normal data and set i_inline_version to CEPH_INLINE_NONE. The OSD request that saves inline data to object contains 3 operations (CMPXATTR, WRITE and SETXATTR). It compares a xattr named 'inline_version' to prevent old data overwrites newer data.
--- fs/ceph/addr.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/ceph/file.c | 14 ++++++ fs/ceph/super.h | 2 +- 3 files changed, 151 insertions(+), 1 deletion(-)
fs/ceph/addr.c +136 -0
@@ -1262,6 +1262,19 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)size_t len;int want, got, ret; +if (ci->i_inline_version !=CEPH_INLINE_NONE ) { +struct page *locked_page =NULL ; +if (off ==0 ) { +lock_page (page); + locked_page = page; + } + ret =ceph_uninline_data (vma->vm_file, locked_page); +if (locked_page) +unlock_page (locked_page); +if (ret <0 ) +return VM_FAULT_SIGBUS ; + } +if (off +PAGE_CACHE_SIZE <= size) len =PAGE_CACHE_SIZE ;else
@@ -1315,6 +1328,7 @@ out: }else {int dirty;spin_lock (&ci->i_ceph_lock); + ci->i_inline_version =CEPH_INLINE_NONE ; dirty =__ceph_mark_dirty_caps (ci,CEPH_CAP_FILE_WR );spin_unlock (&ci->i_ceph_lock);if (dirty)
@@ -1370,6 +1384,128 @@ void ceph_fill_inline_data(struct inode *inode, struct page *locked_page, } } +int ceph_uninline_data (struct file *filp,struct page *locked_page) +{ +struct inode *inode =file_inode (filp); +struct ceph_inode_info *ci =ceph_inode (inode); +struct ceph_fs_client *fsc =ceph_inode_to_client (inode); +struct ceph_osd_request *req; +struct page *page =NULL ; +u64 len, inline_version; +int err =0 ; +bool from_pagecache = false; + +spin_lock (&ci->i_ceph_lock); + inline_version = ci->i_inline_version; +spin_unlock (&ci->i_ceph_lock); + +dout ("uninline_data %p %llx.%llx inline_version %llu\n" , + inode,ceph_vinop (inode), inline_version); + +if (inline_version ==1 ||/* initial version, no data */ + inline_version ==CEPH_INLINE_NONE ) + goto out; + +if (locked_page) { + page = locked_page; +WARN_ON (!PageUptodate (page)); + }else if (ceph_caps_issued (ci) & + (CEPH_CAP_FILE_CACHE |CEPH_CAP_FILE_LAZYIO )) { + page =find_get_page (inode->i_mapping,0 ); +if (page) { +if (PageUptodate (page)) { + from_pagecache = true; +lock_page (page); + }else { +page_cache_release (page); + page =NULL ; + } + } + } + +if (page) { + len =i_size_read (inode); +if (len >PAGE_CACHE_SIZE ) + len =PAGE_CACHE_SIZE ; + }else { + page =__page_cache_alloc (GFP_NOFS ); +if (!page) { + err = -ENOMEM ; + goto out; + } + err =__ceph_do_getattr (inode, page, +CEPH_STAT_CAP_INLINE_DATA , true); +if (err <0 ) { +/* no inline data */ +if (err == -ENODATA ) + err =0 ; + goto out; + } + len = err; + } + + req =ceph_osdc_new_request (&fsc->client->osdc, &ci->i_layout, +ceph_vino (inode),0 , &len,0 ,1 , +CEPH_OSD_OP_CREATE , +CEPH_OSD_FLAG_ONDISK |CEPH_OSD_FLAG_WRITE , + ci->i_snap_realm->cached_context, +0 ,0 , false); +if (IS_ERR (req)) { + err =PTR_ERR (req); + goto out; + } + +ceph_osdc_build_request (req,0 ,NULL ,CEPH_NOSNAP , &inode->i_mtime); + err =ceph_osdc_start_request (&fsc->client->osdc, req, false); +if (!err) + err =ceph_osdc_wait_request (&fsc->client->osdc, req); +ceph_osdc_put_request (req); +if (err <0 ) + goto out; + + req =ceph_osdc_new_request (&fsc->client->osdc, &ci->i_layout, +ceph_vino (inode),0 , &len,1 ,3 , +CEPH_OSD_OP_WRITE , +CEPH_OSD_FLAG_ONDISK |CEPH_OSD_FLAG_WRITE , + ci->i_snap_realm->cached_context, + ci->i_truncate_seq, ci->i_truncate_size, + false); +if (IS_ERR (req)) { + err =PTR_ERR (req); + goto out; + } + +osd_req_op_extent_osd_data_pages (req,1 , &page, len,0 , false, false); + +osd_req_op_xattr_init (req,0 ,CEPH_OSD_OP_CMPXATTR ,"inline_version" , + &inline_version,sizeof (inline_version), +CEPH_OSD_CMPXATTR_OP_GT , +CEPH_OSD_CMPXATTR_MODE_U64 ); + +osd_req_op_xattr_init (req,2 ,CEPH_OSD_OP_SETXATTR ,"inline_version" , + &inline_version,sizeof (inline_version),0 ,0 ); + +ceph_osdc_build_request (req,0 ,NULL ,CEPH_NOSNAP , &inode->i_mtime); + err =ceph_osdc_start_request (&fsc->client->osdc, req, false); +if (!err) + err =ceph_osdc_wait_request (&fsc->client->osdc, req); +ceph_osdc_put_request (req); +if (err == -ECANCELED ) + err =0 ; +out: +if (page && page != locked_page) { +if (from_pagecache) { +unlock_page (page); +page_cache_release (page); + }else +__free_pages (page,0 ); + } + +dout ("uninline_data %p %llx.%llx inline_version %llu = %d\n" , + inode,ceph_vinop (inode), inline_version, err); +return err; +} +static struct vm_operations_struct ceph_vmops = { .fault = ceph_filemap_fault, .page_mkwrite = ceph_page_mkwrite,
fs/ceph/file.c +14 -0
@@ -963,6 +963,12 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)if (err) goto out; +if (ci->i_inline_version !=CEPH_INLINE_NONE ) { + err =ceph_uninline_data (file,NULL ); +if (err <0 ) + goto out; + } + retry_snap:if (ceph_osdmap_flag (osdc->osdmap,CEPH_OSDMAP_FULL )) { err = -ENOSPC ;
@@ -1024,6 +1030,7 @@ retry_snap:if (written >=0 ) {int dirty;spin_lock (&ci->i_ceph_lock); + ci->i_inline_version =CEPH_INLINE_NONE ; dirty =__ceph_mark_dirty_caps (ci,CEPH_CAP_FILE_WR );spin_unlock (&ci->i_ceph_lock);if (dirty)
@@ -1269,6 +1276,12 @@ static long ceph_fallocate(struct file *file, int mode, goto unlock; } +if (ci->i_inline_version !=CEPH_INLINE_NONE ) { + ret =ceph_uninline_data (file,NULL ); +if (ret <0 ) + goto unlock; + } + size =i_size_read (inode);if (!(mode &FALLOC_FL_KEEP_SIZE )) endoff = offset + length;
@@ -1295,6 +1308,7 @@ static long ceph_fallocate(struct file *file, int mode,if (!ret) {spin_lock (&ci->i_ceph_lock); + ci->i_inline_version =CEPH_INLINE_NONE ; dirty =__ceph_mark_dirty_caps (ci,CEPH_CAP_FILE_WR );spin_unlock (&ci->i_ceph_lock);if (dirty)
fs/ceph/super.h +1 -1
@@ -888,7 +888,7 @@ extern int ceph_atomic_open(struct inode *dir, struct dentry *dentry,extern int ceph_release (struct inode *inode,struct file *filp);extern void ceph_fill_inline_data (struct inode *inode,struct page *locked_page,char *data,size_t len); - +int ceph_uninline_data (struct file *filp,struct page *locked_page);/* dir.c */ extern const struct file_operations ceph_dir_fops;extern const struct inode_operations ceph_dir_iops;
Signature · 1 line
1.9.3
PATCH 10/12 ceph: convert inline data for memory mapped read
In reply to Yan, ZhengWe can't use getattr to fetch inline data while holding Fr caps, If there is no Fc cap, ceph_get_caps() does not bring inline data to page cache neither. To simplify this case, just convert inline data to normal data.
--- fs/ceph/addr.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
fs/ceph/addr.c +15 -2
@@ -1215,7 +1215,7 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)struct page *pinned_page =NULL ;loff_t off = vmf->pgoff <<PAGE_CACHE_SHIFT ;int want, got, ret; - +again:dout ("filemap_fault %p %llx.%llx %llu~%zd trying to get caps\n" , inode,ceph_vinop (inode), off, (size_t )PAGE_CACHE_SIZE );if (fi->fmode &CEPH_FILE_MODE_LAZY )
@@ -1236,7 +1236,10 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)dout ("filemap_fault %p %llu~%zd got cap refs on %s\n" , inode, off, (size_t )PAGE_CACHE_SIZE ,ceph_cap_string (got)); - ret =filemap_fault (vma, vmf); +if ((got & want) || ci->i_inline_version ==CEPH_INLINE_NONE ) + ret =filemap_fault (vma, vmf); +else + ret = -EAGAIN ;/* readpage() can't fetch inline data */ dout ("filemap_fault %p %llu~%zd dropping cap refs on %s ret %d\n" , inode, off, (size_t )PAGE_CACHE_SIZE ,ceph_cap_string (got), ret);
@@ -1244,6 +1247,16 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)page_cache_release (pinned_page);ceph_put_cap_refs (ci, got); +if (ret == -EAGAIN ) { + ret =ceph_uninline_data (vma->vm_file,NULL ); +if (ret <0 ) +return VM_FAULT_SIGBUS ; +spin_lock (&ci->i_ceph_lock); + ci->i_inline_version =CEPH_INLINE_NONE ; +spin_unlock (&ci->i_ceph_lock); + goto again; + } +return ret; }
Signature · 1 line
1.9.3
PATCH 11/12 ceph: flush inline version
In reply to Yan, ZhengAfter converting inline data to normal data, client need to flush the new i_inline_version (CEPH_INLINE_NONE) to MDS. This commit makes cap messages (sent to MDS) contain inline_version and inline_data. Client always converts inline data to normal data before data write, so the inline data length part is always zero.
--- fs/ceph/caps.c | 24 ++++++++++++++++++++---- fs/ceph/snap.c | 2 ++ fs/ceph/super.h | 1 + 3 files changed, 23 insertions(+), 4 deletions(-)
fs/ceph/caps.c +20 -4
@@ -975,10 +975,12 @@ static int send_cap_msg(struct ceph_mds_session *session, kuid_t uid, kgid_t gid, umode_t mode, u64 xattr_version, struct ceph_buffer *xattrs_buf, - u64 follows) + u64 follows, bool inline_data) { struct ceph_mds_caps *fc;struct ceph_msg *msg; +void *p; +size_t extra_len;dout ("send_cap_msg %s %llx %llx caps %s wanted %s dirty %s" " seq %u/%u mseq %u follows %lld size %llu/%llu"
@@ -988,7 +990,10 @@ static int send_cap_msg(struct ceph_mds_session *session, seq, issue_seq, mseq, follows, size, max_size, xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0); - msg =ceph_msg_new (CEPH_MSG_CLIENT_CAPS ,sizeof (*fc),GFP_NOFS , false); +/* flock buffer size + inline version + inline data size */ + extra_len =4 +8 +4 ; + msg =ceph_msg_new (CEPH_MSG_CLIENT_CAPS ,sizeof (*fc) + extra_len, +GFP_NOFS , false);if (!msg)return -ENOMEM ;
@@ -1020,6 +1025,14 @@ static int send_cap_msg(struct ceph_mds_session *session, fc->gid =cpu_to_le32 (from_kgid (&init_user_ns, gid)); fc->mode =cpu_to_le32 (mode); + p = fc +1 ; +/* flock buffer size */ +ceph_encode_32 (&p,0 ); +/* inline version */ +ceph_encode_64 (&p, inline_data ?0 :CEPH_INLINE_NONE ); +/* inline data size */ +ceph_encode_32 (&p,0 ); + fc->xattr_version =cpu_to_le64 (xattr_version);if (xattrs_buf) { msg->middle =ceph_buffer_get (xattrs_buf);
@@ -1126,6 +1139,7 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,u64 flush_tid =0 ;int i;int ret; +bool inline_data; held = cap->issued | cap->implemented; revoking = cap->implemented & ~cap->issued;
@@ -1209,13 +1223,15 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, xattr_version = ci->i_xattrs.version; } + inline_data = ci->i_inline_version !=CEPH_INLINE_NONE ; +spin_unlock (&ci->i_ceph_lock); ret =send_cap_msg (session,ceph_vino (inode).ino, cap_id, op, keep, want, flushing, seq, flush_tid, issue_seq, mseq, size, max_size, &mtime, &atime, time_warp_seq, uid, gid, mode, xattr_version, xattr_blob, - follows); + follows, inline_data);if (ret <0 ) {dout ("error sending cap msg, must requeue %p\n" , inode); delayed =1 ;
@@ -1336,7 +1352,7 @@ retry: capsnap->time_warp_seq, capsnap->uid, capsnap->gid, capsnap->mode, capsnap->xattr_version, capsnap->xattr_blob, - capsnap->follows); + capsnap->follows, capsnap->inline_data); next_follows = capsnap->follows +1 ;ceph_put_cap_snap (capsnap);
fs/ceph/snap.c +2 -0
@@ -515,6 +515,8 @@ void ceph_queue_cap_snap(struct ceph_inode_info *ci) capsnap->xattr_version =0 ; } + capsnap->inline_data = ci->i_inline_version !=CEPH_INLINE_NONE ; +/* dirty page count moved from _head to this cap_snap; all subsequent writes page dirties occur _after_ this snapshot. */
fs/ceph/super.h +1 -0
@@ -161,6 +161,7 @@ struct ceph_cap_snap {u64 time_warp_seq;int writing;/* a sync write is still in progress */ int dirty_pages;/* dirty pages awaiting writeback */ +bool inline_data; };static inline void ceph_put_cap_snap (struct ceph_cap_snap *capsnap)
Signature · 1 line
1.9.3
PATCH 12/12 ceph: support inline data feature
In reply to Yan, Zheng--- fs/ceph/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/super.c +2 -1
@@ -515,7 +515,8 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,struct ceph_fs_client *fsc;const u64 supported_features =CEPH_FEATURE_FLOCK | -CEPH_FEATURE_DIRLAYOUTHASH ; +CEPH_FEATURE_DIRLAYOUTHASH | +CEPH_FEATURE_MDS_INLINE_DATA ;const u64 required_features =0 ;int page_count;size_t size;
Signature · 1 line
1.9.3