libceph, ceph: change ceph_calc_file_object_mapping() signature
authorIlya Dryomov <idryomov@gmail.com>
Sat, 17 Feb 2018 08:29:58 +0000 (09:29 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 2 Apr 2018 08:12:38 +0000 (10:12 +0200)
- 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: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
fs/ceph/addr.c
fs/ceph/ioctl.c
include/linux/ceph/osdmap.h
net/ceph/osd_client.c
net/ceph/osdmap.c

index b4336b42ce3bb1fabec247c01f51d86c2c28490f..c0fe1b6f47ac750de0a87e8c41fb75c037ec6345 100644 (file)
@@ -945,19 +945,15 @@ get_more_pages:
                        if (locked_pages == 0) {
                                u64 objnum;
                                u64 objoff;
+                               u32 xlen;
 
                                /* prepare async write request */
                                offset = (u64)page_offset(page);
-                               len = wsize;
-
-                               rc = ceph_calc_file_object_mapping(&ci->i_layout,
-                                                               offset, len,
-                                                               &objnum, &objoff,
-                                                               &len);
-                               if (rc < 0) {
-                                       unlock_page(page);
-                                       break;
-                               }
+                               ceph_calc_file_object_mapping(&ci->i_layout,
+                                                             offset, wsize,
+                                                             &objnum, &objoff,
+                                                             &xlen);
+                               len = xlen;
 
                                num_ops = 1;
                                strip_unit_end = page->index +
index 851aa69ec8f0dae6ec4837b2dc3807c4420cc751..b855d24a895a302d875eca622b01a68a7d5ed079 100644 (file)
@@ -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;
        struct ceph_object_locator oloc;
        CEPH_DEFINE_OID_ONSTACK(oid);
-       u64 len = 1, olen;
+       u32 xlen;
        u64 tmp;
        struct ceph_pg pgid;
        int r;
@@ -195,13 +195,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
                return -EFAULT;
 
        down_read(&osdc->lock);
-       r = ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, len,
-                                         &dl.object_no, &dl.object_offset,
-                                         &olen);
-       if (r < 0) {
-               up_read(&osdc->lock);
-               return -EIO;
-       }
+       ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, 1,
+                                     &dl.object_no, &dl.object_offset, &xlen);
        dl.file_offset -= dl.object_offset;
        dl.object_size = ci->i_layout.object_size;
        dl.block_size = ci->i_layout.stripe_unit;
index d41fad99c0fa7ece3c05fa1478f162c82da7e2ff..92314035dac1705fbfbb03d92b475f8436a14113 100644 (file)
@@ -280,10 +280,9 @@ bool ceph_osds_changed(const struct ceph_osds *old_acting,
                       const struct ceph_osds *new_acting,
                       bool any_change);
 
-/* calculate mapping of a file extent to an object */
-extern int ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
-                                        u64 off, u64 len,
-                                        u64 *bno, u64 *oxoff, u64 *oxlen);
+void ceph_calc_file_object_mapping(struct ceph_file_layout *l,
+                                  u64 off, u64 len,
+                                  u64 *objno, u64 *objoff, u32 *xlen);
 
 int __ceph_object_locator_to_pg(struct ceph_pg_pool_info *pi,
                                const struct ceph_object_id *oid,
index 2814dba5902d7a862a0ffb42b488af473a43fb59..4b0485458d26ff67884769b013aebbf4a3b76169 100644 (file)
@@ -103,13 +103,12 @@ static int calc_layout(struct ceph_file_layout *layout, u64 off, u64 *plen,
                        u64 *objnum, u64 *objoff, u64 *objlen)
 {
        u64 orig_len = *plen;
-       int r;
+       u32 xlen;
 
        /* object extent? */
-       r = ceph_calc_file_object_mapping(layout, off, orig_len, objnum,
-                                         objoff, objlen);
-       if (r < 0)
-               return r;
+       ceph_calc_file_object_mapping(layout, off, orig_len, objnum,
+                                         objoff, &xlen);
+       *objlen = xlen;
        if (*objlen < orig_len) {
                *plen = *objlen;
                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,
        }
 
        dout("calc_layout objnum=%llx %llu~%llu\n", *objnum, *objoff, *objlen);
-
        return 0;
 }
 
index 3faa9e701518afa055ff7a12b787059ad42a74a8..e3ebbe2ecdad8aab18a04d564e0c591f575a3e86 100644 (file)
@@ -2153,9 +2153,9 @@ bool ceph_osds_changed(const struct ceph_osds *old_acting,
  * objno     |      0      |      1      |      2      |      3      |      4
  * 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 *objno, u64 *objoff, u64 *xlen)
+                                  u64 *objno, u64 *objoff, u32 *xlen)
 {
        u32 stripes_per_object = l->object_size / l->stripe_unit;
        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,
        *objno = objsetno * l->stripe_count + stripepos;
        *objoff = objsetpos * l->stripe_unit + blockoff;
        *xlen = min_t(u64, len, l->stripe_unit - blockoff);
-
-       return 0;
 }
 EXPORT_SYMBOL(ceph_calc_file_object_mapping);