return osdmap->get_pg_pool(pool)->get_size();
}
-int Client::get_file_stripe_address(int fd, loff_t offset, string& address)
+int Client::get_file_stripe_address(int fd, loff_t offset, vector<entity_addr_t>& address)
{
Mutex::Locker lock(client_lock);
osdmap->pg_to_acting_osds(pg, osds);
if (!osds.size())
return -EINVAL;
-
- // now we have the osd(s)
- entity_addr_t addr = osdmap->get_addr(osds[0]);
-
- // now we need to turn it into a string
- char foo[30];
- __u8 *quad = (__u8*) &addr.in4_addr().sin_addr;
- snprintf(foo, sizeof(foo), "%d.%d.%d.%d", (int)quad[0], (int)quad[1], (int)quad[2], (int)quad[3]);
- address = foo;
+
+ for (unsigned i = 0; i < osds.size(); i++) {
+ entity_addr_t addr = osdmap->get_addr(osds[i]);
+ address.push_back(addr);
+ }
+
return 0;
}
// expose file layout
int describe_layout(int fd, ceph_file_layout* layout);
- int get_file_stripe_address(int fd, loff_t offset, string& address);
+ int get_file_stripe_address(int fd, loff_t offset, vector<entity_addr_t>& address);
// expose osdmap
int get_local_osd();
int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh);
int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh);
int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh);
-int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fd,
- loff_t offset, char *buf, int buflen);
+int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fd, loff_t offset,
+ struct sockaddr_storage *addr, int naddr);
/* set default layout for new files */
int ceph_set_default_file_stripe_unit(struct ceph_mount_info *cmount, int stripe);
}
extern "C" int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fh,
- loff_t offset, char *buf, int buflen)
+ loff_t offset, struct sockaddr_storage *addr, int naddr)
{
- string address;
- int r = cmount->get_client()->get_file_stripe_address(fh, offset, address);
+ vector<entity_addr_t> address;
+ unsigned i;
+ int r;
+
+ if (naddr < 0)
+ return -EINVAL;
+
+ r = cmount->get_client()->get_file_stripe_address(fh, offset, address);
if (r < 0)
- return r;
- int len = address.size()+1;
- if (len > buflen) {
- if (buflen == 0)
- return len;
+ return r;
+
+ for (i = 0; i < (unsigned)naddr && i < address.size(); i++)
+ memcpy(&addr[i], &address[i].ss_addr(), sizeof(*addr));
+
+ /* naddr == 0: drop through and return actual size */
+ if (naddr && (address.size() > (unsigned)naddr))
return -ERANGE;
- }
- len = address.copy(buf, len, 0);
- buf[len] = '\0'; // write a null char to terminate c-style string
- return 0;
+
+ return address.size();
}
extern "C" int ceph_localize_reads(struct ceph_mount_info *cmount, int val)