Commit dccbf080 authored by Ilya Dryomov's avatar Ilya Dryomov

libceph, ceph: change ceph_calc_file_object_mapping() signature

- make it void
- xlen (object extent length) out parameter should be u32 because only
  a single stripe unit is mapped at a time
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
parent db2196a5
...@@ -945,19 +945,15 @@ static int ceph_writepages_start(struct address_space *mapping, ...@@ -945,19 +945,15 @@ static int ceph_writepages_start(struct address_space *mapping,
if (locked_pages == 0) { if (locked_pages == 0) {
u64 objnum; u64 objnum;
u64 objoff; u64 objoff;
u32 xlen;
/* prepare async write request */ /* prepare async write request */
offset = (u64)page_offset(page); offset = (u64)page_offset(page);
len = wsize; ceph_calc_file_object_mapping(&ci->i_layout,
offset, wsize,
rc = ceph_calc_file_object_mapping(&ci->i_layout,
offset, len,
&objnum, &objoff, &objnum, &objoff,
&len); &xlen);
if (rc < 0) { len = xlen;
unlock_page(page);
break;
}
num_ops = 1; num_ops = 1;
strip_unit_end = page->index + strip_unit_end = page->index +
......
...@@ -185,7 +185,7 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg) ...@@ -185,7 +185,7 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
&ceph_sb_to_client(inode->i_sb)->client->osdc; &ceph_sb_to_client(inode->i_sb)->client->osdc;
struct ceph_object_locator oloc; struct ceph_object_locator oloc;
CEPH_DEFINE_OID_ONSTACK(oid); CEPH_DEFINE_OID_ONSTACK(oid);
u64 len = 1, olen; u32 xlen;
u64 tmp; u64 tmp;
struct ceph_pg pgid; struct ceph_pg pgid;
int r; int r;
...@@ -195,13 +195,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg) ...@@ -195,13 +195,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
return -EFAULT; return -EFAULT;
down_read(&osdc->lock); down_read(&osdc->lock);
r = ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, len, ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, 1,
&dl.object_no, &dl.object_offset, &dl.object_no, &dl.object_offset, &xlen);
&olen);
if (r < 0) {
up_read(&osdc->lock);
return -EIO;
}
dl.file_offset -= dl.object_offset; dl.file_offset -= dl.object_offset;
dl.object_size = ci->i_layout.object_size; dl.object_size = ci->i_layout.object_size;
dl.block_size = ci->i_layout.stripe_unit; dl.block_size = ci->i_layout.stripe_unit;
......
...@@ -280,10 +280,9 @@ bool ceph_osds_changed(const struct ceph_osds *old_acting, ...@@ -280,10 +280,9 @@ bool ceph_osds_changed(const struct ceph_osds *old_acting,
const struct ceph_osds *new_acting, const struct ceph_osds *new_acting,
bool any_change); bool any_change);
/* calculate mapping of a file extent to an object */ void ceph_calc_file_object_mapping(struct ceph_file_layout *l,
extern int ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
u64 off, u64 len, u64 off, u64 len,
u64 *bno, u64 *oxoff, u64 *oxlen); u64 *objno, u64 *objoff, u32 *xlen);
int __ceph_object_locator_to_pg(struct ceph_pg_pool_info *pi, int __ceph_object_locator_to_pg(struct ceph_pg_pool_info *pi,
const struct ceph_object_id *oid, const struct ceph_object_id *oid,
......
...@@ -103,13 +103,12 @@ static int calc_layout(struct ceph_file_layout *layout, u64 off, u64 *plen, ...@@ -103,13 +103,12 @@ static int calc_layout(struct ceph_file_layout *layout, u64 off, u64 *plen,
u64 *objnum, u64 *objoff, u64 *objlen) u64 *objnum, u64 *objoff, u64 *objlen)
{ {
u64 orig_len = *plen; u64 orig_len = *plen;
int r; u32 xlen;
/* object extent? */ /* object extent? */
r = ceph_calc_file_object_mapping(layout, off, orig_len, objnum, ceph_calc_file_object_mapping(layout, off, orig_len, objnum,
objoff, objlen); objoff, &xlen);
if (r < 0) *objlen = xlen;
return r;
if (*objlen < orig_len) { if (*objlen < orig_len) {
*plen = *objlen; *plen = *objlen;
dout(" skipping last %llu, final file extent %llu~%llu\n", dout(" skipping last %llu, final file extent %llu~%llu\n",
...@@ -117,7 +116,6 @@ static int calc_layout(struct ceph_file_layout *layout, u64 off, u64 *plen, ...@@ -117,7 +116,6 @@ static int calc_layout(struct ceph_file_layout *layout, u64 off, u64 *plen,
} }
dout("calc_layout objnum=%llx %llu~%llu\n", *objnum, *objoff, *objlen); dout("calc_layout objnum=%llx %llu~%llu\n", *objnum, *objoff, *objlen);
return 0; return 0;
} }
......
...@@ -2153,9 +2153,9 @@ bool ceph_osds_changed(const struct ceph_osds *old_acting, ...@@ -2153,9 +2153,9 @@ bool ceph_osds_changed(const struct ceph_osds *old_acting,
* objno | 0 | 1 | 2 | 3 | 4 * objno | 0 | 1 | 2 | 3 | 4
* objsetno | 0 | 1 * objsetno | 0 | 1
*/ */
int ceph_calc_file_object_mapping(struct ceph_file_layout *l, void ceph_calc_file_object_mapping(struct ceph_file_layout *l,
u64 off, u64 len, u64 off, u64 len,
u64 *objno, u64 *objoff, u64 *xlen) u64 *objno, u64 *objoff, u32 *xlen)
{ {
u32 stripes_per_object = l->object_size / l->stripe_unit; u32 stripes_per_object = l->object_size / l->stripe_unit;
u64 blockno; /* which su in the file (i.e. globally) */ u64 blockno; /* which su in the file (i.e. globally) */
...@@ -2173,8 +2173,6 @@ int ceph_calc_file_object_mapping(struct ceph_file_layout *l, ...@@ -2173,8 +2173,6 @@ int ceph_calc_file_object_mapping(struct ceph_file_layout *l,
*objno = objsetno * l->stripe_count + stripepos; *objno = objsetno * l->stripe_count + stripepos;
*objoff = objsetpos * l->stripe_unit + blockoff; *objoff = objsetpos * l->stripe_unit + blockoff;
*xlen = min_t(u64, len, l->stripe_unit - blockoff); *xlen = min_t(u64, len, l->stripe_unit - blockoff);
return 0;
} }
EXPORT_SYMBOL(ceph_calc_file_object_mapping); EXPORT_SYMBOL(ceph_calc_file_object_mapping);
......
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