Commit 715e4cd4 authored by Yan, Zheng's avatar Yan, Zheng Committed by Ilya Dryomov

libceph: specify position of extent operation

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: default avatarYan, Zheng <zyan@redhat.com>
Reviewed-by: default avatarIlya Dryomov <idryomov@redhat.com>
parent 864e9197
...@@ -319,7 +319,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max) ...@@ -319,7 +319,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
off, len); off, len);
vino = ceph_vino(inode); vino = ceph_vino(inode);
req = ceph_osdc_new_request(osdc, &ci->i_layout, vino, off, &len, 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, CEPH_OSD_FLAG_READ, NULL,
ci->i_truncate_seq, ci->i_truncate_size, ci->i_truncate_seq, ci->i_truncate_size,
false); false);
...@@ -750,7 +750,6 @@ static int ceph_writepages_start(struct address_space *mapping, ...@@ -750,7 +750,6 @@ static int ceph_writepages_start(struct address_space *mapping,
last_snapc = snapc; last_snapc = snapc;
while (!done && index <= end) { while (!done && index <= end) {
int num_ops = do_sync ? 2 : 1;
unsigned i; unsigned i;
int first; int first;
pgoff_t next; pgoff_t next;
...@@ -850,7 +849,8 @@ static int ceph_writepages_start(struct address_space *mapping, ...@@ -850,7 +849,8 @@ static int ceph_writepages_start(struct address_space *mapping,
len = wsize; len = wsize;
req = ceph_osdc_new_request(&fsc->client->osdc, req = ceph_osdc_new_request(&fsc->client->osdc,
&ci->i_layout, vino, &ci->i_layout, vino,
offset, &len, num_ops, offset, &len, 0,
do_sync ? 2 : 1,
CEPH_OSD_OP_WRITE, CEPH_OSD_OP_WRITE,
CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_WRITE |
CEPH_OSD_FLAG_ONDISK, CEPH_OSD_FLAG_ONDISK,
...@@ -862,6 +862,9 @@ static int ceph_writepages_start(struct address_space *mapping, ...@@ -862,6 +862,9 @@ static int ceph_writepages_start(struct address_space *mapping,
break; break;
} }
if (do_sync)
osd_req_op_init(req, 1, CEPH_OSD_OP_STARTSYNC);
req->r_callback = writepages_finish; req->r_callback = writepages_finish;
req->r_inode = inode; req->r_inode = inode;
......
...@@ -598,7 +598,7 @@ ceph_sync_direct_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos) ...@@ -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; snapc = ci->i_snap_realm->cached_context;
vino = ceph_vino(inode); vino = ceph_vino(inode);
req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout,
vino, pos, &len, vino, pos, &len, 0,
2,/*include a 'startsync' command*/ 2,/*include a 'startsync' command*/
CEPH_OSD_OP_WRITE, flags, snapc, CEPH_OSD_OP_WRITE, flags, snapc,
ci->i_truncate_seq, ci->i_truncate_seq,
...@@ -609,6 +609,8 @@ ceph_sync_direct_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos) ...@@ -609,6 +609,8 @@ ceph_sync_direct_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos)
break; break;
} }
osd_req_op_init(req, 1, CEPH_OSD_OP_STARTSYNC);
n = iov_iter_get_pages_alloc(from, &pages, len, &start); n = iov_iter_get_pages_alloc(from, &pages, len, &start);
if (unlikely(n < 0)) { if (unlikely(n < 0)) {
ret = n; ret = n;
...@@ -713,7 +715,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos) ...@@ -713,7 +715,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos)
snapc = ci->i_snap_realm->cached_context; snapc = ci->i_snap_realm->cached_context;
vino = ceph_vino(inode); vino = ceph_vino(inode);
req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, 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, CEPH_OSD_OP_WRITE, flags, snapc,
ci->i_truncate_seq, ci->i_truncate_seq,
ci->i_truncate_size, ci->i_truncate_size,
...@@ -1111,7 +1113,7 @@ static int ceph_zero_partial_object(struct inode *inode, ...@@ -1111,7 +1113,7 @@ static int ceph_zero_partial_object(struct inode *inode,
req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout,
ceph_vino(inode), ceph_vino(inode),
offset, length, offset, length,
1, op, 0, 1, op,
CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_WRITE |
CEPH_OSD_FLAG_ONDISK, CEPH_OSD_FLAG_ONDISK,
NULL, 0, 0, false); NULL, 0, 0, false);
......
...@@ -328,7 +328,8 @@ extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *, ...@@ -328,7 +328,8 @@ extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
struct ceph_file_layout *layout, struct ceph_file_layout *layout,
struct ceph_vino vino, struct ceph_vino vino,
u64 offset, u64 *len, 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, struct ceph_snap_context *snapc,
u32 truncate_seq, u64 truncate_size, u32 truncate_seq, u64 truncate_size,
bool use_mempool); bool use_mempool);
......
...@@ -753,7 +753,8 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, ...@@ -753,7 +753,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_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
struct ceph_file_layout *layout, struct ceph_file_layout *layout,
struct ceph_vino vino, 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, int opcode, int flags,
struct ceph_snap_context *snapc, struct ceph_snap_context *snapc,
u32 truncate_seq, u32 truncate_seq,
...@@ -785,7 +786,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, ...@@ -785,7 +786,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) { 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 { } else {
u32 object_size = le32_to_cpu(layout->fl_object_size); u32 object_size = le32_to_cpu(layout->fl_object_size);
u32 object_base = off - objoff; u32 object_base = off - objoff;
...@@ -798,17 +799,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, ...@@ -798,17 +799,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
truncate_size = object_size; truncate_size = object_size;
} }
} }
osd_req_op_extent_init(req, which, opcode, objoff, objlen,
osd_req_op_extent_init(req, 0, opcode, objoff, objlen,
truncate_size, truncate_seq); 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); req->r_base_oloc.pool = ceph_file_layout_pg_pool(*layout);
...@@ -2675,7 +2668,7 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc, ...@@ -2675,7 +2668,7 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
dout("readpages on ino %llx.%llx on %llu~%llu\n", vino.ino, dout("readpages on ino %llx.%llx on %llu~%llu\n", vino.ino,
vino.snap, off, *plen); 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, CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
NULL, truncate_seq, truncate_size, NULL, truncate_seq, truncate_size,
false); false);
...@@ -2718,7 +2711,7 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino, ...@@ -2718,7 +2711,7 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
int page_align = off & ~PAGE_MASK; int page_align = off & ~PAGE_MASK;
BUG_ON(vino.snap != CEPH_NOSNAP); /* snapshots aren't writeable */ 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_OP_WRITE,
CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE, CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE,
snapc, truncate_seq, truncate_size, snapc, truncate_seq, truncate_size,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment