summaryrefslogtreecommitdiff
path: root/net/ceph/striper.c
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2019-06-05 19:25:11 +0200
committerIlya Dryomov <idryomov@gmail.com>2019-07-08 14:01:45 +0200
commit22e8bd51bb0469d1a524130a057f894ff632376a (patch)
tree1cf2eaf3fac621e7154f58a7915e94db5851744e /net/ceph/striper.c
parentda5ef6be3467eb2d293790dea69b5b562490715a (diff)
downloadlinux-next-22e8bd51bb0469d1a524130a057f894ff632376a.tar.gz
rbd: support for object-map and fast-diff
Speed up reads, discards and zeroouts through RBD_OBJ_FLAG_MAY_EXIST and RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT based on object map. Invalid object maps are not trusted, but still updated. Note that we never iterate, resize or invalidate object maps. If object-map feature is enabled but object map fails to load, we just fail the requester (either "rbd map" or I/O, by way of post-acquire action). Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'net/ceph/striper.c')
-rw-r--r--net/ceph/striper.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/net/ceph/striper.c b/net/ceph/striper.c
index c36462dc86b7..3b3fa75d1189 100644
--- a/net/ceph/striper.c
+++ b/net/ceph/striper.c
@@ -259,3 +259,20 @@ int ceph_extent_to_file(struct ceph_file_layout *l,
return 0;
}
EXPORT_SYMBOL(ceph_extent_to_file);
+
+u64 ceph_get_num_objects(struct ceph_file_layout *l, u64 size)
+{
+ u64 period = (u64)l->stripe_count * l->object_size;
+ u64 num_periods = DIV64_U64_ROUND_UP(size, period);
+ u64 remainder_bytes;
+ u64 remainder_objs = 0;
+
+ div64_u64_rem(size, period, &remainder_bytes);
+ if (remainder_bytes > 0 &&
+ remainder_bytes < (u64)l->stripe_count * l->stripe_unit)
+ remainder_objs = l->stripe_count -
+ DIV_ROUND_UP_ULL(remainder_bytes, l->stripe_unit);
+
+ return num_periods * l->stripe_count - remainder_objs;
+}
+EXPORT_SYMBOL(ceph_get_num_objects);