Esempio n. 1
0
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 opcode, int flags,
					       struct ceph_snap_context *snapc,
					       int do_sync,
					       u32 truncate_seq,
					       u64 truncate_size,
					       struct timespec *mtime,
					       bool use_mempool, int num_reply,
					       int page_align)
{
	struct ceph_osd_req_op ops[3];
	struct ceph_osd_request *req;
	int r;

	ops[0].op = opcode;
	ops[0].extent.truncate_seq = truncate_seq;
	ops[0].extent.truncate_size = truncate_size;
	ops[0].payload_len = 0;

	if (do_sync) {
		ops[1].op = CEPH_OSD_OP_STARTSYNC;
		ops[1].payload_len = 0;
		ops[2].op = 0;
	} else
		ops[1].op = 0;

	req = ceph_osdc_alloc_request(osdc, flags,
					 snapc, ops,
					 use_mempool,
					 GFP_NOFS, NULL, NULL);
	if (!req)
		return NULL;

	
	r = calc_layout(osdc, vino, layout, off, plen, req, ops);
	if (r < 0)
		return ERR_PTR(r);
	req->r_file_layout = *layout;  

	req->r_num_pages = calc_pages_for(page_align, *plen);
	req->r_page_alignment = page_align;

	ceph_osdc_build_request(req, off, plen, ops,
				snapc,
				mtime,
				req->r_oid, req->r_oid_len);

	return req;
}
Esempio n. 2
0
/*
 * build new request AND message, calculate layout, and adjust file
 * extent as needed.
 *
 * if the file was recently truncated, we include information about its
 * old and new size so that the object can be updated appropriately.  (we
 * avoid synchronously deleting truncated objects because it's slow.)
 *
 * if @do_sync, include a 'startsync' command so that the osd will flush
 * data quickly.
 */
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 opcode, int flags,
					       struct ceph_snap_context *snapc,
					       int do_sync,
					       u32 truncate_seq,
					       u64 truncate_size,
					       struct timespec *mtime,
					       bool use_mempool, int num_reply,
					       int page_align)
{
	struct ceph_osd_req_op ops[3];
	struct ceph_osd_request *req;

	ops[0].op = opcode;
	ops[0].extent.truncate_seq = truncate_seq;
	ops[0].extent.truncate_size = truncate_size;
	ops[0].payload_len = 0;

	if (do_sync) {
		ops[1].op = CEPH_OSD_OP_STARTSYNC;
		ops[1].payload_len = 0;
		ops[2].op = 0;
	} else
		ops[1].op = 0;

	req = ceph_osdc_alloc_request(osdc, flags,
					 snapc, ops,
					 use_mempool,
					 GFP_NOFS, NULL, NULL);
	if (!req)
		return NULL;

	/* calculate max write size */
	calc_layout(osdc, vino, layout, off, plen, req, ops);
	req->r_file_layout = *layout;  /* keep a copy */

	/* in case it differs from natural (file) alignment that
	   calc_layout filled in for us */
	req->r_num_pages = calc_pages_for(page_align, *plen);
	req->r_page_alignment = page_align;

	ceph_osdc_build_request(req, off, plen, ops,
				snapc,
				mtime,
				req->r_oid, req->r_oid_len);

	return req;
}